akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n; str s;
    std::cin >> n >> s;

    std::stack<char> stack;
    for (ll i = 0; i < n; i++)
        if (!stack.empty() && stack.top() == '(' && s[i] == ')')
            stack.pop();
        else
            stack.push(s[i]);

    for (; !stack.empty(); stack.pop())
        if (stack.top() == ')')
            s.insert(s.begin(), '(');
        else
            s.insert(s.end(), ')');

    std::cout << s << '\n';
}


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

struct ModInt {
    using M = ModInt;

    static vector<M> fact, finv;
    static long long MOD;
    long long v;

    // normalize: [-MOD, MOD**2] -> [0, MOD)
    ModInt(const long long _v = 0) : v((_v < 0) ? _v % MOD + MOD : _v % MOD) {}

    M operator+(const M& x) const { return M(v + x.v); }
    M operator-(const M& x) const { return M(v - x.v); }
    M operator*(const M& x) const { return M(v * x.v); }
    M operator/(const M& x) const { return M(v * x.inv().v); }
    M& operator+=(const M& x) { return *this = *this + x; }
    M& operator-=(const M& x) { return *this = *this - x; }
    M& operator*=(const M& x) { return *this = *this * x; }
    M& operator/=(const M& x) { return *this = *this / x; }
    bool operator==(const M& x) const { return v == x.v; }
    bool operator!=(const M& x) const { return v != x.v; }
    friend istream& operator>>(istream& input, M& x) {
        return input >> x.v, x = M(x), input;
    }
    friend ostream& operator<<(ostream& output, const M& x) {
        return output << x.v;
    }
    inline M pow(long long n) const {
        M x(v), res(1);
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
    inline M inv() const { return this->pow(MOD - 2); }
    static void build(int n) {
        fact.assign(n + 1, 1);
        for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
        finv.assign(n + 1, fact[n].inv());
        for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
    }
    static M comb(int n, int k) {
        if (n < k || k < 0) return M(0);
        return fact[n] * finv[n - k] * finv[k];
    }
    static M extgcd(int a, int b, int& x, int& y) {
        M d(a);
        if (b) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 1e9 + 7;

int main() {
    ModInt::build(1e6);
    int n, k;
    cin >> n >> k;
    ModInt ans = 0;
    for (int i = k; i <= n + 1; i++) {
        ModInt r = ModInt(n) * ModInt(n + 1) * ModInt(2).inv() - ModInt(n - i) * ModInt(n - i + 1) * ModInt(2).inv();
        ModInt l = ModInt(i - 1) * ModInt(i) * ModInt(2).inv();
        ans += r - l + 1;
    }
    cout << ans << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define repr(i,n) for(ll i=(ll)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<char> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

bool number[10];
int alphabet[26];
vector<char> v;
vector<int> perm(10);
int n;
string s[12];

int main(){
  cin.sync_with_stdio(false);

  iota(all(perm), 0);
  while (cin >> n, n) {
    v.clear();
    rep(i, 26) alphabet[i] = -1;

    S nonzero;
    rep(i, n) {
      cin >> s[i];
      if (s[i].length() > 1) nonzero.insert(s[i][0]);
      rep(j, s[i].length()) v.pb(s[i][j]);
    }

    sort(all(v));
    uni(v);

    int sum[v.size()] = {}, eq[v.size()] = {};
    rep(i, n) {
      int tmp = 1;
      repr(j, s[i].length()) {
        rep(k, v.size()) {
          if (s[i][j] == v[k] && i < n - 1) sum[k] += tmp;
          else if (s[i][j] == v[k] && i == n - 1) eq[k] += tmp;
        }
        tmp *= 10;
      }
    }
    int tmp = 1;
    repl(i, 1, 11 - v.size()) tmp *= i;

    ll ans = 0, l, r, next = tmp - 1;
    bool same, zero;
    do {
      if (next-- > 0) continue;
      l = r = 0;
      // same = true;
      zero = false;
      rep(i, v.size()) {
        // if (alphabet[v[i] - 'A'] != perm[i]) same = false;
        if (nonzero.count(v[i]) && perm[i] == 0) {
          zero = true;
          break;
        }
        alphabet[v[i] - 'A'] = perm[i];
        l += sum[i] * perm[i];
        r += eq[i] * perm[i];
      }
      if(!zero && l == r) ans++;
      next = tmp - 1;
    } while(next_permutation(all(perm)));

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3180
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <string>

template <intmax_t X = 943681729, intmax_t MOD = 1000000007>
class rolling_hash {
  std::vector<intmax_t> hash, offset;

public:
  rolling_hash(const std::string& s): hash(s.length()+1), offset(s.length()+1) {
    for (size_t i = 0; i < s.length(); ++i)
      hash[i+1] = (hash[i]*X+s[i]) % MOD;

    offset[0] = 1;
    for (size_t i = 1; i <= s.length(); ++i)
      offset[i] = offset[i-1] * X % MOD;
  }

  intmax_t get_base() const { return X; }
  intmax_t get_mod() const { return MOD; }

  intmax_t prefix(size_t i) const {
    // hash of prefix s[0..i-1] (inclusive)
    assert(0 < i);
    return hash[i];
  }

  intmax_t substr(size_t i, size_t j) const {
    // hash of substring s[i..j-1] (inclusive)
    assert(i < j);
    intmax_t res = hash[j];
    res = (res - offset[j-i]*hash[i]) % MOD;
    if (res < 0) res += MOD;
    return res;
  }

  intmax_t inserted(size_t i, int ch) const {
    intmax_t res = 0;
    if (i > 0) res += prefix(i);
    res = (res*X + ch) % MOD;
    size_t n = hash.size()-1;
    if (i < n) res = (res*offset[n-i] + substr(i, n)) % MOD;
    return res;
  }

  void inspect() const {
    for (size_t i = 0; i < hash.size(); ++i)
      fprintf(stderr, "%jd%c", hash[i], i+1<hash.size()? ' ':'\n');
  }
};

bool valid(std::string const& s, size_t k) {
  rolling_hash<> r1(s);
  rolling_hash<1000000007, 123456> r2(s);
  size_t n = s.length();
  std::set<intmax_t> h1, h2;
  for (size_t i = k; i+k <= n; ++i) {
    h1.insert(r1.substr(i-k, i));
    h2.insert(r2.substr(i-k, i));
    if (h1.count(r1.substr(i, i+k)) && h2.count(r2.substr(i, i+k))) return true;
  }
  return false;
}

int main() {
  size_t n;
  scanf("%zu", &n);

  char buf[8192];
  scanf("%s", buf);
  std::string s = buf;

  size_t lb = 0;
  size_t ub = n+1;
  while (ub-lb > 1) {
    size_t mid = (lb+ub) >> 1;
    (valid(s, mid)? lb: ub) = mid;
  }
  printf("%zu\n", lb);
}


Measured memory_bytes: 920
use std::vec::Vec;
use std::cmp::*;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut v: Vec<i64> = read_vec();

    v.sort();
    let mut tmp = (v[0] as f64 + v[1] as f64) / 2.0;
    for i in 2..n {
      tmp = (tmp + v[i] as f64) / 2.0;
    }

    println!("{}", tmp);
}


Measured memory_bytes: 4352
#include<stdio.h>
main(void)
{
	int n,x,a,b;
	
	scanf("%d",&n);
	
	for(x=1;x<=n;x++){
		a=x;
		if(a%3==0)printf(" %d",a);
		else{
			b=a;
			while(b){
				if(b%10==3){
					printf(" %d",a);
					break;
				}
				else b/=10;
			}
		}
	}
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
using System;
public class Program
{
    public static void Main(string[] args)
    {
        // 整数の入力
        string[] input = Console.ReadLine().Split(' ');
        string s = input[0];
        string t = input[1];
        // スペース区切りの整数の入力
        input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        // 文字列の入力
        string u = Console.ReadLine();

        if (s == u)
        {
            Console.WriteLine((a-1) + " " + b);
        }
        else
        {
            //出力
            Console.WriteLine(a + " " + (b - 1));
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

int P[222222], revP[222222];

int main() {
  // ios_base::sync_with_stdio(0);

  int N;
  scanf("%d", &N);
  REP(i,N) {
    scanf("%d", &P[i]);
    --P[i];
    revP[P[i]] = i;
  }

  int result = 0;
  int p = 0;
  while (p < N) {
    int p2 = p + 1;
    while (p2 < N && revP[p2-1] < revP[p2]) ++p2;
    result = max(result, p2-p);
    p = p2;
  }
  printf("%d\n", N - result);
}


Measured memory_bytes: 1792
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

e=min(a)+min(b)

for _ in range(M):
    x,y,c=map(int,input().split())
    f=a[x-1]+b[y-1]-c
    e=min(e,f)

print(e)


Measured memory_bytes: 24864
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

long long b[300005][61]{0};  // 0で初期化
long long bcs[300005][61]{0};  // 0で初期化

int main() {

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

    for (int i=0; i<N; i++) {
        for (int j=0; j<61; j++) {
            long long t = (1LL << j);
            if ((t & A[i]) != 0) {
                b[i][j] = 1;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 61; j++) {
            bcs[i + 1][j] = bcs[i][j] + b[i][j];
        }
    }

    long long res = 0;
    long long mod = pow(10, 9) + 7;

    for (int i=0; i<N-1; i++) {
        for (int j=0; j<61; j++) {
            long long t = (1LL << j);
            long long k;
            if ((t & A[i]) != 0) {
                k = N - (i + 1) - (bcs[N][j] - bcs[i + 1][j]);
            } else {
                k = (bcs[N][j] - bcs[i + 1][j]);
            }
            t %= mod;
            res += k * t;
            res %= mod;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 288512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll s, mod = 1e9+7, ans, fac[2005], modinv[2005];

ll qexp(ll a, ll b) {
    a %= mod;
    ll res = 1, base = a;
    while (b) {
        if (b & 1) {
            res *= base;
            res %= mod;
        }
        base *= base;
        base %= mod;
        b >>= 1;
    }
    return res % mod;
}

ll choose(ll n, ll k) {
	if (n < 0 or k < 0) return 0;
	return (((fac[n] * modinv[k]) % mod) * modinv[n-k]) % mod;
}

int main() {
	fastio; cin >> s;
	fac[0] = 1, modinv[0] = 1;
	FOR(i, 1, s) {
		fac[i] = (i * fac[i-1]) % mod;
		modinv[i] = qexp(fac[i], mod-2);
	}
	FOR(i, 1, s/3) { // i terms
		ll x = s - i*2;
		ans = (ans + choose(x-1, i-1)) % mod;
	}
	cout << ans;
}


Measured memory_bytes: 3668
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI p(n);
    REP(i,0,n) cin >> p[i];
    cout << accumulate(all(p), 0) - *max_element(all(p)) / 2 << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>

using namespace std;

int main(){
   
    int n;
    
    cin >> n;
    
    cout << (n+1)/2 << endl;
    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N, M;
int X[MAX_N];
struct edge {
  edge(int from = 0, int to = 0, int v = 0) : from(from), to(to), y(y) {}
  bool operator < (const edge& e) const {
    return y < e.y;
  }
  int from, to, y;
  void input() {
    cin >> from >> to >> y;
    from--; to--;
  }
};
vector<edge> Edge;

class UnionFind{
public:
  UnionFind(int aN)
  {
    init(aN);
  }

  void init(int aN)
  {
    par.clear(); cnt.clear(); nodeCost.clear(); unusedEdgeCnt.clear();
    par.resize(aN); cnt.resize(aN); nodeCost.resize(aN); unusedEdgeCnt.resize(aN);
    for (size_t i = 0; i < aN; i++) {
      par[i] = i;
      cnt[i] = 1;
      nodeCost[i] = X[i];
      unusedEdgeCnt[i] = 0;
    }
  }

  int find(int aX)
  {
    if(aX == par[aX]) return aX;
    else return par[aX] = find(par[aX]);
  }

  bool same(int aX, int aY)
  {
    return find(aX) == find(aY);
  }

  int size(int aX)
  {
    return cnt[find(aX)];
  }

  void addEdge(int aX, int aY, int cost)
  {
    aX = find(aX);
    aY = find(aY);

    if(aX == aY) {
      if(cost > nodeCost[aY]) {
        unusedEdgeCnt[aY]++;
      } else {
        unusedEdgeCnt[aY] = 0;
      }
    } else {
      //merge
      par[aX] = aY;
      cnt[aY] += cnt[aX];
      nodeCost[aY] += nodeCost[aX];
      unusedEdgeCnt[aY] += unusedEdgeCnt[aX];

      if(cost > nodeCost[aY]) {
        unusedEdgeCnt[aY]++;
      } else {
        unusedEdgeCnt[aY] = 0;
      }
    }
  }

  int getUnused(int x) {
    return unusedEdgeCnt[find(x)];
  }

  vector<int> par;
  vector<int> cnt;
  vector<int> nodeCost;
  vector<int> unusedEdgeCnt;
};

UnionFind uf(MAX_N);

signed main()
{
  cin >> N >> M;
  REP(n,N) {
    cin >> X[n];
  }

  uf.init(N);

  REP(m,M) {
    edge e; e.input(); Edge.emplace_back(e);
  }

  sort(begin(Edge), end(Edge));

  for(const edge& e : Edge) {
    uf.addEdge(e.from, e.to, e.y);
  }

  cout << uf.getUnused(0) << endl;

  return 0;
}

Measured memory_bytes: 8820
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long double a, b, ans;
    cin >> a >> b;
    ans = a * b;
    // cout << int(floor(ans)) << endl;
    // cout << ans << endl;
    // printf("%.5Lf\n", ans);
    cout << fixed << setprecision(0) << floor(ans) << endl;
    return 0;
}

Measured memory_bytes: 3264
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int A = scan.nextInt();
		
		int ans = H/A;
		if (H%A>0) {
			ans++;
		}
		System.out.print(ans);
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e6+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool one = false;
    REP (i,n) {
        d[i] = s[i]-'1';
        if (d[i] == 1) one = true;
    }
    int ans = 0;
    REP (i,n) {
        int cnt = 1;
        REP (j,MAXlg) {
            if (((1<<j)&(n-1)) < ((1<<j)&i)) cnt = 0;
        }
        if (cnt == 1) ans ^= (d[i]&1);
    }
    if (ans == 1) cout << 1 << endl;
    else {
        if (one) cout << 0 << endl;
        else {
            REP (i,n) d[i] /= 2;
            ans = 0;
            REP (i,n) {
                int cnt = 1;
                REP (j,MAXlg) {
                    if (((1<<j)&(n-1)) < ((1<<j)&i)) cnt = 0;
                }
                if (cnt == 1) ans ^= (d[i]&1);
            }
            if (ans == 1) cout << 2 << endl;
            else cout << 0 << endl;
        }
    }
}


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

int main() {
  int a,i,b;
  cin>>a;
  vector<int> vec(a);
  for(i=0;i<a;i++){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  b=a;
  
  for (int i = 0; i < a; i++) {
      if(i!=0){
        if(vec.at(i)==vec.at(i-1))
          b=b-1;
      }
        
  }
  cout<<b;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int mod = 1000000007;
int n, k;

int npk(int n, int k) {
    int ret = 1;
    for(int i = 0; i < k; ++i) {
        ret = (ret*(n-i))%mod;
    }
    return ret;
}

int dfs(vector<vector<int>>& graph, int cur, int parent) {
    vector<int>& children = graph[cur];

    int new_colors = children.size(), used_colors = 1;
    if(parent) {
        new_colors--;
        used_colors++;
    }

    if(k-used_colors < new_colors) {
        cout << 0 << endl;
        exit(0);
    }

    int ret = npk(k-used_colors, new_colors);

    for(int child : children) {
        if(child != parent) {
            ret = (ret*dfs(graph, child, cur))%mod;
        }
    }
    return ret;
}

int32_t main() {

    cin >> n >> k;
    vector<vector<int>> graph(n+1);
    for(int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int ans = dfs(graph, 1, 0);

    ans = k*ans%mod;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 10368
void main() {
	(s => floor(s.length / 2.) - s.count!(i => i == 'p'))(rs).writeln;
}

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

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

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

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

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

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define ll long long int
#define PI 3.1415926
using namespace std;
const int N=1e6+1;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll x,p=100,ans=0;cin>>x;
    while(p<x)
    {
        p+=p/100;
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(int argc,char* argv[]){
  
  int num;

  while(scanf("%d",&num) != EOF){
    int d = num % 39;
    if(d == 0){
      d = 39;
    }
    
    printf("3C%02d\n",d);
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<int>());
// 昇順ソート
// std::sort(data.begin(),data.end());

const long long INF = 1LL << 60;

// ここから開始だよ！
ll N;
vector<ll> v;
string tmp;

void run(ll n){
	if (n == 0) {
		tmp += "0";
	}
	if (n == 1) {
		tmp += "3";
	}
	if (n == 2) {
		tmp += "5";
	}
	if (n == 3) {
		tmp += "7";
	}
}

bool run2(ll n){
	bool is3 = false;
	bool is5 = false;
	bool is7 = false;

	while (true) {
		ll amari = n % 10;
		if (amari == 3) {
			is3 = true;
		} else if (amari == 5) {
			is5 = true;
		} else if (amari == 7) {
			is7 = true;
		} else {
			return false;
		}

		n /= 10;
		if (n == 0) {
			if (is3 && is5 && is7) {
				return true;
			} else {
				return false;
			}
		}
	}
}

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了

	cin >> N;

	rep(n0, 4) {
		rep(n1, 4) {
			rep(n2, 4) {
				rep(n3, 4) {
					rep(n4, 4) {
						rep(n5, 4) {
							rep(n6, 4) {
								rep(n7, 4) {
									rep(n8, 4) {
										rep(n9, 4) {
											tmp = "";
											run(n0);
											run(n1);
											run(n2);
											run(n3);
											run(n4);
											run(n5);
											run(n6);
											run(n7);
											run(n8);
											run(n9);

											ll tmptmp = stoll(tmp);
											if (run2(tmptmp)) {
												v.push_back(tmptmp);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	ll ans = 0;
	rep(i, v.size()) {
		if (N >= v[i]) {
			ans++;
			//cout << v[i] << endl;
		}
	}
	cout << ans << endl;

	return 0;
}


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

/// Prime factorize.
///
/// Usage example:
///
/// ```cpp
/// auto factors = factorize(12)
/// for (auto &factor : factors)
///   std::cout << factor.first << ":" << factor.second << std::endl;
/// ```
std::vector<std::pair<int, int>> factorize(long long n) {
  std::vector<std::pair<int, int>> res;
  for (long long p = 2; p * p <= n; ++p) {
    int exp = 0;
    while (n % p == 0) {
      n /= p;
      ++exp;
    }
    if (exp)
      res.push_back(std::make_pair(p, exp));
  }
  if (n != 1)
    res.push_back(std::make_pair(n, 1));
  return res;
}

int main() {
  int n;
  std::cin >> n;
  auto factors = factorize(n);

  std::cout << n << ":";
  for (auto &factor : factors)
    for (int i = 0; i < factor.second; ++i)
      std::cout << " " << factor.first;
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    int n; cin >> n;
    vector<int> L(n);
    rep(i, n) cin >> L[i];

    sort(all(L));
    int total = 0;
    rep(i, n){
        if(i != n-1){
            total+=L[i];
        }
    }

    if(L[n-1] < total){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
N,M=map(int,input().split())
ks=[[int(a) for a in input().split()] for i in range(M)]
p=[int(a) for a in input().split()]
ans=0

for i in range(2**N):#switch loop
    for j in range(M):#num of light
        sw_see=0
        for k in ks[j][1:]:#switch to see
            sw_see+=2**(k-1)
        if (bin(i&sw_see)).count('1')%2!=p[j]:
            break
    else:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int num=a,ans=1;
	if(b==1){
		cout<<0<<endl;
		return 0;
	}
	while(num<b){
		if(num-1+a==b){
			ans++;
			break;
		}
		num+=a-1;
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12){
		if(b==1 || b==3 || b==5 || b==7 || b==8 || b==10 || b==12){
			
			cout<<"Yes"<<endl;
		}
	else cout<<"No"<<endl;
}
	
	if(a==4 || a==6 || a==9 || a==11 ){
		if(b==4 || b==6 || b==9 || b==11 ){
			
			cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}
	
	if(a==2) cout<<"No"<<endl;
	
	return 0;
	
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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; }



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,x;
    cin>>n>>m>>x;
    vi a(m);
    VIN(a);

    int l=0;
    int r=0;

    REP(i,m){
        if(a[i] < x){
            l++;
        }else{
            r++;
        }
    }

    if(l<r)
        cout << l << endl;
    else
        cout << r << endl;
    return 0;
}

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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int H, W; cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++) {
    cin >> A.at(i);
  }

  auto func = [&](int z) {
    char v[W+1]; v[W] = 0;
    for (int j = 0; j < W; j++) v[j] = '.';
    cout << string(v) << "\n";
    for (int i = 1; i < H-1; i++) {
      if (i % 2 == z) {
	for (int j = 1; j < W-1; j++) v[j] = '#';
      }else {
	for (int j = 1; j < W-1; j++) v[j] = A.at(i).at(j);
      }
      if (z == 0) {
	v[0] = '#';
	v[W-1] = '.';
      }else {
	v[0] = '.';
	v[W-1] = '#';
      }
      cout << string(v) << "\n";
    }
    for (int j = 0; j < W; j++) v[j] = '.';
    cout << string(v) << "\n";
  };

  func(0);
  cout << "\n";
  func(1);

  return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<pair<int, int> > arr(n);
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        arr[i] = {temp, i + 1};
    }
    sort(arr.begin(), arr.end());
    for (auto it: arr) {
        cout << it.second << " ";
    }
    cout <<  '\n';
    return 0;
}


Measured memory_bytes: 1664
N=int(input())
F=[int(input().replace(' ',''),2)for _ in[0]*N]
P=[list(map(int,input().split()))for _ in[0]*N]
ans = -float('inf')
for i in range(1,2**10):
    sum = 0
    for k in range(N):
        sum += P[k][bin(F[k]&i).count('1')]
    if ans < sum:
        ans = sum
print(ans)

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

using namespace std;

long long a[100000];

int main()
{
	long long n, x,i,res=0,tmp=0;
	
	cin >> n >> x;
	for (i = 0; i < n; i++) 
		cin >> a[i];
	for (i = 0; i < n-1; i++) {
		tmp = x;
		if (a[i] == x) {
			res += a[i + 1];
			a[i + 1] = 0;
		}
		else if (a[i] > x) {
			res += a[i] - x;
			a[i] = x;
			res += a[i + 1];
			a[i + 1] = 0;
		}
		else {
			tmp -= a[i];
			if (a[i + 1] > tmp) {
				res += a[i + 1] - tmp;
				a[i + 1] = tmp;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define rnd(d) (ll)((double)d + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)x ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define ceildiv(a, b) ((ll)a / (ll)b + ((ll)a % (ll)b == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
  vi a(3);
  Loop(i, 3) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int cnt = 0;
  while (a[0] <= a[2] - 2) {
    a[0] += 2;
    cnt++;
  }
  while (a[1] <= a[2] - 2) {
    a[1] += 2;
    cnt++;
  }
  if (a[0] == a[2] - 1 && a[1] == a[2] - 1) {
    a[0]++;
    a[1]++;
    cnt++;
  }
  else if (a[0] == a[2] - 1) {
    a[0] += 2;
    a[1]++;
    a[2]++;
    cnt+=2;
  }
  else if (a[1] == a[2] - 1) {
    a[1] += 2;
    a[0]++;
    a[2]++;
    cnt+=2;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    Ans = []
    AnsNum = 0
    if N % 2 == 0:
        for i in range(1, N):
            for j in range(i + 1, N + 1):
                if i + j != N + 1:
                    Ans.append((i, j))
                    AnsNum += 1
    else:
        for i in range(1, N):
            for j in range(i + 1, N + 1):
                if i + j != N:
                    Ans.append((i, j))
                    AnsNum += 1
    print(AnsNum)
    for i in range(AnsNum):
        print(" ".join(map(str, Ans[i])))


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;cin>>n;
vector<long long> v(n);
for(int i=0;i<n;i++)cin>>v[i];
sort(v.begin(),v.end());
for(int i=0;i<n-1;i++){
    if(v[i]+v[i+1]<0){
        v[i]*=-1;
        v[i+1]*=-1;
        
    }
}
long long ans=0;
for(int i=0;i<n;i++)ans+=v[i];
cout<<ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

struct UnionFind {
    vector< int > data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};


int main() {
    int N, K, L;
    cin >> N >> K >> L;
    auto roadUf = UnionFind(N + 1), trainUf = UnionFind(N + 1);
    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        roadUf.unite(p, q);
    }
    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        trainUf.unite(r, s);
    }
    map<int, map<int, int>> ans;
    for (int i = 1; i <= N; i++) {
        int base = roadUf.find(i);
        ans[base][trainUf.find(i)]++;
    }
    for (int i = 1; i <= N; i++) {
        int base = roadUf.find(i);
        cout << ans[base][trainUf.find(i)] << (i == N ? '\n' : ' ');
    }
}

Measured memory_bytes: 27776
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
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; }


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

  string s;
  cin >> s;

  for(ll i = 0; i < sz(s); i++){
    if(s[i] == '?'){
      s[i] = 'D';
    }
  }

  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3784
# -*- coding: utf-8 -*-

import numpy as np
N=int(input())

Z=0
ans="No"
for i in range(N):
    D1,D2=map(int,input().split())
    if D1==D2:
        Z+=1
    else:
        Z=0
    if Z>=3: ans="Yes"

print(ans)


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




int32_t main()
{
    int test;
    cin>>test;

    if(test>=400 and test<600) cout<<8<<endl;
    else if(test>=600 and test<800) cout<<7<<endl;
     else if(test>=800 and test<1000) cout<<6<<endl;
      else if(test>=1000 and test<1200) cout<<5<<endl;
       else if(test>=1200 and test<1400) cout<<4<<endl;
        else if(test>=1400 and test<1600) cout<<3<<endl;
         else if(test>=1600 and test<1800) cout<<2<<endl;
          else if(test>=1800 and test<2000) cout<<1<<endl;


    return 0;
}


Measured memory_bytes: 3628
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int[] input = new int[1000000];

            int i;
            for ( i = 1; i < 1000000; i++)
            {
                input[i] = int.Parse(Console.ReadLine());
                if (input[i] == 0) break;
            }
            for (int t = 1; t < i; t++)
            {
                Console.WriteLine("Case "+t+": "+input[t]);
            }
        }
    }
}

Measured memory_bytes: 15280
def FindSumOfDigit(n):
    sum = 0
    while n > 0:
        n, rest = divmod(n, 10)
        sum += rest
    return sum


def main():
    N, A, B = map(int, input().split(' '))
    total = 0
    for i in range(1, N+1):
        sum = FindSumOfDigit(i)
        if A <= sum <= B:
            total += i
    print(total)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
long long int gcd(long long int a, long long int b)
{
	long long int r = a % b;
	while (r > 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main()
{
	long long int n, m;
	scanf("%lld %lld", &n, &m);
	long long int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		a[i] /= 2;
	}
	long long int l = a[0];
	for (i = 0; i < n; i++)
		l = l / gcd(l, a[i]) * a[i];
	for (i = 0; i < n; i++)
	{
		if (l / a[i] % 2 == 0)
		{
			printf("0\n");
			return 0;
		}
	}
	printf("%lld\n", (m / l + 1) / 2);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  string s;
  cin>>s;
  string t=s;
  bool flag=false;
  int n=s.size();
  for(int i=0; i<n; i++){
    for(int j=0; i+j<n; j++){
      s.erase(s.begin()+i,s.begin()+i+j);
      if(s=="keyence"){
        flag=true;
        break;
      }
      else s=t;
    }
  }
  if(flag)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

v even,odd;

struct edge{
    ll to,cost;
};

vector<vector<edge>> G;

void dfs(int now, int par, int d){
    if(d % 2 == 0)even.PB(now);
    else odd.PB(now);
    for(edge nxt :G[now]){
        if(nxt.to == par)continue;
        else dfs(nxt.to,now,d+nxt.cost);
    }
}

int main(){
    ll N;
    cin >> N;
    ll u,v,w;
    G.resize(N);

    rep(i,0,N-1){
        cin>>u>>v>>w;
        u--;v--;
        edge a = {v,w};
        edge b = {u,w};
        G[u].PB(a);
        G[v].PB(b);
    }

    dfs(0,-1,0);
    sort(even.begin(),even.end());
    sort(odd.begin(),odd.end());
    int ei = 0, oi = 0;
    rep(i,0,N){
        if(even[ei] == i){
            cout<<0<<endl;
            ei++;
            }
        else{
            cout<<1<<endl;
            oi++;
        }
    }
    return 0;
}

Measured memory_bytes: 10956
import java.util.Scanner;

public class Main {

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


	    int N=gi();
	    long[] T=new long[N];
	    long[] A=new long[N];

        for (int i=0; i<N; i++) {
        	T[i]=gl();
        	A[i]=gl();
        }

        long ht=1;
        long ha=1;
        for (int i=0; i<N; i++) {
        	long tn=ht%T[i] ==0 ? ht/T[i]: Math.floorDiv(ht, T[i])+1;
        	long ta=ha%A[i] ==0 ? ha/A[i]: Math.floorDiv(ha, A[i])+1;
            long hi=Math.max(tn, ta);
            ht=hi*T[i];
            ha=hi*A[i];
        }

        System.out.println(ht+ha);

//        if(ans==0) {
//
//		    System.out.println("Yes");
//        } else {
//        	System.out.println("No");
//
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38196
import sys
sys.setrecursionlimit(410000)

mod = 10**9+7

def dfs(v,pr,k):
  if len(G[v]) > k:
    return 0
  
  kc = k-2
  if pr == -1:
    kc = k-1  
  
  ret = 1
  
  for vi in G[v]:
    if vi == pr:
      continue
    ret *= kc
    ret %= mod
    kc -= 1
    
  for vi in G[v]:
    if vi == pr:
      continue
    ret *= dfs(vi,v,k)
    ret %= mod
  
  return ret


n,k = map(int,input().split())
G = [[] for i in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)      
  
print(dfs(0,-1,k) * k % mod )

Measured memory_bytes: 87340