akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    char x, y; cin >> x >> y;
    char ans;
    if(x > y) ans = '>';
    else if(x < y) ans = '<';
    else ans = '=';
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
int n=read(),a[yuzu|10];
ll ans;
int main(){
int i,j;
for (i=1;i<=n;++i) a[i]=read();
int l=1,r=1,now=0;
for (;r<=n;){
  for (;!(now&a[r])&&r<=n;){
    now|=a[r++];
    ans+=r-l;
    } 
  now&=~a[l++];
  }
write(ans);
}

Measured memory_bytes: 1024
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  for(auto&& e: s){
    e -= 'A';
    e += n;
    e %= 26;
    e += 'A';
  }
  print(s);
}


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

int main() {
  long long int N;
  cin >> N;
  vector<long long int> A(N), B(N), C(N);
  for (long long int i = 0; i < N; i++) cin >> A.at(i);
  for (long long int i = 0; i < N; i++) cin >> B.at(i);
  for (long long int i = 0; i < N; i++) cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  long long int ans = 0;
  for (long long int i = 0; i < N; i++) {
    long long int AL = -1, AR = N, CL = -1, CR = N;
    while (AR - AL > 1) {
      long long int AM = (AL + AR) / 2;
      if (A.at(AM) < B.at(i)) AL = AM;
      else AR = AM;
    }
    while (CR - CL > 1) {
      long long int CM = (CL + CR) / 2;
      if (C.at(CM) > B.at(i)) CR = CM;
      else CL = CM;
    }
    ans += (AL + 1) * (N - CL - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

stack<lli> s;

int main(){
    string st;
    while(cin >> st){
        if(st == "+"){
            lli x = s.top();
            s.pop();
            s.top() += x;
        }
        else if(st == "-"){
            lli x = s.top();
            s.pop();
            s.top() -= x;
        }
        else if(st == "*"){
            lli x = s.top();
            s.pop();
            s.top() *= x;
        }
        else if(st == "/"){
            lli x = s.top();
            s.pop();
            s.top() /= x;
        }
        else s.push(stoi(st));
    }
    cout << s.top() << endl;
    return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int calc(int x) {
  int ret = 0;
  while(x%100 == 0) {
    x /= 100;
    ret++;
  }
  return ret;
}

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

  int cnt = 0, val = 0;
  while(cnt < N) {
    val++;
    if(calc(val) == D) cnt++;
  }
  cout << val << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC77 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

#頂点iにmod(k)でiと等しい正の整数の集合を割り当て、頂点iから10i+j(0≦j≦9,mod(k))にコストjの有向辺を張ったグラフを考える
#頂点v(1≦v≦9)への到達コストの初期値をvとし、ダイクストラ法で頂点0(kの倍数)への到達コストを求める
#頂点iから+1して移動できる頂点:=桁和+1(コスト1),頂点iから*10して移動できる頂点:=桁和そのまま(コスト0) の2通りに遷移できる

k = I()
graph = [[] for _ in range(k)]
for i in range(k):
    graph[i].append([(i+1)%k, 1])
    graph[i].append([(10*i)%k, 0])
#print(graph)

def dijkstra(x):
    d = [inf] * k
    d[x] = 1
    visited = {x}
    h = [(0, x)]

    while h:
        u = heappop(h)[1]
        visited.add(u)
        for node, cost in graph[u]:
            if (node not in visited) and d[node] > d[u] + cost:
                d[node] = d[u] + cost
                heappush(h, (d[u]+cost, node))
    return d


print(dijkstra(1)[0])


Measured memory_bytes: 99888
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

bool f(long long N){
  string s = to_string(N);
  long long slen = s.length();
  slen--;
  for (int i = 0; i < s.length(); i++)
  {
    if(s[i]!=s[slen-i])
      return false;
  }
  return true;
}

int main()
{
  long long N, D, X;
  cin >> N >> D >> X;
  long long ans = 0;
  vector<long long>a(N);
  for (int i = 0; i < N;i++)
    cin >> a[i];

    for (int i = 0; i < N; i++)
    {
      long long day = 1-a[i];
      while (day + a[i] <= D)
      {
        ans++;
        day += a[i];
      }
      //cout << "ans==" << ans << endl;
    }
  cout << ans + X << endl;
}


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

int main()
{
    int N;
    cin >> N;
    int low = 1, high = N;
    while(high - low > 1) {
        int mid = (high + low)/2;
        double Y = (double)mid*1.08;
        if(int(Y) >= N) high = mid;
        else low = mid;
    }
    if(int(double(low)*1.08) == N) printf("%d\n", low);
    else if(int(double(high)*1.08)==N) printf("%d\n", high);
    else printf(":(\n");
    return 0;
}

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

using namespace std;

const int N = 300004;
int cnth[N], cntw[N], x[N], y[N];
map <int, bool> mp[N];

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        mp[x[i]][y[i]] = true;
        cnth[x[i]]++, cntw[y[i]]++;
    }
    int mxh = 0, mxw = 0;
    for (int i = 0; i < N; i++) {
        mxh = max(mxh, cnth[i]);
        mxw = max(mxw, cntw[i]);
    }
    vector <int> hall, wall;
    for (int i = 0; i < N; i++) {
        if (cnth[i] == mxh) {
            hall.push_back(i);
        }
        if (cntw[i] == mxw) {
            wall.push_back(i);
        }
    }
    if(hall.size()*wall.size()>m){
    	cout<<mxh+mxw<<endl;
    	return 0;
	}
    int cnt = 0, mx = 0;
    for (int i = 0; i < hall.size(); i++) {
        for (int j = 0; j < wall.size(); j++) {
            mx = max(mx, mxh + mxw - mp[hall[i]][wall[j]]);
        }
    }
    cout << mx;
}


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


int main(){
	int N,T;
	cin >> N >> T;
	vector<int> D(N);
	for(int i = 0 ; i < N ; i++) cin >> D[i];
	sort(D.begin(),D.end());
	long long ans = 1;
	for(int i = 0 ; i < N ; i++){
		int c = i - (lower_bound(D.begin(),D.begin()+i,D[i]-T) - D.begin()) + 1;
		ans *= c;
		ans %= 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1528
# Peaks

n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
g = [[] for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

ans = 0
for v in range(1, n+1):
    for u in g[v]:
        if h[v] <= h[u]:
            break
    else:
        ans += 1

print(ans)


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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造

//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  UnionFind(int N) : UF(N) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    UF.at(rx) = ry; // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> B(M, vector<int>(2));
  for (int i = 0; i < M; i++) {
    cin >> B.at(i).at(0) >> B.at(i).at(1);
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    UnionFind tree(N);
    for (int j = 0; j < M; j++) {
      if (i != j) {
        tree.unite(B.at(j).at(0) - 1, B.at(j).at(1) - 1);
      }
    }
    for (int i = 0; i < N; i++) {
      if (tree.same(0, i) == false) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

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

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

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

#define hell                         1000000007
#define lcm(a,b)                     ((a*b)/__gcd(a,b))
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         3000005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;

ll f[MAXN];
void fact(ll n,ll p){
    f[0]=1;
    for(ll i=1;i<n;i++)
    {
        f[i]=(i*(f[i-1]%p))%p;
    }
}

ll expo(ll base, ll exponent, ll mod){
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}

ll add(ll a,ll b){
    return (a%hell+b%hell)%hell;
}

ll sub(ll a,ll b){
    return (a%hell-b%hell+hell)%hell;
}

ll mul(ll a,ll b){
    return ((a%hell)*(b%hell))%hell;
}

ll inverse(ll n,ll p){
    return expo(n,p-2,p);
}

ll nCr(ll n,ll r){
    return ((f[n]*inverse(f[n-r],hell))%hell)*inverse(f[r],hell)%hell;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	ll x,y;
	cin>>x>>y;
	fact(MAXN,hell);
	if((2*x-y)%3!=0 || (2*y-x)%3!=0) ret(0)
	ll h=(2*x-y)/3,v=(2*y-x)/3;
	if(h<0 || v<0) ret(0)
	ret(mul(f[h+v],inverse(mul(f[h],f[v]),hell)))	
	
	return 0;
}

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


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

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

    map<int,int> mp;
    map<int,int> ans;

    int AC = 0;
    int WA = 0;
    for(int i = 0; i < m; i++){
        int a;
        string s;

        cin >> a >> s;
        a--;
        if(s == "AC" && mp[a] == 0) {
            AC++;
            WA += ans[a];
            mp[a] = 1;
        } else if(s == "AC" && mp[a] == 1){
            continue;
        } else if(s == "WA" && mp[a] == 0){
            ans[a]++;
        }
    }
    cout << AC << " " << WA << endl;
}




Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
string st;
int main()
{
	getline(cin,st);
	for(int i=0;i<st.size()-1;i++)
	  if(st[i]==st[i+1]) {cout<<i+1<<" "<<i+2<<"\n";return 0;}
	for(int i=0;i<st.size()-2;i++)
	  if(st[i]==st[i+2]) {cout<<i+1<<" "<<i+3<<"\n";return 0;}
	cout<<"-1 -1\n";
	return 0;
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main(void){

    while( 1 ){
        string g; cin >> g;
        if( g == "#") break;
        int y, m, d; cin >> y >> m >> d;
        
        if( y <= 30 ){
            cout << g << " " << y << " " << m << " " << d << endl;
        }else if( y == 31&& m <= 4 ){
            cout << g << " " << y << " " << m << " " << d << endl;
        }else{
            cout << '?' << " " << y - 30 << " " << m << " " << d << endl;
         }
    }
    
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
inline int popcount(const int x) { return __builtin_popcount(x);}
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  rep(i,n) {
    cin >> a[i];
    if (a[i]&1 and (i+1)&1) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

def isPrime(p):
    if p == 2:
        return True
    elif p < 2 or p%2 == 0:
        return False
    elif pow(2, p-1, p) == 1:
        return True
    else:
        return False

n = int(raw_input())
count = 0
for i in range(n):
    if isPrime(int(raw_input())):
        count += 1
print count

Measured memory_bytes: 6432
from collections import deque
def main():
    n, a, b = int(input()), list(map(int, input().split())), deque()
    append, appendleft = b.append, b.appendleft
    flag = True
    for el in a:
        if flag: append(el)
        else: appendleft(el)
        flag = not flag
    if not flag: b.reverse()
    print(" ".join(list(map(str, b))))
main()

Measured memory_bytes: 29124
N,L = map(int,input().split())

taste_all = ((L+1-1) + (L+N-1)) * N // 2

diff = 99999999
ans_taste = 0
ans_i = 9999
for i in range(1,N+1) :
    taste = taste_all - (L+i-1)
    d = abs(taste_all - taste)
    if (d < diff ) :
        diff = d
        ans_taste = taste
        ans_i = i

print(ans_taste)


Measured memory_bytes: 3060
#include<stdio.h>

#define INF 100000000

int m[100][100],p[100];

int main(){
  int n,r,c,i,j,k,min,l;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&r,&c);
    p[i]=r;
    p[i+1]=c;
  }

  for(i=1;i<n;i++){
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      min=m[i][j]=INF;
      for(k=i;k<j;k++){
        if(min>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
        min=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
      m[i][j]=min;
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2112
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int a[100000], b[100000];
int c[100000],in[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int n, sum = 0;
	scanf("%d", &n);
	int l[10] = { 0 };
	REP(i, n) {
		scanf("%d", &l[i]);
		sum += l[i];
	}
	int flag = 1;
	REP(i, n) {
		int tmp = sum;
		if (tmp - l[i] <= l[i]) {
			flag = 0;
			break;
		}
	}
	if (flag) {
		puts("Yes");
	}
	else {
		puts("No");
	}
}

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

int main(void){
    // Your code here!
    int N;
    cin >> N;
    int res = 0;
    int total = 0;
    for (int i = 0; i <= 25; ++i)
    {
        for (int j = 0; j <= 14; ++j)
        {
            total = i * 4 + j * 7;
            if (total == N)
            {
                res = 1;
                break;
            }
        }
    }
    if (res == 1) cout << "Yes" << endl;
    if (res == 0) cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
struct Point{int x,y;};
int main(){
  int w,h,p[60][60]={},v[60][60]={},i,j,k,o;
  queue <Point> q;
  Point n,b;
  cin >> w >> h;
  while(w!=0){
    for(j=0;j<h;j++){
      for(i=0;i<w;i++){
	cin >> p[i][j];
	v[i][j]=0;
      }
    }
    o=0;
    for(j=0;j<h;j++){
      
      for(i=0;i<w;i++){
	if(p[i][j]==1){
	  o++;
	  n.x=i;n.y=j;
	  q.push(n);
	  p[i][j]=0;
	  while(!q.empty()){
	    n=q.front();
	    q.pop();
	    if(n.x+1<w&&p[n.x+1][n.y]==1) {
	      b.x=n.x+1;b.y=n.y;
	      p[n.x+1][n.y]=0;
	      q.push(b);
	    }
	    if(n.y+1<h&&p[n.x][n.y+1]==1) {
	      b.x=n.x;b.y=n.y+1;
	      p[n.x][n.y+1]=0;
	      q.push(b);
	    }
	    if(n.x-1>=0&&p[n.x-1][n.y]==1) {
	      b.x=n.x-1;b.y=n.y;
	      p[n.x-1][n.y]=0;
	      q.push(b);
	    }
	    if(n.y-1>=0&&p[n.x][n.y-1]==1) {
	      b.x=n.x;b.y=n.y-1;
	      p[n.x][n.y-1]=0;
	      q.push(b);
	    }
	    if(n.x+1<w&&n.y+1<h&&p[n.x+1][n.y+1]==1) {
	      b.x=n.x+1;b.y=n.y+1;
	      p[n.x+1][n.y+1]=0;
	      q.push(b);
	    }
	    if(n.x-1>=0&&n.y-1>=0&&p[n.x-1][n.y-1]==1) {
	      b.x=n.x-1;b.y=n.y-1;
	      p[n.x-1][n.y-1]=0;
	      q.push(b);
	    }
	    if(n.x+1<w&&n.y-1>=0&&p[n.x+1][n.y-1]==1) {
	      b.x=n.x+1;b.y=n.y-1;
	      p[n.x+1][n.y-1]=0;
	      q.push(b);
	    }
	    if(n.x-1>=0&&n.y+1<h&&p[n.x-1][n.y+1]==1) {
	      b.x=n.x-1;b.y=n.y+1;
	      p[n.x-1][n.y+1]=0;
	      q.push(b);
	    }
	  }
	}
      }
    }
    cout << o << endl;
    cin >> w >> h;
  }
  return 0;
}

Measured memory_bytes: 1232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int tSum = 0;
		int hSum = 0;
		int n = Integer.parseInt(br.readLine());

		for (int i = 0; i < n; i++) {
			String[] input = br.readLine().split(" ");
			if (input[0].compareTo(input[1]) > 0) {
				tSum += 3;
			} else if (input[0].compareTo(input[1]) == 0) {
				tSum += 1;
				hSum += 1;
			} else {
				hSum += 3;
			}
		}
		System.out.println(tSum + " " + hSum);
	}
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll A,V,B,W,T;
	cin >> A>>V>>B>>W>>T;
	if(A < B)
	{
	if(A + V*T >= B + W*T)
		cout <<"YES";
	else
	{
		cout <<"NO";
	}
	}
	else if(A>B)
	{
		if(B - W*T >= A-V*T)
			cout <<"YES";
		else
		{
			cout <<"NO";
		}
	} 
	else
	{
		cout <<"YES";
	}
	

}


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

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		int n = seer.nextInt(); int m = seer.nextInt();
		PriorityQueue<Long> set = new PriorityQueue<>();
		for(int i = 0; i < n; i++){
			set.add(seer.nextLong());
		}
		Pair[] ps = new Pair[m];
		for(int i = 0; i < m; i++){
			int b = seer.nextInt();
			int c = seer.nextInt();
			ps[i] = new Pair(b, c);
		}
		Arrays.sort(ps);
		for(int i = m-1; i >= 0; i--){
			int b = ps[i].b; long c = ps[i].c;
			while(b > 0){
				long x = set.poll();
				if(x < c){
					set.add(c);
					b--;
				}
				else{
					set.add(x);
					break;
				}
			}
			if(b > 0) break;
		}
		long tot = 0;
		for(long a: set) tot += a;
		System.out.println(tot);
	}
	static class Pair implements Comparable<Pair>{
		int b; long c;
		public Pair(int b, long c){
			this.b = b; this.c = c;
		}
		@Override
		public int compareTo(Pair P) {
			if(c < P.c) return -1;
			else if(c == P.c) return 0;
			else return 1;
		}
	}
}


Measured memory_bytes: 102652
N,K=map(int,input().split())

h=list(map(int,input().split()))
for i in range(101):
  h.append(0)
  
big=10**5+101
dp=[float('inf') for i in range(big)]

dp[0]=0

for i in range(N):
  for j in range(1,K+1):
    if dp[i+j] > dp[i] + abs(h[i+j]-h[i]):
      dp[i+j] = dp[i] + abs(h[i+j]-h[i])
      
print(dp[N-1])

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

typedef long long ll;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int H,W;
vector<string> s;

int bfs(int x, int y){
  vector<vector<ll>> dist(H, vector<ll>(W, -1));
  queue<pair<int,int>> que;
  dist[x][y] = 1;
  que.push(make_pair(x,y));
  while(!que.empty()){
    pair<int,int> n = que.front();
    int nx = n.first, ny = n.second;
    que.pop();
    for(int dir = 0; dir < 4; dir++){
      int nwx = nx + dx[dir];
      int nwy = ny + dy[dir];
      if(nwx < 0 || nwy < 0 || nwx >= W || nwy >= H) continue;
      if(s[nwy][nwx] == '#') continue;
      if(dist[nwy][nwx] == -1){
	dist[nwy][nwx] = dist[ny][nx] + 1;
      }else{
	continue;
      }      
      que.push(make_pair(nwx, nwy));
    }
  }
  // for(auto x: dist){
  //   for(auto y: x){
  //     cout << y << " ";
  //   }
  //   cout << endl;
  // }
  return dist[H-1][W-1];
}

int main(){
  cin >> H >> W;
  s.resize(H);
  int res = 0;
  for(int i = 0; i < H; i++){
    cin >> s[i];
    for(int j = 0; j < W; j++){
      if(s[i][j] == '#') res++;
    }
  }
  if(bfs(0,0) == -1){
    cout << -1 << endl;
  }else{
    cout << H * W - bfs(0,0) - res << endl;
  }

}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (auto&& w : s) cin >> w;
  vector<int> a(26, 0), b(26, 0);
  for (int j = 0; j < s[0].size(); j++) {
    a[s[0][j] - 'a']++;
  }
  for (int i = 1; i < s.size(); i++) {
    b.assign(26, 0);

    for (int j = 0; j < s[i].size(); j++) {
      b[s[i][j] - 'a']++;
    }
    for (int j = 0; j < 26; j++) {
      a[j] = min(a[j], b[j]);
    }
  }
  string ans = "";
  for (int i = 0; i < 26; i++) {
    ans += string(a[i], 'a' + i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long n, m, k;
    cin >> n;
    int j;
    for (int i = n;; i++)
    {
        for (j = 2; j <= i; j++)
        {
            if (i % j == 0)
                break;
        }
        if (i == j)
        {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

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

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

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

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

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

int main() {
	ll n, d, x; cin >> n >> d >> x;
	vl a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		if (d % a[i] == 0) cnt += d / a[i];
		else cnt += d / a[i] + 1;
	}
	cout << cnt + x << endl;
}

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

using namespace std;

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

const int N = 100010;
const double eps = 1e-6;

int n, k;

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

    double res = 0.0;
    for(int i = 1; i <= n; i++)
    {
        int s = i;
        double rate = 1.0;
        while(s < k)
        {
            s *= 2;
            rate *= 0.5;
        }
        res += rate;
    }

    printf("%.12f\n", res / (double)n);
    return 0;
}


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

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

    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0));
    dp[0][0] = 1.0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i + 1; j++) {
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
            dp[i + 1][j + 1] += dp[i][j] * p[i];
        }
    }
    double ans = 0.0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += dp[n][i];
    }
    printf("%.9f\n", ans);
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }

ll m[1123456];

int main(){
    ll N=ii();
    ll g=0;
    REP(i,0,N){
        ll a=ii();
        g=__gcd(g,a);
        m[a]++;
    }
    bool pc=true;
    REP(i,2,1123456){
        ll x=0;
        for(ll j=i;j<1123456;j+=i){
            x+=m[j];
        }
        if(x>=2){
            pc=false;
            break;
        }
    }
    if(pc){
        ose("pairwise coprime");
        return 0;
    }
    if(g==1){
        ose("setwise coprime");
    }else{
        ose("not coprime");
    }

    return 0;
}

Measured memory_bytes: 11400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define pw(x) (1LL<<(x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl

using namespace std;

typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;


int main() {
#define TASK "A"
#ifdef HOME
  assert(freopen(TASK".in", "r", stdin));
#endif
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int bit = 0;
      bit ^= (j < a);
      bit ^= (i < b);
      cout << bit;
    }
    cout << endl;
  }




  return 0;
}



//
// Created by Ivan Belonogov on 2019-09-28.
//



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

int K[101];
char l[52];
map<char, int> idx;

void solve(int n) {
    for (int i = 0; i < n; i++) {
        cin >> K[i];
        K[i] %= 52;
    }
    string S;
    cin >> S;
    char ans;
    for (int i = 0; i < S.size(); i++) {
        int now_idx = idx[S[i]];
        cout << l[(52 + now_idx - K[i % n]) % 52];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 0; i < 26; i++) {
        l[i] = 'a' + i;
        idx[l[i]] = i;
    }
    for (int i = 26; i < 52; i++) {
        l[i] = 'A' + i - 26;
        idx[l[i]] = i;
    }
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        solve(N);
    }
    return 0;
}


Measured memory_bytes: 3184
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;

	vector <ll> A(N);
	vector <ll> B(N);
	vector <ll> C(N);
	for (int ii = 0; ii < N; ++ii) cin >> A[ii];
	for (int ii = 0; ii < N; ++ii) cin >> B[ii];
	for (int ii = 0; ii < N; ++ii) cin >> C[ii];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	ll ans = 0;
	for (int ii = 0; ii < N; ++ii){
		ll sum = 0;
		auto aitr = lower_bound(A.begin(), A.end(), B[ii]);
		ll anum = (aitr!=A.begin()) ? aitr - A.begin() : 0;

		auto citr = upper_bound(C.begin(), C.end(), B[ii]);
		ll cnum = C.end() - citr;

		ans += anum * cnum;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 5612
#include <iostream>
#include <stdio.h>
using namespace std;


int main(void){
    //printf("fdsfjaofiojaisdf");
    int x;
    int ans;
    
    for(int i = 0; i < 5; i ++){
        // i 0 ~~ 4
        cin >> x;
        if(x == 0) ans = i+1;
    }
    
    cout << ans;
    
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
int main()
{
   int a[3],c=0,d=0,i;
    for(i=0;i<3;i++){
       scanf("%d",&a[i]);
        if(a[i]==5)
        c++;
        else if(a[i]==7)
        d++;
    }
    if(c==2 && d==1)
    printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // 最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     // 最小公倍数

ll f(ll x, int c, int d)
{
  ll res = x;
  res -= x / c;
  res -= x / d;
  res += x / lcm(c, d);
  return res;
}

int main()
{
  ll a, b;
  int c, d;
  cin >> a >> b >> c >> d;
  ll ans = f(b, c, d) - f(a - 1, c, d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    VI A(N),B(M);
    set<int> mpa,mpb;
    REP(i,N)  {
        cin >> A[i];
        mpa.insert(A[i]);
    }
    REP(i,M) {
        cin >> B[i];
        mpb.insert(B[i]);
    }

    A.erase(unique(A.begin(),A.end()),A.end());
    B.erase(unique(B.begin(),B.end()),B.end());
    if(int(A.size()) != N || int(B.size()) != M){
        cout << 0 << endl;
        return 0;
    }
    LL ans = 1;
    for(int i = N*M; i >= 1; i--){
        if(mpa.find(i) != mpa.end() && mpb.find(i) != mpb.end()){

        }
        else if(mpa.find(i) != mpa.end()){ //Aだけで見つかった
            int cnt = 0;
            REP(j,M){
                if(B[j] >= i) cnt++;
            }
            ans = (ans * cnt) % MOD;
        }
        else if(mpb.find(i) != mpb.end()){ //Bだけで見つかった
            int cnt = 0;
            REP(j,N){
                if(A[j] >= i) cnt++;
            }
            ans = (ans * cnt) % MOD;
        }
        else{
            int cnta = 0, cntb = 0;
            REP(j,N){
                if(A[j] >= i) cnta++;
            }
            REP(j,M){
                if(B[j] >= i) cntb++;
            }
            ans = (ans * (cnta*cntb-(N*M-i))) % MOD;
        }

    }
    cout << ans << endl;




}


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

int main() {
  string a;
  cin >> a;
  int i,p,m;
  p = 0;
  m = 0;
  for (i = 0; i < 4; i++){
    if (a[i] == '+'){
      p += 1;
    }
    else{
      m += 1;
    }
  }
  cout << p-m << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N, temp, Ans = 0;
	vector<int> V;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> temp;
		V.push_back(temp);
	}
	for (int i = 0; i < N; i++) {
		cin >> temp;
		if (V[i] > temp) {
			Ans += (V[i] - temp);
		}
	}
	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long a,b,c,d,d1,ct=0,e,f,g,h;
    cin>>a;
    vector<long long>vc;
    c=a;
    while(c--)
    {
        cin>>b;
        vc.push_back(b);
        ct+=b;

    }
    if(ct%a==0)
    {
        e=0;
        d=ct/a;
        for(long long i=0; i<a; i++)
        {
            e=e+(vc[i]-d)*(vc[i]-d);
        }
      cout<<e;
    }
    else
    {

        e=0;f=0;
        d=ct/a;
        d1=d+1;
         for(long long i=0; i<a; i++)
        {
            e=e+(vc[i]-d)*(vc[i]-d);
            f=f+(vc[i]-d1)*(vc[i]-d1);
        }
        cout<<min(e,f);

    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int calc(int x){
    if(x % 2 == 0) return x/2;
    else return x*3+1;
}

int main(){
    int s; cin >> s;
    vector<int> a;
    a.push_back(s);
    map<int,int> m; m[s]++;
    int cnt = 0;
    while(1){
        int num = calc(a[cnt]);
        a.push_back(num);
        cnt++;
        if(m[num] != 0) break;
        else m[num]++;
    }
    cout << cnt+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
  char s[200010];
  int result = 0;
  scanf("%s",s);
  int n = strlen(s);
  for(int i = 0;i<n;i++){
    result += (int)(s[i] - '0');
  }
  if(result%9==0){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}

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

int main() {
  int N, sum = 0;
  cin >> N;
  for (int i = 0; i <= 30; i++) {
    for (int j = 0; j <= 15; j++) {
      if (4 * i + 7 * j == N)
        sum++;
    }
  }
  if (sum)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    int countre=0;
    for(int i=1;i<n;i++){
        if(s.at(i)=='E') countre++;
    }
    int min=countre;
    for(int i=0;i<n-1;i++){
        if(s.at(i)=='W'){
            countre++;
        }
        if(s.at(i+1)=='E'){
            countre--;
        }
        if(min>countre) min=countre;
    }
    cout<<min;
}

Measured memory_bytes: 900
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int i;
	int n;
	int sum = 0;
	cin >> n;

	for (i = 1; i <= n; i++) {
		sum += i;
	}

	cout << sum << endl;
	
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int N, M;
    multiset<int> A;

    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int a;
            cin >> a;
            A.insert(a);
        }
    }

    int result=0;
    for (int l = 0; l <= 30; ++l) {
        if(A.count(l) == N){
            result++;
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  int A[100] = {};
  REP(i,M) cin >> A[i];
  int i = 0;
  while(i < M && A[i] < X) i++;
  cout << min(i,M-i) << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;

fn main () {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let a:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		_ => panic!(""),
	};
	let b:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		_ => panic!(""),
	};
	let ar = [a+b, a-b, a*b];
	println!("{}", ar.iter().max().unwrap());
}

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

int main() {
  int h,w; cin >> h >> w;
  vector<vector<char>> s(h,vector<char>(w));
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> s[i][j];
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if((s[i][j]=='#')
         &&(i==0||s[i-1][j]=='.')
         &&(i==h-1||s[i+1][j]=='.')
         &&(j==0||s[i][j-1]=='.')
         &&(j==w-1||s[i][j+1]=='.')) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3628
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         HashMap<Long, Integer> map = new HashMap<Long, Integer>();
         long temp = N;
         if(temp%2 == 0)
         {
            int cnt = 0;
            while(temp%2 == 0)
            {
               temp /= 2;
               cnt++;
            }
            map.put(2L, cnt);
         }
         for(long i=3; i <= (long)(Math.sqrt(N)+0.000001); i+=2)
            if(temp%i == 0)
            {
               int cnt = 0;
               while(temp%i == 0)
               {
                  temp /= i;
                  cnt++;
               }
               map.put(i, cnt);
            }
         long res = 0L;
         if(temp > 2)
            res++;
         for(long key: map.keySet())
         {
            long low = 1L;
            long high = 40L;
            while(low != high)
            {
               long mid = (low+high+1)/2;
               if(mid*(mid+1)/2 > map.get(key))
                  high = mid-1;
               else
                  low = mid;
            }
            res += low;
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 33312