akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

//Sieve sieve(1e6);
//auto f = sieve.factor(x);
// for(auto p:f){
//   p.firstは約数
//   p.secondは割れる回数
// }


int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  Sieve sieve(1e6);
  map<int,int> mp;
  bool flag = 1;
  rep(i,n){
    auto f = sieve.factor(a[i]);
    for(auto p:f){
      if(mp.count(p.first))flag=0;
      mp[p.first]++;
    }
  }
  if(flag)cout<<"pairwise coprime"<<endl;
  else{
    rep(i,n)a[0]=gcd(a[0],a[i]);
    if(a[0]==1)cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
  }
}

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

int main(){
    int n;
    cin >> n;
    ll a = 0;
    ll b = 0;
    ll ans = 1e18;
    vector<int> x(n);
    rep(i,n){
        cin >> x[i];
        a += x[i];
    }
    rep(i,n-1){
        b += x[i];
        ans = min(ans,abs(a-b*2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int N,K;

    scanf("%d %d", &N, &K);
    for( i=0; N>0; i++)
    {
        N /= K;
    }
    printf("%d\n", i);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


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

bool dfs(string str) {
    if (str == "mew") return true;

    for (int i = 1; i < str.size() - 3; i++) {
        string tmp = string(str.begin() + i, str.begin() + i + 3);
        if (tmp == "mew" && ((str[i - 1] == 'm' && str[i + 3] == 'e') || (str[i - 1] == 'e' && str[i + 3] == 'w'))) {
            return dfs(string(str.begin(), str.begin() + i) + string(str.begin() + i + 3, str.end()));
        }
    }

    return false;
}

int main () {
    string str;
    cin >> str;
    if (dfs(str)) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;

    return 0;
}

Measured memory_bytes: 1328
open String
open Str

let rec sort swapOccurred (result: int list) (list: int list) =
  match list with
  | [] ->
    if swapOccurred then sort false [] (List.rev result)
    else List.rev result
  | x :: y :: tail ->
    if x <= y then sort swapOccurred (x :: result) (y :: tail)
    else sort true (y :: result) (x :: tail)
  | x :: tail -> sort swapOccurred (x :: result) [];;

let rec string_of_list result list =
  match list with
  | [] -> result
  | x :: tail ->
    if String.length result == 0 then string_of_list (string_of_int x) tail
    else string_of_list (result ^ " " ^ string_of_int x) tail;;

read_line()
|> Str.split (Str.regexp " ")
|> List.map int_of_string
|> sort false []
|> string_of_list ""
|> print_endline



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

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

  switch (D)
  {
  case 22:
    cout << "Christmas Eve Eve Eve" << endl;
    break;
  case 23:
    cout << "Christmas Eve Eve" << endl;
    break;
  case 24:
    cout << "Christmas Eve" << endl;
    break;
  case 25:
    cout << "Christmas" << endl;
    break;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

class Main {
    int N;
    vector<int> C;
    void input() {
        cin >> N;
        C.emplace_back(0);
        REP(i, N) {
            int c;
            cin >> c;
            if (C.back() != c) { C.emplace_back(c); }
        }
        N = C.size();
    }
    void output() {
        vector<mint> dp(N);
        dp[0] = 1;
        vector<mint> sum(*max_element(C.begin(), C.end()) + 1);
        REP(i, N - 1) {
            dp[i + 1] = dp[i] + sum[C[i + 1]];
            sum[C[i + 1]] += dp[i];
        }
        cout << dp[N - 1] << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 7168
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string str; cin >> str;
	if(str == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}


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

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


Measured memory_bytes: 3612
import bisect


def nearest_pair(lst, x):
    left = None
    right = None
    idx = bisect.bisect_left(lst, x)
    if idx != 0:
        left = lst[idx - 1]
    if idx != len(lst):
        right = lst[idx]
    return left, right


def distance(l, r, x):
    if l is None:
        return abs(r - x)
    elif r is None:
        return abs(l - x)
    else:
        return min(abs(r - x), abs(l - x))


A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
Q = [int(input()) for _ in range(Q)]

for x in Q:
    s_l, s_r = nearest_pair(S, x)
    t_l, t_r = nearest_pair(T, x)

    result1 = float('inf')
    if s_l is not None:
        result1 = abs(x - s_l)
        l, r = nearest_pair(T, s_l)
        result1 += distance(l, r, s_l)

    result2 = float('inf')
    if s_r is not None:
        result2 = abs(x - s_r)
        l, r = nearest_pair(T, s_r)
        result2 += distance(l, r, s_r)

    result3 = float('inf')
    if t_l is not None:
        result3 = abs(x - t_l)
        l, r = nearest_pair(S, t_l)
        result3 += distance(l, r, t_l)

    result4 = float('inf')
    if t_r is not None:
        result4 = abs(x - t_r)
        l, r = nearest_pair(S, t_r)
        result4 += distance(l, r, t_r)

    print(min(result1, result2, result3, result4))


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

int W, H, S;
char M[55][55];
char MS[11][55][55];
int flr[55][55];

int dist[2][55][55][1<<10];

int sx, sy, gx, gy;

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

int main(){
  cin >> W >> H;
  rep(i, H) rep(j, W) {
    cin >> M[i][j];
    if(M[i][j] == '%') sx = j, sy = i;
    if(M[i][j] == '&') gx = j, gy = i;
    if(islower(M[i][j]) || M[i][j] == '_') flr[i][j] = 0;
    if(isupper(M[i][j]) || M[i][j] == '^') flr[i][j] = 1;
  }
  cin >> S;
  rep(i, S) rep(j, H) rep(k, W) cin >> MS[i][j][k];
  
  int ans = -1;

  memset(dist, -1, sizeof(dist));
  queue< tuple<int, int, int, int> > que;
  que.emplace(0, sy, sx, 0);
  dist[0][sy][sx][0] = 0;
  while(!que.empty()) {
    int f, y, x, bit;
    tie(f, y, x, bit) = que.front(); que.pop(); 
    if(y == gy && x == gx) {
      ans = dist[f][y][x][bit];
      break;
    }
    //cout << f << " " << y << " " << x << " " << endl;
    //rep(i, 10) cout << (int)((bit >> i) & 1);
    //cout << endl;
    rep(i, 4) {
      int nf = f, ny = y + dy[i], nx = x + dx[i], nbit = bit;
      if(0 <= ny && ny < H && 0 <= nx && nx < W &&
	 M[ny][nx] != '#' && dist[nf][ny][nx][nbit] == -1) {
	int t = flr[ny][nx];
	rep(k, S) if((nbit >> k) & 1) if(MS[k][ny][nx] == '*') t = !t;
	if(nf == t || M[ny][nx] == '|') {
	  que.emplace(nf, ny, nx, nbit);
	  dist[nf][ny][nx][nbit] = dist[f][y][x][bit] + 1;
	}
      }
    }
    if(M[y][x] == '|' && dist[!f][y][x][bit] == -1) {
      que.emplace(!f, y, x, bit);
      dist[!f][y][x][bit] = dist[f][y][x][bit] + 1;
    }
    int t = flr[y][x];
    rep(k, S) if((bit >> k) & 1) if(MS[k][y][x] == '*') t = !t;
    if(t == f && isalpha(M[y][x])) {
      int nf = f;
      int nbit = bit;
      int digit = 0;
      if(islower(M[y][x])) digit = M[y][x] - 'a';
      else digit = M[y][x] - 'A';      
      if((nbit >> digit) & 1) nbit = nbit - (1 << digit);
      else nbit = nbit + (1 << digit);
      if(MS[digit][y][x] == '*') nf = !nf;
      if(dist[nf][y][x][nbit] == -1) {
	que.emplace(nf, y, x, nbit);
	dist[nf][y][x][nbit] = dist[f][y][x][bit] + 1;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0 && A.at(i) % 3 != 0 && A.at(i) % 5 != 0){
      count ++;
      break;
    }
  }
  
  if (count > 0){
    cout << "DENIED" << endl;
  }
  else {
    cout << "APPROVED" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int a, b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

const int MOD = 1e9 + 7;

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

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

    sort(a.begin(), a.end());

    bool possible = true;
    if (n % 2 == 0) {
        for (int i = 0; i < n; i++) {
            if (a[i] != 2 * (i / 2) + 1) {
                possible = false;
                break;
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (a[i] != 2 * ((i + 1) / 2)) {
                possible = false;
                break;
            }
        }
    }

    if (!possible) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 1;
    for (int i = 0; i < n / 2; i++) {
        ans *= 2;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
// https://atcoder.jp/contests/abc160/tasks/abc160_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K, N;
    cin >> K >> N;
    vector<int> v(N);
    REP(i, N) { cin >> v[i]; }
    int sum = 0, maxv = 0, diff = 0;
    REP(i, N) {
        if (i == N - 1) {
            diff = K - v[N - 1] + v[0];
        } else {
            diff = v[i + 1] - v[i];
        }
        sum += diff;
        maxv = max(maxv, diff);
    }
    cout << sum - maxv << endl;

    return 0;
}


Measured memory_bytes: 1792
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    
    int max_val=0;
    string tmp;
    map<string, int> paper_dict;
    for(int i=0; i<N; i++)
    {
        cin >> tmp;
        paper_dict[tmp]++;
        max_val = paper_dict[tmp] > max_val ? paper_dict[tmp] : max_val;
    }

    vector<string> result;
    for(auto &x: paper_dict)
    {
        if(x.second == max_val) result.push_back(x.first);
    }

    sort(result.begin(), result.end());
    for(auto &x: result) cout << x << endl;
    return 0;
}

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

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

  vector<int> v(m,0);
  int k, a;
  for (int i = 0; i < n; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> a;
      v.at(a-1)++;
    }
  }

  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = m-1; i >= 0; i--) {
    if (v.at(i) == n) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    ll now=1;
    ll cnt=0;
    rep(i,n){
        ll a;cin>>a;
        if(a==now){
            now++;
        }else{
            cnt++;
        }
    }
    if(cnt==n)cout<<-1<<endl;
    else cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}

int main(){
  string s;
  cin>>s;
  string ans="keyence";
  bool t=false;
  
  if(s==ans){cout<<"YES"<<endl;return 0;}
  string tmp="";
  
  rep(i,s.size()){
    Rep(j,i,s.size()){
      if(s.substr(0,i)+s.substr(j)==ans){t=true;}
	}
  }
  


    
  if(t)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val br = System.`in`.bufferedReader()
    val (hp, attack) = br.readLine().split(" ").map { it.toInt() }

    val res = if (hp % attack == 0) {
        hp / attack
    } else {
        hp / attack + 1
    }
    print(res.toString())
}


Measured memory_bytes: 35528
import scala.collection.mutable
import scala.io.Source.stdin

/**
  * AOJ
  */
object Main {

  val alphabet = "abcdefghijklmnopqrstuvwxyz"

  def main(args: Array[String]): Unit = {

    val alphabetMap = mutable.Map.empty[Char, Int]
    setValues(alphabetMap)
    for(c <- alphabet){
      println(c + " : " + alphabetMap(c).toString)
    }
  }

  def setValues(alphabetMap:mutable.Map[Char,Int]):Unit = {
    for (c <- alphabet) {
      alphabetMap += c -> 0
    }
    for (line <- stdin.getLines()){
      if (line.length == 0) {
        return
      }
      for(c <- line.toLowerCase) {
        if (alphabetMap.contains(c)) {
          alphabetMap(c) += 1
        }
      }
    }
  }
}

Measured memory_bytes: 44264
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long LL;
const int MAX=1010;
int n,m;
LL a[MAX],b[MAX];
int main()
{
    int i,j,k,t,l;
    while(~scanf("%d",&n))
    {
        for(i=0; i<n; i++)
        {
            scanf("%lld%lld",&a[i],&b[i]);
        }
        LL ans=0;
        for(i=1; i<n; i++)
        {
            if(a[i]<a[i-1]||b[i]<b[i-1])
            {
                LL tmp=max(a[i-1]/a[i],b[i-1]/b[i]);
                if(a[i]*tmp>=a[i-1]&&b[i]*tmp>=b[i-1])
                {
                    a[i]*=tmp;
                    b[i]*=tmp;
                }
                else
                {
                    tmp++;
                    a[i]*=tmp;
                    b[i]*=tmp;
                }
            }
//            printf("%lld %lld\n",a[i],b[i]);
        }
        printf("%lld\n",a[n-1]+b[n-1]);

    }
    return 0;
}


Measured memory_bytes: 256
import math
from itertools import product

N = int(input())

values = sorted([9**i for i in range(1, math.ceil(math.log(100000, 9)))] +
                [6**i for i in range(math.ceil(math.log(100000, 6)))])
values = [x for x in values if x <= N]
dp = [N] * (N + 1)
dp[0] = 0
for i, v in product(range(1, N + 1), values):
    if i - v >= 0:
        dp[i] = min(dp[i - v] + 1, dp[i])
print(dp[N])


Measured memory_bytes: 7796
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

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

  if(n > 1){
    for(int i = n-1; i > 0; i--){
      if(h[i-1] - h[i] == 1) h[i-1]--;
      else if(h[i-1] - h[i] >= 2){
	cout << "No" << endl;
	return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
 
void read (int&a) {
	a = 0; char k = getchar(); int f = 1;
	for(;!isdigit(k); k = getchar()) if (k == '-') f = -1;
	for(; isdigit(k); k = getchar()) a = a * 10 + k - '0';
	a *= f;
}
 
const int N = 200000 + 5, mod = 1000000007;
int fpow (int base, int v) {
	int tot = 1;
	for(; v; v >>= 1, base = 1LL * base * base % mod) if (v & 1) tot = 1LL * tot * base % mod;
	return tot;
}
void add (int&a, int b) { a = (a + b) % mod; }
vector<int> G[N], D[N];
int n, sz[N], dep[N], st[N][20];
 
void dfs (int u, int f) {
	dep[u] = dep[f] + 1;
	D[ dep[u] ].push_back (u);
	st[u][0] = f;
	for (int i = 1; i <= 19; ++i) st[u][i] = st[ st[u][i - 1] ][i - 1];
	for (int i = 0; i < (signed)G[u].size(); ++i) if (G[u][i] != f) {
		dfs (G[u][i], u);
	}
}
 
int LCA (int u, int v) {
	if (dep[u] < dep[v]) swap (u, v);
	for (int i = 19; i >= 0 && dep[u] != dep[v]; --i)
		if (dep[u] - (1 << i) >= dep[v])
			u = st[u][i];
	for (int i = 19; i >= 0 && u != v; --i)
		if (st[u][i] != st[v][i])
			u = st[u][i], v = st[v][i];
	return u == v ? u : st[u][0];
}
 
int stk[N], top, dp[N], sum0[N], pow2[N];
 
int dp0(int x) { return (pow2[sz[x]] - dp[x] + mod) % mod; }
 
void upd (int x, int y) {
	sz[y] += sz[x];
	dp[y] = 1LL * dp[y] * fpow (sum0[y], mod - 2) % mod;
	sum0[y] = 1LL * sum0[y] * dp0(x) % mod;
	add (dp[y], 1LL * dp[x] * fpow(dp0(x), mod - 2) % mod);
	dp[y] = 1LL * dp[y] * sum0[y] % mod;
}

int fa[N], L[N], llca[N];
int Find (int u) { return u == fa[u] ? u : fa[u] = Find (fa[u]); }

void tarjan (int u, int f) {
	if (L[u]) llca[L[u]] = Find (L[u]);
	for (int i = 0; i < (signed)G[u].size(); ++i) if (G[u][i] != f) {
		tarjan (G[u][i], u);
		fa[Find (G[u][i])] = Find(u);
	}
}

int main ()
{
	read (n); n++;
	pow2[0] = 1; for(int i = 1; i <= n; ++i) pow2[i] = 1LL * pow2[i - 1] * 2 % mod;
	for (int i = 2; i <= n; ++i) {
		int x; read (x); ++x;
		G[x].push_back (i), G[i].push_back (x);
	}
	dfs (1, 0);

	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int i = 1; i <= n; ++i) for (int j = 0; j < (signed)D[i].size() - 1; ++j) L[D[i][j + 1]] = D[i][j];
	tarjan (1, 0);

	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		int nowdep = i;
		if (!D[i].size()) break;
		stk[ top = 1 ] = D[i][0], dp[D[i][0]] = 1, sum0[D[i][0]] = 1, sz[D[i][0]] = 1;
		for (int j = 1; j < (signed)D[i].size(); ++j) {
			int p = D[i][j], lca = llca[stk[top]];
 
			dp[p] = 1, sum0[p] = 1, sz[p] = 1;
 
			while(dep[ stk[top] ] > dep[lca]) {
				if (top == 1 || dep[stk[top - 1]] < dep[lca]) { dp[lca] = 0, sum0[lca] = 1, sz[lca] = 0; upd (stk[top], lca); }
				else upd(stk[top], stk[top - 1]);
				top--;
			}
			if (top == 0 || stk[top] != lca) stk[++top] = lca;
			stk[++top] = p;
		}
		for (int i = top; i > 1; --i) upd (stk[i], stk[i - 1]);
		int tans;
		add (ans, tans = 1LL * pow2[n - (signed)D[nowdep].size()] * dp[stk[1]] % mod);
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 58880
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program
{
    static int N;
    static int A;
    static int B;
    static int[] h;

    static void Main()
    {
        /* 入力の受け取り */
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = input[0];
        A = input[1];
        B = input[2];
        h = new int[N];
        for (int i = 0; i < N; i++) h[i] = int.Parse(Console.ReadLine());

        /* 二分探索で答えを探す */
        int l = 0;
        int r = h.Max() / B + 1;
        while (r - l > 1)
        {
            int m = (r + l) / 2;
            if (Judge(m)) r = m;
            else l = m;
        }
        Console.WriteLine(r);
    }

    /* k回の爆発で倒せるか */
    static bool Judge(int k)
    {
        int[] h_ = h.Select(s => Max(0, s - k * B)).ToArray();
        long c = 0;
        foreach (var hp in h_) c += hp / (A - B) + (hp % (A - B) == 0 ? 0 : 1);
        return c <= k;
    }
}

Measured memory_bytes: 34996
import java.util.*; 

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

		while(true){
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if(op.equals("+")){
			System.out.println(a + b);
			} else if(op.equals("-")){
				System.out.println(a - b);	
			} else if(op.equals("*")){
				System.out.println(a * b);
			} else if(op.equals("/")){
				System.out.println(a / b);
			} else {
				break;
			}
	    }
		}
	  }
	



Measured memory_bytes: 26336
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int N = 2010;
const int M = 10100;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, k;
char s[N][M];
int len[N];
int hs[M], pw[M];
const int base = 233;
 
char ans[M][M];
bool has[M];
inline int cmp(char * s0, char * s1, int len) {
	for(int i = 0;i < len;++i, ++ s0, ++ s1) if(*s0 != *s1) return *s0 < *s1 ? 1 : -1;
	return 0;
}
int ok[N][M];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	ok[0][0] = 1;
	*pw = 1;
	for(int i = 1;i < M;++i) pw[i] = (ll) pw[i - 1] * base % mod;
	rep(i, 1, n) {
		cin >> s[i];
		len[i] = strlen(s[i]);
		rep(j, 0, k) {
			ok[i][j] = ok[i - 1][j] || j >= len[i] && ok[i - 1][j - len[i]];
		}
	}
	has[0] = 1;
	for(int i = n;i >= 1;--i) {
		int val = 0;
		for(int j = 0;j < len[i];++j) val = (val + (ll) s[i][j] * pw[j]) % mod;
		for(int j = k;j >= len[i];--j) if(ok[i - 1][k - j]) {
			if(has[j - len[i]]) {
				int o = ((ll) hs[j - len[i]] * pw[len[i]] + val) % mod;
				int flag = 0;
				if(!has[j]) {
					flag = 1;
				} else if(o != hs[j]) {
					int c = cmp(ans[j], s[i], len[i]);
					if(c <= 0) flag = c || cmp(ans[j] + len[i], ans[j - len[i]], j - len[i]) == -1;
				}
				if(flag) {
					hs[j] = o;
					has[j] = 1;
					memcpy(ans[j], s[i], len[i]);
					memcpy(ans[j] + len[i], ans[j - len[i]], j - len[i]);
				}
			}
		}
	}
	cout << ans[k] << '\n';
}


Measured memory_bytes: 198912
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, a, maxv = 0, idx = 0;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    cin >> a;
    if(abs(a) > abs(maxv)){
      maxv = a;
      idx = i;
    }
  }
  cout << 2*n-1 << endl;
  FOR(i, 0, n) cout << idx+1 << " " << i+1 << endl;
  if(maxv > 0){
    FOR(i, 1, n) cout << i << " " << i+1 << endl;
  }else{
    FORR(i, n, 2) cout << i << " " << i-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b;
  if(b/10==0) c=a*10+b;
  else if(b/100==0) c=a*100+b;
  else c=a*1000+b;
  for(int i=0;i<=1000;i++){
  	if(i*i==c){
    	cout<<"Yes"<<endl;
      break;
    }
    if(i==1000) cout<<"No"<<endl;
  }
}	


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void EducationalDP_E()
{
	int N, W;
	cin >> N >> W;
	vector<int> w(N);
	vector<int> v(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> w[i] >> v[i];
	}

	int M = N * 1000 + 1;
	vector<vector<ll> > weight(N, vector<ll>(M, 10000000000000));
	weight[0][0] = 0;
	weight[0][v[0]] = w[0];
	for (int i = 1; i < N; ++i)
	{
		for (int j = 0; j < M; ++j)
		{
			weight[i][j] = min(weight[i - 1][j], (j - v[i] >= 0 ? weight[i - 1][j - v[i]] + w[i] : 10000000000000));
		}
	}

	for (int j = M-1; j > -1; --j)
	{
		if (weight[N - 1][j] <= W)
		{
			cout << j << endl;
			return;
		}
	}
}

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

Measured memory_bytes: 79488
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;


int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >>y;
	int a_num = x;
	int b_num = y;
	int c_num = 0;
	while (true) {
		if (a_num * a + b_num * b + c_num * c > max(a_num - 1, 0) * a + max(b_num - 1, 0) * b + (c_num + 2) * c) {
			if (a_num > 0) a_num--;
			if (b_num > 0) b_num--;
			c_num+=2;
		}
		else {
			break;
		}
	}
	cout << a_num * a + b_num * b + c_num * c << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
if (n - 2) * (n - 1) // 2 >= k:
    m = (n - 1) * n // 2 - k
    print(m)
    cnt = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            print(i, j)
            cnt += 1
            if cnt == m:
                exit()
else:
    print(-1)

Measured memory_bytes: 9304
import java.util.*;
import java.math.*;

public class Main{

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[][] a = new int[m][2];
    int ma = 0;
    for(int i = 0; i < m; ++i) {
      a[i][0] = sc.nextInt();
      if(a[i][0] > ma) ma = a[i][0];
      a[i][1] = sc.nextInt();
    }
    n = n + ma;
    int[] dp = new int[n + 1];
    for(int i = 0; i < n + 1; ++i) {
      dp[i] = Integer.MAX_VALUE;
    }
    for(int i = 0; i < m; ++i) {
      for(int j = 0; j <= n; ++j) {
        if(j < a[i][0]) {
          dp[j] = Math.min(a[i][1], dp[j]);
        } else {
          dp[j] = Math.min(dp[j], dp[j - a[i][0]] + a[i][1]); 
        }
      }
    }
    int res = Integer.MAX_VALUE;
    for(int i = n - ma - 1; i < n; ++i) {
      if(dp[i] < res) res = dp[i];
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 25648
n = int(input())
p = list(map(int,input().split()))

a = [0] * n
b = [0] * n
c = []

for i in range(n):
    a[i] = 30000*(i+1)+5
    b[i] = 30000*(n-i-1)+5

for i in range(n):
    k = p[i]
    b[k-1] += i

res = ''
ans = ''
for i in range(n):
    if i == n-1:
        res += str(a[i])
        ans += str(b[i])
    else:
        res += str(a[i]) + ' '
        ans += str(b[i]) + ' '

print(res)
print(ans)

Measured memory_bytes: 6636
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(long i=0;i<(n);i++)
long gcd(long a,long b){
    return b?gcd(b,a%b):a;
}
long pattern(long n,vector<pair<long,long>> x,long p,long q){
    long ansij=n;
    For(i,n){
        for(long j=i+1;j<n;j++){
            if(p==x.at(j).first-x.at(i).first&&q==x.at(j).second-x.at(i).second){
                ansij--;
            }
        }
    }
    return ansij;
}
long n,ans=50;
int main(){
    cin>>n;
    vector<pair<long,long>> x(n);
    For(i,n){
        cin>>x.at(i).first>>x.at(i).second;
    }
    sort(x.begin(),x.end());
    For(i,n){
        for(long j=i+1;j<n;j++){
            long p=x.at(j).first-x.at(i).first;
            long q=x.at(j).second-x.at(i).second;
            ans=min(ans,pattern(n,x,p,q));
        }
    }
    if(n==1){
        ans=1;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc090.contest.atcoder.jp/tasks/arc090_a>
問題文============================================================
 2×N のマス目があります。上から i 行目、左から j 列目 (1≤i≤2, 1≤j≤N) のマスをマス (i,j) と表すことにします。
 
 あなたははじめ、左上のマス (1,1) にいます。
 あなたは、右方向または下方向への移動を繰り返し、右下のマス (2,N) に移動しようとしています。
 
 マス (i,j) には Ai,j 個のアメが置かれています。
 あなたは移動中に通ったマスに置いてあるアメをすべて回収します。
 左上および右下のマスにもアメが置かれており、あなたはこれらのマスに置かれているアメも回収します。
 
 移動方法をうまく選んだとき、最大で何個のアメを回収できるでしょうか。
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<vector<ll>> A(2,vector<ll>(N));
    for(int i = 0; i < 2;i++)for(int j = 0; j < N;j++) cin >> A[i][j];
    vector<vector<ll>> dp(3,vector<ll>(N+1,0));
    for(int i = 0; i < 2;i++){
        for(int j = 0; j < N;j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]+A[i][j]);
            dp[i][j+1] = max(dp[i][j+1],dp[i][j]+A[i][j]);
        }
    }
    cout << dp[1][N-1] + A[1][N-1] << endl;
	return 0;
}


Measured memory_bytes: 256
a= int(input())
b= int(input())
c= int(input())
d= int(input())
e= int(input())
k= int(input())
if e-a>k or b-a>k or e-b>k or c-a>k or c-e>k or d-a>k or d-e>k:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 12;
int N, D;
int X[Max][Max];

double dist(int i, int j){
    double dist2 = 0;
    rep(k, D) {
        dist2 += pow(X[i][k] - X[j][k], 2);
    }
    return sqrt(dist2);
}

bool double_is_int(double trouble) {
   double absolute = abs( trouble );
   return absolute == floor(absolute);
}

int main(int argc, const char * argv[]) {
    cin >> N >> D;
    rep(i, N) {
        inputArray(X[i], D);
    }

    int ans = 0;
    rep(i, N) {
        repd(j, i+1, N) {
            if (double_is_int(dist(i, j))) {
                ans += 1;
            }
        }
    }

    output(ans);

    return 0;
}

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

using namespace std;

int main() {
    int N,M; cin >> N >> M;

    vector<int> gate(N+1);
    for(int i=0;i<M;i++) {
        int L,R;
        cin >> L >> R;
        L--;
        R--;
        gate[L]++;
        gate[R+1]--;
    }

    int cnt = (gate[0] == M) ? 1 : 0;
    for(int i=1;i<N;i++) {
        gate[i] += gate[i-1];
        if(gate[i] == M) cnt++;
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define file "gemo"
using namespace std;
typedef long long ll;
const int mod=1000000007;
int read(){
	char c=getchar();
	int x=0;
	while(c<'0' || c>'9')
		c=getchar();
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x;
}
int a[15][15];
ll dp[1<<15],pw[2333];
int to[16][1<<15],qwq[1<<15];
int main(){
	//freopen(file".in","r",stdin);
	//freopen(file".out","w",stdout);
	int n=read(),m=read();
	pw[0]=1;
	for(int i=1;i<=m;i++)
		pw[i]=pw[i-1]*2%mod;
	for(int i=1;i<=m;i++){
		int u=read()-1,v=read()-1;
		a[u][v]=1;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<(1<<n);j++){
			if (j>>i&1)
				continue;
			for(int k=0;k<n;k++)
				if (j>>k&1)
					to[i][j]+=a[i][k];
			//fprintf(stderr,"to[%d][%d]=%d\n",i,j,to[i][j]);
		}
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<n;j++)
			if (!(i>>j&1))
				qwq[i]+=to[j][i];
	dp[0]=1;
	for(int i=0;i<(1<<n);i++){
		int s=(1<<n)-1-i;
		if ((i&1)!=(i>>1&1))
			continue;
		//fprintf(stderr,"i=%d\n",i);
		if (!dp[i])
			continue;
		for(int j=s;j;j=(j-1)&s){ //i->j ~to->j
			if ((j&1)!=(j>>1&1))
				continue;
			ll ans=1;
			int sm=0;
			int v=i|j;
			for(int o=0;o<n;o++)
				if (!(v>>o&1))
					ans=ans*((1<<to[o][j])-1)%mod,sm+=to[o][j];
			ans=ans*pw[qwq[j]-sm]%mod;
			if (!ans)
				continue;
			dp[v]=(dp[v]+dp[i]*ans)%mod;
		}
	}
	ll ans=dp[(1<<n)-1];
	printf("%lld",((pw[m]-ans)%mod+mod)%mod);
	//fprintf(stderr,"%.5f",(double)clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = (int)1e4 + 10;
// make sure N size is correctttt!!!!!!!!!


int n, a[N], m;
vector<int> f;
int dp[15][N];

int solve(int idx, int coins){
   if(coins < 0)
      return -inf;

   if(idx == m){
      return dp[idx][coins] = ((coins == 0) ? 0 : -inf);
   }

   int &ans = dp[idx][coins];
   if(~ans)
      return ans;

   ans = -inf;
   if(f[a[idx]] <= coins){
      smax(ans, 1 + solve(idx, coins-f[a[idx]]));
   }

   smax(ans, solve(idx+1, coins));
   return ans;
}

void trace(int idx, int coins){
   if(idx == m){
      assert(coins == 0);
      exit(0);
   }

   int arr[] = {dp[idx][coins], dp[idx][coins-f[a[idx]]], dp[idx+1][coins]};
   if(f[a[idx]] <= coins){
      if(arr[0] == 1 + arr[1]){
         cout << a[idx];
         return trace(idx, coins-f[a[idx]]);
      }
   }

   assert(arr[0] == arr[2]);
   return trace(idx+1, coins);
}

int32_t main(){_

   cin>>n>>m;
   f = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

   memset(dp, -1, sizeof dp);
   for (int i = 0; i < m; ++i)
      cin>>a[i];

   sort(a, a+m);
   reverse(a, a+m);
   int faltu = solve(0, n);
   trace(0, n);

   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)

int main(void)
{
	string a, b;
	cin >> a >> b;
	if (a.size() == b.size()) {
		for (int i = 0; i < a.size(); i++) {
			cout << a[i] << b[i];
		}
	}
	else {
		int i = 0;
		for (i; i < b.size(); i++) {
			cout << a[i] << b[i];
		}
		cout << a[i];
	}
	cout << endl;
	}

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

binary_tree = [{"parent": -1, "sibling": -1} for _ in range(N)]
for _ in range(N):
    node_input = input()
    id, left, right = map(int, node_input.split())

    binary_tree[id]["left"] = left
    binary_tree[id]["right"] = right

    degree = 0
    if left != -1:
        degree += 1
        binary_tree[left]["parent"] = id
        binary_tree[left]["sibling"] = right
    if right != -1:
        degree += 1
        binary_tree[right]["parent"] = id
        binary_tree[right]["sibling"] = left
    binary_tree[id]["degree"] = degree


def measure_depth_and_height(id, depth):
    H[id] = max(H[id], depth)

    parent_id = binary_tree[id]["parent"]
    if parent_id == -1:
        return depth

    return measure_depth_and_height(parent_id, depth+1)

D = [0 for i in range(N)]
H = [0 for i in range(N)]
for id in range(N):
    depth = measure_depth_and_height(id, 0)
    D[id] = depth


def get_type(node):
    if node["parent"] == -1:
        return "root"
    if node["degree"] == 0:
        return "leaf"
    return "internal node"

for id in range(N):
    node = binary_tree[id]
    parent_id = node["parent"]
    sibling_id = node["sibling"]
    degree = node["degree"]
    node_type = get_type(node)
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(id, parent_id, sibling_id, degree, D[id], H[id], node_type))


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
	ll a, b, n;
	cin >> n >> a >> b;
	ll x = (ll)floor((double)n / (double)(a + b)) * a;
	ll y =min(n % (a+b),a);
	cout <<x + y << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n;
string s;
int dp[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>s;
	dp[0]=1;
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1])
			dp[i]=dp[i-1]+1;
		else
			dp[i]=dp[i-1];
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 848
n,m,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(q)]
ans=0

def dfs(x):
    global ans
    if len(x) == n+1:
        t=0
        for a,b,c,d in l:
            if x[b]-x[a] == c:
                t+=d
        ans=max(ans,t)        
    else:    
        x.append(x[-1])
        while(x[-1] <= m):
            dfs(x.copy())
            x[-1] += 1
 
    
dfs([1])
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int n,c;
vi v;

signed main(){
    FASTER;
    cin>>n>>c;
    v=vi(n);
    for(int &i:v)cin>>i;
    int ans=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i+j>c || i+j>n)continue;
            vi hand;
            int cst=c,sum=0;
            for(int k=0;k<i;k++)hand.push_back(v[k]),cst--,sum+=hand.back();
            for(int k=0;k<j;k++)hand.push_back(v[n-k-1]),cst--,sum+=hand.back();
            sort(all(hand));
            
            for(int i:hand){
                if(i>=0)break;
                if(cst){
                    cst--;
                    sum-=i;
                }
            }
            ans=max(ans,sum);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3668