akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

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

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

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

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

void solve() {
    string s;
    sc(s);
    vector<int> cnt(26, 0);
    for(char ch : s) {
        cnt[ch - 'a']++;
    }
    ll ans = (sz(s) * 1LL * (sz(s) - 1)) / 2 + 1;
    fr(i, 0, 25) {
        ans -= (cnt[i] * 1LL * (cnt[i] - 1)) / 2;
    }
    cout << ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3756
import heapq
X, Y, Z, K = map(int, input().split())
a =list(map(int, input().split()))
b =list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
ans = [(-(a[0]+b[0]+c[0]), 0, 0, 0)]
for i in range(K):
    m, j, k, h = heapq.heappop(ans)
    print(-m)
    if j+1 <= X-1:
        s =(-(a[j+1]+b[k]+c[h]), j+1, k, h)
        if s not in ans:
            heapq.heappush(ans, s)
    if k+1 <= Y-1:
        s =(-(a[j]+b[k+1]+c[h]), j , k+1, h)
        if s not in ans:
            heapq.heappush(ans, s)
    if h+1 <= Z-1:
        s =(-(a[j]+b[k]+c[h+1]), j , k, h+1)
        if s not in ans:
            heapq.heappush(ans, s)



Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
	int a,b;
	char op;
	
	while(scanf("%d %c %d",&a,&op,&b),op!='?'){
		if(op=='+')
			printf("%d\n",a+b);
		else if(op=='-')
			printf("%d\n",a-b);
		else if(op=='*')
			printf("%d\n",a*b);
		else
			printf("%d\n",a/b);
			
	}
return 0;
}



Measured memory_bytes: 1996
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
using LL = long long;
LL prefix(LL n) {
    n++;
    
    LL ans = 0;
    REP(bit, 0, 40) {
        int res = 0;
        LL gumi = n / (1LL << (bit+1));
        if (bit==0 && gumi%2==1) res = 1;
        LL tmp = n - (1LL << (bit+1))*gumi - (1LL << (bit));
        if (tmp>0 && tmp%2==1) res ^= 1;

        ans |= (1LL << bit) * res;
    }
    return ans;
}
int main()
{
    LL A,B;
    while (~scanf("%lld %lld",&A,&B)) {
        printf("%lld\n", prefix(B) ^ prefix(A-1));
    }
    
    return 0;
}



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



signed main() {
  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  string S; cin >> S;
  S = "." + S;
  S += "###";
  
  vector<bool> a(N+3, false), b(N+3, false);
  a[A] = true; b[B] = true;
  
  rep_(i, B, D) {
    if(b[i]) {
      if(S[i+1] == '.') b[i+1] = true;
      if(S[i+2] == '.') b[i+2] = true;
    }
  }
  
  vector<int> over(0);
  rep(i, D) if(b[i] && b[i+1] && b[i+2]) over.push_back(i);
  b[D+1] = false;
  
  rep_(i, A, N+1) {
    if(a[i]) {
      if(S[i+1] == '.') a[i+1] = true;
      if(S[i+2] == '.') a[i+2] = true;
    }
  }
  
  bool ov = false;
  for(int i : over) if(a[i] && a[i+1] && a[i+2]) ov = true;
  if(a[B-1] && a[B] && a[B+1]) ov = true;
  
  if(!ov) {
    rep_(i, D, N+1) a[i] = false;
  }
  
  //rep(i, N+1) cout << a[i]; cout << endl;
  //rep(i, N+1) cout << b[i]; cout << endl;
  
  if(a[C] && b[D]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  

  
}


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

int main()
{
  int a, b;
  bool ans = true;
  string s, s1, s2;
  cin >> a >> b >> s;

  if (s.find('-') != string::npos)
  {
    for (int i = 0; i < s.length(); i++)
    {
      if (i == a)
      {
        continue;
      }
      int buf = s[i] - '0';
      if (buf >= 10 || buf < 0)
      {
        ans = false;
        break;
      }
    }
  }
  else
  {
    ans = false;
  }
  if (ans)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

using namespace std;

const int MaxN = 2005;

int n;
string s;
int Mark[MaxN], Child[MaxN];
vector<int> adj[MaxN];
int High[MaxN], Low[MaxN];

void DFS(int u, int p)
{
    High[u] = Low[u] = 0;
    Child[u] = Mark[u];
    for (auto v : adj[u])
    {
        if (v != p)
        {
            DFS(v, u);
            Child[u] += Child[v];
            High[v] += Child[v];
            Low[v] += Child[v];
            High[u] += High[v];
        }
    }
    int mx = 0;
    int mxh = 0;
    for (auto v : adj[u])
    {
        if (v != p && High[v] > mxh)
        {
            mxh = High[v];
            mx = Low[v];
        }
    }
    if (mx <= High[u] - mxh)
    {
        Low[u] = High[u] % 2;
    }
    else
    {
        Low[u] = mx - (High[u] - mxh);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s;
    for (int i = 1; i <= n; i++)
    {
        Mark[i] = s[i - 1] - '0';
    }
    int u, v;
    for (int i = 1; i < n; i++)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int Res = -1;
    for (int i = 1; i <= n; i++)
    {
        DFS(i, -1);
        if (High[i] % 2 == 0 && Low[i] == 0)
        {
            if (Res == -1 || Res > High[i] / 2)
            {
                Res = High[i] / 2;
            }
        }
    }
    cout << Res;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i = 0;i < K;i++) {
        int d;
        cin >> d;
        for(int j = 0;j < d;j++) {
            int A;
            cin >> A;
            vec.at(A - 1)++;
        }
    }
    int ret = 0;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) == 0) {
            ret++;
        }
    }
    cout << ret << endl;
}

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

using namespace std;

int a,b;

int main() {

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

  int mi = min(a,b);
  int ma = max(a,b);

  for (int i = 0; i < ma; i++) printf("%d",mi);

  return 0;
}


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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
LL gcd(LL a, LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a, LL b) { return a/gcd(a,b)*b;}

//main code

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	VL a(n);
	cin >> a;
	LL ans = INT32_MAX;
	for (int i = -100; i <= 100; i++) {
		LL tmp = 0;
		for (int j = 0; j < n; j++) {
			tmp += abs(i-a[j])*(abs(i-a[j]));
		}
		chmin(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
x = int(input())

#facx = fac(x)
a,b = 0,0
for i in range(1000):
    u = i**5
    if u <= x:
        for j in range(1000):
            v = j**5
            if u + v > x:
                break
            elif u + v == x:
                a,b = i,-j
    elif u == x:
        a,b = i,0
    else:
        for j in range(i):
            v = j**5
            if u-v < x:
                break
            elif u-v == x:
                a,b = i,j
print(a,b)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
typedef long long ll;
#define int long long
const int mod = 1000000007;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    
    int n;
    cin >> n;
    
    int ans = n * (n + 1) / 2;
    ans -= n;
    cout << ans << endl;
    
    
    return 0;
}






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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a.at(i);

	sort(a.begin(), a.end());
	
	cout << a.at(n - 1) - a.at(0) << endl;

 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <climits>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int min, max;
    min = INT_MAX;
    max = INT_MIN;
    long long sum = 0;
    for (int i = 0; i < n; i ++)
    {
        int x;
        cin >> x;
        sum += x;
        if (x < min) min = x;
        if (x > max) max = x;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(void)

{
 int  h,w,n;
 int max;
int count = 0;
int ma = 0;

scanf("%d",&h);
scanf("%d",&w);
scanf("%d",&n);

max  = (h>w ? h:w);

do
{
 ma+= max;
count ++;
} while( ma<n);

printf("%d",count);
return 0;
}



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

class Main {

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int ans = 0;
        if (B == 1){
            System.out.println(0);
            return;
        }
        if (B <= A){
            System.out.println(1);
            return;
        }
        B -= A;
        ans = 1;
        while (B>0) {
            B -= A-1;
            ans++;
        }
        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22996
a1=list(input().split( ))
a=list(map(int, a1))
b= a[1] - a[0]
d=2018

if b > 2019:
 print(0)
else:
 for j in range(b):
  for k in range(b-j):
    c= ((a[0] + j )* (a[0] + j  + k + 1)) % 2019
    if c<=d:
     d=c
 print(d)

Measured memory_bytes: 3188
/*
   TASK: nocows
   LANG: C++14
 */

#include "bits/stdc++.h"

//region Template

typedef long long ll;
typedef long double ld;

using namespace std;
#define finish(x) return cout << x, 0;
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

const string USCAO_TAG = "nocows";
void usaco() { setIn(USCAO_TAG + ".in"); setOut(USCAO_TAG + ".out"); }


template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
//endregion

/* Notes:
 * I didn't wanna do this round :/
 */

vector<double> a;

int main() {
	#ifdef LOCAL
	setIn("in.txt");
	#endif

	int n;
	cin >> n;

	a.assign(n, 0);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	sort(a.begin(), a.end(), greater<int>());

	while(a.size() != 1){
		double x = a.back();
		double y = a[a.size() - 2];

		a.pop_back();
		a.pop_back();

		a.push_back((x + y) / 2.0);
		sort(a.begin(), a.end(), greater<int>());
	}

	cout << fixed << setprecision(9) <<  a.back();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int dx[]= {0, 0, 1, -1};
int dy[]= {1, -1, 0, 0};
int dist[1001][1001];
bool vis[1001][1001];

void solve() {
        int n, m; cin >> n>> m;
        int sx, sy; cin >> sx>> sy;
        int ex, ey; cin >> ex>> ey;
        sx--, sy--, ex--, ey--;

        vector<string> v(n);

        for (auto& i: v) cin >> i;

        for (int i= 0; i<= n; i++) for (int j= 0; j<= m; j++) dist[i][j]= 2e9;
        for (int i= 0; i<= n; i++) for (int j= 0; j<= m; j++) vis[i][j]= 0;

        deque<pair<pair<int, int>, int>> dq;
        dist[sx][sy]= 0;
        dq.push_back({{sx, sy}, 0});

        while (dq.size()) {
                int x= dq.front().first.first;
                int y= dq.front().first.second;
                int cst= dq.front().second;
                dq.pop_front();

                if (vis[x][y]) continue;
                vis[x][y]= 1;

                for (int i= 0; i< 4; i++) {
                        int tox= x+ dx[i];
                        int toy= y+ dy[i];

                        if (tox< 0|| toy< 0|| tox>= n|| toy>= m|| v[tox][toy]== '#') {
                                continue;
                        }
                        if (dist[tox][toy]> dist[x][y]) {
                                dist[tox][toy]= dist[x][y];
                                dq.push_front({{tox, toy}, cst});
                        }
                }
                for (int j= -2; j<= 2; j++)
                for (int i= -2; i<= 2; i++) {
                        int tox= x+ j;
                        int toy= y+ i;

                        if (tox< 0|| toy< 0|| tox>= n|| toy>= m|| v[tox][toy]== '#') {
                                continue;
                        }

                        if (dist[tox][toy]> dist[x][y]+ 1) {
                                dist[tox][toy]= dist[x][y]+ 1;
                                dq.push_back({{tox, toy}, cst+ 1});
                        }

                }
        }

        cout << (dist[ex][ey]== 2e9? -1: dist[ex][ey])<< "\n";

}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

using namespace std;

int main(void)
{
  long a,b;

  cin >> a >> b;
  
  if((a + b) % 2){
    cout << "IMPOSSIBLE" << endl;
  }

  else {
    cout << (a + b)/2 << endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,j;
    cin>>n;
    vector<int> a(n);
    vector<vector<long long>> dp(n,vector<long long>(n,__LONG_LONG_MAX__));
    for(int i=0;i<n;i++)cin>>a[i];
    auto sum = [&](int i,int j){
        long long res = 0LL;
        for(int k=i;k<=j;k++){
            res+=a[k];
        }
        return res;
    };
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i==j){
                dp[i][j]=0;
            }else{
                long long s = sum(i,j);
                for(int k=i;k<=j-1;k++){
                    dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
                }

            }
        }
    }
    cout<<dp[0][n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1536
const debug = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (input) => {
  switch (input) {
    case "A":
      return "T"
    case "T":
      return "A"
    case "C":
      return "G"
    case "G":
      return "C"
  }
  return
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}


Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-2){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(std::abs(s)>std::abs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1||b==N-1)continue;
            if(std::abs(t)>std::abs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

ll mod = 1e9 + 7;

ll modpow(ll a,ll n){
    ll res = 1;
    while(n > 0){
        if(n&1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x,mod-2);
}

ll comb(ll n, ll k){
    ll ans1 = 1;
    ll ans2 = 1;
    rep(i,k) ans1 = ans1 * (n-i) % mod;
    rep(i,k) ans2 = ans2 * (i+1) % mod;
    return ans1*modinv(ans2) % mod;
}

int main(){
    ll n,a,b; cin >> n >> a >> b;
    ll ans = modpow(2,n)-1-comb(n,a)-comb(n,b);
    while (ans < 0) ans += mod;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

int main() {
    string s;cin>>s;
    int count[127]={0};
    for(auto i:s){
        count[i]++;
    }
    
    for(auto i = 0; i<127;i++){
        if(count[i]>=2) {cout<<"no"<<endl;return 0;}
    }
    cout<<"yes"<<endl;
    
    return 0;
}







Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

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

    vector<ll> dists(5);
    dists[0] = A;
    dists[1] = B;
    dists[2] = C;
    dists[3] = D;
    dists[4] = E;

    vector<ll> divs(5);
    ll max_div = 0;
    bool has_rem = false;
    for (int i = 0; i < 5; i++) {
        divs[i] = N / dists[i];
        if (max_div < divs[i]) {
            max_div = divs[i];
            has_rem = ((N % dists[i]) != 0);
        }
    }

    if (has_rem) {
        cout << 5LL + max_div << endl;
    } else {
        cout << 5LL + max(0LL, max_div - 1LL) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

bool bingo(bool m[3][3]){
    rep(i,3){
        if(m[i][0] && m[i][1] && m[i][2]) return true;
        if(m[0][i] && m[1][i] && m[2][i]) return true;
    }
    if(m[0][0] && m[1][1] && m[2][2]) return true;
    if(m[0][2] && m[1][1] && m[2][0]) return true;
    return false;
}

int main(void){
    map<int, pair<int,int>> dic;
    bool m[3][3];
    rep(i,3){
        rep(j,3){
            int a;
            cin >> a;
            dic[a] = make_pair(i,j);
            m[i][j] = false;
        }
    }
    int n;
    cin >> n;
    int b;
    rep(_,n){
        cin >> b;
        if(dic.count(b)){
            auto p = dic.at(b);
            m[p.fs][p.sc] = true;
        }
    }
    if(bingo(m)){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
int f[maxn];
int v[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	rep(i,1,n+1)cin >> v[i];
	k = min(k,(int)5e7/n);
	rep(i,0,k){
		rep(j,1,n+1)f[j] = 0;
		rep(j,1,n+1){
			int l = max(j - v[j],1);
			int r = min(n+1,j+v[j]+1);
			++f[l],--f[r];
		}
		int q = 0;
		rep(j,1,n+1){
			q += f[j];
			v[j] = q;
		}
	}
	rep(i,1,n+1)cout << v[i] << ' ';
	return 0;
}


Measured memory_bytes: 5176
#include<iostream>
#include<array>
#include<algorithm>
using namespace std;
int
main()
{
	array<int,3> a= {},b={5,5,7};
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(),a.end());
	if(a[0]==b[0] and a[1]==b[1] and a[2]==b[2])
	{
		cout << "YES" << endl;
	}
	else 
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
n = gets.chomp.to_i

num_len = 0
num = 1
while true
	num_s = num.to_s(4)
	ok_7 = false
	ok_5 = false
	ok_3 = false
	ok = true
	for i in 0..num_s.length-1
		if num_s[i] == '3'
			ok_7 = true
			num_s[i] = '7'
		elsif num_s[i] == '2'
			ok_5 = true
			num_s[i] = '5'
		elsif num_s[i] == '1'
			ok_3 = true
			num_s[i] = '3'
		else
			ok = false
			break
		end
	end
	if num_s.to_i > n
		break
	end
	if ok && ok_7 && ok_5 && ok_3
		num_len += 1
	end
	num += 1
end




puts num_len.to_s

Measured memory_bytes: 1788
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=500001;
P a[maxn],b[maxn];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
  }
  for(int i=0;i<n;i++){
    cin>>b[i].first>>b[i].second;
  }
  sort(a,a+n);
  sort(b,b+n);
  bool used[maxn];
  fill(used,used+maxn,true);
  int res=0;
  for(int i=0;i<n;i++){
    int tmp=-1;
    int tmp2=-1;
    for(int j=0;j<n;j++){
      if(used[j] and b[i].first>a[j].first){
        if (b[i].second>a[j].second){
          if(tmp2<=a[j].second){
            tmp=j;
            tmp2=a[j].second;
          }
        }
      }
    }
    if(tmp!=-1){
      used[tmp]=false;
      res++;
    
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 2816
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int ans = max(a+b,a-b);
  ans = max(ans,a*b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=[chomp(readline()) for i in 1:n]
    cnt=[100 for i in 1:26]
    for i in s
        res=[0 for _ in 1:26]
        for j in i
            res[j-'a'+1]+=1
        end
        for j in 1:26
            cnt[j]=min(cnt[j],res[j])
        end
    end
    ans=""
    for i in 0:25
        ans=join([ans,string('a'+i)^cnt[i+1]])
    end
    println(ans)
end
main()

Measured memory_bytes: 167696
INF = 10**9+7
N = int(input())
dp = [[[[0]*4 for k in range(4)] for j in range(4)] for i in range(110)]
# T:0 A:1 G:2 C:3
res = 0
dp[0][0][0][0]=1
for n in range(1,N+1):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if (i,j,k)==(1,2,3):continue
                    if (i,j,k)==(2,1,3):continue
                    if (i,j,k)==(1,3,2):continue
                    if (j,k,l)==(1,2,3):continue
                    if (j,k,l)==(2,1,3):continue
                    if (j,k,l)==(1,3,2):continue
                    if (i,k,l)==(1,2,3):continue
                    if (i,j,l)==(1,2,3):continue
                    dp[n][j][k][l]+=dp[n-1][i][j][k]
                    dp[n][j][k][l]%=INF
for i in range(4):
    for j in range(4):
        for k in range(4):
            res = (res+dp[N][i][j][k])%INF
print(res) 

Measured memory_bytes: 3444
#include<stdio.h>
int main(void){
  int N,D,X,i,j,C;
  scanf("%d",&N);
  scanf("%d %d",&D,&X);
  int A[N+1];
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
    for(j=0;j*A[i]+1<=D;j++){
    }
    A[i] = j;
    C = C + A[i];
  }
  C = C + X;
  printf("%d",C);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define vll vector<long long>

using namespace std;

typedef long long ll;

#define MAX 100001

int N;
ll A[MAX];
ll B[MAX];
ll c = 0;

bool check(ll i)
{
    ll val = B[i];
    bool f = true;
    FOR(j, i + 1, N)
    {
        if (val * 2 >= A[j]) {
            val += A[j];
        } else {
            f = false;
            break;
        }
    }
    if (f) {
        c++;
    }
    return f;
}

int main()
{
    cin >> N;
    rep(i, N)
    {
        cin >> A[i];
    }
    std::sort(A, A + N);
    rep(i, N)
    {
        if (i == 0) {
            B[i] = A[i];
        } else {
            B[i] = B[i - 1] + A[i];
        }
    }

    ll min = 0;
    ll max = N - 1;
    ll ans = 0;
    while (true) {
        ll mid = (min + max) / 2;
        if (min == max) {
            ans = max;
            break;
        }
        if (check(mid)) {
            max = mid;
        } else {
            if (min == mid) {
                ans = min + 1;
                break;
            }
            min = mid;
        }
    }
    cout << N - ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    char c = s[0];
    int ans = 1;
    for (int i = 1; i < n; i++) {
        if (c != s[i]) { ans++; c = s[i]; }
        else continue;
    }
    cout << ans << endl;
}


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

typedef long long ll;

int N;
ll C;
ll MAX[100010];
ll V[100010],X[100010];
ll ans = 0;

void unit()
{
    ll sum = 0;
    for(int i = 0; i < N; i++)
    {
        sum += V[i];
        if(i)MAX[i] = max(MAX[i - 1],sum - X[i]);
        else MAX[i] = sum - X[i];
        ans = max(ans,MAX[i]);
    }
    sum = 0;
    reverse(V,V + N);
    reverse(X,X + N);
    for(int i = 0; i < N; i++)
    {
        sum += V[i];
        ans = max(ans,sum - 2LL * (C - X[i]) + MAX[N - 2 - i]);
    }
    reverse(V,V + N);
    reverse(X,X + N);
}

int main()
{
    scanf("%d%lld",&N,&C);
    for(int i = 0; i < N; i++)
    {
        ll x,v;
        scanf("%lld%lld",&x,&v);
        X[i] = x;
        V[i] = v;
    }

    unit();
    reverse(X,X + N);
    reverse(V,V + N);
    for(int i = 0; i < N; i++)X[i] = C - X[i];
    unit();

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int64_t kRem = 1000000007;

tuple<int64_t, int64_t, int64_t> gcd(int64_t x, int64_t y)
{
	assert(0 < x);
	assert(0 <= y);

	if (x < y) swap(x, y);

	if (y == 0) return make_tuple(x, 1, 0);

	tuple<int64_t, int64_t, int64_t> ret = gcd(y, x % y);

	return make_tuple(get<0>(ret), get<2>(ret), get<1>(ret) - (x / y) * get<2>(ret));
}

int64_t divide_rem(int64_t divident, int64_t dividor, int64_t rem)
{
	int64_t ret = get<2>(gcd(rem, dividor));
	while (ret < 0) ret += rem;

	ret *= divident;
	ret %= rem;

	return ret;
}

int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

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

	int n, a, b, c; cin >> n >> a >> b >> c;
	int ab = a + b;

	vector<int64_t> ncr(n * 2);
	{
		int64_t val = 1;
		ncr[0] = val;
		FOR_LT(i, 1, n * 2) {
			val *= (n  - 1 + i);
			val %= kRem;
			val = divide_rem(val, i, kRem);
			ncr[i] = val;
		}
	}

	int64_t ans = 0;
	FOR_LT(i, 0, n) {
		int m = n + i;

		int64_t val = ncr[i];
		val *= pow_rem(a, n, kRem);
		val %= kRem;
		val *= pow_rem(b, i, kRem);
		val %= kRem;

		int64_t q = pow_rem(ab, m, kRem);
		int64_t cur_ans = (n + i) * val;
		cur_ans %= kRem;
		cur_ans = divide_rem(cur_ans, q, kRem);
		ans += cur_ans;
		ans %= kRem;
	}

	FOR_LT(i, 0, n) {
		int m = n + i;

		int64_t val = ncr[i];
		val *= pow_rem(b, n, kRem);
		val %= kRem;
		val *= pow_rem(a, i, kRem);
		val %= kRem;

		int64_t q = pow_rem(ab, m, kRem);
		int64_t cur_ans = (n + i) * val;
		cur_ans %= kRem;
		cur_ans = divide_rem(cur_ans, q, kRem);
		ans += cur_ans;
		ans %= kRem;
	}

	if (c != 0) {
		ans *= 100;
		ans %= kRem;
		ans = divide_rem(ans, (100 - c), kRem);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    vector<string> s(3);
    for(LL i=0; i<3; i++){
        cin >> s[i];
    }
    for(LL i=0; i<3; i++){
        cout << s[i][i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

int main(){
  int n;cin >> n;
  vector<vector<int>> happy(n,vector<int>(3));
  rep(i,n)rep(j,3)cin >> happy[i][j];
  //dp[i][j]:=i日目に活動jを行う場合の最大値(0 A,1 B,2 C)
  vector<vector<int>> dp(n,vector<int>(3));
  rep(i,3)dp[0][i]=happy[0][i];
  rep(i,n-1)rep(j,3){
    int k=0,l=1;
    if(j==0){k=1;l=2;}
    else if(j==1){k=0;l=2;}
    dp[i+1][j]=max(dp[i][k],dp[i][l])+happy[i+1][j];
  }
  cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    string s;
    int w;
    cin >> s;
    cin >> w;
    REP(i,s.size()) if(i%w == 0) cout << s[i];
    cout << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
int n,G[101][101];
int d[101];
int T = 0;
int F[101] = {0};
int k = 0;
 
void visit(int u) {
  int i,j,v;
  T++;
  d[u] = T;
 
  for(v=0;v<n;v++) {
    if(G[u][v] == 1 && d[v] == 0 ) {
      visit(v);
    }
  }
 
  T++;
  F[u] = T;
 
}
 
 
 
int main() {
 
 
  int i,j,k,l,u,a,t;
 
  for(i=0;i<n;i++) d[i] = 0;
 
  scanf("%d",&n);
 
  for(i=0;i<n+1;i++)
    for(j=0;j<n+1;j++) {
      G[i][j] = 0;
 
    }
 
  for(i=0;i<n;i++){
 
    scanf("%d %d ",&k,&u);
    //    printf("u = %d\n",u);
 
    for(j=0;j<u;j++) {
      scanf("%d",&a);
      G[k -1][a-1] = 1;
      // printf("G[%d][%d] = 1\n",i,k-1);
    }
  }
  for(i=0;i<n;i++) {
    if(d[i] == 0)
    visit (i);
  }
 
  for(i=0;i<n;i++) {
    printf("%d %d %d\n",i+1,d[i],F[i]);
  }
  return 0;
 
 
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

const long long INF = 1LL << 60;


//kubaru DP

int main() {
	int n, k;
	long long h[100010];

	long long dp[100100];

	cin >> n >> k;
	rep(i, n) cin >> h[i];
	rep(i, 100100) dp[i] = INF;
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}

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

	return 0;
}


Measured memory_bytes: 1792
S = STDIN.gets.chomp

oneNum = 0
zeroNum = 0

S.chars { |c|
  if c == '0' then
    oneNum = oneNum + 1
  else
    zeroNum = zeroNum + 1
  end
}

small = oneNum < zeroNum ? oneNum : zeroNum
puts small * 2

Measured memory_bytes: 3836
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(N, 0);
    vector<int> b(N, 0);
    int M = 0;

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

    for (int i = N - 1; i >= 0; i--) {
        int sum = 0;
        for (int j = 2 * i + 1; j < N; j = j + (i + 1)) {
            sum += b[j];
        }

        sum %= 2;

        if (sum == a[i]) {
            b[i] = 0;
        } else {
            b[i] = 1;
            M++;
        }
    }

    cout << M << endl;

    for (int i = 0; i < N; i++) {
        if (b[i] == 1) {
            cout << i + 1 << " ";
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
from collections import Counter

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

S = [0]

for a in A:
    S.append((S[-1]+a)%M)

c = Counter()
ans = 0

for s in S:
    ans += c[s]
    c[s] += 1
    
print(ans)

Measured memory_bytes: 16544
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCommonRaccoonVsMonster solver = new BCommonRaccoonVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCommonRaccoonVsMonster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            long sum = 0;
            for (int i = 0; i < k; i++) sum += in.nextInt();
            if (n <= sum) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 32148
#include <stdio.h>

int main(void){
    int a,b,c,n,i;
    scanf("%d",&n);
    a=1;b=1;
    if(n==0||n==1){
        printf("1\n");
        return 0;
    }
    for(i=2;i<=n;i++){
        c = a+b;
        a = b;
        b = c;
    }
    printf("%d\n",b);
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main() {
	int a, b;
	cin>>a>>b;
	if (a == 0) {
		if (b != 100) cout<<b<<endl;
		else cout<<"101"<<endl;
	}
	else if (a == 1) {
		if (b != 100) cout<<100*b<<endl;
		else cout<<"10100"<<endl;
	}
	else {
		if (b != 100) cout<<10000*b<<endl;
		else cout<<"1010000"<<endl;
	}
}

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

const int MAX_X = 1000000;
bool sosu[MAX_X+1];
bool sum[MAX_X+1];
int costs[30];

int main(){
	for(int i = 2; i <= MAX_X; i++) sosu[i] = true;
	for(int i = 2; i * i <= MAX_X; i++){
		if(sosu[i] == true)
			for(int j = 2; i * j <= MAX_X; j++)
				sosu[i*j] = false;
	}
	sosu[0] = sosu[1] = false;
	int n, x;
	while(cin >> n >> x){
		if(n == 0 && x == 0) break;
		for(int i = 1; i <= x; i++){
			sum[i] = false;
		}
		sum[0] = true;
		for(int i = 0; i < n; i++){
			cin >> costs[i];
		}
		for(int i = 0; i < x; i++){
			if(sum[i])
				for(int j = 0; j < n; j++){
					if(i + costs[j] <= x)
						sum[i+costs[j]] = true;
				}
		}
		int m = x;
		while(m > 1){
			if(sum[m] && sosu[m]) break;
			m--;
		}
		if(m == 1) cout << "NA" << endl;
		else cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 2820
S = input()[::-1]
T = input()[::-1]

p = 0
e = len(T)
ans = ''
while 1:
    s = S[p:e]

    if len(s) != len(T):
        print('UNRESTORABLE')
        break
    tmp = ''
    for i in range(len(T)):
        if s[i] == T[i] or s[i] == '?':
            tmp += T[i]
        else:
            ans += s[0]
            break
    else:
        ans += tmp
        ans += S[e::]
        print(ans.replace('?','a')[::-1])
        exit()
    p += 1
    e += 1

Measured memory_bytes: 8976