akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

struct State {
  int r, c;
  int cost;
};

int main() {
  in(int, h, w, k);
  in(int, x1, y1, x2, y2);
  --x1, --y1, --x2, --y2;
  vector<string> grid(h);
  rep(i, h) cin >> grid[i];

  State init = {x1, y1, 0};
  vector<vector<int>> seen(h, vector(w, -1));
  seen[x1][y1] = 0;
  queue<State> que;
  que.push(init);

  while (!que.empty()) {
    State here = que.front();
    dbg(here.r, here.c, here.cost);
    que.pop();
    if (here.r == x2 && here.c == y2) {
      out(here.cost);
      return 0;
    }
    int dr[] = {1, -1, 0, 0};
    int dc[] = {0, 0, 1, -1};
    rep(i, 4) {
      for (int j = 1; j <= k; ++j) {
        State there(here);
        there.r = here.r + dr[i] * j;
        there.c = here.c + dc[i] * j;
        there.cost++;
        if (there.r < 0 || h <= there.r ||
            there.c < 0 || w <= there.c) {
          break;
        }
        if (grid[there.r][there.c] == '@') {
          break;
        }
        int& s = seen[there.r][there.c];
        if (s != -1 && s < there.cost) break;
        if (s != -1 && s <= there.cost) continue;
        s = there.cost;
        que.push(there);
      }
    }
  }
  out(-1);
}


Measured memory_bytes: 12164
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 998244353LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N;
int A[200001];
int E[200001];
int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N;
    repp(i, 1, N+1) cin >> A[i];

    vector<int> res;
    repr(i, N+1, 1) {
        int p = 0;
        for (int j = 2*i; j <= N; j += i) p ^= E[j];
        if (p != A[i]) res.pb(i), E[i] = 1;
    }

    reverse(all(res));
    cout << sz(res) << endl;
    repi(i, res) cout << i << ' ';
}

Measured memory_bytes: 2936
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;

int n, m;
int a[200];
int dp[N][2];

inline int go(int x, int p) {
	if (x == 0 && p == 0) re 2;
	if (x == 0 && p == 1) re 1;
	if (dp[x][p]) re dp[x][p];
	if (p == 0) {
	    int ans = 2;
		for (int i = 0; i < n; i++)
			if (x - a[i] >= 0 && go(x - a[i], 1) == 1)
				ans = 1;
		re dp[x][p] = ans;
	} else {
	    int ans = 1;
		for (int i = 0; i < n; i++)
			if (x - a[i] >= 0 && go(x - a[i], 0) == 2)
				ans = 2;
		re dp[x][p] = ans;
	} 
}	

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	int p = go(m, 0);
	if (p == 1) cout << "First";
	else cout << "Second";
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
 
int main(){
int a,b;
cin >> a >>b;
if(b==100){
b++;
}
if(a==0){
cout << b << endl;
}else if(a==1){
cout << b*100 << endl;
}else if(a==2){
cout << b*10000 << endl;}
return 0;
}

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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

const int maxn = 2010;
const int maxm = maxn;
int s[maxn][maxm];
int n, m, q;
int v[maxn][maxm]; //vertex
int ei[maxn][maxm]; //edge(vertical)
int ej[maxn][maxm]; //edge(horizontal)
int e[maxn][maxm]; //edge(total)

int edge_in_area(int x1, int y1, int x2, int y2) {
  int ret = e[x2][y2];
  ret = ret - ej[x2][y1] - ej[x1 - 1][y2] + ej[x1 - 1][y1];
  ret = ret - ei[x1][y2] - ei[x2][y1 - 1] + ei[x1][y1 - 1];
  return ret;
}

void solve() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) {
    string str;
    cin >> str;
    for (int j = 1; j <= m; ++j) {
      s[i][j] = str[j - 1] - '0';
    }
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      v[i][j] = v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1] + s[i][j];
      ei[i][j] = ei[i - 1][j] + ei[i][j - 1] - ei[i - 1][j - 1];
      ej[i][j] = ej[i - 1][j] + ej[i][j - 1] - ej[i - 1][j - 1];
      ei[i][j] += (s[i - 1][j] == 1 && s[i][j] == 1 ? 1 : 0);
      ej[i][j] += (s[i][j - 1] == 1 && s[i][j] == 1 ? 1 : 0);
      e[i][j] = ei[i][j] + ej[i][j];
    }
  }

  rep(query_index, 0, q)
  {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int edges = edge_in_area(x1, y1, x2, y2);
    int vertices = v[x2][y2] - v[x1 - 1][y2] - v[x2][y1 - 1] + v[x1 - 1][y1 - 1];
    cout << vertices - edges << endl;
  }

}

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


Measured memory_bytes: 80640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const int INF = 1e9;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int N;
int A[18];
int B[18];
int dp[1<<18][51];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < (1 << N); i++) {
        for(int j = 0; j <= 50; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        int num = __builtin_popcount(bits);
        for(int card = 0; card < N; card++) {
            if(!((1 << card) & bits)) continue;
            int now;
            if((num & 1) ^ (card & 1)) {
                now = A[card];
            } else {
                now = B[card];
            }
            int Plus = 0;
            for(int j = 0; j < card; j++) {
                if(!((1 << j) & bits)) Plus++;
            }
            for(int before = 0; before <= now; before++) {
                chmin(dp[bits][now], dp[bits & (~(1 << card))][before] + Plus);
            }
            //cerr << bits << " " << card << " " << now << " " << dp[bits][now] << endl;
        }
    }
    int ans = 1e9;
    for(int val = 0; val <= 50; val++) {
        chmin(ans, dp[(1 << N) - 1][val]);
    }
    if(ans == 1e9) ans = -1;
    cout << ans << endl;
    return 0;
}

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

class BipartiteMatching {
	vector<vector<int>> edge;
	vector<int> match, used;
    size_t N;

    int dfs(int prev) {
        used[prev] = 1;
        for(int curr:edge[prev]){
            int next = match[curr];
            if(next < 0 || (!used[next] && dfs(next)) ) {
                match[prev] = curr;
                match[curr] = prev;
                return 1;
            }
        }
        return 0;
    }

public:

	BipartiteMatching(int N) : N(N), edge(N), match(N,-1), used(N) {
		// do nothing
	}

	void make_edge(int from, int to) {
		edge[from].push_back(to);
	}

	int max_flow() {
		int res = 0;
        for(int i = 0; i < N; ++i) {
            if(match[i] < 0) {
                for(int j = 0; j < N; ++j) used[j] = 0;
                if(dfs(i)) res++;
            }
        }
        return res;
	}
    vector<pair<int,int>> restoration(){
        vector<pair<int,int>> vp;
        for(int i = 0; i < N; ++i) {
            if(match[i] >= 0 && i < match[i]) vp.push_back({i,match[i]});
        }
        return vp;
    }
};

int main() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> c(H);
    for(int i = 0; i < H; ++i) {
        cin >> c[i];
    }    
    BipartiteMatching bm(H*W);
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if(i+1<H&&c[i][j]=='.'&&c[i+1][j]=='.') {
                int u=i*W+j,v=(i+1)*W+j;
                bm.make_edge(u,v);
                bm.make_edge(v,u);
            }
            if(j+1<W&&c[i][j]=='.'&&c[i][j+1]=='.') {
                int u=i*W+j,v=i*W+j+1;
                bm.make_edge(u,v);
                bm.make_edge(v,u);
            }
        }
    }    
    cout << bm.max_flow() << "\n";
    auto vp = bm.restoration();
    for(auto& p:vp) {
        if(p.first>p.second) swap(p.first,p.second);
        int sy=p.first/W, sx=p.first%W;
        int ty=p.second/W,tx=p.second%W;
        if(p.first + W == p.second) c[sy][sx]='v',c[ty][tx]='^';
        else c[sy][sx]='>',c[ty][tx]='<';
    }
    for(int i = 0; i < H; ++i) {
        cout << c[i] << "\n";
    }    
    return 0;
}

Measured memory_bytes: 4548
H, W = map(int, input().split())

if (H == 1 or W == 1):
    ans = 1
    print(ans)
    exit()

if (H % 2 == 1 and W % 2 == 1):
    ans = H * W // 2 + 1
else:
    ans = H * W // 2

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m, ans = 0; cin >> n >> m;
    vi k(n), p(m); vvi s(m, vi());
    // 入力処理
    rep(i, m){
        cin >> k[i];
        s[i].resize(k[i]);
        rep(j, k[i]){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i, m) cin >> p[i];
    
    // ビット全探索
    for(ll bit=0; bit<(1LL<<(n)); bit++){
        vector<bool> sw(n, false);
        vector<bool> light(m, false);
        rep(j, n){
            ll mask = (1LL<<j);
            if(bit&mask) sw[j] = true;
        }
        rep(i, m){
            ll cnt = 0;
            rep(j, k[i]) if(sw[s[i][j]])cnt++;
            if(cnt%2 == p[i]) light[i] = true;
        }
        bool tmp = 1;
        rep(i, m) tmp = tmp&light[i];
        ans += tmp;
    }

    // 答えの出力
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi=3.14159265358979;

ll fac[MAX], finv[MAX], inv[MAX];
ll POW[MAX];

void POWinit(){
    POW[0]=0;
    POW[1]=1;
    for(ll i=2;i<MAX;i++){
        POW[i]=POW[i-1]*i;
        POW[i]%=MOD;
    }
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans[1010]={};
    cin>>n>>k;
    COMinit();
    POWinit();
    if(n<k){
        cout<<0<<endl;
        return 0;
    }
    ans[1]=1;
    rep2(i,2,k+1){
        ans[i]=1;
        rep(j,n){
            ans[i]*=i;
            ans[i]%=MOD;
        }
        rep2(j,1,i){
            ans[i]-=COM(i,j)*ans[j]%MOD;
            ans[i]%=MOD;
            if(ans[i]<0) ans[i]+=MOD;
        }
    }
    cout<<ans[k]<<endl;
    return 0;
}


Measured memory_bytes: 19168
public class Hello{
    public static void Main(){
        
        string s = System.Console.ReadLine();
        string[] array = s.Split(' ');
        
        int a = int.Parse(array[0]);
        int b = int.Parse(array[1]);
        int c = int.Parse(array[2]);
        
        string result = "win";
        if(a+b+c >= 22)
        {
            result = "bust";
        }
        
        System.Console.WriteLine(result);
    }
}


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

int main() {
  int64_t K, N;
  cin >> K >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int MAX = 0;
  int mi;
  for (int i = 0; i < N; i++) {
    int i2 = i + 1;
    int d;
    if (i2 >= N) {
      i2 = 0;
      d = K - A.at(N - 1) + A.at(0);
    } else {
      d = A.at(i2) - A.at(i);
    }
    if (MAX < d) {
      MAX = d;
      mi = i2;
    }
  }

  int64_t res = 0;
  for (int i = mi; i < mi + N - 1; i++) {
    int i1 = (i >= N) ? i - N : i;
    int i2 = (i1+1 >= N) ? i1 + 1 - N : i1 + 1;
    if (i1 < i2) {
      res += A.at(i2) - A.at(i1);
    } else {
      res += A.at(i2) + (K - A.at(i1));
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll MOD = 1e9+7;
const ll D = 1e4+9;
const ll R = 1e2+9;

ll mod(ll n, ll m) {
    n %= m;
    if(n < 0)  n += m;
    return n;
}

ll mod(ll n) {
    return mod(n, MOD);
}

void modadd(ll &a, ll b) {
    a = mod( mod(a) + mod(b) );
}

string s;
int d, r;
ll eq[D][R];
ll lt[D][R];

int main() {
    cin >> s >> r;
    d = s.size();

    for(int i = 0; i <= 9; i++) {
        modadd(eq[0][mod(i, r)], i == s[0]-'0');
        modadd(lt[0][mod(i, r)], i < s[0]-'0');
    }

    for(int di = 1; di < d; di++) {
        for(int ri = 0; ri < r; ri++) {
            int num = s[di] - '0';
            eq[di][ri] = eq[di-1][mod(ri-num, r)];
            for(int i = 0; i <= 9; i++)
                modadd(lt[di][ri], lt[di-1][mod(ri-i, r)]);
            for(int i = 0; i < num; i++)
                modadd(lt[di][ri], eq[di-1][mod(ri-i, r)]);
        }
    }

    ll ans = 0;
    modadd(ans, lt[d-1][0]);
    modadd(ans, eq[d-1][0]);
    modadd(ans, -1);
    cout << ans << endl;
}

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

int main(){
  int N,count,tmp;
  count = 0;
  tmp=0;
  cin >>N;
  int mochi[N];
  for(int i=0;i<N;i++){
    cin >>mochi[i];
  }
  for(int i=0;i<N;i++){
    //cout <<mochi[i]<<",";
  }
  cout <<endl;
  int flag=1;
  int times;
  times=0;
  while(flag==1){
    flag=0;
    for(int i=0;i<N-1;i++){
      if(mochi[i]<mochi[i+1]){
        //cout << "do in "<<i<<","<<i<<":"<<mochi[i]<<"smaller"<<i+1<<":"<<mochi[i+1]<<endl;
        tmp = mochi[i+1];
        //cout <<i<<endl;
        mochi[i+1] = mochi[i];
        mochi[i] = tmp;
        for(int j=0;j<N;j++){
          //cout<<mochi[j]<<",";
        }
        //cout<<endl;
        flag = 1;
      } 
    }
    //cout<<times<<" times done."<<endl<<endl;
    times++;
  }
  for(int i=0;i<N-1;i++){
    //cout << mochi[i]<<endl;
    if(mochi[i]==mochi[i+1]){
   
      count++;
    }
  }
  cout << N-count;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn a() {
    let s = read!(String);
    let c: Vec<char> = s.chars().collect();
    let mut prev_c = '*';
    let mut runlen: Vec<(char, usize)> = vec![];
    for cc in c {
        if prev_c == cc {
            runlen.last_mut().unwrap().1 += 1;
        } else {
            runlen.push((cc, 1));
            prev_c = cc;
        }
    }
    let mut ans = 0;
    let mut index = 0;

    if runlen[0].0 == '>' {
        let r = runlen[0];
        ans += r.1 * (r.1 + 1) / 2;
        index = 1;
    }

    while index < runlen.len() {
        let next = index + 1;
        let r = runlen[index];

        if next == runlen.len() {
            ans += r.1 * (r.1 + 1) / 2;
        } else {
            let r2 = runlen[next];
            // rが増加列、r2が減少列
            if r.1 < r2.1 {
                ans += r.1 * (r.1 - 1) / 2;
                ans += r2.1 * (r2.1 + 1) / 2;
            } else if r.1 >= r2.1 {
                ans += r.1 * (r.1 + 1) / 2;
                ans += r2.1 * (r2.1 - 1) / 2;
            }
        }
        index += 2;
    }

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

fn b() {
    unimplemented!();
}

fn c() {
    unimplemented!();
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    a();
}


Measured memory_bytes: 11376
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n: i32 = read();
    let _: i32 = read();
    let mut ss: Vec<String> = (0..n).map(|_| -> String { read::<String>() }).collect();
    ss.sort();
    println!("{}", ss.concat());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long int n; cin>>n;
  int t[n];
  long int sum=0;
  for(int i=0;i<n;i++){  cin>>t[i]; sum+=t[i];  }
  int m;  cin>>m;
  int p[m],x[m];
  for(int i=0;i<m;i++)
  {
    cin>>p[i]>>x[i];
  }
  
  for(int i=0;i<m;i++)
  {
    cout<<sum-t[p[i]-1]+x[i]<<"\n";
  }

  return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n), a(n);
    rep(i, n){
         cin >> p.at(i);
         a.at(i) = p.at(i);
    }

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

    int cnt = 0;
    rep(i, n)
    {
        if(a.at(i) != p.at(i)) cnt++;
    }

    if(cnt == 0 or cnt == 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    
    return 0;
}

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

int main(void)
{
  int n, cnt = 0;
  cin >> n;
  bool ans = false;
  for (int i = 0; i < n; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) cnt++;
    if (cnt >= 3) ans = true;
    if (d1 != d2) cnt = 0;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  if (n % 3 != 0) cout << (a == vector<int>(n, 0) ? "Yes" : "No") << '\n';
  else {
    sort(a.begin(), a.end());
    if (a == vector<int>(n, 0)) {
      cout << "Yes" << '\n';
      return 0;
    }
    int x = a[n / 3];
    vector<int> res(n / 3, 0);
    rep(i, n * 2 / 3) res.push_back(x);
    if (a == res) {
      cout << "Yes" << '\n';
      return 0;
    }
    int y = a[n * 2 / 3];
    int z = a[0];
    int xsum = x ^ y ^ z;
    if (xsum != 0) {
      cout << "No" << '\n';
      return 0;
    }
    res.clear();
    rep(i, n / 3) res.push_back(z);
    rep(i, n / 3) res.push_back(x);
    rep(i, n / 3) res.push_back(y);
    if (a == res) {
      cout << "Yes" << '\n';
    }
    else cout << "No" << '\n';
  }





  
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;

struct BIT{
    vector<int> data;

    void init(int n){
        data.assign(n+1, 0);// 1-indexed [1,n]
    }

    void add(int i, int x){
        while(i <= data.size() - 1){
            data[i] += x;
            i += (i & -i);
        }
    }

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += data[i];
            i -= (i & -i);
        }
        return s;
    }
};

template<class T>
long long int inversion(const vector<T> &a){
    vector<T> b = a;
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());

    long long int num = 0;
    BIT bit;
    bit.init(a.size());

    for(int i=0; i<a.size(); i++){
        int pos = lower_bound(b.begin(), b.end(), a[i]) - b.begin() + 1;
        num += bit.sum(a.size()) - bit.sum(pos);
        bit.add(pos,1);
    }
    return num;
}

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

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

    long long int upper = INF, lower = 0, mid;
    while(upper - lower > 1){
        mid = (upper + lower) / 2;
        //cout << lower << " " << upper << " -> " << mid << endl;

        vector<int> sum(n+1);
        for(int i=0; i<n; i++){
            if(a[i] >= mid) sum[i+1] =  1;
            if(a[i] <  mid) sum[i+1] = -1;
        }
        for(int i=1; i<n+1; i++){
            sum[i] += sum[i-1];
        }
        
        if((n+1)*n/2 - inversion(sum) < ((n+1)*n/2+1)/2) upper = mid;
        else lower = mid;
    }
    cout << lower << endl;
    return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

vector< int > v,neg;
int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n,l;
    cin >> n >>l;

    int maxi=0,mini=0;

    maxi= (l+n-1);
    mini = maxi - (n-1);
    int ans=0;

    if(mini<=0 && maxi>=0){
        for(int i=maxi ; i>=mini ; i--){
            ans+=i;
        }
    }else if(maxi<0 && mini<0){
        for(int i=maxi ; i>=mini ; i--){
            ans+=i;
        }
        ans -= maxi;
    }else {
        for(int i=maxi ; i>=mini ; i--){
            ans+=i;
        }
        ans -= mini;
    }

    cout << ans << endl;

    return 0;
}



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

int main() {
  string S;
  cin>>S;
  string X="";
  
  for(int i=0; i<5;i++){
    X=X+"hi";
    if(X==S){
      cout<<"Yes"<< endl;
      return 0;
    }
  }
  cout<<"No"<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;

int main() {
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    // double hs = (a*30.0+b*0.5)*(M_PI/180.0);
    // double ms = b*6.0*(M_PI/180.0);
    double hs = (h*30.0+m*0.5);
    double ms = m*6.0;
    // double ang = abs(hs-ms);
    double ang = abs(hs-ms)*(M_PI/180.0);
    double ans = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(ang));
    // cout << hs << endl;
    // cout << ms << endl;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3508
#include<iostream>
#include<set>
using namespace std;
int main(){
  int s;cin>>s;
  int ans=2;
  set<int>st;
  st.insert(s);
  while(1){
	if(s%2)s=s*3+1;
	else s/=2;
	if(st.count(s))break;
	st.insert(s);
	ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5],gl[MAXN+5],gr[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	fu(i,1,n)sc(A[i]);
	fu(i,1,n)gl[i]=__gcd(gl[i-1],A[i]);
	fd(i,n,1)gr[i]=__gcd(gr[i+1],A[i]);
	
	fu(i,1,n){
		maxize(ans,__gcd(gl[i-1],gr[i+1]));
	}
	pr(ans);


	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' '; cout << endl;
#define OUTP(a) cout << a.f << ' ' << a.s << endl;
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
#define get_lind(vec, val) (int)(lower_bound(all(vec), val) - vec.begin())
#define get_rind(vec, val) (int)(upper_bound(all(vec), val) - vec.begin())


using  namespace std;
const int N = 2e5 + 5;
ll sufix[N], prefix[N];
int main()
{
    ll k, n; cin >> k >> n;
    ll a[n + 1];
    FOR(i, n, 0) cin >> a[i + 1];
    a[0] = 0;
    ll ans = 1e15, sum = 0;
    FOR(i, n + 1, 1)
    {
        ans = min(ans, sum + (k - a[i]));
        sum += a[i] - a[i - 1];
    }
    ans = min(ans, sum - a[1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  string s;cin >>s;
  int n = s.size();
  int cnt_r = 0;
  int cnt_l = 0;
  for(int i=n/2;i<n;++i){
    auto sub_r = s.substr(i,1);
    if(sub_r =="S"){
      ++cnt_r;
    } else {
      if(cnt_r>0) --cnt_r;
    }
    auto sub_l = s.substr(n-1-i,1);
    if(sub_l =="T"){
      ++cnt_l;
    } else {
      if(cnt_l>0) --cnt_l;
    }
  }
  cout << 2*max(cnt_r,cnt_l) << endl;
  return 0;
}


Measured memory_bytes: 640
S = input()

a = int(S[:2])
b = int(S[2:])

result = ''
if 0 < a and a <= 12:
    result += 'MM'
else:
    result += 'YY'
if 0 < b and b <= 12:
    result += 'MM'
else:
    result += 'YY'

if 'MMMM' == result:
    result = 'AMBIGUOUS'
elif 'YYYY' == result:
    result = 'NA'
print(result)


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

int main()
{
  int n;
  cin >> n;
  if (n == 1) cout << 1 << endl;
  else {
    long long l0 = 2;
    long long l1 = 1;
    long long ans = l0 + l1;
    for (int i = 2; i < n; i++) {
      l0 = l1;
      l1 = ans;
      ans = l0 + l1;
    }
    cout << ans << endl;
  }
}


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

int a[200010];
int ans[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=2;i<=n;i++)scanf("%d",&a[i]);
for(int i=2;i<=n;i++)ans[a[i]]++;
for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 5276
b = str(input())
num = list(b)
appear = b.count(num[0])
if appear == 3:
    print(b)
elif num[0]>num[1]:
    c = num[0]
    d=str(c)
    print(d*3)
elif num[0] == num[1]:
    if num[1]<num[2]:
        c = int(num[0])+1
        d=str(c)
        print(d*3)
    else:
        c = num[1]
        d=str(c)
        print(d*3)
else:
    c = int(num[0])+1
    d=str(c)
    print(d*3)


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

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>

using namespace std;

int main() {
	string str;
	cin >> str;
	int s, n, w, e;
	s = count(str.begin(), str.end(), 'S');
	n = count(str.begin(), str.end(), 'N');
	w = count(str.begin(), str.end(), 'W');
	e = count(str.begin(), str.end(), 'E');
	bool a, b;
	if (s != 0 && n != 0) {
		a = true;
	}
	else if (s == 0 && n == 0) {
		a = true;
	}
	else {
		a = false;
	}

	if (w != 0 && e != 0) {
		b = true;
	}
	else if (w == 0 && e == 0) {
		b = true;
	}
	else {
		b = false;
	}

	if (a == true && b == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        a_vec: [usize; n]
    }

    let mut set: HashSet<usize> = HashSet::new();
    
    for &a in a_vec.iter() {
        if !set.contains(&a) {
            set.insert(a);
        } else {
            set.remove(&a);
        }
    }

    println!("{}", set.len());
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 5488
n = gets.chomp!.to_i
as = Array.new
n.times do |e|
  e = gets.chomp!.to_i
  as.push(e)
end

am = as.max

bs = as.clone
bs.delete(am)
bm = bs.max
#bs.delete(m)
#p as
#p bs
dl = as.length - bs.length

as.each do |i|
  if dl >= 2
    p am
  else
    if i == am
      if bm == nil
        p am
      else
        p bm
      end
    else
      p am
    end
  end
end

Measured memory_bytes: 8116
def calc_gcd (a, b) :
    p = a * b

    if a > b:
        a, b = b, a

    while b != 0:
        a, b = b, a % b

    return p // a


N = int(input())
T = []

for i in range(N):
     T += [int(input())]

while len(T) > 1:
    T = [calc_gcd(T[0], T[1])] + T[2:]

print(T[0])

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int dig = 0, bi = 0, mill = 0, mil = 0, cent = 0, dez = 0, uni = 0, res = 0, num = 0;
  scanf("%d", &dig);
  num = dig;
  
  while (dig != 0) {
        res   += dig % 10;
        dig  = dig / 10;
    }


  if (num % res == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
def getNums(As):
    nums = [0] * N
    stack = [(-1, 0)]
    for iA, A in enumerate(As):
        while stack[-1][1] > A:
            stack.pop()
        nums[iA] = iA - stack[-1][0]
        stack.append((iA, A))

    return nums


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

numLs = getNums(As)
numRs = getNums(reversed(As))
print(sum([A * numL * numR for A, numL, numR in zip(As, numLs, reversed(numRs))]))


Measured memory_bytes: 40896
N, K = map(int, input().split())
A = list(map(int, input().split()))
# dp[上からi桁まで][smaller]
dp = [[-1 for _ in range(2)]for _ in range(51)]
dp[0][0] = 0
MAX_DIGIT = 50

for d in range(MAX_DIGIT):
    # d = 0なら1<<49
    # d = 49なら1<<0
    mask = 1 << (MAX_DIGIT - d - 1)

    # A で元々 d 桁目にビットが立っているものの個数
    num = 0
    for i in range(N):
        if A[i] & mask:
            num += 1
    # X の d 桁目を 0, 1 にしたときのスコア
    cost0 = mask * num
    cost1 = mask * (N - num)

    # smaller -> smaller
    # 0 でも 1 でも良い、スコアが大きい方
    if dp[d][1] != -1:
        dp[d + 1][1] = max(dp[d + 1][1], dp[d][1] + max(cost0, cost1))

    # exact -> smaller
    # K の d 桁目が 1 だったら、X の d 桁目は 0 にする
    if dp[d][0] != -1:
        if K & mask:
            dp[d + 1][1] = max(dp[d + 1][1], dp[d][0] + cost0)

    # exact -> exact (K にぴったり合わせる)
    if dp[d][0] != -1:
        if K & mask:
            dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost1)
        else:
            dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost0)

print(max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]))
# print(dp)


Measured memory_bytes: 86740
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n,x;
    cin>>x;
    n=ceil(x/1.08);
    if(floor(n*1.08)==x)
    cout<<n;
    else
    cout<<":("<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
typedef long long lint;
const int N=1e5+5;
int n,m,q;
lint seq[N],ans[N];
std::map <lint,lint> buk;

template <class T> inline T nxi(){
	T x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

inline void work(){
	std::map <lint,lint> ::iterator it=--buk.end();
	for(int j=m; ; --it){
		while(j&&seq[j]>=it->first) --j;
		if(j==0) break;
		if(!it->second) continue;
		lint tmp=it->first/seq[j];
		buk[seq[j]]+=tmp*it->second;
		buk[it->first-seq[j]*tmp]+=it->second;
		if(it==buk.begin()) break;
	}
}

int main(){
	n=nxi<int>(),q=nxi<int>();
	seq[++m]=n;
	for(int i=1; i<=q; ++i){
		lint x=nxi<lint>();
		while(m&&seq[m]>x) --m;
		seq[++m]=x;
	}
	buk[seq[m]]=1;
	work();
	lint sum=0;
	for(int i=seq[1]; i; --i){
		ans[i]=(sum+=buk[i]);
	}
	for(int i=1; i<=n; ++i){
		printf("%lld\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 27904
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main(){
    double n;
    cin>>n;
   int h=0;
   long long int g=100;
   while(g<n){
   	g=g*1.01;
   	h++;
   }
   cout<<h<<"\n";
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second


int main() {
	ll x,y,a,b,c ; cin >> x >> y >> a >> b >> c ;
	vector<ll> ai(a),bi(b),ci(c) ;
	for(int i = 0; i < a ; i++)cin>>ai[i];
	for(int i = 0; i < b ; i++)cin>>bi[i];
	for(int i = 0; i < c ; i++)cin>>ci[i];
	sort(ai.begin(),ai.end(),greater<ll>());
	sort(bi.begin(),bi.end(),greater<ll>());
	sort(ci.begin(),ci.end(),greater<ll>());
	vector<ll> comb ;
	for(int i = 0; i < x ; i++)comb.pb(ai[i]);
	for(int i = 0; i < y ; i++)comb.pb(bi[i]);
	sort(comb.begin(),comb.end()) ;
	for(int i = 0; i < c ; i++){
		if(i >= comb.size())break ;

		if(ci[i] >= comb[i] ){
			swap(ci[i],comb[i]) ;
		}
		else break ;
	}
	ll ans = 0 ;
	for(auto x : comb)ans+=x;
	cout << ans ;
	return 0 ;
}

Measured memory_bytes: 4724
N = int(input())
A = list(map(int,input().split()))
AN = list(enumerate(A))
sAN = sorted(AN, key=lambda x: x[1])
ans = []
for i in range(N):
    ans.append(sAN[i][0]+1)
ans2 = [str(ans[i]) for i in range(len(ans))]
print(" ".join(ans2))

Measured memory_bytes: 30048
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            String str = sc.next();
            if(str.equals("-")) break;
            int n = str.length();
            char[] ch = new char[n];
            char[] newch = new char[n];

            for(int i = 0; i < n; i++){
                ch[i] = str.charAt(i);
            }

            int m = sc.nextInt();
            for(int i = 0; i < m; i++){
                int h = sc.nextInt();
                for(int j = 0; j < h; j++){
                    newch[n-h+j] = ch[j];
                }
                for(int j = 0; j < n - h; j++){
                    newch[j] = ch[j+h];
                }
                for(int j = 0; j < n; j++){
                    ch[j] = newch[j];
                }
            }

            for(int i = 0; i < n; i++){
                System.out.print(ch[i]);
            }
            System.out.println();
        }
    }
}



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

public class Main {
	
	public static void main(String[] args) throws Exception {
		FastScanner fs = new FastScanner();
		long a = fs.nextInt() , b = fs.nextInt(), c = fs.nextInt(), d = fs.nextInt();
		long ans = Long.MAX_VALUE;
		long ans1 = a*c;
		long ans2 = a*d;
		long ans3 = b*c;
		long ans4 = b*d;
		long temp1 = Math.max(ans1, ans2);
		long temp2 = Math.max(ans3, ans4);
		ans = Math.max(temp1, temp2);
		System.out.println(ans);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32596
package main

import "fmt"

func main() {
	var (
		h1 int
		m1 int
		h2 int
		m2 int
		k  int
	)
  fmt.Scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k)
	fmt.Printf("%d", (60*h2+m2)-(60*h1+m1)-k)
}

Measured memory_bytes: 1816
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
while(true){
int A=scan.nextInt();
int B=scan.nextInt();
if(A==0&&B==0)
break;
for(int a=0;a<A;a++){
for(int b=0;b<B;b++){
	if(a%2==0){
	if(b%2==0)
System.out.print("#");
	else
		System.out.print(".");
	}
	else{
		if(b%2==1)
			System.out.print("#");
				else
					System.out.print(".");
				}
}
System.out.println();
}
System.out.println();
}
}
}

Measured memory_bytes: 34556