akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(int x, int y, int mod){
    int ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << "No" << endl;
    exit(0);
}

template <class T>bool chmax(T &a, const T &b){if (a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;} return 0;}





int main(){
    sonic();
    int n, A=0, B=0, AB=0, ans=0;
    R n;
    rep(i, n) {
        string s;
        R s;
        int l = s.length();
        if ((s[l - 1] == 'A') && (s[0] == 'B'))AB += 1;
        else {
            if (s[l - 1] == 'A')A += 1;
            else if (s[0] == 'B')B += 1;
        }
        rep(j, l - 1) {
            if ((s[j] == 'A') && (s[j + 1] == 'B'))ans += 1;
        }
    }
        if(AB==0)ans+=min(A,B);
        else{
            ans+=AB-1;
            if(A){
                A-=1;
                ans+=1;
            }
            if(B){
                B-=1;
                ans+=1;
            }
            ans+=min(A,B);
        }
        co(ans);
}


Measured memory_bytes: 3616
fun main(args: Array<String>) {
    val n = readLine()
    val s = readLine()!!.split(" ")
    val a = s[0]
    val b = s[1]
    var result = a.zip(b) {
        a, b -> a.toString() + b.toString()
    }.joinToString("")
    print(result)
}


Measured memory_bytes: 36072
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        System.out.println(solve(N, M));

        sc.close();
    }

    static long solve(int N, int M) {
        if (N > M) {
            return solve(M, N);
        }

        if (N == 1) {
            if (M == 1) {
                return 1;
            } else {
                return M - 2;
            }
        }

        return (N - 2L) * (M - 2);
    }
}

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

int main(int argc, char const* argv[])
{
  string s;
  int a=0,b=0,ind=0;
  cin >> s;
  for (auto ite=s.begin();ite!=s.end();ite++){
    if (*ite-'0'!=ind) a++;
    else  b++;
    ind = !ind;
  }
  cout << min(a,b) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
	int n,m,i,a,b,c=0,data1[200001]={0},datan[200001]={0};
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		if(a==1){
			data1[b]=1;
		}else if(b==n){
			datan[a]=1;	
		}
	}
	
	for(i=0;i<n;i++){
		if(datan[i]==1){
			if(data1[i]==1){
				printf("POSSIBLE\n");
				return 0;
			}
		}
	}
	
	printf("IMPOSSIBLE\n");
	
return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	
	if(a < b && b < c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;

namespace 練習１
{
    class Program
    {
        static void Main(string[] args)
        {
            var x1 = Console.ReadLine().Split(' ');
            var x2 = new decimal[2];
            for(var i = 0; i < x1.Length; i++)
            {
                x2[i] = decimal.Parse(x1[i]);
            }
            var N = x2[0];
            var K = x2[1];

            var x = N % K;
            var y = Math.Abs(x - K);
            if (x >= y)
            {
                Console.WriteLine(y);
            }
            else
            {
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

struct team{
	int name;
	int s;
};

int main() {
	int n;
	int m[4];
	int s[4];
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector<team> t(n);
		for (int i = 0; i < n; i++) {
			cin >> t[i].name >> m[0] >> s[0] >> m[1] >> s[1] >> m[2] >> s[2] >> m[3] >> s[3]; 
			t[i].s = 0;
			for (int j = 0; j < 4; j++) {
				t[i].s += s[j];
				t[i].s += (m[j] * 60);
			}
		}
		int juni[4][2];
		for (int i = 3; i > 0; i--) {
			for (int j = 0; j < i; j++) {
				if (t[j].s > t[j+1].s) {
					swap(t[j].s, t[j+1].s);
					swap(t[j].name, t[j+1].name);
				}
			}
		}
		for (int i = 0; i < 4; i++) {
			juni[i][0] = t[i].name;
			juni[i][1] = t[i].s;
		}
		for (int i = 4; i < n; i++) {
			if (t[i].s < juni[0][1]) {
				juni[1][1] = juni[0][1];
				juni[1][0] = juni[0][0];
				juni[0][1] = t[i].s;
				juni[0][0] = t[i].name;
			} else if (t[i].s < juni[1][1]) {
				juni[1][1] = t[i].s;
				juni[1][0] = t[i].name;
			} else if (t[i].s > juni[3][1]) {
				juni[2][1] = juni[3][1];
				juni[2][0] = juni[3][0];
				juni[3][1] = t[i].s;
				juni[3][0] = t[i].name;
			} else if (t[i].s > juni[2][1]) {
				juni[2][1] = t[i].s;
				juni[2][0] = t[i].name;
			}
		}
		for (int i = 0; i < 3; i++) {
			cout << juni[i][0] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
A = gets.to_i
B = gets.to_i
C = gets.to_i
X = gets.to_i

ans = 0
(0..A).each do |a|
  s1 = 500 * a
  (0..B).each do |b|
    s2 = 100 * b
    (0..C).each do |c|
      s3 = 50 * c
      ans += 1 if s1 + s2 + s3 == X
    end
  end
end
p ans



Measured memory_bytes: 1788
#include<iostream>
#include<vector>
int main() {
	std::vector<int> v;
	while(1){
	int n;
	int x = 0;
	std::cin >> n;
	if (n == 0)
		break;
	std::vector<int>a(n / 4);
		for (int i = 0;i < n / 4;++i) {
			std::cin >> a[i];
			x += a[i];
		}
		v.push_back(x);
	}
	for (int i = 0;i < v.size();++i) {
		std::cout << v[i] << std::endl;
	}
	return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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

  vector<int> q = p;
  sort(q.begin(),q.end());
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(p[i] != q[i]) cnt++;
  }
  if(cnt == 0 || cnt == 2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//??£?????°????????¨????????????
//????????????????????????????????? (????????????????????¨?????°?????????DFS??¨??????????????????)
//???DFS??¨?????????u(???root)???????????????lowlink[u] > prenum[u??????] ??? u?????? --> u?????? (??¨??????)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Edge {
	int u, v;
	Edge(int u, int v) { this->u = u; this->v = v; }
	Edge() { }
	bool operator<(const Edge &r) const { return (u != r.u) ? u < r.u : v < r.v; }
};

int n, m;
vector<int> et[100000];

int timer;
bool visited[100000];
int prenum[100000];
int lowest[100000];
int parent[100000];

void dfs(int u, int prev) {
	prenum[u] = timer;
	lowest[u] = timer;
	parent[u] = prev;
	visited[u] = true;
	timer++;
	
	for (int i = 0; i < et[u].size(); i++) {
		int v = et[u][i];
		
		if (!visited[v]) {
			dfs(v, u);
			lowest[u] = min(lowest[u], lowest[v]);
		}
		else if (parent[u] != v) {
			//u --> v????????????
			lowest[u] = min(lowest[u], prenum[v]);
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int src, dst;
		cin >> src >> dst;
		et[src].push_back(dst);
		et[dst].push_back(src);
	}
	
	//????????????
	timer = 0;
	for (int i = 0; i < n; i++) visited[i] = false;
	dfs(0, -1);
	
	static vector<Edge> ans;
	
	for (int i = 1; i < n; i++) {
		if (prenum[parent[i]] < lowest[i]) {
			ans.push_back(Edge(min(parent[i], i), max(parent[i], i)));
		}
	}
	
	sort(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].u << " " << ans[i].v << endl;
	}
	
	return 0;
}

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

int main(){
	int a = 0;
	int b = 0;
	int sum = 0;
	cin >> a;
	cin >> b;
	sum = a * b;
	sum = sum % 2;
		if (sum == 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll N;

int main(){
	cin >> N;
	// num, pos
	vector<pair<ll, ll> > P(N);
	rep(i, N) {
		ll tmp;
		cin >> tmp;
		P.push_back(make_pair(tmp, i));
	}

	sort(P.rbegin(), P.rend());

	set<ll> pos;

	ll ans = 0;
	rep(i, N) {
		ll cur = P[i].second;
		ll firstLeft = -1, secondLeft = -1;
		ll firstRight = N, secondRight = N;

		pos.insert(cur);
		set<ll>::iterator it = pos.find(cur);

		if(it != pos.begin()) {
			it--;
			firstLeft = *it;
			if(it != pos.begin()) {
				it--;
				secondLeft = *it;
				it++;
			}
			it++;
		}
		it++;
		if(it != pos.end()) {
			firstRight = *it;
			it++;
			if(it != pos.end()) {
				secondRight = *it;
			}
		}

		ll tmp = 0;
		tmp += (firstLeft - secondLeft) * (firstRight - cur);
		tmp += (cur - firstLeft) * (secondRight - firstRight);
		tmp *= P[i].first;
		ans += tmp;

		//cout << "cur = " << cur << " firstleft " << firstLeft << " secondLeft " << secondLeft << " firstRight " << firstRight << " secondRight " << secondRight << endl;
	}
	cout << ans << endl;
}



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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999

using namespace std;

#define int long long

int32_t main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	if((a%2) || (b%2) || (c%2)){
		cout << 0 << endl;
		return 0;
	}

	if(a==b && b==c){
		cout << -1 << endl;
		return 0;
	}	
	
	int cnt=0;
	while(true){
		if((a%2) || (b%2) || (c%2)){
			cout << cnt << endl;
			return 0;
		}
		
		cnt++;
		int x, y, z;
		x=a/2;
		y=b/2;
		z=c/2;
		
		a=y+z;
		b=x+z;
		c=x+y;		
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
typedef long long LL;
int n,m,js,a[105],kl[105],b[105];
int main()
{
	scanf("%d%d",&n,&m);
	for(RI i=1;i<=m;++i) {
		scanf("%d",&a[i]);
		if(a[i]&1) kl[++js]=i;
	}
	if(js>2) {puts("Impossible");return 0;}
	if(js>=1) swap(a[kl[1]],a[1]);
	if(js>=2) swap(a[kl[2]],a[m]);
	if(m==1) {
		printf("%d\n",a[1]);
		b[1]=n/2+1;
		if(n-b[1]) puts("2"),printf("%d %d\n",b[1],n-b[1]);
		else puts("1"),printf("%d\n",b[1]);
	}
	else {
		b[1]=a[1]+1;for(RI i=2;i<m;++i) b[i]=a[i];
		for(RI i=1;i<=m;++i) printf("%d ",a[i]);
		puts("");
		if(a[m]-1) {
			printf("%d\n",m);b[m]=a[m]-1;
			for(RI i=1;i<=m;++i) printf("%d ",b[i]);
		}
		else {
			printf("%d\n",m-1);
			for(RI i=1;i<=m-1;++i) printf("%d ",b[i]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.numeric;

void main() {
    auto tmp = readln.split.to!(long[]);
    auto N = tmp[0], X = tmp[1];
    auto xs = readln.split.to!(long[]);
    xs.map!(x => abs(x - X)).reduce!((a,b) => gcd(a,b)).writeln;
}



Measured memory_bytes: 4276
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll n;
vector<ll> a, b;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    ll N = n;
    FOR(i,2,int(sqrt(n))) {
        if (N % i == 0) {
            int cnt = 0;
            a.push_back(i);
            while (N % i == 0) {
                N /= i;
                cnt++;
            }
            b.push_back(cnt);
        }
    }
    if (N > 1) {
        a.push_back(N);
        b.push_back(1);
    }
    ll res = 0;
    FOR(i,0,SZ(a)-1) {
        ll u = a[i], v = b[i];
        ll now = 1;
        while (v >= now) {
            v -= now;
            now++;
            res++;
        }
    }
    cout << res;
    return 0;
}


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

 

int main() {
    int x, y;
    cin >> x >> y;
    int ans =INFINITY;
    if (y - x > 0) ans = min(ans, y - x);
    if (y - (-x) >= 0) ans = min(ans, y - (-x) + 1);
    if (-y - x >= 0) ans = min(ans, -y - x + 1);
    if (-y - (-x) >= 0) ans = min(ans, -y - (-x) + 2);
    cout << ans << endl;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(void)
{
        int A, B;
        scanf("%d%d", &A, &B);

        int ans = 0;
        if (A > B) ans = 2 * A - 1;
        else if (A < B) ans = 2 * B - 1;
        else ans = A + B;

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


Measured memory_bytes: 128
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int two[] = {1,2,4,8,16,32,64};
int max = 0;
for(int i = 0;i<7;i++){
if(two[i] > N) break;
max = i;
}


System.out.println(two[max]);

} 
}

Measured memory_bytes: 22740
#include<stdio.h>

int main(void)
{
        int A,B,K;
        int i,j;

        scanf("%d%d%d",&A,&B,&K);



        if(A>B)i=B;
        else i=A;



        for(j=0;j<K;i--){
                if(A%i==0 && B%i==0)j++;
        }






        printf("%d\n",i+1);

        return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int k;
    cin >> k;
    cout << (k / 2) * (k / 2 + k % 2);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll= long long;
using ld= long double;
using vi= vector<int>;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvi= vector<vector<int>>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N, M;
    cin >> N >> M;
    scc_graph G(N);
    REP(i, M) {
        ll x, y;
        cin >> x >> y;
        G.add_edge(x, y);
    }
    vvi SC= G.scc();
    cout << SC.size() << "\n";
    REP(i, SC.size()) {
        cout << SC[i].size() << " ";
        REP(l, SC[i].size()) {
            cout << SC[i][l] << (l == SC[i].size() - 1 ? "\n" : " ");
        }
    }
}

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

int main() {
  int S;
  cin >> S;
  vector<int> s={S/1000,S%1000/100,S%100/10,S%10};
  vector<char> p(3),o={'+','-'};
  int i;
  for(char a:o){
    for(char b:o){
      for(char c:o){
        p={a,b,c};
        i=s.at(0);
        for(int j=0;j<3;j++){
          if(p.at(j)=='+')
            i+=s.at(j+1);
          else
            i-=s.at(j+1);
        }
        if(i==7){
          for(int j=0;j<3;j++)
            cout << s.at(j) << p.at(j);
          cout << s.at(3) << "=7" << endl;
          break;
        }
      }
      if(i==7)
        break;
    }
    if(i==7)
    break;
  }
}

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

int main() {
  int k,n;
  cin >> k >> n;
  int A[n]; //家の地点
  int d[n];
  int way = k; //最短距離
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    if(i > 0){
      d[i-1] = A[i] - A[i-1]; //時計回りの隣の家の距離
      d[i-1] = k - d[i-1]; //全体の距離-時計回りの隣の家の距離
      if(way > d[i-1]){
        way = d[i-1];
      }
      //最後かつ今の最短距離より最初の家と最後の家との距離が近いとき
      if (i == n-1 && way > A[i] - A[0]){ 
          way = A[i] - A[0];
      }
      }
  }
  cout << way;
 return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>

using namespace std;

int main(void)
{
	//freopen("C:\\Users\\h2539\\Desktop\\in.txt","r",stdin);
	//freopen("C:\\Users\\h2539\\Desktop\\out.txt","w",stdout);

	int L, A, B, C, D;

	// L : 日数 |  A : 国語p |  B : 算数p  |  C : 国語max |   D : 算数max
	cin >> L >> A >> B >> C >> D;

	int a = A, b = B, i = 0;

	for(i = 0; !(a <= 0 && b <= 0) ; i++)
	{
			a -= C;
			b -= D;
	}

	cout << L - i << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>


using namespace std;
typedef long long LL;

int main(void) {
	string str;
	int w;

	str.resize(1000);

	cin >> str;
	cin >> w;

	for (int i = 0; i < (int)str.size(); i++) {
		if (i%w == 0) {
			cout << str[i];
		}
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll smod=998244353;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;





ll i,j,k;


int main(){
  //オーバーフローに注意！
  int N;
  cin>>N;
  int jud=N%10;
  if(jud==3)cout<<"bon";
  else if(jud==0||jud==1||jud==6||jud==8)cout<<"pon";
  else cout<<"hon";
  cout<<endl;
  

 
  
  
}


Measured memory_bytes: 3628
io = STDIN
d,n=io.gets.split.map(&:to_i)
case d
when 0
  if n==100
    puts 101
  else
    puts n
  end
when 1
  if n==100
    puts 10100
  else
    puts 100*n
  end
else
  if n==100
    puts 1010000
  else
    puts 10000*n
  end
end


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

string S[10009]; int N; map<string, int>M; bool OK = true;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		if (i >= 1 && S[i - 1][S[i - 1].size() - 1] != S[i][0]) OK = false;
		if (M[S[i]] == 1) OK = false;
		M[S[i]] = 1;
	}
	if (OK == true) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
 using namespace std;
	int main()
	{
		ll n;
		cin>>n;
		string s;
		cin>>s;
		string s2;
		if(s.length()>n)
		{
			for(int i=0;i<n;i++)
			{
				s2+=s[i];
			}
			s2+="...";
			cout<<s2<<endl;
			return 0;
		}
		else
		{
			cout<<s<<endl;
		}
	}


Measured memory_bytes: 3628
N=int(input())
dp=[N]*(N+1)
dp[0]=0
for i in range(N):
    pow6=1
    while i+pow6<=N:
        dp[i+pow6]=min(dp[i+pow6],dp[i]+1)
        pow6*=6
    pow9=1
    while i+pow9<=N:
        dp[i+pow9]=min(dp[i+pow9],dp[i]+1)
        pow9*=9
print(dp[N])

Measured memory_bytes: 3828
#include <stdio.h>

int main() {
    int a=0,b=0,X=0,c;
    scanf("%d",&X);
    while(X>=500)
    {
        a++;
        X=X-500;
    }
    while(X>=5)
    {
        b++;
        X=X-5;
    }
    c=(a*1000)+(b*5);
    printf("%d\n",c);
    return 0;
}


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

using namespace std;

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

    string s;
    cin >> s;

    int zero = 0;
    int one = 0;
    for (char c : s) {
        if (c == '0') {
            zero++;
        } else {
            one++;
        }
    }

    cout <<min(zero, one) * 2 << '\n';
    
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N,K;

	cin >> N >> K;
	
	int comb=((N-1)*(N-2))/2;
	if(K>comb)
	{
		cout << -1 << endl;
		return 0;
	}

	vector<pair<int,int>> vec;
	for(int i=2;i<=N;i++)
		vec.push_back(make_pair(1,i));
	int cnt=0;
	for(int i=2;i<=N && cnt<comb-K;i++)
	{
		for(int j=i+1;j<=N && cnt<comb-K;j++)
		{
			vec.push_back(make_pair(i,j));
			cnt++;
		}
	}

	cout << vec.size() << endl;
	for(auto& i:vec)
		cout << i.first << " " << i.second << endl;
	return 0;
}



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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

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

  while(true) {
    int n; cin >> n;
    if(!n) break;
    VI t(n), c(n);
    vector<PII> p(n);
    REP(i, n) {
      cin >> t[i] >> c[i];
      p[i] = {t[i], i};
    }
    sort(ALL(p));

    // (人i, 折り返すまでにかかる時間, 周回数)
    queue<VI> que[2];
    REP(i, n) que[0].push({p[i].second, p[i].first, 0});

    int ans = 0;
    while(que[0].size() || que[1].size()) {
      // curのqueueから取り出す
      int cur = 0;
      if(que[cur].empty()) cur ^= 1;
      else if(que[cur^1].size() && que[cur].front()[1] > que[cur^1].front()[1]) cur ^= 1;

      // next以下のものを取り出す
      VVI v;
      int next = que[cur].front()[1];
      while(que[cur].size() && que[cur].front()[1] <= next) {
        v.PB(que[cur].front());
        que[cur].pop();
      }
      // vの中身を速度順でソートする
      sort(ALL(v), [&](const VI&a, const VI&b){
        return t[a[0]] < t[b[0]];
      });
      // vの中身を次のqueueに移す
      REP(i, v.size()) {
        if(cur == 1) v[i][2]++;
        if(v[i][2] == c[v[i][0]]) ans = next;
        else que[cur^1].push({v[i][0], next+t[v[i][0]], v[i][2]});
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000

int a[MAX_N];
int b[MAX_N];


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int A, B, C;
  cin >> A >> B >> C;


  if ( (A == B) && (A != C) ) cout << "Yes" << endl;
  else if ( (A == C) && (A != B) ) cout << "Yes" << endl;
  else if ( (B == C) && (B != A) ) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
  
}


Measured memory_bytes: 256
//AtCoder ABC120 C - Unification
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
std::string replaceStringAll(std::string str,
                             const std::string& replace,
                             const std::string& with) {
    if(!replace.empty()) {
        std::size_t pos = 0;
        while ((pos = str.find(replace, 0)) != std::string::npos) {
            str.replace(pos, replace.length(), with);
            //pos += with.length();
        }
    }
    return str;
}
int main() {
#if LOCAL&0
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    string S="0011";
    cin>>S;
    ll cnt0=0;
    for(const auto& c:S){
        if(c=='0'){
            ++cnt0;
        }
    }
    ll cnt1=S.size()-cnt0;
    cout<<min(cnt0,cnt1)*2<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	FOR(i,0,N)cin >> A[i];

	ll bits = 61;
	vector<ll> cnt(bits,0);
	for(auto a:A){
		FOR(i,0,bits){
			if(a&(1LL<<i))cnt[i]++;
		}
	}

	ll ans = 0;
	FOR(i,0,N){
		ll k = N-1-i;
		FOR(j,0,bits){
			if(A[i]&(1LL<<j))cnt[j]--;
			if(A[i]&(1LL<<j)){
				(ans += ((1LL<<j)%MOD) * (k-cnt[j]) %MOD ) %= MOD;
			}else{
				(ans += ((1LL<<j)%MOD) * cnt[j] %MOD ) %= MOD;
			}
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
fun solve(S: Int){
    val a = S / 100
    val b = S % 100
    if (1<= a && a<= 12){
        if (1<= b && b<= 12){
            println("AMBIGUOUS")
            return
        }
            println("MMYY")
            return
    }
    if (1<= b && b<= 12){
        println("YYMM")
        return
    }
        println("NA")
        return
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next().toInt()
    solve(S)
}



Measured memory_bytes: 31380
num = [int(x) for x in input().split()]

student = []
for i in range(0, num[0]):
    student.append([int(x) for x in input().split()])
checkpoint = []
for j in range(0, num[1]):
    checkpoint.append([int(x) for x in input().split()])


res = []
cnt = 0
for k in student:
    dis = float("inf")
    for l in checkpoint:
        if dis > abs(k[0]-l[0]) + abs(k[1]-l[1]):
            dis = abs(k[0]-l[0]) + abs(k[1]-l[1])
            cnt = checkpoint.index(l)
    res.append(cnt+1)


for m in res:
    print(m)

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

using namespace std;

int main(){

	int N;
	cin >> N;
	set<int> a;
	int count=0;
		
	for(int i=0;i<N;i++){
		int x;
		cin >> x;			
		if(a.insert(x).second){count++;};	
	}

	cout << count<<endl;


	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int a,b,c,x=0;
    cin>>a>>b>>c;
    for(a;a<=b;a++){
        if(c%a==0){
            x++;
        }
    }
    cout<<x<<endl;
    return 0;
}

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

long crec[31][100001];

int main(){long N, C; 
cin >> N >> C;
vector<long> s(N + 1); vector<long> t(N + 1); vector<long> c(N + 1);
erep(i, N) cin >> s.at(i) >> t.at(i) >> c.at(i);
erep(i, C){
    erep(j, 100000) crec[i][j] = 0;
}
erep(i, N){
    for(long j = s.at(i); j < t.at(i); j++){
        crec[c.at(i)][j] = 1;
    }
}
erep(i, C){
    erep(j, 99999){
        if(crec[i][j] == 0 && crec[i][j + 1] == 1){
            crec[i][j] = 1;
        }
    }
}
vector<long> reccnt(100001);
rep(i, 100001) reccnt.at(i) = 0;
erep(j, 100000){
    erep(i, C){
        reccnt.at(j) += crec[i][j];
    }
}
sort(reccnt.begin(), reccnt.end());
reverse(reccnt.begin(), reccnt.end());
long ans = reccnt.at(0);

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

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

void dfs(vector<int> v, int before, int res){
    if(res == 0){
        for(int i = 0; i < v.size(); i++){
            if(i)   cout << " ";
            cout << v[i];
        }
        cout << endl;
        return;
    }

    for(int j = res; j >= 1; j--){
        if(before >= j){
            v.push_back(j);
            dfs(v, j, res-j);
            v.pop_back();
        }
    }
}

int main(){
    int n;
    while(cin >> n, n){
        for(int j = n; j >= 1; j--){
            vector<int> v;
            v.push_back(j);
            dfs(v, j, n-j);
        }
    }
    return 0;
}


Measured memory_bytes: 3068
void main() {
	auto ip = readAs!(int[]);
	ip.sort();
	auto A = ip[0], B = ip[1], C = ip[2];
	// どのような順番で操作しても、単純に足し算をしているだけなので影響しません
	// sortしても全然オッケー
	auto m = max(A, B, C);
	int r = m;
	int count;
	if(!(m & 1) == ((A + B + C) & 1)) r++; // ゴールの値 editorial参照
	while(A + 2 <= r) { A += 2; count++; } //
	while(B + 2 <= r) { B += 2; count++; } // 可能な限り2を足し続ける
	while(C + 2 <= r) { C += 2; count++; } //
	// 上限に満ちてない値が2つある状況 or ない状況になるはず
	if(A + B == 2*r - 2 || B + C == 2*r - 2 || C + A == 2*r - 2) count++;
	count.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
// Problem : B - Checkpoints
// Contest : AtCoder - AtCoder Beginner Contest 057
// URL : https://atcoder.jp/contests/abc057/tasks/abc057_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,m, x, y, c, mx, d;
	cin >> n >> m;
	vector<pair<int,int>> st(n), ch(m);
	vector<int> ans(n);
	for(int i = 0; i < n; i++){
	    cin >> x >> y;
	    st[i] = make_pair(x,y);
	}
	for(int i = 0; i < m; i++){
	    cin >> x >> y;
	    ch[i] = make_pair(x,y);
	}
	for(int i = 0; i < n; i++){
	    mx = INT_MAX;
	    for(int j = 0; j<m; j++){
	        d = abs(st[i].first - ch[j].first) + abs(st[i].second- ch[j].second);
	        if(mx > d){
	            ans[i] = j+1;
	            mx = d;
	        }
	    }
	}
	for(int answer:ans){
	    cout << answer<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
int main(){
    int a,b,c,x;
    while(scanf("%d%d%d%d",&a,&b,&c,&x)!=EOF){
        int count=0,i,j,k;
        for(i=0;i<=a;i++){
            for(j=0;j<=b;j++){
                for(k=0;k<=c;k++){
                    if(i*500+j*100+k*50==x){
                        count++;
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
#define INF 10000000


int scalar(int *);
int min(int,int);

int p[MAX];
int m[MAX][MAX];
int n;

int main(){
  int i;
  
  scanf("%d",&n);
  
  for(i=0 ; i<n ;i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }

  printf("%d\n",scalar(p));
  
  return 0;
}

int scalar(int *p){
  int i,j,k,l,q;
  for(i=1 ; i<=n ; i++){
    m[i][i]=0;
  }

  for(l=2 ; l<=n ; l++){
    for(i=1 ; i<=n-l+1 ; i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i ; k<j ; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]* p[k] * p[j];
	m[i][j]=min(m[i][j],q);
      }     
    }
  }
  return m[1][j];
}

int min(int m,int q){
  if(m<q)return m;
  else return q;
}

Measured memory_bytes: 636
#include<stdio.h>
 
int main(void){
 
  double g=9.8;
  double high;
  double time;
  double speed;
  double n;
 
  while(scanf("%lf",&speed)!=EOF){
    time = speed / g;
    high = time * time * g / 2.0;
    n = (5 + high) / 5;
    if((int)n != n)n++;
    printf("%d\n",(int)n);
  }
 
  return 0;
}


Measured memory_bytes: 1916
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{

    class ProgramC
    {
        //決まっている条件はすべての関数内で作用するようにする
        static int[] a = new int[50];
        static int[] b = new int[50];
        static int[] c = new int[50];
        static int[] d = new int[50];
        static List<int> ans = new List<int>();
        static int n;
        static int m;
        static int q;
        static int[] array = new int[10];//考えた配列

        static void Main(string[] args)
        {
            //入力
            string[] z = Console.ReadLine().Split(' ');
            n = int.Parse(z[0]);
            m = int.Parse(z[1]);
            q = int.Parse(z[2]);

            for (int i = 0; i < q; i++)
            {
                string[] y = Console.ReadLine().Split(' ');
                a[i] = int.Parse(y[0]);
                b[i] = int.Parse(y[1]);
                c[i] = int.Parse(y[2]);
                d[i] = int.Parse(y[3]);

            }

            //最初の文字と入れる場所の位置でDFS
            dfs(1, 0);

            Console.WriteLine(ans.Max());



        }

        /*深さ優先検索*/
        static void dfs(int f,int j)
        {
            if (j == n)
            {
                int count = 0;
                for (int i = 0; i < q; i++)
                {
                    if (array[b[i] - 1] - array[a[i] - 1] == c[i])
                        count += d[i];
                }

                ans.Add(count);//数えたものを入れておく
            }
            else
            {
                for (int c = f; c <= m; c++)
                {
                    array[j] = c;//追加する
                    dfs(c,j+ 1);//次の追加するところと始めるところを決める
                }
            }
        }
    }
}


Measured memory_bytes: 29012
#include<stdio.h>
int main(void){
int a,b,c,K;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
K=a;
a=b;
b=K;
}
if(a>c){
K=a;
a=c;
c=K;
}
if(b>c){
K=b;
b=c;
c=K;
}
printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 1976
import math
#import itertools
#import statistics
#import numpy as np
#import collections
n = int(input())
#a, b, c = list(map(int, input().split()))
#a = list(map(int, input().split()))
a = []
check = [0]*n
for i in range(n):
    a.append(int(input()))

find = False
i = 0
check[0]=1
count = 1
while not find:
    if a[i]!=2:
        if check[a[i]-1]==0:
            check[a[i]-1]=1
            count += 1
        else:
            print(-1)
            exit()

        i = a[i]-1   
    else:
        find=True


print(count)

Measured memory_bytes: 7852
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define MAX 500000

void Merge(int [],int,int,int,int *);
void MergeSort(int [],int,int,int *);

int main(){
int A[MAX],n;
int cnt = 0;
int i;

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

MergeSort(A,0,n,&cnt);

for (i = 0;i < n;i++){
if (i)
printf(" ");

printf("%d",A[i]);
}

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

  return 0;
}

void Merge(int A[],int left,int mid,int right,int *cnt){
  int n1,n2;
  int i,j,k;
  int *L,*R;

  n1 = mid - left;
  n2 = right - mid;
  L = (int *)malloc(sizeof(int) * (n1 + 1));
  R = (int *)malloc(sizeof(int) * (n2 + 1));
  
  for (i = 0;i < n1;i++)
    L[i] = A[left + i];

  for (i = 0;i < n2;i++)
    R[i] = A[mid + i];

  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  i = 0;
  j = 0;

  for (k = left;k < right;k++){
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }

    else{ 
      A[k] = R[j];
      j = j + 1;
    }

    (*cnt)++;
  }

}

void MergeSort(int A[],int left,int right,int *cnt){
 int mid;

  if (left+1 < right){
    mid = (left + right)/2;
    MergeSort(A, left, mid,cnt);
    MergeSort(A, mid, right,cnt);
    Merge(A, left, mid, right,cnt);
    }

    }


Measured memory_bytes: 64548
#include <bits/stdc++.h>
using namespace std;
int main() {
	long double A = 0, B= 0, C = 0, D = 0;
	cin >> A >> B >> C;
	D = sqrt(A * B);
	if(A + B + 2 * D < C){
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N=input()
A=input()
B=input()
C=input()
D=input()
E=input()
N=int(N)
A=int(A)
B=int(B)
C=int(C)
D=int(D)
E=int(E)
a=N//A
b=N//B
c=N//C
d=N//D
e=N//E
f=max(a,b,c,d,e)
g=min(A,B,C,D,E)
if N%g==0:
    print(f+4)
else:
    print(f+5)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*
dist[a] + w >= dist[b]

a ??? b ????????????:
dist[b] + 0 >= dist[a]

d ??????????????\???:
dist[b] - d >= dist[a]

d ??????????????\???:
dist[a] + d >= dist[b]
*/

const int INF = 1 << 28;

struct Edge {
	int src, dst, cost;
	Edge(){}
	Edge(int src, int dst, int cost): src(src), dst(dst), cost(cost){}
};

int n, c;
vector<Edge> es;
vector<int> any;
int dist[100][100];

int calc()
{
	fill_n(*dist, 100 * 100, INF);
	for (int i = 0; i < 100; i++) dist[i][i] = 0;
	for (auto &e : es) dist[e.src][e.dst] = min(dist[e.src][e.dst], e.cost);
	
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	for (int i = 0; i < n; i++) if (dist[i][i] < 0) return -1;
	int res = 0;
	for (int i = 0; i < n; i++) res = max(res, dist[0][i]);
	
	return res;
}

int main()
{
	scanf("%d %d", &n, &c);
	for (int i = 0; i < c; i++){
		int a, b, d;
		char o, s;
		
		scanf("%d", &a); --a;
		scanf("%c", &o);
		if (o != '*') scanf("%*c");
		else any.push_back(i);
		scanf("%d%c%d", &b, &s, &d); --b;
		
		if (o == '>') swap(a, b);
		es.push_back(Edge(b, a, 0));
		if (s == '+') es.push_back(Edge(b, a, -d));
		else es.push_back(Edge(a, b, d));
	}
	for (int i = 1; i < n; i++){
		es.push_back(Edge(i, 0, 0));
	}
	
	//for (auto e : es) printf("%d -> %d %d\n", e.src, e.dst, e.cost);
	
	int res = -1;
	for (int i = 0; i < (1 << any.size()); i++){
		for (int j = 0; j < any.size(); j++){
			if (i & (1 << j)){
				swap(es[any[j] * 2].src, es[any[j] * 2].dst);
				swap(es[any[j] * 2 + 1].src, es[any[j] * 2 + 1].dst);
			}
		}
		res = max(res, calc());
		for (int j = 0; j < any.size(); j++){
			if (i & (1 << j)){
				swap(es[any[j] * 2].src, es[any[j] * 2].dst);
				swap(es[any[j] * 2 + 1].src, es[any[j] * 2 + 1].dst);
			}
		}
	}
	if (res == INF) puts("inf");
	else printf("%d\n", res);
}

Measured memory_bytes: 1244
#include <stdio.h>
int main(void)
{
	int n,i,x=0,max=0;
	char s[101];
	scanf("%d%s",&n,s);
	for(i=0; i<n; i++){
		if(s[i]=='I'){
			x=x+1;
		}
		if(s[i]=='D'){
			x=x-1;
		}
		if(max<x){
			max=x;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
n = input()
n_l = len(n)
k = int(input())

# dp[i][j][s] = 左からi番目の桁までで0でない数がj個である数の個数の総和（sは未満フラグ）
dp = [[[0]*2 for j in range(100+2)] for i in range(n_l+1)]
dp[0][0][0] = 1

for i in range(1,n_l+1) :
  m = int(n[i-1])
  for s in range(2) :
    for j in range(100+1) :
      if s == 0 :
        for num in range(m+1) :
          if num == m :
            if num == 0 :
              dp[i][j][0] += dp[i-1][j][0]
            else :
              dp[i][j+1][0] += dp[i-1][j][0]
          else :
            if num == 0 :
              dp[i][j][1] += dp[i-1][j][0]
            else :
              dp[i][j+1][1] += dp[i-1][j][0]
      else :
        for num in range(10) :
          if num == 0 :
            dp[i][j][1] += dp[i-1][j][1]
          else :
            dp[i][j+1][1] += dp[i-1][j][1]
            
print(dp[n_l][k][0]+dp[n_l][k][1])

Measured memory_bytes: 4332
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main()
{
    ll N ;
    ll x ;

    vector<ll> a;
    cin >> N >> x;
    rep(i,N){
        ll inp;
        cin >> inp;
        a.pb(inp);
    }
    sort(all(a));

    rep(i,N){
        x-=a[i];
        if(x == 0){
            cout << i+1 << endl;
            return 0;
        }
        if(x < 0){
            cout << i << endl;
            return 0;
        }
    }

    cout <<  N-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1, tt;
const ll N = 1000005;
void solve(){
	string s;
	cin>>s;
	ll f=0;
	rep(i,0,3){
		if(s[i]!=s[(i+1)%3])f=1;
	}
	f==0?cout<<"No":cout<<"Yes";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum[400000], ans , d[3000][3000], a[400000], b[400000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<int>>vec;
vector<edge>ed;
vector<LL>v;
map<Pll, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n>>m;
	rep(i, n) {
		cin >> a[i];
		sum[i + 1] = sum[i] + a[i];
	}
	sum[n + 1] = INF;
	sum[n + 2] = INF;
	rep(i, m) {
		LL x;
		cin >> x;
		ans = 0;
		LL  r = upper_bound(sum, sum + n, x)-sum;
		rep(l, n) {
			while (sum[r] - sum[l] <= x) r++;
			ans += r - l -1;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll gcd(ll m, ll n) {//最大公約数
    if (n == 0)return m;
    return gcd(n, m % n);
}//gcd

ll lcm(ll m, ll n) {//最小公倍数
    return m / gcd(m, n) * n;
}
int main() {
  ll a,b,c,d ;
  cin>>a>>b>>c>>d;
  ll wc,wd,wcd;
  wc=b/c-(a-1)/c;
  wd=b/d-(a-1)/d;
  ll cd=lcm(c,d);
  wcd=b/cd-(a-1)/cd;
  cout<<b-a+1-(wc+wd-wcd)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int comb(int n)
{
    if(n < 2) return 0;
    int p = n - 2 + 1;

    int comb = 1;
    for( ; p <= n; p++) comb *= p;
    comb /= 2;

    return comb;
}

int main()
{
    int n, m, even_sum;
    scanf("%d %d", &n, &m);
    even_sum = comb(n) + comb(m);
    printf("%d\n", even_sum);
    return 0;
}


Measured memory_bytes: 128