akhauriyash/Code-Regression huggingface dataset:
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int n, k;
    std::cin >> n >> k;
    std::vector<i64> a(n);
    rep(i, n) std::cin >> a[i];
    if(n < k) {
        std::cout << 0 << std::endl;
    } else {
        i64 tmp = 0;
        std::sort(a.begin(), a.end());
        rep(i, n - k) {
            tmp += a[i];
        }
        std::cout << tmp << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <cstdlib>
using namespace std;
int main()
{
    long long n,i;
    static long long ara[100002],t[100002];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>ara[i];
    t[0]=0;
    for(i=1;i<n;i++)
    {
        if(i==1)
            t[i]=abs(ara[i]-ara[i-1]);
        else
            t[i]=min(t[i-1]+abs(ara[i]-ara[i-1]),t[i-2]+abs(ara[i]-ara[i-2]));
    }
    cout<<t[n-1]<<endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int P[n];
  int cnt = 0;
  int min = INF;
  rep(i,n) {
    cin >> P[i];
    if(P[i]<=min){
      cnt++;
      min = P[i];
    }
  }
  cout << cnt <<endl;

}


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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


class BIT{
private:
  int n;
  VL bit;
public:
  BIT(int n_){
    n = n_;
    bit.assign(n+1, 0);
  }

  // return bit[0,i)
  LL max(int i){
    LL s = 0;
    while(i > 0){
      maxi(s, bit[i]);
      i -= i & -i;
    }
    return s;
  }

  void add(int i, LL x){
    ++i;
    while(i <= n){
      maxi(bit[i], x);
      i += i & -i;
    }
  }
};


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

  int N;
  cin >> N;
  VI hs(N);
  cin >> hs;
  VL xs(N);
  cin >> xs;

  BIT bit(N+2);
  REP(i,N){
    LL s = bit.max(hs[i]);
    bit.add(hs[i], s + xs[i]);
  }
  cout << bit.max(N+1) << endl;

  return 0;
}


Measured memory_bytes: 4224
import math

a, b, h, m = map(int, input().split())
ret = ""

# 角度
angle_h = h / 12 * 360  # 0～360
angle_h = angle_h + m / 60 * 30
angle_m = m / 60 * 360  # 0～360
angle = abs(angle_h - angle_m)
if angle > 180:
    angle = 360 - angle
#print("angle = {}".format(angle))

# 距離
test1 = pow(a, 2) + pow(b, 2)
#print("test1 = {}".format(test1))
test2 = 2 * a * b * math.cos(math.radians(angle))
#print("test2 = {}".format(test2))
ret = math.sqrt(test1 - test2)

print("{}".format(ret))

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

int main() {
	char c[1001] = {};

	cin >> c;
	int i = 0; 
	while (c[i]) {
		c[i] = (c[i] - 'A' - 3 + 26) % 26 + 'A';
		cout << c[i];
		i++;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1132
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll d, n;
  cin >> d >> n;
  if (n == 100) n = 101;
  ll ans = n;
  rep(i, d) ans *= 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def left(i)
    (i+1)*2-1
end

def right(i)
    (i+1)*2
end

def max_heapify(nodes, i)
    l = left(i)
    r = right(i)
    largest = i
    if l < nodes.length && nodes[l] > nodes[i]
        largest = l
    end
    if r < nodes.length && nodes[r] > nodes[largest]
        largest = r
    end
    if largest != i
        nodes[i],nodes[largest] = nodes[largest],nodes[i]
        max_heapify(nodes, largest)
    end
end

def reverse_heapify(nodes)
    i = nodes.length - 1
    while i > 0 do
        j = (i+1)/2-1
        if nodes[i] > nodes[j]
            nodes[i], nodes[j] = nodes[j], nodes[i]
        else
            break
        end
        i = j
    end
end

nodes = []
loop do
    operation=gets.chomp.split(" ")
    if operation[0] == "insert"
        k = operation[1].to_i
        nodes.push(k)
        reverse_heapify(nodes)
    elsif operation[0] == "extract"
        puts nodes[0]
        nodes[0] = -1
        max_heapify(nodes, 0)
    else
        break
    end
end



Measured memory_bytes: 18696
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L >=2019:
    ans = 0
else:
    if l < r:
        min = 100000000
        for i in range(l, r):
            for j in range(i+1,r+1):
                tmp = i*j%2019
                if tmp < min:
                    min = tmp
        ans = min
    else: # l > r:
        min = 100000000
        for i in range(l, r+2019):
            for j in range(i+1,r+2019+1):
                tmp = i*j%2019
                if tmp < min:
                    min = tmp
        ans = min

print(ans)


Measured memory_bytes: 9032
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    int l = log10(n);
    int x = 0;
    int res = 0;
    int a;
    while (pow(10, x+1) <= n) {
        a = int(log10(pow(10, x)));
        if (a % 2 == 0 || x == 0) res += (9 * pow(10, x));
        x++;
    }

    if (int(log10(n)) % 2 == 0) res += (n - pow(10, log10(pow(10, x))) + 1) ;

    cout << res << endl;
}

Measured memory_bytes: 4064
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int N; cin >> N;

  int cnt = 0;
  if (N < 10) {
    cnt = N;
  } else if (N < 100) {
    cnt = 9;
  } else if (N < 1000) {
    cnt = N-99+9;
  } else if (N < 10000) {
    cnt = 9 + 999 - 99;
  } else if (N < 100000) {
    cnt = 9 + 999 - 99 + N - 9999;
  } else {
    cnt = 9 + 999 - 99 + 99999 - 9999;    
  }

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    flags = [0] * n
    up = False
    prev = 1000
    for i, a in enumerate(A):
        if up:
            if a < prev:
                flags[i-1] = -1
                up = False
        else:
            if a > prev:
                flags[i-1] = 1
                up = True
        prev = a

    money = 1000
    kabu = 0
    for flag, a in zip(flags, A):
        if flag == 1:
            kabu += money // a
            money %= a

        elif flag == -1:
            money += kabu * a
            kabu = 0

    if kabu:
        money += A[-1] * kabu

    print(money)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9020
import java.util.*;

public class Main {

	public static void main(String[] args) {

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

		int n = s.length();
		int result = 0;

		for (int i = 0; i <= n - 1; i++) {
			String a = s.substring(i, i + 1);
			String b = t.substring(i, i + 1);
			//System.out.println(a);
			//System.out.println(b);

			if (a.equals(b)) {
				//System.out.println("OK " + result);
			} else {
				result++;
				//System.out.println("NG " + result);
			}
		}

		System.out.println(result);

	}
}

Measured memory_bytes: 55224
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>=(int)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

ll N, A, B, C, D;

bool solve() {
    REP(i, 0, N){
        if((A + i * C - (N - i - 1) * D) <= B && B <= (A + i * D - (N - i - 1) * C)){
            eprintf("%d\n", i);
            return true;
        }
    }

    return false;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> A >> B >> C >> D;
    cout << (solve() ? "YES" : "NO") << "\n";
    return 0;
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    string str;
    cin >> n >> str;
    int l = 0, r = n - 1;
    int ans = 0;
    while (l < r) {
        if (str[l] == 'R') {
            l++;
        } else if (str[r] == 'W') {
            r--;
        } else if (str[l] == 'W' && str[r] == 'R') {
            swap(str[l], str[r]);
            l++, r--;
            ans++;
        } 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3744
while 1:
   H, W = map(int, raw_input().split())
   if H == 0 and W == 0:
      break
   else:
      for i in range(H):
         ans = ""
         for j in range(W):
            if (i+j)%2 == 0:
               ans += "#"
            else:
               ans += "."
         print ans
      print ("")

Measured memory_bytes: 6384
#include<stdio.h>

int main() {
    long long int lli_CellHeight = 0;
    long long int lli_CellWidth  = 0;

    /* Standard Input */
    (void)scanf("%lld %lld", &lli_CellHeight, &lli_CellWidth);

    /* process */
    long long int lli_Ans = (lli_CellHeight * lli_CellWidth) / 2;
    if ((lli_CellHeight % 2 == 1) && (lli_CellWidth % 2 == 1)) {
        lli_Ans += 1;
    }
    if ((lli_CellHeight == 1) || (lli_CellWidth == 1)) {
        lli_Ans = 1;
    }

    /* Answer */
    (void)printf("%lld\n", lli_Ans);

    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

ll n;
void solve(map<ll,ll> m){
  for(auto &&e : m){
    if(e.se > n/2){
      cout << e.fi << endl;
      return ;
    }
  }
  cout << "NO COLOR" << endl;
  return ;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> n && n){
    ll k;
    map<ll,ll> m;
    rep(i,n){
      cin >> k;
      m[k]++;
    }
    solve(m);
  }
  return 0;
}

Measured memory_bytes: 7252
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

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

unsigned int len(unsigned int n)
{
    return n ? len(n/10)+1 : 0;
}

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

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

  sort(v.begin(), v.end());
  long double sum_ = 0;
  sum_ = (v[0] + v[1]) / 2.0;
  repd(i, 2, n) {
    // cout << sum_ << endl;
    sum_ = (sum_ + v[i]) / 2.0;
  }
  cout << sum_ << endl;
  return 0;
}


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

int main() {
  string s;
  int k;
  cin >> s >> k;

  vector<string> sub;
  for (int i = 0; i < s.size(); ++i) {
    for (int j = 1; j <= 5; ++j) {
      sub.push_back(s.substr(i, j));
    }
  }
  sort(sub.begin(), sub.end());
  unique(sub.begin(), sub.end());

  cout << sub[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, t, h, cnt, num, a[N], mx[N];
int main()
{
	int i;
//	freopen ("input.txt", "r", stdin);
	cin >> n >> t;
	for (i = 0; i <n; i++) {
		scanf ("%d", &a[i]);
	}
	for (i = n - 1; i >= 0; i--) {
		mx[i] = max(mx[i + 1], a[i]);
	}
	for (i = 0; i < n; i++) {
		num = mx[i] - a[i];
		if (num > h) {
			h = num;
			cnt = 1;
		} else if (num == h) {
			cnt++;
		}
	}
    cout << cnt << endl;
    return 0;
}


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

using namespace std;
#define ll long long
const ll INF=1e18;
const int N=1e5+5;
ll a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    for(int i=0;i<n;i++)
    {
        if(ans>INF/a[i])
        {
            ans=-1;
            break;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4396
a = input() 
b = input() 
a = int(a) 
b = b.split() 
b = [int(s) for s in b] 
c = 0 
flag = True 
while True:
    for i in range(a):
        if b[i] % 2 != 0:
            flag = False
        b[i] = b[i] / 2
    if flag == False:
        break     
    c += 1             
print(c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int x;
    cin >> x;
    cout << (1999-x)/200 +1<< endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3668
n = int(input())
s = input()
a = s.count("E") #1はs[0]の分
if s[0] == "E":
    a -= 1
ans = a
for i in range(n-1):
    if s[i] == "E":
        pass
    else:
        a += 1
    if s[i+1] == "E":
        a -= 1
    else:
        pass
    ans = min(ans,a)
print(ans)


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}


using bint = boost::multiprecision::cpp_int;

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  cin >> a;
  rep(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return;
    }
  }
  bint x = 1;
  rep(i, n) {
    x *= a[i];
    cerr << x << endl;
    if (x > 1000000000000000000LL) {
      cout << -1 << endl;
      return;
    }
  }
  cout << x << endl;
}


Measured memory_bytes: 4044
n = int(input())
a = list(map(int, input().split()))

ans = "APPROVED"

for i in range(n):
  if a[i] % 2 == 0:
    if (a[i] % 3 != 0) and (a[i] % 5 != 0):
      ans = "DENIED"
  
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void) {
	int N, X, T;

	scanf("%d %d %d", &N, &X, &T);

	if (N != X) {
		if (N % X != 0) {
			T = (N / X + 1)*T;
		}
		else {
			T = (N / X )*T;
		}
	}
	else {
		T = T;
	}

	printf("%d",T);

	return 0;
}

Measured memory_bytes: 1728
use proconio::input;
use proconio::marker::Usize1;
use itertools::Itertools;
use std::cmp::max;
fn main() {
    input! {
        n:usize,m:usize,q:usize,
        qs: [(Usize1, Usize1, usize, usize); q]
    };
    let mut ans = 0;
    for A in (1..m+1).combinations_with_replacement(n) {
        let mut sm = 0;
        for &(a,b,c,d) in &qs {
            if A[b]-A[a] == c {
                sm += d;
            }
        }
        ans = max(ans, sm);
    }
    println!("{}", ans);
}

Measured memory_bytes: 2192
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

bool check(vector<int> a){
  REP(i,(int)a.size()-1){
    if(a[i] > a[i+1]) return false;
  }
  return true;
}

bool f(vector<int> a, int i, int j){
  swap(a[i], a[j]);
  return check(a);
}


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

  int n;
  while(cin >> n){
    vector<int> p(n); cin >> p;

    bool ans = false;

    REP(i,n){
      REP(j,n){
        if(f(p,i,j)) ans = true;
      }
    }
    

    cout << (ans ? "YES" : "NO") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
vector<char> l,r;
string str;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q,t,f;
    char a;
    cin>>str;
    bool flag=true;
	cin>>q;
	while(q--){
		cin>>t;
		if(t==1){
			flag=!flag;
		}
		else{
			if(flag){
				cin>>f>>a;
				if(f==1){
					l.push_back(a);
				}
				else{
					r.push_back(a);
				}
			}
			else{
				cin>>f>>a;
				if(f==1){
					r.push_back(a);
				}
				else{
					l.push_back(a);
				}
			}
		}
	}
	if(flag){
		for(int i=l.size()-1;i>=0;i--)cout<<l[i];
		cout<<str;
		for(int i=0;i<r.size();i++)cout<<r[i];
		cout<<'\n';
	}
	else{
		for(int i=r.size()-1;i>=0;i--)cout<<r[i];
		reverse(str.begin(),str.end());
		cout<<str;
		for(int i=0;i<l.size();i++)cout<<l[i];
		cout<<'\n';
	}
    return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl; 
 	return 0;
}







Measured memory_bytes: 256
// Template by [thunder_blade]
// IIIT ALLAHABAD
// includes :)

#include<bits/stdc++.h>
using namespace std;
#define TEST  int test_case; cin>>test_case; while(test_case--)
#define all(v) (v).begin(),(v).end()
#define pii pair<int,int>
#define fi  first
#define se  second
#define pb push_back
#define mp make_pair
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);  cin.tie(0);  cout.tie(0);
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define pf(x) printf("%f\n",x)
#define ps(x) printf("%s\n",x)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%f",&x)
#define ss(x) scanf("%s",x)
#define pis(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pfs(x) printf("%f ",x)
#define pss(x) printf("%s ",x)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007

int start[500005], far[500005], color[500005], dist[500005][40];
vector<int>adj[500005];

int main()
{
	int i,j;
	int n,m;
	si(n), si(m);
	FOR(i,0,m){
		int u,v;
		si(u), si(v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int q;
	si(q);
	queue<pii>que;
	FOR(i,1,q+1){
		int u,d,c;
		si(start[i]), si(far[i]), si(color[i]);
		dist[start[i]][far[i]] = i;
		que.push({start[i], far[i]});
	}

	while(!que.empty())
	{
		int node = que.front().fi;
		int level = que.front().se;
		int cost = dist[node][level];
		que.pop();

		if(level){
			level--;
			FOR(i,0, adj[node].size())
				if(dist[adj[node][i]][level] < cost){
					dist[adj[node][i]][level] = cost;
					que.push({adj[node][i], level});
				}
		}
	}

	int maxi = 0;
	FOR(i,1,n+1){
		maxi = 0;
		FOR(j,0,20){
			maxi = max(maxi, dist[i][j]);
		}
		pi(color[maxi]);

	}


	return 0;
}

Measured memory_bytes: 46840
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

int N, A[MAX_N], B[MAX_N], cp_val[MAX_N << 1];
int cnt[MAX_N << 1], fa[MAX_N];

int find(int x) {
  return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main() {
  scanf("%d", &N);
  int xor_val = 0, tot = 0;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
    xor_val ^= A[i], cp_val[++tot] = A[i];
  }
  A[N + 1] = xor_val; cp_val[++tot] = A[N + 1];
  
  xor_val = 0;
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &B[i]);
    xor_val ^= B[i], cp_val[++tot] = B[i];
  }
  B[N + 1] = xor_val, cp_val[++tot] = B[N + 1];

  sort(cp_val + 1, cp_val + tot + 1);
  tot = unique(cp_val + 1, cp_val + tot + 1) - cp_val - 1;

  N++;
  for (int i = 1; i <= N; ++i) {
    A[i] = lower_bound(cp_val + 1, cp_val + tot + 1, A[i]) - cp_val;
    B[i] = lower_bound(cp_val + 1, cp_val + tot + 1, B[i]) - cp_val;
    cnt[A[i]]--, cnt[B[i]]++;
  }
  
  for (int i = 1; i <= tot; ++i)
    if (cnt[i]) {
      puts("-1");
      return 0;
    }

  static bool vis[MAX_N];
  for (int i = 1; i <= N; ++i) fa[i] = i;

  int res = 0;
  for (int i = 1; i < N; ++i) 
    if (A[i] != B[i]) {
      vis[A[i]] = vis[B[i]] = 1;
      if (find(A[i]) != find(B[i])) fa[find(A[i])] = find(B[i]);
      res++;
    }
  vis[A[N]] = vis[B[N]] = 1;
  for (int i = 1; i <= tot; ++i)
    if (vis[i] && find(i) == i) res++;

  printf("%d\n", res - 1);
  return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String str = sc.next();
        int num = sc.nextInt();
        while(sc.hasNext()){
            String operation = sc.next();
            if (operation.equals("print")){
                int a = sc.nextInt();
                int b = sc.nextInt();
                System.out.println(str.substring(a, b + 1));
            } else if (operation.equals("reverse")){
                int a = sc.nextInt();
                int b = sc.nextInt();
                int point = b - a + 1;
                char arr[] = str.toCharArray();
                for (int i = 0; i < point / 2; i++){
                    char tmp = arr[a + i];
                    arr[a + i] = arr[b - i];
                    arr[b - i] = tmp;
                }
                str = new String(arr);
            } else {
                int a = sc.nextInt();
                int b = sc.nextInt();
                String part = sc.next();
                char arr[] = str.toCharArray();
                char partArr[] = part.toCharArray();
                int count = 0;
                for (int i = 0; i < arr.length; i++){
                    if (i >= a && i <= b){
                        arr[i] = partArr[count++];
                    }
                }
                str = new String(arr);
            }
        }
    }
}



Measured memory_bytes: 29424
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int H, W, K, A[309][309], num;
int cnt[309];
char c[309][309];

void solve(int cl, int cr) {
	vector<int> P;
	for (int i = cl; i <= cr; i++) {
		for (int j = 1; j <= W; j++) {
			if (c[i][j] == '#') P.push_back(j);
		}
	}
	sort(P.begin(), P.end());

	for (int i = 0; i < P.size(); i++) {
		int v1 = 1, v2 = W;
		if (i >= 1) v1 = P[i - 1] + 1;
		if (i < (int)P.size() - 1) v2 = P[i];

		num++;
		for (int j = cl; j <= cr; j++) {
			for (int k = v1; k <= v2; k++) A[j][k] = num;
		}
	}
}

int main() {
	cin >> H >> W >> K;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> c[i][j];
			if (c[i][j] == '#') cnt[i]++;
		}
	}

	vector<int> vec;
	for (int i = 1; i <= H; i++) { if (cnt[i] >= 1) vec.push_back(i); }
	for (int i = 0; i < vec.size(); i++) {
		int v1 = 1, v2 = H;
		if (i >= 1) v1 = vec[i - 1] + 1;
		if (i < (int)vec.size() - 1) v2 = vec[i];

		solve(v1, v2);
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (j >= 2) cout << " "; cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std; 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define length size()
#define int long long
#define ll long long
const int MOD = 1000000007;
const int MAX = 510000;
template<typename T> string join(vector<T> &vec ,const string &sp){
    int si = vec.length;
    if(si==0){
        return "";
    }else{
        stringstream ss;
        rep(i,si-1){
            ss << vec[i] << sp;
        }
        ss << vec[si - 1];
        return ss.str();
    }
}
signed main(void){
  	int n;
  cin >> n;
  rep(i,n){
  cout << "ACL";
  }
  cout << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			a++;
		}
		if(a!=0&&s[i]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char ch[250] = { 0 };
	char a[250] = { 0 };
	int h;
	int i, j, k, l, n, m;


	while (1) 
	{
		i = 0;
		while (1) {
			scanf("%c", &ch[i]);
			if (ch[i] == '\n') 
			{
				break;
			}
			i++;
		}

		if (i == 1 && ch[0] == '-')
		{
			break;
		}

		scanf("%d", &m);

		for (j = 0; j < m; j++) 
		{
			scanf("%d", &h);

			for (k = 0; k < i - h; k++) 
			{
				a[k] = ch[h + k];
			}
			for (k = 0; k < h; k++) 
			{
				a[i - h + k] = ch[k];
			}
			for (k = 0; k < i; k++) 
			{
				ch[k] = a[k];
			}
		}
		for (k = 0; k < i; k++) 
		{
			printf("%c", ch[k]);
		}
		printf("\n");
		scanf("%c", &ch[0]);
	}
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<char, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int main(){
	char t;
	while(cin >> t){
		P c[4][13];
		int fp = 0;
		int ns = 0, ew = 0;
		if(t == '#') break;
		rep(i,4) rep(j,13){
			int num = 0;
			string str;
			cin >> str;
			c[i][j].fi = str[1];
			if(str[0] == 'T') c[i][j].sec = 10;
			else if(str[0] == 'J') c[i][j].sec = 11;
			else if(str[0] == 'Q') c[i][j].sec = 12;
			else if(str[0] == 'K') c[i][j].sec = 13;
			else if(str[0] == 'A') c[i][j].sec = 14;
			else c[i][j].sec = str[0]-'0';
		}
		rep(i,13){
			bool x = false;
			int tmp = 0;
			rep(j,4) if(c[j][i].fi == t) x = true;
			if(x){
				rep(j,4){
					if(c[j][i].fi != t) continue;
					if(tmp < c[j][i].sec){
						fp = j;
						tmp = c[j][i].sec;
					}
				}
			} else{
				rep(j,4){
					if(c[j][i].fi != c[fp][i].fi) continue;
					if(tmp < c[j][i].sec){
						fp = j;
						tmp = c[j][i].sec;
					}
				}
			}
			if(fp%2) ew++;
			else ns++;
		}
		if(ns > ew) cout << "NS " << ns-6 << endl;
		else cout << "EW " << ew-6 << endl;
	}
}

Measured memory_bytes: 1188
#include"bits/stdc++.h"
using namespace std;

int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 - y2 + y1 << endl;
	cout << x2 - x1 + y2 << endl;
	cout << x1 - y2 + y1 << endl;
	cout << x2 - x1 + y1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;

int main(){
  ll h,w;
  cin >> h >> w;
  vector<vector<ll>>c(10,vector<ll>(10));
  for(int i=0; i<=9; i++){
   for(int j=0; j<=9; j++){
    cin >> c[i][j]; 
   }
  }
  
  vector<vector<ll>>a(h,vector<ll>(w));
  for(int i=0; i<h; i++){
   for(int j=0; j<w; j++) cin >> a[i][j]; 
  }
  
  for(int k=0; k<=9; k++){
    for(int i=0; i<=9; i++){
      for(int j=0; j<=9; j++){
        c[i][j]=min(c[i][k]+c[k][j],c[i][j]);
      }
    }
  }
  
  ll ans=0; 
  for(int i=0; i<h; i++){
   for(int j=0; j<w; j++){
     if(a[i][j]==-1) continue;
     ans+=c[a[i][j]][1]; 
   }
  }
  
  cout << ans << endl;
  
  return 0;
  
  
}
  
  


Measured memory_bytes: 512
using System;
using System.IO;

class Solve{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var answer = int.MaxValue;
        for (int i = 0; i < N; i++){
            var ai = Convert.ToString(A[i],2);
            if (ai[^1] == '1'){
                answer = 0;
                break;}
            var count = ai.Length - ai.LastIndexOf('1') - 1;
            answer = count < answer ? count : answer;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27696
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
 

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	for (int z=1;z<=n;z++){
		if (floor(ld(z)*ld(1.08)) == n){
			cout << z << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a == c){
        cout << "No";
    }else if(a == b && a != c){
        cout << "Yes";
    }else if(a != b && a == c){
        cout << "Yes";
    }else if(a != b && b == c){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int a[N],b[N];
int n;
bool check(int x)
{
    int L=1,R=2*n-1;
    for(int i=1;i<=2*n-1;i++)
        b[i]=(a[i]>=x);
    for(int i=1;i<n;i++)
        if(b[i]==b[i+1])
            L=i+1;
    for(int i=2*n-1;i>n;i--)
        if(b[i]==b[i-1])
            R=i-1;
    if(n-L<R-n)
        return (b[L]==1);
    else
        return (b[R]==1);
}
int main()
{
    cin>>n;
    for(int i=1;i<=2*n-1;i++)
        cin>>a[i];
    int low=1,high=2*n-1,ans=0;
    while(low<=high)
    {
        int mid=(low+high)/2;
        if(check(mid))
        {
            low=mid+1;
            ans=mid;
        }
        else
            high=mid-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int dp[1000001];
int solve(int src)
{
    if(dp[src]!=-1)
    {
        return dp[src];
    }
    int bestchild=0;
    for(int child: graph[src])
    {
        bestchild = max(bestchild,solve(child));
    }
    int leaf=0;
    if(graph[src].size()==0)
    {
        leaf=1;
    }
    return dp[src] = leaf ? 0 : 1 + bestchild;

}

int main() {
    int n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans = max(ans,solve(i));
    }
    cout<<ans<<endl;
}


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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cr = 0,cb = 0,cg = 0;
  rep(i,n){
    if(s[i] == 'R') cr++;
    if(s[i] == 'B') cb++;
    if(s[i] == 'G') cg++;
  }
  ll ans = (ll)cr*cb*cg;
  
  int res = 0;
  rep(i,n)rep(j,n){
    if(i+j+j>=n) continue;
    if(s[i] != s[i+j] && s[i+j] != s[i+j+j] && s[i] != s[i+j+j]) res++;
  }
  
  ans -= res; 
  cout << ans << endl;
}


Measured memory_bytes: 3624
a, b, c, d = map(int, input().split())

ab = abs(a - b)
bc = abs(b - c)
ac = abs(a - c)

if (ab <= d) and (bc <= d):
    print("Yes")

elif (ab+bc <= d):
    print("Yes")

elif (ac <= d):
    print("Yes")

else:
    print("No")


Measured memory_bytes: 9188
import scala.io.StdIn._
object Main extends App {
  val k = readInt()
  val isono = Array.tabulate(k){_ ⇒ readLine.trim}
  val nakajima = Array.tabulate(k){_ ⇒ readLine.trim}
  println(
    isono.zip(nakajima).foldLeft(new Continue: State){
      case (c, (i, n)) ⇒ c.next(Pose.parse(i), Pose.parse(n))
    } match {
      case Continue(_, _) ⇒ "Hikiwake-kun"
      case WonBy(Isono) ⇒ "Isono-kun"
      case WonBy(Nakajima) ⇒ "Nakajima-kun"
    }
  )
}

sealed trait State {
  def next(isonos: Pose, nakajimas: Pose): State = this
}
case class Continue private (isono: Int, nakajima: Int) extends State {
  def this(){this(0, 0)}

  override def next(isonos: Pose, nakajimas: Pose): State = {
    (isonos, nakajimas) match {
      case (Attack, Attack) if isono == nakajima ⇒ new Continue()
      case (Attack, Attack) ⇒ WonBy(if (isono > nakajima) Isono else Nakajima)
      case (Attack, _) if isono == 0 ⇒ WonBy(Nakajima)
      case (_, Attack) if nakajima == 0 ⇒ WonBy(Isono)
      case (Attack, Defence) ⇒ if (isono == 5) WonBy(Isono) else new Continue(0, nakajima)
      case (Defence, Attack) ⇒ if (nakajima == 5) WonBy(Nakajima) else new Continue(isono, 0)
      case (Attack, Charge) ⇒ WonBy(Isono)
      case (Charge, Attack) ⇒ WonBy(Nakajima)
      case _ ⇒ new Continue(if (isonos == Charge && isono < 5) isono + 1 else isono, if (nakajimas == Charge && nakajima < 5) nakajima + 1 else nakajima)
    }
  }
}
case class WonBy(player: Player) extends State

sealed trait Player
object Isono extends Player
object Nakajima extends Player
sealed trait Pose
object Pose{
  def parse(arg: String): Pose = {
    arg match {
      case Attack() ⇒ Attack
      case Defence() ⇒ Defence
      case Charge() ⇒ Charge
      case _ ⇒ ???
    }
  }
}
object Attack extends Pose {
  def unapply(arg: String): Boolean = arg == "kougekida"
}
object Defence extends Pose {
  def unapply(arg: String): Boolean = arg == "mamoru"
}
object Charge extends Pose {
  def unapply(arg: String): Boolean = arg == "tameru"
}


Measured memory_bytes: 44220
#include<iostream>

using namespace std;

int main() {

    int miss = 0, cur;
    int n;

    cin >> n;

    for(int i = 0; i < n; i++) {
        cin >> cur;
        if ( cur != i + 1) {
            miss++;
        }
    }

    string ans = (miss <= 2) ? "YES" : "NO";
    cout << ans << endl;

    return 0;
}


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

int main() {
    int h, w, k, h_options, w_options, k_count, count = 0;
    char c;
    vector<vector<bool>> a;
    cin >> h >> w >> k;
    h_options = 1;
    w_options = 1;
    h_options <<= h;
    w_options <<= w;
    for (int i = 0; i < h; i++) {
        a.push_back(vector<bool>(0, false));
        for (int j = 0; j < w; j++) {
            cin >> c;
            if (c == '.') {
                a[i].push_back(0);
            }
            else { // c == '#'
                a[i].push_back(1);
            }
        }
    }
    for (int i = 0; i < h_options; i++) {
        for (int j = 0; j < w_options; j++) {
            k_count = 0;
            for (int x = 0; x < h; x++) {
                for (int y = 0; y < w; y++) {
                    if ((i >> x) & 1 && (j >> y) & 1 && a[x][y])
                    {
                        k_count++;
                    }
                }
            }
            if (k_count == k) {
                count++;
            }
        }
    }
    cout << count;
    return 0;
}

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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

int main(){
  int r;
  cin >> r;
  cout << pow(r,2) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int n;cin>>n;
    V<ll>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    map<ll,int>m;
    for(int i=0;i<n;i++){
        m[a[i]]++;
    }
    int q;cin>>q;
    while(q--){
        int k;cin>>k;
        if(m[k]){
            cout<<1<<endl;

        }
        else cout<<0<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 22376
#include <bits/stdc++.h>
 using namespace std;
 int main(){
     int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
     int b,c;
     cin>>b>>c;
     if(a[b]==a[c]){
         cout<<"Yes";
     }
     else{
        cout<<"No";
     }
  }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <climits>
using namespace std;
#define ll long long
const ll N = 2e5+507, N1 = 1e6+107;
ll n,i,maxx,nr,j,a[N],f[N1];
bitset <N1> g;
int main ()
{
   cin>>n;
   for (i=1;i<=n;++i)
       cin>>a[i],f[a[i]]++;
   sort(a+1,a+n+1);
   maxx=a[n];
   for (i=1;i<=n;++i)
   {
       for (j=2;j<=maxx/a[i];++j)
            g[a[i]*j]=1;
   }
   for (i=1;i<=n;++i)
       if (f[a[i]]==1 && !g[a[i]]) nr++;
   cout<<nr<<"\n";
}



Measured memory_bytes: 12892