akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

//////nCrのmodを求めたいときに開けよ/////////
int64_t univMod = 1000000007;
int64_t factnum = 200000; //変更すること
vector<int64_t> modfact(factnum);
vector<int64_t> modinvfact(factnum);

void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t modpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t modinverse(int64_t n){
	return modpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = modpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t modcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(n-r))%univMod)*modinvfact.at(r))%univMod;
}

int64_t modperm(int64_t n,int64_t r){
  return (modfact.at(n)*modinvfact.at(n-r))%univMod;
}

int main(){
  int64_t h,w,a,b;
  cin >> h >> w >> a >> b;
  setmodfact();
  setmodinvfact();
  h = h-1;
  w = w-1;
  int64_t total = 0;
  for(int64_t i=0;i <= h-a;i++){
    total = (total + (modcomb(b+i-1,i)*modcomb(w-b+h-i,w-b))%univMod)%univMod;
  }
  cout << total << endl;
    
    
  
}

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

int main(){
  ll X;
  cin>>X;
  
  ll ans=3;
  for(ll i=0;i<X;i++){
    ans=ans+ans+1;
  }
  cout<<ans-1<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

for i in range(n):
  v = A[i]
  j = i - 1
  while j >= 0 and A[j] >v:
    A[j + 1] = A[j]
    j -= 1

  else:
    A[j + 1] = v
    for b in range(n):
      print(A[b], end=" \n"[b + 1 == n])


Measured memory_bytes: 5984
import java.util.*

fun main(args: Array<String>) {
    val mod = 1000000007L
    val N = readInt()
    println(111 * ((N-1)/111+1))
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt).toList()
fun readLongList() = readLine()!!.split(" ").map(String::toInt).toList()


Measured memory_bytes: 31660
#include <stdio.h>

int main(void)
{
	int i,n,s,profit;
	scanf("%d",&n);
	int array[n];

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

	s = array[0];
	profit = array[1] - array[0];
	for (i = 1;i < n - 1;i++) {
		if (s > array[i]) {
			s = array[i];
		}
		if (profit < array[i+1] - s) {
			profit = array[i+1] - s;
		}
	}

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


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  if(n < m) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  bool ok = false;
  auto check = [&](int i) {
    rep(j, m) {
      if(s[i+j] != t[j] && s[i+j] != '?') return false;
    }
    return true;
  };
  for(int i = n-m; i >= 0; --i) {
    if(check(i)) {
      rep(j, m) s[i+j] = t[j];
      rep(i, n) if(s[i] == '?') s[i] = 'a';
      cout << s << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;

    int len = s.length(), half = len / 2, count = 0;
    for(int i = 0; i < half; ++i){
        if(s.at(i) != s.at(len - 1 - i)){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

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

typedef long long int ll;
#define ent cout << "\n"
#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define pair < ll, ll > pp
#define f(a, b) for(auto i = a;i < b;i++)
#define rev_f(a, b) for(auto i = b;i >= a;i--)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define st(x) sort(x.begin(), x.end()) 
#define rv(x) reverse(x.begin(), x.end()) 
#define cintc() ll tc;while(tc--) 
#define deb(x) cout << x << "\n";
#define cin(a) ll a; cin >> a;
#define cin2() ll a, b; cin >> a >> b
#define cin3() ll a, b, c; cin >> a >> b >> c
#define cinn(vect, n) def_v vect(n); f(0, n) cin >> vect[i]
#define coutn(vect, n)  f(0, n) {cout << vect[i] << "";} cout << " ";

typedef vector < ll > def_v;
typedef tuple< ll, ll, ll> def_tuple;
ll mod = 1e9 + 7,cnt = 0;

vector < ll > bfs(vector < ll > graph[], vector < ll > vect, ll start, ll flag, ll n)
{

    ll vis[n + 1] = {0};
    vis[start] = 1;
    queue < ll > q;
    q.push(start);
    while(!q.empty())
    {

        ll start = q.front();
        q.pop();
        auto size = ll(graph[start].size());
        for(ll j = 0;j < size;j++)
        {
            ll x = graph[start][j];
            if(!vis[x])
            {
                vis[x] = 1;
                if(x == 1 && flag == 2)
                {
                    flag = 2;
                }
                else
                    q.push(x);
                vect[x] = flag;
            }
        }
    }

    return vect;
}

int main()
{

    ll n, k;
    cin >> n >> k;

    ll freq[101] = {0};

    f(0, k)
    {
        ll d;
        cin >> d;
        for(ll j = 0;j < d;j++)
        {
            ll a;
            cin >> a;
            freq[a]++;
        }
    }

    ll cnt = 0;
    f(1, n + 1)
        if(freq[i] == 0)
            cnt++;
    cout << cnt << "\n";
    
    return 0;
}

Measured memory_bytes: 3628
a,b,m = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = []
y = []
c = []
for i in range(m):
	xs,ys,cs = map(int,input().split())
	x.append(xs)
	y.append(ys)
	c.append(cs)

ans1 = 10**10
for j in range(m):
	if ans1 >= a[x[j]-1] + b[y[j]-1] - c[j]:
		ans1 = a[x[j]-1] + b[y[j]-1] - c[j]
ans2 = min(a)+min(b)
print(min(ans1,ans2))

Measured memory_bytes: 24948
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto nw = readInts();
		auto n = nw[0];
		auto w = nw[1];
		if((n|w) == 0) return;

		auto b = new int[](100);
		int c;
		int d;
		
		for(int i; i < n; ++i) {
			auto v = readInt();
			++b[v/w];
			c = max(c, v/w);
			d = max(d, b[v/w]);
		}
		double ink = 0;
		for(int i; i <= c; ++i) {
			ink += 1.0 * b[i] * (c-i) / c;
		}
		ink /= d;
		ink += 0.01;
		writeln(ink);
	}
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int n;
VI a(214514);
VVI edge(214514, VI(0));
VI ans(214514);
VI dp(214514,LINF);

void dfs(int v, int p) {
	int itr=lower_bound(ALL(dp), a[v])-dp.begin();
	ll z=dp[itr];
	dp[itr]=a[v];
	ans[v]=lower_bound(ALL(dp), INF)-dp.begin();
	for (auto to : edge[v])
		if (to != p) dfs(to, v);
	dp[itr]=z;
}

int main() {
	cin >> n;
	REP(i,n) cin >> a[i];
	int u, v;
	REP(i,n-1) {
		cin >> u >> v;
		u--; v--;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	dfs(0,-1);
	REP(i,n)
		cout << ans[i] << endl;
	return 0;
}

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

#define finish(i) return cout << i, 0;

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

    string s;
    int n;
    long long ans = 0, a = 0;
    cin >> s;
    n = s.size();

    for (int i = 0; i < n - 1; i++) {
        if (s[i] == 'B' && s[i + 1] == 'C' && a) {
            s[i] = 'C', s[i + 1] = 'A', ans += a, i++;
            continue;
        }
        s[i] == 'A' ? a++ : a = 0;
    }

    cout << ans << '\n';

    return 0;
}
/*
AABC
BCAA

AAABC
AABCA
ABCAA
BCAAA


abc
bca*/

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

int main(){
	string s;
	while ( cin >> s ){
		s += '0';
		int size = s.size();
		int* arabian = new int[ size ];

		for ( int i = 0; i < size; ++i ){
			switch( s[ i ] ){
				case 'I' : arabian[ i ] = 1; break;
				case 'V' : arabian[ i ] = 5; break;
				case 'X' : arabian[ i ] = 10; break;
				case 'L' : arabian[ i ] = 50; break;
				case 'C' : arabian[ i ] = 100; break;
				case 'D' : arabian[ i ] = 500; break;
				case 'M' : arabian[ i ] = 1000; break;
				default : arabian[ i ] = 0;break;
			}
		}

		int figure = 0;
		for ( int i = 0; i < size-1; ++i ){
			if ( arabian[ i ] < arabian[ i + 1 ] ){
				arabian[ i ] = -arabian[ i ];
			}
			figure += arabian[ i ];
		}

		cout << figure << endl;

		delete[] arabian;
	}

	return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<int> data;
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }

public:
	UnionFind(int size) : data(size, -1) { }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	void unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
};

template<class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	struct town { int x, y, idx; };
	vector<town> t(N);
	for (int i = 0; i < N; i++) {
		cin >> t[i].x >> t[i].y;
		t[i].idx = i;
	}

	// 辺のをすべてpriority_queに入れる
	priority_queue<Edge<>, vector<Edge<>>, greater<Edge<>>> pq;
	// xが近い同士
	sort(t.begin(), t.end(), [&](town r, town l) {return r.x < l.x; });
	for (int i = 0; i < N - 1; i++) pq.emplace(t[i].idx, t[i + 1].idx, t[i + 1].x - t[i].x);
	// yが近い同士
	sort(t.begin(), t.end(), [&](town r, town l) {return r.y < l.y; });
	for (int i = 0; i < N - 1; i++) pq.emplace(t[i].idx, t[i + 1].idx, t[i + 1].y - t[i].y);

	// kruskal法
	UnionFind uf(N);
	lint ans = 0;
	while (!pq.empty()) {
		
		auto now = pq.top(); pq.pop();

		if (!uf.is_same(now.from, now.to)) {
			uf.unify(now.from, now.to);
			ans += now.cost;
		}
	
	}

	assert(uf.size(0) == N);

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 7664
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
const float PI = 3.14;


int main()
{
	string n;
	cin >> n;
	if (n[0] == '7' || n[1] == '7' || n[2] == '7') {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>

#define INF (1e+9)
#define LLINF (1e+18)
#define LL long long

using namespace std;


typedef pair<int ,int > P;

int n;
int m;
P data[20000];
bool flag[20000] = {0};
int field[20000] = {0};

int ans;

int main (void){
	while(true){
		scanf("%d",&n);
		scanf("%d",&m);
		if((n == 0) && (m == 0))break;

		for(int i = 0;i < m;i++)flag[i] = false;
		for(int i = 0;i < m;i++)field[i] = 0;

		int a,b;
		for(int i = 0;i < m;i++){
			scanf("%d %d",&a,&b);
			data[i] = P(a,b);
			if(a == 1){
				field[b] = 1;
				flag[i] = true;
			}
			else if(b == 1){
				field[a] = 1;
				flag[i] = true;
			}
		}

		for(int i = 0;i < m;i++){
			if(!flag[i]){
				if(field[data[i].first] == 1){
					if(field[data[i].second] != 1){
						field[data[i].second] = 2;
					}
				}
				else if(field[data[i].second] == 1){
					if(field[data[i].first] != 1){
						field[data[i].first] = 2;
					}
				}
			}
		}

		ans = 0;
		for(int i = 1;i <= n;i++){
			if(field[i])ans++;
		}

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

	}


	return 0;
}

Measured memory_bytes: 1400
# input
N, D = map(int, input().split())
dots = []
for _ in range(N):
    dots.append(list(map(int, input().split())))

# process
ans = 0
d2 = D**2
for x, y in dots:
    if x**2 + y**2 <= d2:
        ans += 1

# output
print(ans)


Measured memory_bytes: 45456
//by sdfzchy
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int inf=(1<<30),N=100010,mod=1e9+7;
int n,m;
inline int in()
{
	char tmp=getchar();
	int res=0,f=1;
	while((tmp<'0'||tmp>'9')&&tmp!='-')tmp=getchar();
	if(tmp=='-') f=-1,tmp=getchar();
	while(tmp>='0'&&tmp<='9')	res=(res<<1)+(res<<3)+(tmp^48),tmp=getchar();
	return res*f;
}
char s[100];
char a[100]={'A','K','I','H','A','B','A','R','A'};
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	int j=0,pos=0;
	for(int i=0;i<len;i++,j++)
	{
		while(s[i]!=a[j]&&j<9)
		{
			if(a[j]!='A') {puts("NO");return 0;}
			j++;
		}
		if(j==9)  {puts("NO");return 0;}
		pos=j;
	}
	if(pos<7) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 
 
 
int32_t main() {
    fastio;
    vector<ll> a,b;
    ll n,m,k;
    cin>>n>>m>>k;
    a.PB(0);
    for(ll i=0;i<n;i++) {
        ll x;
        cin>>x;
        a.PB(x);
    }
    for(ll i=0;i<m;i++) {
        ll x;
        cin>>x;
        b.PB(x);
    }
    for(ll i=1;i<m;i++) {
        b[i] += b[i-1];
    }
    ll val = 0,ans=-1;
    for(ll i=0;i<=n;i++) {
        val += a[i];
        if(val>k) break;
        ll lb = lower_bound(b.begin(), b.end(), k-val)-b.begin();
        if(b[lb]+val>k) lb--;
        // cout<<i<<" "<<lb<<endl;
        ans = max(ans, i+lb+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7952
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int main(void){
  uint32_t k, a, b;
  scanf("%"SCNu32"%"SCNu32"%"SCNu32, &k, &a, &b);
  puts((a-1)/k==b/k?"NG":"OK");
}



Measured memory_bytes: 1600
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<string, pair<int, int>>PP;
typedef long long ll;

int main() {
	int n; cin >> n;
	cout << 180 * (n - 2) << endl;
	return 0;
}

Measured memory_bytes: 256
N, A, B = list(map(int, input().split()))
S = input()
passed_num = 0
passed_foreigners_num = 0
for i in S:
    if passed_num < A + B:
        if i == 'a':
            print('Yes')
            passed_num += 1 
        elif i == 'b' and passed_foreigners_num < B:
            print('Yes')
            passed_num += 1 
            passed_foreigners_num += 1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a,b,ans=0,max=0;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(max<a){
            max=a;
            ans=a+b;
        }
    }
    cout<<ans;
    return 0;
}

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

struct sp {
    int idx;
    string s;
    int p;
    
};

bool compare(sp a, sp b) {
    if (a.s == b.s) {
        return a.p > b.p;
    } else {
        return a.s < b.s;
    }
}

int main(void)
{
    int n;
    cin >> n;
    vector<sp> v;
    for(int i = 0;i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        v.emplace_back(sp{i+1,s,p});
    }
    sort(v.begin(),v.end(),compare);

    for(int i = 0; i < n; i++){
        cout <<v[i].idx << endl;;
    }

    return 0;
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

string s,t;cin>>s>>t;
int a,b;cin>>a>>b;
string u;cin>>u;
if(u==s) a--;
else if(u==t) b--;
cout<<a<<" "<<b;

return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string A,B,C;
  cin>>A>>B>>C;
  bool res=A[A.length()-1]==B[0]&&B[B.length()-1]==C[0];
  if(res)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}


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



#define rep(i,n) for(int i = 0 ; i< (n);i++)

#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
using namespace std;



typedef long long ll;

typedef pair<int,int> P;




int main(){

  	int n;cin>>n;
	int t,a;//aは求める平均気温
	cin >> t >> a;
	vector<int> x(n);//x i はi番目の山の高さ
	rep(i,n){
		cin>>x[i];
	  }
	vector<double> A(n);
	rep(i,n){
		double b = t-0.006*x[i];
		A[i]=b;
	  }
	 int ans = 1;
	 double Avemin = abs(a- A[0]);

	 rep(i,n){
		double Ave = abs(a - A[i]);
		if (Avemin>Ave){
			Avemin=Ave;
			ans = i+1;
		  }
	   }
	   cout<<ans<<endl;
}

	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
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; }

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const int INF = 1001001001;

int main(){
    int N;
    cin >> N;
    int A[N];
    int x[N][N];
    int y[N][N];
    rep(i, N){
        cin >> A[i];
        rep(j, A[i]) cin >> x[i][j] >> y[i][j];
    }
    int ans = 0;
    rep(ii, pow(2, N)) {
        int num_shoujiki = 0;
        int temp = ii;
        while(true) {
            num_shoujiki += temp%2;
            temp /= 2;
            if (temp==0) break;
        }
        
        // if this satisfies;
        bool flag = true;
        rep(i, N) {
            if (!(ii & (1<<i))) continue;
            rep(j, A[i]) {
                if (y[i][j]==0 && (ii & (1<<(x[i][j]-1)))) flag = false;
                if (y[i][j]==1 && !(ii & (1<<(x[i][j]-1)))) flag = false;
            }
        }
        if (flag == true && ans < num_shoujiki) ans = num_shoujiki ;
    }
    cout << ans << endl;

}

Measured memory_bytes: 384
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a))
    exit()
x = [a[0], gcd(a[0], a[1])]
for i in range(n - 3):
    x.append(gcd(x[i + 1], a[i + 2]))
ans = x[-1]
y = a[-1]
for i in range(1, n - 1):
    z = gcd(y, a[-i])
    ans = max(ans, gcd(x[-i - 1], z))
    y = z
print(max(ans, gcd(y, a[1])))


Measured memory_bytes: 16124
import numpy as np
np.seterr(all='ignore')

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

Xs = []
for _ in range(N):
    Xs.append(list(map(int, input().split())))
mat = np.array(Xs)

d = np.empty([mat.shape[0], mat.shape[0]])
d[:,:] = np.nan

for i in range(mat.shape[0]):
    for j in range(i+1, mat.shape[0]):
        d[i,j] = np.sqrt(((mat[i,:] - mat[j,:])**2).sum())

np.mod(d,1,d)
print('{}'.format(np.sum(d==0)))


Measured memory_bytes: 12508
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(void){
    int n;cin>>n;
    set<string> s;

    for(int i=0;i<n;i++){
        string t;cin>>t;
        s.insert(t);
    }

    cout<<s.size()<<endl;

    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
LL INF = 1e17;
double EPS=1.0e-9;
double PI=atan2(0,-1);

int main()
{
    int n;
    cin>>n;
    vector<int> a(n+1);
    FOR(i,1,n+1)
        cin>>a[i];
    int cnt=0;
    FOR(i,1,n+1)
    {
        if(a[a[i]]==i)
            cnt++;
    }
    cout<<(cnt/2)<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
constexpr int MAXN = 200000;
constexpr int MOD = 1000000000 + 7;

constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

class Combination
{
private:
    vector<int> fact, rev_fact;

public:
    Combination(int n)
    {
        setFact(n);
    }
    void setFact(int n)
    {
        fact.resize(n + 1);
        rev_fact.resize(n + 1);
        fact[0] = 1;
        for (int i = 1; i <= n; i++)
        {
            fact[i] = fact[i - 1] * i;
            fact[i] %= MOD;
        }
        rev_fact[n] = modpow(fact[n], MOD - 2);
        for (int i = n - 1; i >= 0; i--)
        {
            rev_fact[i] = rev_fact[i + 1] * (i + 1);
            rev_fact[i] %= MOD;
        }
    }
    int c(int n, int k)
    {
        return (((fact[n] * rev_fact[k]) % MOD) * rev_fact[n - k]) % MOD;
    }
    int h(int n, int k) { return c(n + k - 1, k); }
};

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

    int n, k;
    cin >> n >> k;

    Combination c(MAXN);

    int ans = 0;

    // i: 空き部屋の数
    for (int i = 0; i <= min(n - 1, k); i++)
    {
        // n部屋から空き部屋をi室選ぶ場合の数
        const int aki = c.c(n, i) % MOD;
        // 空き部屋から移動したi人がどの部屋に移動するか選ぶ場合の数
        const int hito_iru = c.h(n - i, i) % MOD;

        (ans += (aki * hito_iru) % MOD) %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int m,p[200];
bool v[200],e[200][200];
bool match(int s){
	if(s<0)return 1;
	rep(i,2*m)if(!v[i]&&e[s][i]){
		v[i]=1;
		if(match(p[i]))return p[i]=s,p[s]=i,1;
	}
	return 0;
}
int calc(vi &x){
	m=x.size();
	rep(i,2*m)rep(j,2*m)e[i][j]=0;
	rep(i,2*m)p[i]=-1;
	rep(i,m)rep(j,m)e[i][j+m]=e[j+m][i]=i!=j&&x[i]%x[j]==0;
	
	int res=m;
	rep(i,m)if(p[i]<0){
		rep(j,2*m)v[j]=0;
		if(match(i))res--;
	}
	return res;
}
int ans,sz,a[100];
void solve(vi &x){
	if(x.empty())return;
	vi nxt;
	rep(i,x.size()-1){
		if(x[i+1]%x[0]==0||x[0]%x[i+1]==0)continue;
		nxt.pb(x[i+1]);
	}
	if(calc(nxt)==ans-sz-1){
		a[sz++]=x[0];
		solve(nxt);
	}
	else{
		x.erase(x.begin());
		solve(x);
	}
}

int main(){
	int n; cin>>n;
	vi x(n);
	map<int,int> idx;
	rep(i,n)cin>>x[i],idx[x[i]]=i+1;
	ans=calc(x);
	
	solve(x);
	rep(i,sz)cout<<idx[a[i]]<<(i==sz-1?"\n":" ");
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		int K = scanner.nextInt();
		String S = scanner.next();
		int num = S.length();
		
		String x ="";
		
		if (num <= K) {
			
			System.out.println(S);
			
		} else {
			System.out.println(S.substring(0, K) + "...");
		}

	}

}

Measured memory_bytes: 27032
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
const double eps = 1e-9;

string s, r = "";

int32_t main()
{
	cin >> s;
	for(int i=0; i<s.size(); i++)
	{
		if(s[i] == '1' or s[i] == '0')
			r += s[i];
		else if(s[i] == 'B' and r.size() >= 1)
			r.pop_back();
	}
	
	cout << r << '\n';
}

Measured memory_bytes: 256
/* ALDS1_3_C: Doubley Linked List */
/* 20181115 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct Node_{
	int key;
	struct Node_ *prev;
	struct Node_ *next;
} Node;

Node *nil ;

void initList();
void insertKey(int key);
Node *listSearch(int key);
void deleteNode(Node *node);
void deleteKey(int key);
void deleteFirst();
void deleteLast();
void printList();

int main(void){
	int n, key, i = 0;
	char cmd[12];

	initList();
	scanf("%d", &n);
	 
	while((i++) < n){
		scanf("%s%d", cmd, &key);
		if(cmd[0] == 'i'){
			insertKey(key);
		}else if(cmd[0] == 'd' && cmd[6] == 0){
			deleteKey(key);
		}else if(cmd[6] == 'F'){
			deleteFirst();
		}else if(cmd[6] == 'L'){
			deleteLast();
		}else{
			/* Do nothing */
		}
	}

    printList();

	return 0;
}

void initList(){
	nil = (Node *)malloc(sizeof(Node));
	nil->key = 0;
	nil->next = nil;
	nil->prev = nil;
}

void insertKey(int key){
	Node *node = (Node *)malloc(sizeof(Node));

	node->key = key;
	node->next = nil->next;
	nil->next->prev = node;
	nil->next = node;
	node->prev = nil;
}

Node* listSearch(int key){
	Node *curNode = nil->next;

	while(curNode != nil && curNode->key != key){
		curNode = curNode->next;
	}

	return curNode;
}

void deleteNode(Node *node){
	if(node == nil) return;
	node->prev->next = node->next;
	node->next->prev = node->prev;
	free(node);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);	
}

void printList(){
	Node *curNode = nil->next;

	while(curNode != nil){
		printf("%d", curNode->key);
		curNode = curNode->next;
		if(curNode != nil){
			printf(" ");
		}else{
			printf("\n");
		}
	}
}


Measured memory_bytes: 32972
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [w,h,x,y,r] <- getInts
  ; if x < r then putStrLn "No"
    else if y < r then putStrLn "No"
         else if x + r > w then putStrLn "No"
              else if y + r > h then putStrLn "No"
                   else putStrLn "Yes"
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3652
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 200001;
int32_t main()
{

   IOS
    string s;
    cin>>s;
    if(s=="ABC")
      cout<<"ARC"<<endl;
    else{
      cout<<"ABC"<<endl;
    } 
} 


Measured memory_bytes: 3640
#include <stdio.h>

int MAX(int a,int b){
    return a>b?a:b;
}
int main()
{   int h,w;
    scanf("%d%d",&h,&w);
    char s[h][w+1];
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }
    int width[h][w],height[h][w];
    for(int i=0;i<h;i++){
        //printf("\n");
        int j=0;
        while(j<w){
            while(j<w&&s[i][j]=='#'){
                width[i][j]=0;
                j++;
            }
            int left=j;
            while(j<w&&s[i][j]=='.'){
                j++;
            }
            //printf("exit w loop left=%d,j=%d ",left,j);
            for(int k=left;k<j;k++){
                width[i][k]=j-left;
            }
        }
        
    }
    for(int i=0;i<w;i++){
        int j=0;
        while(j<h){
            while(j<h&&s[j][i]=='#'){
                height[j][i]=0;
                j++;
            }
            int top=j;
            while(j<h&&s[j][i]=='.'){
                j++;
            }
            
            for(int k=top;k<j;k++){
                height[k][i]=j-top;
            }
        }
        
    }
    int ans=0;
    //printf("height\n");
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            //printf("%d ",height[i][j]);
            ans=MAX(ans,width[i][j]+height[i][j]);
        }
        //printf("\n");
    }
    
    /*printf("width\n");
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            printf("%d ",width[i][j]);
        }
        printf("\n");
    }*/
    printf("%d",ans-1);

    return 0;
}


Measured memory_bytes: 35328
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    ll n;
    cin >> n;
    ll ans = INF;
    for(ll a = 1;a * a <= n;a++){
        if(n%a)continue;
        ll b = n/a;
        ans = min(ans,ll(to_string(b).size()));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <limits.h>

int main(void) {
    long long n, m;
    long long minimum = LLONG_MAX;

    scanf("%lld\n", &n);

    m = (long long) sqrt(n);

    for (long long i = 1; i <= m; i++) {
        long long a, b;
        if (n % i == 0) {
            a = n / i;
            b = (i - 1) + (a - 1);
            if (b < minimum) {
                minimum = b;
            }
        }
    }

    fprintf(stdout, "%lld\n", minimum);

    return 0;
}


Measured memory_bytes: 128
from itertools import groupby, islice

N = int(input())
D = []
c=[]
for i in range(0, N):
    D.append(list(map(int, input().split(" "))))
for i in D:
    if i[0]==i[1]:
        c.append(True)
    else:
        c.append(False)
answer = any(sum(1 for _ in islice(g, 3)) == 3 for k, g in groupby(c) if k)
if answer:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9200
S = input()
T = input()
ss = len(S)
tt = len(T)
a = tt
for r in range(ss - tt + 1):
    n = 0
    for x in range(tt):
        z = S[r:r+tt]
        if z[x] != T[x]:
            n += 1
    a = min(a, n)
print(a)

Measured memory_bytes: 73540
#include <stdio.h>
#include<math.h>
using namespace std;

int main(){
	int n,m,min,tmp;
	scanf("%d",&n);
	int minimum[n+1];
	scanf("%d",&m);
	int coin[m];
	for(int i=0;i < m; i++)scanf("%d",&coin[i]);

	minimum[0] = 0;
	minimum[1] = 1;
	for(int i=2;i<=n;i++){
		min = n+1;
		for(int k=0;k<m;k++){
			if(coin[k] <= i){	
				tmp = 1 + minimum[i-coin[k]];
				min = (min <= tmp)?min:tmp;
			}
		}
		minimum[i] = min;
	}

	printf("%d\n",minimum[n]);

    return 0;
}


Measured memory_bytes: 2936
#include<stdio.h>
int main()
{
  int n,i,sum;
  sum=0;
  scanf("%d",&n);
  
  int a[n],b[n],c[n];
  for(i=0;i<n;++i)
  {scanf("%d",&a[i]);}
  
  for(i=0;i<n;++i)
  {scanf("%d",&b[i]);
  sum=sum+b[i];
  }
  
  for(i=0;i<n;++i)
  {scanf("%d",&c[i]);
  }
  
  for(i=0;i<n;++i)
  {
  if(a[i+1]-a[i]==1) sum=sum+c[a[i]-1];  
  }
  
  printf("%d",sum);
return 0;  
}

Measured memory_bytes: 1708
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.shift();
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ` ${e}`, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    largest = left < n && arr[left] > arr[i] ? left : i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X; cin >> N >> X;
  int sm = 0;
  int ans = 1;
  REP(i, N){
    int l; cin >> l;
    sm += l;
    if(sm <= X) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	n, _ := strconv.Atoi(nextLine())

	if n < 1000 {
		fmt.Println("ABC");
	} else {
		fmt.Println("ABD");
	}

}


Measured memory_bytes: 640
import sys, math
from itertools import accumulate
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    s, K = input(), ii()
    l = list(map(lambda c: (ord('z')-ord(c)+1)%26, s))

    acc = 0
    t = ['']*len(s)
    for i in range(len(s)):
        if acc + l[i] <= K:
            acc += l[i]
            t[i] = 'a'
        else:
            t[i] = s[i]

    if i == len(s)-1 and K-acc > 0:
        t[i] = chr((ord(t[i])-ord('a')+K-acc)%26+ord('a'))

    print(''.join(t))

if __name__ == "__main__":
    main()

Measured memory_bytes: 10968
#pragma warning(disable : 4996)
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=a; i!=(b); i+=(b)>(a)?1:-1)
#define vll vector<ll>
#define vch vector<char>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sll set<ll>
#define all(c) c.begin(), c.end()
#define on(x) cout<<x<<"\n";
#define os(x) cout<<x<<' ';
#define nl cout<<"\n";

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll n, ans=0;
    cin>>n;
    FO(i, 1, n+1)
    {
        if(i%3 && i%5) ans+=i;
    }
    on(ans)
    return 0;
}

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

using namespace std;

int main()
{
    int s;
    scanf("%d",&s);
    char a[s];
    scanf("%s",a);
    int t=0;
    for(int i=0; i<s; i++)
    {
        bool c[26]= {0},d[26]= {0};
        int p=0;
        for(int k=0;k<i;k++)
            c[a[k]-'a']=1;
        for(int k=i;k<s;k++)
            d[a[k]-'a']=1;
        for(int k=0;k<26;k++)
            if(c[k]==1&&d[k]==1)
                p++;
        t=max(p,t);
    }
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;



void solve(long long N, long long X, long long T){
    int ans=(N/X)*T;
    if(N%X!=0)ans+=T;
    cout<<ans<<endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    vector<ll> acc(N);
    acc[N - 1] = A[N - 1] % MOD;
    for (int i = N - 2; i >= 0; i--) {
        acc[i] = acc[i + 1] + A[i];
        acc[i] %= MOD;
    }

    ll ans = 0;
    REP(i, 0, N - 1) {
        ans += (A[i] * acc[i + 1]) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

struct Problem {
public:

	void Solve() {
		string T; cin >> T;
		ULL N = T.size();
		T.push_back('0');
		ULL L = 0;
		ULL R = N;
		ULL ans = 0;
		rep(i, N ) {
			if (L & 1) {
				if (T[i] == '1' && T[i + 1] == '0') {
					ans += (N - R + 1) / 2; R--;
				}
				else if (T[i] == '1') {
					ans += (N - R + 1) / 2; L++;
				}
				else {
					L++;
				}
			}
			else {
				if (T[i] == '0') {
					R--;
				}
				else {
					ans += (N - R) / 2;
					ans += R - L;
					L++;
				}
			}
		}
		cout << ans << endl;
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
int isprime(int n) {
  int i;
  for(i = 2; i * i <= n; i++) {
    if(n % i == 0) return 0;
  }
  return 1;
}

int main(){
  int i, n, max;
  while(1){
    scanf("%d", &n);
    if(n == 0) break;
    for(i = n;i > 0;i--){
      if(isprime(i) == 1 && isprime(i - 2) == 1){
        max = i;
        break;
      }
    }
    printf("%d %d\n", max - 2, max);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>

using namespace std;
long long n,i,a,b,r,ca,cb;
int main()
{
    cin>>n;
    cin>>a;
    for(i=2;i<=n;++i)
    {
        cin>>b;
        ca=a;
        cb=b;
        while(cb!=0)
        {
            r=ca%cb;
            ca=cb;
            cb=r;
        }
        a=a/ca*b;
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.se!=b.se)
        return a.se<b.se;
    else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------
    string s;cin>>s;
    ll sum=0;
    for(ll i=0;i<s.lg;i++){
        sum+=s[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<Endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------









































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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int d = ni();
		int result = n / (1 + 2*d);
		result += n % (1 + 2*d) == 0 ? 0:1;
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

using ll = long long;
const int mod = 1e9 + 7;
const double PI = 3.141592653589793238;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    int sum = 0;
    for (int i = 0; i < M; i++) {
        int A;
        cin >> A;
        sum += A;
    }
    if (sum <= N)
        cout << N - sum << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if((a*b)%2==0) cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int a, b; cin >> a >> b;
    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256