akhauriyash/Code-Regression huggingface dataset:
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of jonathanirvings' template v3.0.3 (BETA)

int r,c;
string data[505];
string A[505],B[505];

int main()
{
  scanf("%d %d",&r,&c);
  REP(i,r)
  {
    REP(j,c)
    {
      A[i] += '.';
      B[i] += '.';
    }
  }
  REP(i,r)
  {
    data[i] = GetString();
    REP(j,c)
    {
      if (j == 0) A[i][j] = '#';
      if (j == c - 1) B[i][j] = '#';
      if (i % 2 == 0 && j < c - 1) A[i][j] = '#';
      else if (i % 2 == 1 && j > 0) B[i][j] = '#';
      if (data[i][j] == '#')
      {
        A[i][j] = B[i][j] = '#';
      }
    }
  }
  REP(i,r)
  {
    REP(j,c) printf("%c",A[i][j]);
    puts("");
  }
  puts("");
  REP(i,r)
  {
    REP(j,c) printf("%c",B[i][j]);
    puts("");
  }
  return 0;
}











Measured memory_bytes: 1664
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	
	while (true) {
		int n, m, a; cin >> n >> m >> a;

		if (n == 0 && m == 0 && a == 0)return 0;

		vector<vector<int>> tb(1001, vector<int>(101,0));

		for (int i = 0; i < m; i++) {
			int h, from, to; cin >> h >> from >> to;

			tb[h][from] = to;
			tb[h][to] = from;

		}

		int ans = a;

		for (int i = 1000; i >= 0; i--) {
			if (tb[i][ans] != 0)ans = tb[i][ans];
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> r(n);
  for(long long int i=0; i<n; i++){
    cin>>r.at(i);
  }
  long long int maxv=-9999999999;
  long long int minv=r.at(0);
  for(long long int i=1; i<n; i++){
    minv=min(minv,r.at(i-1));
    maxv=max(maxv,r.at(i)-minv);
  }
  cout<<maxv<<endl;
  return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int n;
int fa[N], deg[N], f[N];
int head[N], nex[N], to[N], te;

vector <int> val[N];

inline void cmax(int &u, int v) { if(u < v) u = v; }
inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}
inline void ade(int u, int v) {
	nex[++te] = head[u], head[u] = te;
	to[te] = v;
}

void dfs(int u) {
	for(int i = head[u]; i; i = nex[i]) {
		int v = to[i];
		dfs(v);
		val[u].push_back(f[v]);
	}
	sort(val[u].begin(), val[u].end());
	for(int i = deg[u] - 1; ~i; --i)
		cmax(f[u], val[u][i] + deg[u] - i);
	return;
}

int main() {
	read(n);
	for(int i = 2; i <= n; ++i) {
		read(fa[i]), ade(fa[i], i);
		++deg[fa[i]];
	}
	dfs(1);
	cout << f[1] << endl;
	return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
#define MAX 40
 
struct node
{
    int p;
    int l, r;
} typedef node;
 
int P[MAX];
int I[MAX];
node N[MAX];
 
int CreateTree(int parent, int n, int head_P, int head_I){
    int root;
    int root_P, root_I;
    int n_l, n_r;
     
    root = P[head_P];
     
    if(n == 0) return -1;
 
    root_P = head_P;
    root_I = Position(n, head_I, I, root);
     
    n_l = root_I - head_I;
    n_r = n - n_l - 1;
     
    N[root].p = parent;
    N[root].l = CreateTree(root, n_l, root_P + 1, head_I);
    N[root].r = CreateTree(root, n_r, root_P + 1 + n_l, root_I + 1);
     
    return root;
}
 
int Position(int n, int h, int A[], int s){
    int i;
     
    for(i = h; i < h + n; i++){
        if(A[i] == s) return i;
    }
    return -1;
}
 
void Postorder(int id, int n){
    static int count = 0;
     
    if(id==-1) return;
     
    Postorder(N[id].l, n);
    Postorder(N[id].r, n);
     
    count++;
    if(count != n) printf("%d ", id);
    else printf("%d\n", id);
}

int main(){
    int i;
    int n;
    int root;
     
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &P[i]);
    }
    for(i = 0; i < n; i++){
        scanf("%d", &I[i]);
    }
     
    root = CreateTree(-1, n, 0, 0);
     
    Postorder(root, n);
     
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n+1], b[n];
    for (int i=0; i<n+1; i++) {
        cin >> a[i];
    }
    for (int i=0; i<n; i++) {
        cin >> b[i];
    }
    long long sum = 0;
    //c[i],d[i]はi番目の勇者がそれぞれi番目、i+1番目の街で倒すモンスターの数
    //i番目の勇者はi番目の街のモンスターを優先して倒すことにする
    int c[n], d[n];            
    c[0] = min(a[0], b[0]);     
    d[0] = min(b[0]-c[0], a[1]);
    sum += c[0] + d[0];
    for (int i=1; i<n; i++) {
        c[i] = min(a[i]-d[i-1], b[i]);
        d[i] = min(b[i]-c[i], a[i+1]);
        sum += c[i] + d[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
    int len;
    scanf("%d", &len);

    int array[100];
    for (int i=0;i<len;i++) {
        scanf("%d", &array[i]);
    }

    for(int i=0;i<len;i++) {
        if (i != len-1) {
            printf("%d ", array[i]);
        } else {
            printf("%d\n", array[i]);
        }
    }

    int target;
    for (int i=1;i<len;i++) {

        target = array[i];
        int j = i - 1;
        while (j>=0 & array[j] > target) {
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = target;
        
        for(int i=0;i<len;i++) {
            if (i != len-1) {
                printf("%d ", array[i]);
            } else {
                printf("%d\n", array[i]);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2752
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   


    ll k;
    string s;
    cin >> k >> s;

    if(s.length() <= k) {
        cout << s;
    }
    else {
        cout << s.substr(0 , k) << "...";
    }
    
    return 0;
}

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

int main()
{
    string S;
    cin >> S;
    
    bool ans = false;
    if (S[0] == S[1]) {
        ans = true;
    }
    if (S[1] == S[2]) {
        ans = true;
    }
    if (S[2] == S[3]) {
        ans = true;
    }
    
    if (ans) {
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}

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

using namespace std;

struct comp {
  double re, im;

  comp(double x = 0, double y = 0) : re(x), im(y) {}

  comp operator+(const comp& a) { return comp(re + a.re, im + a.im); }
  comp operator-(const comp& a) { return comp(re - a.re, im - a.im); }
  comp operator*(const comp& a) { return comp(re * a.re - im * a.im, re * a.im + im * a.re); }
};

const double pi = acos(-1);

void fft(vector<comp>& x) {
  int n = x.size();
  for (int i = 1, k = 0; i < n; ++i) {
    for (int bit = n >> 1; (k ^= bit) < bit; bit >>= 1) {}
    if (i < k) {
      swap(x[i], x[k]);
    }
  }
  for (int k = 1; k < n; k <<= 1) {
    comp wlen(cos(pi / k), sin(pi / k));
    for (int i = 0; i < n; i += (k << 1)) {
      comp w(1);
      for (int j = 0; j < k; ++j) {
        comp tmp = w * x[i + j + k];
        x[i + j + k] = x[i + j] - tmp;
        x[i + j] = x[i + j] + tmp;
        w = w * wlen;
      }
    }
  }
}

template<class T> vector<T> mul(vector<T>& a, vector<T>& b) {
  int n = max(a.size(), b.size());
  int lg = 31 - __builtin_clz(n);
  n = 1 << (lg + 1 + (n != (1 << lg)));
  vector<comp> fa(n), fb(n);
  for (int i = 0; i < a.size(); ++i) {
    fa[i] = a[i];
  } for (int i = 0; i < b.size(); ++i) {
    fb[i] = b[i];
  }
  fft(fa);
  if (a == b) {
    fb = fa;
  } else {
    fft(fb);
  }
  for (int i = 0; i < n; ++i) {
    fa[i] = fa[i] * fb[i];
  }
  fft(fa);
  reverse(fa.begin() + 1, fa.end());
  vector<T> c(n);
  for (int i = 0; i < n; ++i) {
    c[i] = (T)(fa[i].re / n + (fa[i].re > 0 ? 0.5 : -0.5));
  }
  return c;
}

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

  int n;
  long long m;
  cin >> n >> m;
  vector<long long> cnt((int)1e6 + 1);
  while (n--) {
    int x;
    cin >> x;
    ++cnt[x];
  }
  cnt = mul(cnt, cnt);
  long long ans = 0;
  for (int i = cnt.size() - 1; m > 0 and i >= 0; --i) {
    ans += i * min(cnt[i], m);
    m -= min(cnt[i], m);
  }
  cout << ans;

  return 0;
}

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

int main()
{
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <tuple>
#include <queue>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x = Tp()) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

constexpr size_t di[] = {-1_zu, 0, 1, 0};
constexpr size_t dj[] = {0, -1_zu, 0, 1};

int f(std::vector<std::string> const& s, size_t si, size_t sj) {
  size_t h = s.size();
  size_t w = s[0].length();
  auto dp = make_vector<int>({h, w}, 1e9);
  using zahyo = std::pair<size_t, size_t>;
  std::queue<zahyo> q;
  q.emplace(si, sj);
  dp[si][sj] = 0;
  while (!q.empty()) {
    size_t i, j;
    std::tie(i, j) = q.front();
    q.pop();
    for (size_t k = 0; k < 4; ++k) {
      size_t ni = i + di[k];
      size_t nj = j + dj[k];
      if (!(ni < h && nj < w)) continue;
      if (s[ni][nj] == '#') continue;
      if (dp[ni][nj] > dp[i][j] + 1) {
        dp[ni][nj] = dp[i][j] + 1;
        q.emplace(ni, nj);
      }
    }
  }

  int res = 0;
  for (size_t i = 0; i < h; ++i)
    for (size_t j = 0; j < w; ++j)
      if (s[i][j] == '.')
        res = std::max(res, dp[i][j]);

  return res;
}

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

  std::vector<std::string> s(h);
  for (size_t i = 0; i < h; ++i) {
    char buf[32];
    scanf("%s", buf);
    s[i] = buf;
  }

  int res = 0;
  for (size_t i = 0; i < h; ++i)
    for (size_t j = 0; j < w; ++j)
      if (s[i][j] == '.')
        res = std::max(res, f(s, i, j));

  printf("%d\n", res);
}


Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, min(n - 1, int(x / 3))):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if (i + j + k) == x:
                    cnt += 1
    print(cnt)

Measured memory_bytes: 7564
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
#warning "// FOR has been inclusive now!!!!"
ll m, d;
int main()
{
	FAST
	cin>>m>>d;
	ll ans=0;
	FOR(i,1,m){
		FOR(j,1,d){
			if(10<=j&&j<=99&&j/10>=2&&j%10>=2&&(j/10)*(j%10)==i){
				++ans;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 2000000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back
#define lc (id * 2)
#define rc (id * 2 + 1)
typedef long long ll;
const ll INF = (1e8);
const ll mod = (1e9 + 7);
char s[maxn],t[maxn];
int main(){
    scanf("%s%s",s + 1,t + 1);
    int n = strlen(s + 1);
    int ans = 0;
    for(int i = 1;i <= n;i++){
        ans += (s[i] != t[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4256
use std::cmp::{min, Ordering};
use std::collections::{BinaryHeap, HashSet};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[derive(Debug, PartialEq, Eq)]
struct Query {
    cost: u64,
    num: u64,
}

impl Ord for Query {
    fn cmp(&self, other: &Self) -> Ordering {
        self.cost.cmp(&other.cost).reverse()
    }
}

impl PartialOrd for Query {
    fn partial_cmp(&self, other: &Query) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn solve(v: Vec<u64>) {
    let (n, a, b, c, d) = (v[0], v[1], v[2], v[3], v[4]);
    let threshold = (1e+20 as u64) / d;

    let mut queue = BinaryHeap::new();
    let mut seens = HashSet::new();

    queue.push(Query { cost: 0, num: n });

    while !queue.is_empty() {
        let q: Query = queue.pop().unwrap();

        if q.num == 0 {
            println!("{}", q.cost);
            return;
        }

        if seens.contains(&q.num) {
            continue;
        }

        seens.insert(q.num);

        if q.num < threshold {
            queue.push(Query {
                num: 0,
                cost: q.cost + q.num * d,
            });
        }

        for [k, v] in [[2, a], [3, b], [5, c]].iter() {
            if q.num < *k {
                break;
            }

            let m = q.num % *k;
            let n = q.num / *k;

            if m == 0 {
                queue.push(Query {
                    num: n,
                    cost: q.cost + *v,
                });
            } else {
                queue.push(Query {
                    num: n,
                    cost: q.cost + *v + (d * m),
                });
                queue.push(Query {
                    num: n + 1,
                    cost: q.cost + *v + (d * (*k - m)),
                });
            }
        }
    }

    panic!("aaa");
}

fn main() {
    input! { n: u64, vs: [[u64; 5]; n] }

    for v in vs {
        solve(v);
    }
}


Measured memory_bytes: 2624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  char S[15] = {};
  int num[15] = {};
  int l;//文字列sの長さ
  int X;
  int min;//abs(X - 753)の最小値
  int i;//カウンタ

  scanf("%s", S);
  l = strlen(S);
  //文字列Sを数値に変換
  for(i = 0; i < l; i++){
    num[i] = S[i] - '0';
  }

  X = num[0]*100 + num[1]*10 + num[2];
  min = abs(X - 753);
  for(i = 1; i < l-2; i++){
    X = num[i]*100 + num[i+1]*10 + num[i+2];
    if(abs(X - 753) < min){
      min = abs(X - 753);
    }
  }

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


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <unordered_map>




int main(){
    long long i, n, x, m, buf, before;
    long long result;
    std::vector<long long> cumulative_sum;
    std::cin >> n >> x >> m;
    std::unordered_map<long long, long long> mp;
    cumulative_sum.push_back(0);
    buf = 0;
    for(i=1; i<=n; i++){
        before = mp[x];
        mp[x] = i;
        buf = (buf + x);
        cumulative_sum.push_back(buf);
        // std::cout << buf << '\n';
        if(before!=0){
            long long rest_len = n - i;
            long long roop_len = i - before;
            long long roop_sum = cumulative_sum[i] - cumulative_sum[before];
            long long roop_rest = cumulative_sum[before + (rest_len % roop_len)] - cumulative_sum[before];
            result = cumulative_sum[i];
            result += roop_sum * (rest_len/roop_len);
            result += roop_rest;
            break;
        }
        x = (x * x) % m;
    }
    if(i>n){
        // std::cout << "last element" << '\n';
        // std::cout << cumulative_sum.size() << '\n';
        result = cumulative_sum.back();
    }
    std::cout << result << '\n';
    return 0;

}


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int n, x;

//       4
//     3 4 5
//   2 3 4 5 6
// 1 2 3 4 5 6 7


//       2
//     5 2 2
//   5 5 2 2 3 
// 4 5 6 1 2 3 7

//       2
//     4 2 2
//   5 4 2 2 3 
// 5 4 6 1 2 3 7

//       6
//     5 6 6
//   2 5 6 6 4
// 1 2 5 6 7 4 3

// 同じのが真ん中らへんに２つ連続で出たら、絶対それ。

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n >> x;
  int N = n * 2 - 1;
  if(x == 1 || x == N) {
    cout << "No" << '\n';
  } else {
    vector<int> ans(N + 1);
    ans[N / 2] = x;
    ans[N / 2 - 1] = x - 1;
    ans[N / 2 + 1] = x + 1;
    ans[N / 2 + 2] = x - 2;

    queue<int> q;
    for(int i = 1; i <= N; ++i) {
      if(i == x || i == x-1 || i == x+1 || i == x-2) continue;
      q.push(i);
    }
    for(int i = 0; i < N; ++i) {
      if(ans[i] == 0) {
        ans[i] = q.front();
        q.pop();
      }
    }

    cout << "Yes" << '\n';
    for(int i = 0; i < ans.size()-1; ++i) cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int prime[1010];
vector<pair<int,int> >par[1010];
int pr2[1010];
int ans;
signed main()
{
	int n;
	cin>>n;
	ans=1;
	for (int i=2;i<1008;i++)
		if (!prime[i])
			for (int j=i;j<=1008;j+=i){
				prime[j]=1;
				int d=0,h=j;
				while (h%i==0){
					h/=i;
					d++;
				}
				par[j].pb(mp(i,d));
				//cout<<j<<' '<<i<<' '<<d<<endl;
			}
	for (int i=2;i<=n;i++){
		for (int j=0;j<sz(par[i]);j++){
			pr2[par[i][j].first]+=par[i][j].second;
			//cout<<par[i][j].first<<' '<<par[i][j].second<<' '<<i<<endl;
		}
	} 
	for (int i=0;i<=n;i++){
		ans=(ans*(pr2[i]+1))%1000000007;
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
    ll N;
    int K;
    cin >> N >> K;
    vector<int> h(N);
    for(ll i = 0; i < N; i++){
        cin >> h[i];
    }

    ll cost[N+1];
    for(int i = 0; i < N; i++){
        cost[i] = __LONG_LONG_MAX__;
    }

    cost[0] = 0;
    for(ll i = 0; i < N-1; i++){
        for(int j = 1; j <= K; j++){
            if(i+j > N-1) break;
            cost[i+j] = min(cost[i+j],cost[i]+abs(h[i+j]-h[i]));
        }
    }

    cout << cost[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();

        int r = cin.nextInt();
        Console.WriteLine(r * r * 3);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"

using namespace std;

int main()
{

  long long  L,R;
  cin >> L >> R;

  long long M = 2019;
  
  long long min_amari = (L*(L+ 1))%M;
  /*
  for (long long i = L; i <= R-1; ++i) {
    for (long long j = i + 1; j <= R; ++j) {
      //cerr << "i=" << i << ", j=" << j << ", i*j=" << (i * j) << ", (i*j)%2019=" << (i * j) % M << endl;
      min_amari = std::min(min_amari, (i * j) % M);
    }
  }
  cout << min_amari << endl;
  min_amari = (L * L) % M;
  */  
  for (long long i = L; i <= std::min(R-1, L + M-1); ++i) {
    for (long long j = i + 1; j <= std::min(R,L+M); ++j) {
      //cerr << "is=" << i << ", j=" << j << ", i*j=" << (i * j) << ", (i*j)%2019=" << (i * j) % M << endl;
      min_amari = std::min(min_amari, (i * j) % M);
    }
  }
  cout << min_amari;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const long long inf=1e15;
struct node
{
	int x,y,z;
}a[maxn];
int x,y,z;
long long ans,_max=-inf,f[maxn],g[maxn];
priority_queue<int>q;
inline void chkmax(long long &x,long long y)
{
	if(x<y)
		x=y;
}
inline bool cmp(node x,node y)
{
	return x.x-x.y>y.x-y.y;
}
int main()
{
	scanf("%d%d%d",&x,&y,&z);
	int n=x+y+z;
	for(register int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
		ans+=a[i].z;
	}
	sort(a+1,a+n+1,cmp);
	long long now=0;
	for(register int i=1;i<=n;i++)
	{
		now+=a[i].x-a[i].z;
		q.push(a[i].z-a[i].x);
		if(i>x)
		{
			now+=q.top();
			q.pop();
		}
		f[i]=now;
	}
	now=0;
	while(!q.empty())
		q.pop();
	for(register int i=n;i>=1;i--)
	{
		now+=a[i].y-a[i].z;
		q.push(a[i].z-a[i].y);
		if(i<=n-y)
		{
			now+=q.top();
			q.pop();
		}
		g[i]=now;
	}
	for(register int i=x;i<=n-y;i++)
		chkmax(_max,f[i]+g[i+1]);
	printf("%lld",_max+ans);
	return 0;
}

Measured memory_bytes: 3448
# フェルマーの小定理
N, M, K = map(int, input().split())

m = 998244353

result = 0
n = 1
k = 1
for i in range(K + 1):
    # result += M * mcomb(N - 1, i) * pow(M - 1, N - 1 - i, 998244353)
    result += n * pow(k, m - 2, m) * pow(M - 1, N - 1 - i, m)
    result %= m
    n *= N - 1 - i
    n %= m
    k *= i + 1
    k %= m
result *= M
result %= m
print(result)


Measured memory_bytes: 9200
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    string s; cin >> s;
    bool ok = false;
    rep(i,2){
        if(s[i] != s[i+1]) ok = true;
    }
    cout << (ok?"Yes":"No") << endl;
}

    



Measured memory_bytes: 256
N = int(input())
K = int(input())
anss = []
for i in range(2**N):
    tmp = 1
    for j in range(N):
        if (i >> j) % 2 == 1:
            tmp *= 2
        else:
            tmp += K
    anss.append(tmp)
print(min(anss))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;

int main() {
  ll n,k;
  cin>>n>>k;
  vector<ll> h(n);
  rep(i,n)cin>>h[i];
  ll dp[n+1];
  rep(i,n+1)dp[i]=INF;
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(ll i=1;i<n;i++){
    for(ll j=1;j<=k;j++){
      if (i-j>=0){
        dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
      //  cout<<dp[i]<<" "<<i<<"i"<<endl;
      }
    }
  }
  cout<<dp[n-1];
}


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

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

lli solve(lli n)
{
    lli sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    return  sum;

}
int main()
{
    lli n;
	cin>>n;
	cout<<solve(n)<<"\n";

	return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextInt();
        long sum = 0;
        for(int i=1;i<n;i++){
            int one = 0;
            if(n%i==0)one=1;
            int tmp=(int)n/i-one;
            sum+=tmp;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 35868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		Integer run[] = new Integer[S.length()-2];
		int ans = 10000;

		for (int i = 0; i < S.length()-2; i++) {
			Integer num = Integer.valueOf(S.substring(i, i+3));
			run[i] = num;
		}

		for (int i = 0; i < run.length; i++) {
			int tmp = Math.abs(run[i].intValue() - 753);
			if(tmp < ans) {
				ans = tmp;
			}
		}
		System.out.println(ans);
	}
}


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

int N;

int main() {
    cin >> N;
  
    string ans = "No";
    for(int i=0;i<=(N/4);i++){
      for(int j=0;j<=(N/7);j++){
        if(N == i*4 + j*7 ) ans = "Yes";
      }
    }
    cout << ans << endl;
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    string s;
    cin >> s;
    int res = INF;
    rep(i, s.size() - 2) {
        int n = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        chmin(res, abs(753 - n));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
F,E = int(S[:2]),int(S[2:])
def j(s):
    if 0 < s <= 12:
        return 1
    else:
        return 0
R = j(F)+j(E)
if R == 0:
    print("NA")
elif R == 1:
    if j(F):
        print("MMYY")
    else:
        print("YYMM")
else:
    print("AMBIGUOUS")

Measured memory_bytes: 3060
import bisect
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
mx = a[-1]

idx = bisect.bisect_left(a, mx//2)
if a[idx] == mx//2:
    print(mx, a[idx], sep=" ")
else:
    if a[idx] == mx:
        print(mx, a[idx-1], sep=" ")
        exit()
    if idx > 0:
        if abs(mx//2 - (mx-a[idx])) > abs(mx//2 - a[idx-1]):
            print(mx, a[idx-1], sep=" ")
        else:
            print(mx, a[idx], sep=" ")
    else:
        print(mx, a[idx], sep=" ")
            


Measured memory_bytes: 62704
#include <iostream>

using namespace std;

int main()
{
int A, B, C, D;
cin >> A >> B >> C >> D ;
if((A * B)>= (C * D)){
    cout << A * B << endl;
}
else if(( A * B )<= (C * D)){
    cout << C * D << endl;
}

    return 0;
}


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

using namespace std;

int main(){

    int a;
    string s;

    cin>>a>>s;
    
    if(a == 0 || a == 26) cout<<s<<"\n";
    else{
        for (int i = 0; i < (int)s.size(); i++)
        {   
            if(s[i]+a>90) s[i] = '@'+(a-(90-s[i]));
            else s[i]+=a;
            
        }
        cout<<s<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct { template <typename T> operator T() { T x; cin >> x; return x; } } IN;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a,b;
    cin>>a>>b;
    char buf[100];
    sprintf(buf,"\\d{%lld}-\\d{%lld}",a,b);
    regex re(buf);
    string s;
    cin>>s;
    cout<<(regex_match(s,re)?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
n=int(input())
def f(A):
    LL=permutations(range(n))
    for i,L in enumerate(LL):
        if A==L:
            return i
P=tuple(map(lambda x: int(x)-1,input().split()))
Q=tuple(map(lambda x: int(x)-1,input().split()))
print(abs(f(P)-f(Q)))

Measured memory_bytes: 38512
def pushHeap(array, elem):
    n = len(array)
    array.append(elem)
    while n != 0:
        i = int((n - 1) / 2)
        if array[n] > array[i]:
            tmp = array[n]
            array[n] = array[i]
            array[i] = tmp
        n = i


def popHeap(array):
    n = len(array) - 1
    array[0] = array[n]
    del array[-1]
    i = 0
    while 2 * i + 1 < n:
        j = 2 * i + 1
        if j != n - 1 and array[j] < array[j + 1]:
            j += 1
        if array[i] < array[j]:
            tmp = array[j]
            array[j] = array[i]
            array[i] = tmp
        i = j


N, M = map(int, input().split())
A = list(map(int, input().split()))
heap_A = []

for a in A:
    pushHeap(heap_A, a)

for _ in range(M):
    discount_max = int(heap_A[0] / 2)
    popHeap(heap_A)
    pushHeap(heap_A, discount_max)

print(sum(heap_A))


Measured memory_bytes: 14480
M=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(M[K-1])

Measured memory_bytes: 3060
<?php

fscanf(STDIN, "%d", $n);
$to = [];
$cost = [];
for ($i = 0; $i < $n - 1; ++$i) {
    fscanf(STDIN, "%d %d %d", $u, $v, $w);
    --$u;
    --$v;
    $to[$u][] = $v;
    $to[$v][] = $u;
    $cost[$u][] = $w;
    $cost[$v][] = $w;
}

$ans = array_fill(0, $n, -1);
$q = new SplQueue();
$ans[0] = 0;
$q->enqueue(0);

while (!$q->isEmpty()) {
    $u = $q->dequeue();

    for ($i = 0; $i < count($to[$u]); ++$i) {
        $v = $to[$u][$i];
        $c = $cost[$u][$i];

        if ($ans[$v] !== -1) continue;

/* echo "u: $u, v: $v, cost: $c", PHP_EOL; */
        $ans[$v] = ($c + $ans[$u]) % 2;
        $q->enqueue($v);
    }
}


for ($i = 0; $i < $n; ++$i) {
    echo $ans[$i], PHP_EOL;
}


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

int main(){
  int N,M,j=0;
  cin>>N>>M;
  vector<int> A(N);
  for(int &i:A){
    cin>>i;
    j+=i;
  }
  sort(A.begin(),A.end());
  if(A[N-M]*4*M<j)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}


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

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

  bool ok = true;

  for(int i = 0; i < 5; i++) {
    for(int j = i + 1; j < 5; j++){
      if(t[j] - t[i] > k) {
        ok = false;
        break;
      }
    }
    if(ok == false){
      break;
    }
  }

  if (ok) {
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

int a;

inline void Solve (){
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i * j == a){
				printf("Yes\n");
				return;
			}
		}
	}
	printf("No\n");
}

inline void Input (){
	a = read<int>();
}

int main(){
	Input();
	Solve();
	return 0;
}

Measured memory_bytes: 256
S = input()
L = len(S)
Flag = True
if not S[0] == 'A':
    Flag = False
cnt = 0
a = str(S[1])
for i in range(2,L-1):
    if S[i] == 'C':
        cnt += 1
    else:
        a += S[i]
a += S[-1]
if a.islower() and cnt == 1:
    pass
else:
    Flag = False
if Flag:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val set = mutableSetOf<String>()
    var p = mutableMapOf<String, Int>()

    repeat(m) {
        val (mondai, result) = readLine()!!.split(" ")
        if (!set.contains(mondai)) {
            if (result == "WA") {
                p.put(mondai, p.getOrElse(mondai, { 0 }) + 1)
            } else {
                set.add(mondai)
            }
        }
    }

    var psum = 0
    for (v in set) {
        psum += p.getOrElse(v, { 0 })
    }
    println("${set.size} ${psum}")
}



Measured memory_bytes: 62200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;



int main(){
    int x,y,z;
    x=-1;y=-1;z=-1;
    int n,t;
    cin >> n >> t;
    t=t/1000;
    int sum=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            sum=9*i+4*j;
            if(sum==t-n){
                x=i;y=j;z=n-i-j;
            }
        }
    }
    cout << x <<" "<< y <<" "<< z << endl;
}


Measured memory_bytes: 256
from queue import Queue
from sys import stdin, stdout
input = stdin.readline
print = stdout.write

n, q = map(int, input().split())
adj = [[] for _ in range(n + 1)]
lazy = [0] * (n + 1)

for _ in range(n - 1):
    u, v = map(int, input().split())
    adj[u].append(v)
    adj[v].append(u)

for _ in range(q):
    p, x = map(int, input().split())
    lazy[p] += x

qu = Queue()
qu.put((1, 0))
while not qu.empty():
    pair = qu.get()
    u = pair[0]
    for v in adj[u]:
        if v == pair[1]: continue
        lazy[v] += lazy[u]
        qu.put((v, u))

for i in range(1, n + 1):
    print(str(lazy[i]) + ' ')
 

Measured memory_bytes: 91592
N = int(input())
H = list(map(int,input().split()))

sbn = 0
maxim = 0
for i in range(1,N):
    if maxim < H[i-1]:
        maxim = H[i-1]
    if H[i-1] > H[i]:
        sbn = maxim - H[i]
    if abs(sbn) > 1:
        print("No")
        exit(0)

print("Yes")

Measured memory_bytes: 20680
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n, k; cin >> n >> k;
  int data;
  vector <bool> flag(10, true);
  bool key = true;
  for(int i = 0; i < k; i++)
  {
      cin >> data;
      flag[data] = false;
  }
  int temp;
  int answer = n;
  while(key)
  {
    temp = answer;
    while((flag[temp%10] != false) && (temp != 0))
    {
      temp/=10;
      if(temp == 0)
      {
        key = false;
      }
    }
    answer++;
  }
    answer--;
  cout << answer << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int64_t n,cntR = 0,cntG = 0,cntB = 0,check = 0;
  cin >> n;
  vector<char>table(n);
  for (int i = 0; i < n; i++) {
    cin >> table.at(i);
    if (table.at(i) == 'R') cntR++;
    else if (table.at(i) == 'G') cntG++;
    else if (table.at(i) == 'B') cntB++;
  }
  int64_t sum = cntR * cntG * cntB;
  
  for (int i = 0; i < n-1; i++) {
    if (table.at(i) == 'R') {
      for (int j = i+1; j < n; j++) {
        if (table.at(j) == 'G') {
          if (j*2-i <= n-1 && table.at(j*2-i) == 'B') {
            check++;
          }
        }
      }
    }
  }

  for (int i = 0; i < n-1; i++) {
    if (table.at(i) == 'R') {
      for (int j = i+1; j < n; j++) {
        if (table.at(j) == 'B') {
          if (j*2-i <= n-1 && table.at(j*2-i) == 'G') {
            check++;
          }
        }
      }
    }
  }

  for (int i = 0; i < n-1; i++) {
    if (table.at(i) == 'G') {
      for (int j = i+1; j < n; j++) {
        if (table.at(j) == 'R') {
          if (j*2-i <= n-1 && table.at(j*2-i) == 'B') {
            check++;
          }
        }
      }
    }
  }

  for (int i = 0; i < n-1; i++) {
    if (table.at(i) == 'G') {
      for (int j = i+1; j < n; j++) {
        if (table.at(j) == 'B') {
          if (j*2-i <= n-1 && table.at(j*2-i) == 'R') {
            check++;
          }
        }
      }
    }
  }
  for (int i = 0; i < n-1; i++) {
    if (table.at(i) == 'B') {
      for (int j = i+1; j < n; j++) {
        if (table.at(j) == 'R') {
          if (j*2-i <= n-1 && table.at(j*2-i) == 'G') {
            check++;
          }
        }
      }
    }
  }

  for (int i = 0; i < n-1; i++) {
    if (table.at(i) == 'B') {
      for (int j = i+1; j < n; j++) {
        if (table.at(j) == 'G') {
          if (j*2-i <= n-1 && table.at(j*2-i) == 'R') {
            check++;
          }
        }
      }
    }
  }
  cout << sum - check << endl;
}  

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            List<int> resultlist = new List<int>();

            string resultoutput = string.Empty;
            int cardNum = int.Parse(Console.ReadLine());

            string[] Input = Console.ReadLine().Split(' ');

            for(int i = 0; i < cardNum; i++)
            {
                resultlist.Add(int.Parse(Input[i]));
            }

            resultlist.Reverse();

            for(int x = 0; x < cardNum; x++)
            {
                resultoutput += resultlist[x];
                if (x != cardNum - 1) resultoutput += ' ';
            }

            Console.WriteLine(resultoutput);
        }

    }         
}

Measured memory_bytes: 9148