akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main()
{
    int dice[6];
    for(auto&v:dice)
        cin>>v;
    char c;
    while(cin>>c)
    {
        int temp;
        switch(c)
        {
            case 'E':
                temp=dice[0];
                dice[0]=dice[3];
                dice[3]=dice[5];
                dice[5]=dice[2];
                dice[2]=temp;
                break;
            case 'S':
                temp=dice[0];
                dice[0]=dice[4];
                dice[4]=dice[5];
                dice[5]=dice[1];
                dice[1]=temp;
                break;
            case 'W':
                temp=dice[0];
                dice[0]=dice[2];
                dice[2]=dice[5];
                dice[5]=dice[3];
                dice[3]=temp;
                break;
            case 'N':
                temp=dice[0];
                dice[0]=dice[1];
                dice[1]=dice[5];
                dice[5]=dice[4];
                dice[4]=temp;
        }
    }
    cout<<dice[0]<<endl;
}


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

using namespace std;
char s[15],t[15],u[15];
int a,b;
int main()
{
    scanf("%s",s);
    getchar();
    scanf("%s",t);
    scanf("%d%d",&a,&b);
    getchar();
    scanf("%s",u);
    if(strcmp(s,u)==0)
        a-=1;
    else
        b-=1;
    printf("%d %d",a,b);
    return 0;
}






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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool u[200001];
	rep(i, 200001) u[i] = false;

	int n, m; cin>>n>>m;

	stack<int> st;
	rep(i, m){
		int temp; cin>>temp;
		st.push(temp);
	}
	while(st.size()){
		int p = st.top(); st.pop();
		if (!u[p]){
			cout << p << "\n";
			u[p] = true;
		}
	}

	for(int i=1; i<=n; i++){
		if (!u[i]) cout << i << "\n";
	}
	return 0;
}


Measured memory_bytes: 3696
# BFS的にやるDAGの最長経路
from collections import deque
import copy
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n=int(input())
a= [list(map(int, input().split())) for i in range(n)]
v=n*(n-1)//2
# 試合を格納
b=[[] for i in range(v)]
# 入次数を記録
indeg = [0 for _ in range(v)]

for i in range(n):
    for j in range(n-1):
        # i+1<a[i][j]で統一
        if i+1>a[i][j]:
            x=a[i][j]
            y=i+1
        else:
            x=i+1
            y=a[i][j]
        # 試合を頂点に変換
        a[i][j]=(n-1+n-x+1)*(x-1)//2+y-x-1
    for j in range(n-2):
        indeg[a[i][j+1]]+=1
        b[a[i][j]].append(a[i][j+1])

dp = [0 for _ in range(v)]
q = deque([])
# 最長辺の候補を入れる
for i in range(v):
    if indeg[i] == 0:
        q.append(i)

while q:
    v = q.popleft()
    for w in b[v]:
        indeg[w] -= 1
        if indeg[w] == 0:
            q.append(w)
            dp[w] = max(dp[w], dp[v] + 1)

# indegが全てゼロになってなければ閉路あり
if sum(indeg)!=0:
    print(-1)
else:
    # 最長経路
    print(max(dp)+1)


Measured memory_bytes: 138576
#include <iostream>

using namespace std;

auto abs(int a, int b)
{
    return a - b > 0 ? a - b : b - a;
}

int main()
{
    int x[5], k;
    for (int i = 0; i < 5; ++i) {
        cin >> x[i];
    }
    cin >> k;

    for (int i = 0; i < 5; ++i) {
        for (int j = i + 1; j < 5; ++j) {
            if (abs(x[i], x[j]) > k) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int h, w;
    cin >> h >> w;
    auto a = initVec2<bool>(h, w, false);
    queue<pair<P, int>> q;
    rep(i, h) rep(j, w){
        char c;
        cin >> c;
        if(c == '#'){
            q.emplace(make_pair(i, j), 0);
        }
    }

    auto b = initVec2<int>(h, w, -1);
    vector<int> dd = {1, 0, -1, 0};
    while(not q.empty()){
        int x = q.front().first.first;
        int y = q.front().first.second;
        int d = q.front().second;
        q.pop();

        if(a[x][y]){
            continue;
        }
        a[x][y] = true;
        b[x][y] = d;

        rep(k, 4){
            int nx = x + dd[k];
            int ny = y + dd[k^1];
            if(nx < 0 || h <= nx || ny < 0 || w <= ny){
                continue;
            }
            if(a[nx][ny]){
                continue;
            }
            q.emplace(make_pair(nx, ny), d + 1);
        }
    }

    int ans = 0;
    rep(i, h){
        rep(j, w){
            ans = max(ans, b[i][j]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 55424
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n;
  string s;
  lll cnt = 0;
  lll k;
  cin >> n;

  cin >> s;

  //for(ii=0;ii<n-2;ii++){
  //  for(jj=ii+1;jj<n-1;jj++){
  //    for(kk=jj+1;kk<n  ;kk++){
  //
  //      //cout << "ii:" << ii << "jj:" << jj << "kk:" << kk << endl;
  //      
  //      if(s[ii] != s[jj] )
  //        if(s[ii] != s[kk])
  //          if(s[jj] != s[kk]){
  //            if(jj - ii != kk - jj){
  //              cnt++;
  //            }
  //          }
  //    }
  //  }
  //}

  lll rgb[3];
  memset(rgb,0,sizeof(rgb));

  for(ii=0;ii<n;ii++){
    if(s[ii] == 'R'){rgb[0]++;}
    if(s[ii] == 'G'){rgb[1]++;}
    if(s[ii] == 'B'){rgb[2]++;}
  }
  lll ans;
  ans = rgb[0] * rgb[1] * rgb[2];
  
  for(jj=0;jj<n;jj++){
    for(ii=0;ii<n;ii++){
      if(jj > ii){
        k = 2*jj - ii;
        if(k < n){
          if(s[ii] == s[jj]){continue;}
          if(s[ii] == s[k]) {continue;}
          if(s[jj] == s[k]) {continue;}
          cnt++;
        }
      }
    }
  }

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


Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

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

        final int x = sc.nextInt();
        final int y = sc.nextInt();
        final int z = sc.nextInt();
        
        System.out.println(z + " " + x + " " + y);
    }
}


Measured memory_bytes: 39200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final int N = scn.nextInt();
			final int T = scn.nextInt();
			final int A = scn.nextInt();

			double min = Double.MAX_VALUE;
			int ret = -1;
			for (int i = 0; i < N; i++) {
				double work = Math.abs(A - (T - scn.nextInt() * 0.006));
				if (min > work) {
					min = work;
					ret = i + 1;
				}
			}
			System.out.println(ret);
		}
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

typedef vector<ll> vec;
typedef vector<vec> mat;

mat mul(mat a, mat b){
    int sz = a.size();
    mat c(sz, vec(sz));
    REP(i,sz){
        REP(j,sz){
            REP(k,sz){
                c[i][j] += a[i][k] * b[k][j];
                c[i][j] %= MOD;
            }
        }
    }

    return c;
}

vec mul_vec(mat A, vec b){
    int sz = A.size();
    vec B(sz);
    REP(i,sz){
        REP(j,sz){
            B[i] += A[i][j] * b[j];
            B[i] %= MOD;
        }
    }
    return B;
}

mat pow(mat A, ull n){
    int sz = A.size();
    mat B(sz, vec(sz));
    REP(i,sz){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n&1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

int main(){
    int N;
    ull K;
    cin >> N >> K;
    mat A(N, vec(N));
    REP(i,N){
        REP(j,N){
            int a;
            cin >> a;
            A[j][i] = a; 
        }
    }

    mat AA = pow(A, K);

    vec b(N, 1);
    vec B = mul_vec(AA, b);

    ll ans = 0;
    REP(i,N){
        ans += B[i];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
def gcd(x, y):
    """
    ユークリッドの互除法を用いてxとyの最大公約数を求める。
    """
    while True:
        r = x%y
        if r == 0:
            break
        x = y
        y = r
    return y
    
def prime_factorize(x):
    """
    素因数分解
    """
    res = []
    while x%2 == 0:
        res.append(2)
        x = x//2
    p = 3
    while p*p <= x:
        while x%p == 0:
            res.append(p)
            x = x//p
        p += 2
    if x != 1:
        res.append(x)
    return res


A, B = map(int, input().split())
print(len(set(prime_factorize(gcd(A, B)))) + 1)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main(){
  vector<int> a(4);
  rep(i,4) cin >> a[i];
  
  if(a[3]==1) cout << 1 << endl;
  else cout << 0 << endl;
  return;
}
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VB = vector<bool>;
using VS = vector<string>;
using graph = vector<vector<int>>;

int main()
{
ll a,v,b,w,t;
cin>>a>>v>>b>>w>>t;
if (a<b)
{
 if (v<=w||v*t+a<w*t+b)
{
    cout<<"NO"<<endl;
}
else
{
    cout<<"YES"<<endl;
}
   
}

else
{
  if (v<=w||-v*t+a>-w*t+b)
{
    cout<<"NO"<<endl;
}
else
{
    cout<<"YES"<<endl;
}
  
}

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {

	ll N, M;

	std::cin >> N >> M;

	ll A, d = 0;
	rep(i, 0, M) {
		std::cin >> A;
		d += A;
	}
	if (N < d) {
		std::cout << -1 << endl;
	}
	else {
		std::cout << N - d << endl;
	}
	return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#pragma GCC target("avx")

#include <cstdio>

using namespace std;

using int64 = long long;

class Combination {
 public:
  constexpr Combination() { Build(); }
  static constexpr int mod_ = 1000000007;
  static constexpr int n_ = 800000;
  class LookupTable {
   public:
    int64 factorial_[n_];
    int64 inverse_[n_];
    int64 finverse_[n_];
  };
  LookupTable lt{};
  // return nCk
  constexpr int64 Get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return lt.factorial_[n] * (lt.finverse_[k] * lt.finverse_[n - k] % mod_) %
           mod_;
  }

 private:
  constexpr void Build() noexcept {
    lt.factorial_[0] = 1;
    lt.factorial_[1] = 1;
    lt.finverse_[0] = 1;
    lt.finverse_[1] = 1;
    lt.inverse_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      lt.factorial_[i] = lt.factorial_[i - 1] * i % mod_;
      lt.inverse_[i] = mod_ - lt.inverse_[mod_ % i] * (mod_ / i) % mod_;
      lt.finverse_[i] = lt.finverse_[i - 1] * lt.inverse_[i] % mod_;
    }
  }
};

template<typename T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

Combination com;

int main() {
  int x, y; fastin(x); fastin(y);

  if ((x + y) % 3 != 0) {
    printf("%d", 0);
    return 0;
  }
 
  int nn = (x + y) / 3;
  int r = x - nn;
 
  int64 ans = com.Get(nn, r);
  printf("%lld", ans);

  return 0;
}


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

using namespace std;
const int N = 501;
int c[N], s[N], f[N];

int calculate(int t, int i, int n) {
	if (i == n - 1) { 
		return t;
	} else {
		if (t < s[i]) t = s[i];
		if (t % f[i] != 0) t += f[i] - (t % f[i]);
		return calculate(t + c[i], i + 1, n);
	}
}

int main() {
	
	int n; cin >> n;
	
	for (int i = 0; i < n-1; i++) cin >> c[i] >> s[i] >> f[i];
	for (int i = 0; i < n; i++) cout << calculate(0, i, n) << endl;
	return 0;
}

Measured memory_bytes: 3532
import java.io.*;

public class Main {	
	public static void main(String[] args) throws IOException {
		BufferedReader din = new BufferedReader( new InputStreamReader(System.in));
		int n = Integer.parseInt(din.readLine());
		for ( int i = 0; i < n; i++ ) {
			String str = din.readLine();
			System.out.println(str.replace("Hoshino","Hoshina"));
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
using ll = int64_t;

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<int> order(m);
  vector<ll> value(m);

  int ord = 1;
  ll ans = 0;
  while (n > 0) {
    if (order[x] > 0) {
      ll len = ord - order[x];
      ll val = ans - value[x] + x;
      ans += n / len * val;
      n %= len;
    }
    if (n > 0) {
    ans += x;
    --n;
    order[x] = ord++;
    value[x] = ans;
    x = x * x % m;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 4552
import java.util.Scanner;

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

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int t = stdIn.nextInt();

        System.out.println((int)(t+0.5)/a*b);
    }
}


Measured memory_bytes: 22740
h,w=map(int,raw_input().split())
temp=[]
e='eee'
for i in range(w-1):
	e='e'+e
temp.append(e)	
for i in range(h):
	ip=raw_input()
	ip='e'+ip+'e'
	temp.append(ip)
temp.append(e)
n=0
op=[]	
fop=[]
for i in range(h):
	for j in range(w):
		if temp[i+1][j+1]=='.':
			if temp[i+2][j+1]=='#':
				n=n+1
			if temp[i][j+1]=='#':
				n=n+1
			if temp[i+1][j+2]=='#':
				n=n+1
			if temp[i+1][j]=='#':
				n=n+1
			if temp[i+2][j+2]=='#':
				n=n+1	
			if temp[i][j+2]=='#':
				n=n+1
			if temp[i+2][j]=='#':
				n=n+1	
			if temp[i][j]=='#':
				n=n+1
			op.append(str(n))	
			n=0
		elif temp[i+1][j+1]=='#':
			op.append('#')
	fop.append(op)
	op=[]

for i in range(h):
	print ''.join(fop[i])

Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <bitset>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <functional>
#include <stack>
#include <cmath>
#include <string>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
using ll = long long;

inline bool bit(ll x, int b) { return (x >> b) & 1; }

constexpr int SZ = 100000;
constexpr int prs = 10;
ll pre[1 << prs][SZ + 1];

int main() {
  int N;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  REP(i, N) cin >> V[i + 1] >> W[i + 1];
  FOR(i, 1, min(N + 1, 1 << prs)) {
    if (i != 1) copy(pre[i / 2], pre[i / 2] + SZ + 1, pre[i]);
    for (int j = SZ; j >= W[i]; --j)
      pre[i][j] = max(pre[i][j], pre[i][j - W[i]] + V[i]);
    REP(j, SZ) pre[i][j + 1] = max(pre[i][j + 1], pre[i][j]);
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    if (v < (1 << prs)) {
      cout << pre[v][L] << "\n";
    } else {
      int lvl = 32 - __builtin_clz(v) - prs;
      ll ans = 0;
      REP(b, 1 << lvl) {
        int w = 0;
        ll va = 0;
        REP(i, lvl) {
          if ((b >> i) & 1) {
            w += W[v >> i];
            va += V[v >> i];
          }
          if (w > L) break;
        }
        if (w <= L) ans = max(ans, pre[v >> lvl][L - w] + va);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7716
n = int(input())
li = list(map(int,input().split()))
cnt = 0
for i in li:
    if i <= 0:cnt+=1
if cnt%2:
    d = sorted(li,key=lambda x:abs(x))[0]
    print(sum(list(map(lambda x:abs(x),li)))-abs(d)*2)
else:print(sum(list(map(lambda x:abs(x),li))))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

vector<int> places[210000];

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

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

    ll MOD = 1e9+7;

    ll dp[210000];
    dp[0] = 1;

    for(int i = 0; i < 210000; i++) places[i].clear();
    for(int i = 0; i < N; i++) places[c[i]].push_back(i);

    for(int i = 1; i <= N; i++){

        dp[i] = (dp[i] + dp[i-1]) % MOD;

        int color = c[i-1];
        int it = lower_bound(places[color].begin(), places[color].end(), i-1)
            - places[color].begin();
        if(it > 0){
            int j = places[color][it-1];
            if((i-1) - j > 1) dp[i] = (dp[i] + dp[j+1]) % MOD;
        }
    }
    cout << dp[N] << endl;


    return 0;
}



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

using namespace std;

int main()
{
  int N, M, A, B, D[1000];

  cin >> N >> M >> A >> B;
  for(int i = 0; i < N; ++i) {
    cin >> D[i];
  }

  vector< int > Koho;
  for(int i = 0; i < N; i++) {
    if(D[i] >= A) {
      Koho.push_back(i);
    } else {
      break;
    }
  }

  if(N - Koho.size() < M) {
    reverse(begin(Koho), end(Koho));
    for(int k : Koho) {
      if(D[k] <= B) {
        Koho.pop_back();
      } else {
        break;
      }
    }
  }

  cout << Koho.size() << endl;
}

Measured memory_bytes: 3156
#include<iostream>

int main() {
	char str[100001];
	std::cin >> str;
	int length = 0;
	int i = 0;
	while (str[i] != '\0') 	i++;
	length = i;
	int ans = 0;
	for (int i = 0; i < length; i++) {
		ans += i % 2 ^ (str[i] - '0');
	}
	if (ans > length - ans)ans = length - ans;
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

bool isPalindrome(string s){
    string es = s;
    reverse(all(es));
    return s == es;
}

int main(){
    string S;
    cin >> S;
    int i1 = (S.size()-1)/2, i2 = (S.size()+3)/2;
    string s1 = S.substr(0, i1), s2 = S.substr(i2-1, S.size());
    cout << (isPalindrome(S) && isPalindrome(s1) && isPalindrome(s2) ? "Yes" : "No") << endl;
}

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

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

int main() {
    int n;
    cin >> n;
    bool ans = false;
    int cnt = 0;
    rep(i, n) {
        if (cnt >= 3) ans = true;

        int a, b;
        cin >> a >> b;

        if(a == b)cnt++;
        else cnt = 0;
    }

    if(cnt>=3) ans = true;

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

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

#define MAX_V 20
const int INF = 1<<20;

int cost[MAX_V][MAX_V];
int V;
bool used[MAX_V];  // 最小距離の確定した頂点
int d[MAX_V];

void dijkstra(int s) {
  fill(d, d+V, INF);
  fill(used, used+V, false);
  
  d[s] = 0;
  while(true) {
    int v = -1;
    for(int u=0; u<V; u++) {
      // 最小が確定していない頂点からd[v]を最小距離であることが確定させる
      if(!used[u] && ( v == -1 || d[u] < d[v] ) ) v = u;
    }
    if(v == -1) {
      // 全ての頂点の最小距離が確定
      break;
    }
    used[v] = true;
    

    
    // 上で確定させた最小距離の頂点から伸びうる頂点を更新しておく
    for(int u=0; u<V; u++) {
      d[u] = min(d[u], d[v]+cost[v][u]);
    }
  }
}

int main() {
  int m;

  cin >> V >> m;

  for(int i=0; i<V; i++) {
    for(int j=0; j<V; j++) {
      cost[i][j] = INF;
    }
  }
  
  for(int i=0; i<m; i++) {
    int a, b;
    char c1, c2;
    cin >> a >> c1 >> b >> c2; a--, b--;
    cin >> cost[a][b] >> c1 >> cost[b][a];
  }
  
  int x1, x2, y1, y2;
  char c1,c2,c3;
  cin >> x1 >> c1 >> x2 >> c2 >> y1 >> c3 >> y2; x1--, x2--;
  
  dijkstra(x1);
  
  int money = y1-(y2+d[x2]);
  
  dijkstra(x2);
  
  money -= d[x1];
  cout << money << endl;
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main (){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  
  if(A1+A2+A3 > 21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=2e5+5;
const int MX=1e6+1;
int a[mxn];
int used[MX];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		used[a[i]]++;
	}
	int cnt=0;
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	if(used[1]){
		if(used[1]==1)cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	for(int i=0; i<n; i++){
		int cur = a[i];
		bool ok=1;
		if(used[cur]>1)ok=0;
		for(int j=2; j*j<=cur&&ok; j++){
			if(cur%j==0){
				if(used[j])ok=0;
				if(j!=cur/j){
					if(used[cur/j])ok=0;
				}
			}
		}
		if(ok)cnt++;
	}
	cout << cnt << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 8304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll W;
    cin >> W;
    vector<ll> w(N,0);
    vector<ll> v(N,0);
    for(ll i=0;i<N;++i)cin>>w[i]>>v[i];
    vector<ll> dp(W+1,-INF);
    dp[0]=0;
    for(ll i=0;i<N;++i){
        for(ll j=W;j>=w[i];--j){
            chmax(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    ll ans=0;
    for(auto p: dp)chmax(ans,p);
    prt(ans)

    return 0;
}


Measured memory_bytes: 1024
import java.util.Date

object Main {

  val amari = 1000000007

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val S = sc.next()
    val d = Date.parse(S)
    println(
      if (d.compareTo(Date.parse("2019/04/30")) <= 0)
        "Heisei"
      else
        "TBD"
    )
  }
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s.at(i);
    }

    vector<int> dx = {-1, 0, 1, -1, 1, -1, 0, 1};
    vector<int> dy = {-1, -1, -1, 0, 0, 1, 1, 1};
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s.at(i).at(j) == '#')
            {
                continue;
            }
            int cnt = 0;
            for (int k = 0; k < 8; k++)
            {
                if (j + dx.at(k) < 0 || w <= j + dx.at(k))
                {
                    continue;
                }
                if (i + dy.at(k) < 0 || h <= i + dy.at(k))
                {
                    continue;
                }
                if (s.at(i + dy.at(k)).at(j + dx.at(k)) == '#')
                {
                    cnt++;
                }
            }
            s.at(i).at(j) = cnt + '0';
        }
    }
    for (int i = 0; i < h; i++)
    {
        cout << s.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const double eps=1e-6; 
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=100+10;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll w[maxm],v[maxm];
ll dp[maxn];
int main()
{
	io();
	int N,W;
	int sum=0;
	cin>>N>>W;
	for(int i=1;i<=N;++i){
		cin>>w[i]>>v[i];
		sum+=v[i];
	}
	for(int i=0;i<=sum;++i)
		dp[i]=inf;
	dp[0]=0;
	for(int i=1;i<=N;++i)
		for(int j=sum;j>=v[i];--j){
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	int ans=0;
	for(int i=0;i<=sum;++i){
		if(dp[i]<=W)
			ans=max(ans,i);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
num=Array.new(4100,0)
1001.times{|a|1001.times{|b|num[a+b]+=1}}
while gets
    n=$_.to_i
    count=0
    2001.times do|x|
        if n-x>=0
            count+=num[x]*num[n-x]
        else
            break
        end
    end
    p count
end

Measured memory_bytes: 6132
# 数列の個数
num_count = int(input())

# 数列を定義
nums_list = list(map(int, input().split()))

max_num = 0
zero_count = 0
minus_count = 0

for num in nums_list:
    max_num += abs(num)

    if num == 0:
        zero_count += 1
    if num < 0:
        minus_count += 1

if zero_count == 0 and minus_count % 2 != 0:
    max_num -= min(list(map(abs, nums_list))) * 2

print(max_num)

Measured memory_bytes: 14224
#include<stdio.h>

int	main(){
	int	i,	k,	x,	cnt[1000001],	data[1000000];
	cnt[0]	=	0;
	data[0]	=	0;
	data[1]	=	0;
	for(i	=	2;	i	<=	1000000;	i++){
		data[i]	=	1;
	}
	for(i	=	2;	i	*	i	<=	1000000;	i++){
		if(data[i]){
			for(k	=	2	*	i;	k	<=	1000000;	k	+=	i){
				data[k]	=	0;
			}
		}
	}
	for(i	=	0;	i	<=	1000000;	i++){
		cnt[i	+	1]	=	cnt[i]	+	data[i];
	}
	while(scanf("%d",	&x)	!=	EOF){
		printf("%d\n",	cnt[x	+	1]);
	}
	return	0;
}

Measured memory_bytes: 8836
//--------ROMAN ITERATION -------------
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
#define fix( x ) cout << fixed << setprecision( x ) ;
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
const int eps = 1e-9;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    Fast_IO();
    ll a ; 
    cin >> a ; 
    cout << (3ll * a *a );
    return 0 ;
}



Measured memory_bytes: 256
/*Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout << #x << " " << x <<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<int, vector<int>, function<bool(int, int)>> pq_func;
/*---------------------------------------------------------------------------------------------------------------------------*/
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	int s, w;
	cin >> s >> w;
	if (w >= s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
	return 0;
}

Measured memory_bytes: 3676
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
S.insert(0,[0]*W)
S.append([0]*W)
for i in range(len(S)):
    S[i].insert(0,0)
    S[i].append(0)
dx = [1,0,-1,0,1,-1,-1,1]
dy = [0,1,0,-1,1,1,-1,-1]
tmp = [[0] * W for i in range(H)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j] == "#":
            tmp[i-1][j-1] = "#"
            continue
        num = 0
        for k in range(len(dx)):
            if S[i+dx[k]][j+dy[k]] == "#":
                num += 1
                tmp[i-1][j-1] = num
for j in range(len(tmp)):
    print(*tmp[j],sep = "")

Measured memory_bytes: 3572
import numpy as np
U = 10**5
T = np.zeros(U,np.int32)
T[2] = 1
T[3::2] = 1
for i in range(U):
  if i*i>U:
    break
  if T[i]:
    T[i*i::2*i] = 0
pls = np.where(T)[0]
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
N, M = map(int, input().split())
dic = {}
for p in pls:
  cnt = 0
  while M%p==0:
    M //= p
    cnt += 1
  dic[p] = cnt
if M!=1:
  dic[M] = 1
ans = 1
for k in dic.keys():
  ans *= cmb(dic[k]+N-1,N-1,mod)
  ans %= mod
print(ans)

Measured memory_bytes: 133492
#include <iostream>
    #include <algorithm>
    #include <string>
    #include <list>
    #include<vector>
    #include <sstream>
    #include <stdio.h>
    #include <utility>
    #include <unordered_set>
    #include <valarray>
    #include <iomanip>
    using namespace std;
     
     
    int main(void)
    {
    	int A, B = 0;
    	int TargetData=0;
     
    	cin >> TargetData;
     	bool BreakFlag=false;
      	for(int i=-1000;i<=2000;i++)
        {
          for(int z=-2000;z<=2000;z++)
          {
            if((pow(i,5)-pow(z,5))==TargetData)
            {
              A=i;
              B=z;
              cout << A<<" "<<B << endl;
              
              return 0;
            }
          }
        }
     
    	cout << A<<" "<<B << endl;
     
    	return 0;
    }


Measured memory_bytes: 4164
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
	priority_queue<int> q;
	int h, w, a, b,ans=0;
	int s[100005] = {};
	cin >> a>>b;
	for (int i = 0; i < a; i++)
	{
		cin >> s[i];
		if (s[i]>=b)
		{
			ans++;
		}
	}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

string s,p;

int H(int &idx){
    if(s[idx]=='['){
        ++idx;
        char op = s[idx];
        ++idx;

        int val=-1;
        if(op=='+') val = H(idx)|H(idx);
        else if(op=='*') val = H(idx)&H(idx);
        else if(op=='^') val = H(idx)^H(idx);
        else assert(false);

        assert(s[idx]==']');
        ++idx;

        return val;
    }
    else{
        int letter = s[idx]-'a';
        ++idx;
        assert(0<=letter && letter<=3);
        return p[letter]-'0';
    }
}

int main(){
    while(cin >>s,(s!=".")){
        cin >>p;

        int idx = 0;
        int v = H(idx);

        int ct = 0;
        rep(i,10000){
            int t = i;
            rep(j,4){
                p[3-j] = t%10+'0';
                t/=10;
            }
            idx = 0;
            if(H(idx) == v) ++ct;
        }

        cout << v << " " << ct << endl;
    }
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n, d;
  cin >> n >> d;
  d *= 2;
  d++;
  cout << n / d + (n % d != 0) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define int long long
using namespace std;
struct A{
	int a, b;
}a[N];
int cmp(A x, A y){
	return x.a + x.b > y.a + y.b;
}
int n, s1, s2;
signed main(){
	scanf("%lld", &n);
	for(int i = 1; i <= n; i ++) scanf("%lld%lld", &a[i].a, &a[i].b);
	sort(a + 1, a + 1 + n, cmp);
	for(int i = 1; i <= n; i ++){
		if(i&1) s1 += a[i].a;
		else s2 += a[i].b;
	}
	printf("%lld", s1 - s2);
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
}


Measured memory_bytes: 2604
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H;i++){
    string s;
    cin>>s;
    cout<< s << endl;
    cout<< s << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





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

  REP(i,n){

    int h,w;
    cin >> h >> w;
    bool f[h][w] = {};
    string s[h];
    REP(i,h){
      cin >> s[i];
    }
    vector <char> c;
    REP(i,h){
      REP(j,w){
	if(s[i][j] != '.'){
	  if(c.empty()){
	    c.pb(s[i][j]);
	  }
	  else{
	    bool t = false;
	    REP(k,c.size()){
	      if(c[k] == s[i][j]){
		t = true;
	      }
	    }
	    if(!t){
	      c.pb(s[i][j]);
	    }
	  }
	}

      }
    }
    
      REP(m,c.size()){
	bool b[h][w];
	
	int l = 100,d = -1,r = -1, u= 100;
	bool q[h][w] = {};
	REP(j,h){
	  REP(k,w){
	    if(s[j][k] == c[m]){
	      l = min(k,l);
	      r = max(k,r);
	      d = max(j,d);
	      u = min(j,u);
	      q[j][k] = true;
	    }
	    
	    
	  }
	}
      
      bool v = true;
      rep(j,u,d+1){
	rep(k,l,r+1){
	  if(!q[j][k] && !f[j][k]){
	    v = false;
	  }
	}
      }
      //cout << u << "    " << d << "   " << l << "    " << r << endl;
      if(v){
	c.erase(c.begin()+m);
	m = -1;
	rep(j,u,d+1){
	  rep(k,l,r+1){
	    f[j][k] = true;
	  }
	}
      }
      
    }
      /*
    REP(m,h){
      REP(j,w){
	cout << f[m][j] << "  "; 
      }
      cout << endl;
      }*/
    bool rr = true;
    REP(m,h){
      REP(mm,w){
	if(s[m][mm] != '.' && !f[m][mm]){
	  rr = false;
	}
	
	
      }
    }
    if(rr){
      cout << "SAFE" << endl;
    }
    else{
      cout << "SUSPICIOUS" << endl;
    }

  }
  
  return 0;
}



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

//{{{
/********************************************************************/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)
#define endl '\n'

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
inline int in() { int x; std::cin >> x; return x; }
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

/****************************************************************/
//}}}

signed main()
{
  int n = in();
  int sum = 0, cnt = 0;
  vi v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
    if (v[i] % 10 == 0) cnt++;
  }
  if (cnt == n) sum = 0;

  sort(all(v));
  for (int i = 0; sum % 10 == 0 and sum != 0; i++) {
    if (v[i] % 10 == 0) continue;
    sum -= v[i];
  }

  cout << sum << endl;

  return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N='z'+4;
int main()
{
	string s;
	cin>>s;
	int t=0;
	int a[N]={0};
	for(int i=0;i<4;i++)
	{
		bool f=1;
		for(int j=0;j<i;j++)
		{
			if(s[i]==s[j])
			{
				f=0;
				break;
			}
		}
		if(f==1)
		{
			t++;
			
		}
		a[s[i]]++;
	}
	for(int i=0;i<4;i++)
	{
		if(a[s[i]]!=2)
		{
			cout<<"No";
			return 0; 
		}
	}
	if(t!=2) cout<<"No";
	else cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int hi[3],mi[3],si[3],ho[3],mo[3],so[3],h,i,j,k;
    for(i=0;i<3;i++)
        scanf("%d%d%d %d%d%d",&hi[i],&mi[i],&si[i],&ho[i],&mo[i],&so[i]);
    for(i=0;i<3;i++){
        j=3600*hi[i]+60*mi[i]+si[i];
        k=3600*ho[i]+60*mo[i]+so[i];
        h=k-j;
        printf("%d %d %d\n",h/3600,h%3600/60,h%60);
    }
    return 0;
}


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

const int N = 2e5 + 10;
const int M = 199999;
#define mk make_pair
#define P pair<int,int>
#define ll  long long

int main()
{
    ll d,t,s;
    cin >> d >> t >> s;
    if(s*t>=d)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}
/*
 6
 1 5 4 3 3 5
 */

Measured memory_bytes: 3632
inf = input().split()
N = int(inf[0])
M = int(inf[1])
ls = []
m = 0
pair = [0,N]
for i in range(M):
  inf = input().split()
  L = int(inf[0])
  R = int(inf[1])
  pair[0] = max(pair[0], L)
  pair[1] = min(pair[1], R)
  if pair[0]>pair[1]:
    print(0)
    break
else:
  print(pair[1]-pair[0]+1)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    char s[20];
    scanf("%s", s);
    int i = 0;
    while (s[i] != ',')
    {
        printf("%c", s[i]);
        i++;
    }
    printf(" ");
    i++;
    while (s[i] != ',')
    {
        printf("%c", s[i]);
        i++;
    }
    printf(" ");
    i++;
    while (s[i] != '\0')
    {
        printf("%c", s[i]);
        i++;
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128