akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	cin >> n;
	int k = n % 100;
	n /= 100;
	//n回でkを達成できるか
	if (k > n * 5) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int c=0;

void bubbleSort(int a[],int n){
  bool flag=1;
  while(flag){
    flag=0;
    for(int j=n-1;j>0;j--){
      if(a[j]<a[j-1]){
        int t=a[j];
        a[j]=a[j-1];
        a[j-1]=t;
        c++;
        flag=1;
      }
    }
  }
}
int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  bubbleSort(a,n);
  for(int i=0;i<n-1;i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << '\n';
  cout << c <<endl;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
ll n;
ll fac[100005];
ll rfac[100005];
ll ans;
ll x[100005];
ll f(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

int main() {
  cin >> n;

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

  fac[0] = 1;
  
  for(ll i = 1; i <= n; i++) {
    fac[i] = fac[i-1] * i % mod;
  }
  for(ll i = 1; i <= n; i++) rfac[i] = f(i,mod-2);
  ll tmp = 0;
  
  for(ll i = 1; i < n; i++) {
    tmp += fac[n-1] * rfac[i] % mod;
    tmp %= mod;
    ans = (ans + tmp * (x[i] - x[i-1]) % mod) % mod;
  }
   
    // cout << fac[n-1] * rfac[i] % mod << endl;
  

  cout << ans << endl;
			       

  
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)

const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 1e9 + 12;

vector<int> dp, v;
int n,k;
int memo(int i=n){
    if(i <= 1) return 0;
    if(dp[i]!=INF)
        return dp[i];
    int ans = memo(i-1) + abs(v[i] - v[i-1]);
    if(i > 2)
        ans = min(ans, memo(i-2) + abs(v[i] - v[i-2]));
    return dp[i] = ans;
}

void solve() {
    cin >> n;
//    cin >> k;
    v.resize(n+1);
    dp.assign(n+1,INF);
    for(int i=1; i<=n; i++){
        cin >> v[i];
    }
    cout << memo();
//    dp[1] = 0;
//    for(int i=2; i<=n; i++){
//        for(int j=1;j<=k;j++){
//            if(i-j < 1) continue;
//            dp[i] = min(dp[i], dp[i-j] + abs(v[i] - v[i-j]));
//        }
//    }
//    cout << dp[n] << endl;
}

signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
}


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

int main()
{
    for (int i = 0; i < 10000; ++i)
    {
        int x = 0;
        cin >> x;
        if (x == 0)
            break;
        cout << "Case " << i + 1 << ": " << x << endl;
    }
    return 0;
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> n(4);
  bool one,four,seven,nine;
  one = four = seven = nine = false;
  for(int i = 0;i <4;i++){
    int n;
    cin >> n; 
    if(n == 1) one = true;
    if(n == 4) four = true;
    if(n == 7) seven = true;
    if(n == 9) nine = true;
  }
  if(one == true && four == true && seven == true && nine == true) cout << "YES" << endl;
  else cout << "NO" << endl;
}
    

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

import heapq
from collections import defaultdict
h = []
heapq.heapify(h)

n, m, s = list(map(int, input().split()))
a, b = [[None] * m for _ in range(2)]
c, d = [[None] * n for _ in range(2)]

ns = defaultdict(set)
uv2e = {}
for i in range(m):
    u,v,a[i],b[i] = list(map(int, input().split()))
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
for i in range(n):
    c[i], d[i] = list(map(int, input().split()))

maxs = max(a)*(n-1)
s = min(s, maxs)
state = (0, 0, s) # (距離, ノード, 銀貨枚数)
ans = [[None] * (maxs+1) for _ in range(n)]
heapq.heappush(h, state)
count = 0
while h:
    count += 1
    dd, u, ss = heapq.heappop(h)
#     print(dd, u, ss)
    if ans[u][ss] is not None and ans[u][ss] <= dd:
        continue
    ans[u][ss] = dd
    
    # グラフの隣接点
    for v in ns[u]:
        e= uv2e[u,v]
        if ss<a[e] or ans[v][ss-a[e]] is not None:
            continue
        heapq.heappush(h, (dd + b[e], v, ss-a[e]))
    # 両替
    if ss+c[u] <= maxs:
        heapq.heappush(h, (dd + d[u], u, ss+c[u]))
    elif ss < maxs:
        heapq.heappush(h, (dd + d[u], u, maxs))

for item in ans[1:]:
    print(min(item))


Measured memory_bytes: 125592
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

class Main {
  private static void solve(int n, int[] a) {
    int[] ax = new int[n + 1];
    for (int i = 1; i <= n; i++) {
      ax[i] = a[i - 1];
    }
    int[] b = new int[n + 1];
    List<Integer> balls = new ArrayList<>();
    for (int i = n; i > 0; i--) {
      int j = 2;
      int c = 0;
      while (i * j <= n) {
        c += b[i * j];
        j++;
      }
      if (c % 2 == ax[i]) {
        b[i] = 0;
      } else {
        b[i] = 1;
        balls.add(i);
      }
    }
    System.out.println(balls.size());
    if (balls.size() == 0) {
      return;
    }
    StringBuilder sb = new StringBuilder();
    for (int i = balls.size() - 1; i >= 0; i--) {
      sb.append(balls.get(i));
      if (i != 0) {
        sb.append(" ");
      }
    }
    System.out.println(sb.toString());
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] a = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    sc.close();
    solve(n, a);
  }
}

Measured memory_bytes: 59188
import scala.io.StdIn.readLine

object Main extends App {
  val word = readLine()
  var count = 0
  var continue = true
  while (continue) {
    val line = readLine()
    if (line == "END_OF_TEXT") continue = false
    else line.split(" ").foreach(eachWord => if (eachWord.equalsIgnoreCase(word)) count += 1)
  }
  println(count)
}



Measured memory_bytes: 43696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  vector<int> y(n);
  vector<vector<int>> xy(n);
  for(int i=0;i<n;i++){
    cin>>x.at(i)>>y.at(i);
    xy.at(i)={x.at(i),y.at(i)};
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  sort(xy.begin(),xy.end());
  vector<vector<int>> s(n+1,vector<int>(n+1,0));
  for(int p=0,i=0;i<n;i++){
    for(int j=0;j<n;j++){
      s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j];
      if(p<n&&xy.at(p).at(0)==x.at(i)&&xy.at(p).at(1)==y.at(j)){
        s[i+1][j+1]++;
        p++;
      }
    }
  }
  map<int64_t,int> m;
  for(int il=0;il<n-1;il++){
    for(int jl=0;jl<n-1;jl++){
      for(int ig=il+1;ig<n;ig++){
        for(int jg=jl+1;jg<n;jg++){
          int64_t k=(int64_t)(x[ig]-x[il])*(y[jg]-y[jl]);
          m[k]=max(m[k],s[ig+1][jg+1]-s[il][jg+1]-s[ig+1][jl]+s[il][jl]);
        }
      }
    }
  }
  int64_t a;
  for(auto d:m){
    if(d.second>=k){
      a=d.first;
      break;
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 97320
from decimal import Decimal
n,k=map(int,input().split())
ans=0
ans+=Decimal(max(0,(n+1-k))/n)
for i in range(1,min(k,n+1)):
    tmp=i
    tt=Decimal(1/n)
    while 0<tmp<k:
        tmp*=2
        tt=Decimal(tt/2)
        if tmp>=k:
            ans+=Decimal(tt)
print(Decimal(ans))

Measured memory_bytes: 10048
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

long long pow(long long a, int n)
{
    long long ans = 1;
    for(int i=0; i<n; ++i)
        ans *= a;
    return ans;
}

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

    for(long long a=0; ; ++a){
        for(long long b=-a; b<=a; ++b){
            for(int i=0; i<2; ++i){
                if(pow(a, 5) - pow(b, 5) == x){
                    cout << a << ' ' << b << endl;
                    return 0;
                }
                a *= -1;
            }
        }
    }
}


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

int main(){
  
  long long n;
  long long flag=0;
  cin >> n;
  vector<string> a(n);
  set<string> b;
  for(int i=0; i<n;i++){
    cin >> a[i];
    b.insert(a[i]);
  }
  if(b.size()!=n) flag=1;
  
  for(int i=0; i<n-1; i++){
    if(a[i+1][0]!=a[i][a[i].size()-1]){
      flag=1;
      break;
    }
  }
  if(flag==1) cout << "No" << endl;
  else cout << "Yes" << endl;
  
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

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

  string S;
  cin >> S;
  auto sa = suffix_array(S);
  auto lcp = lcp_array(S, sa);

  int64 res = S.size() - sa[0];
  REP(i, lcp.size()) {
    res += S.size() - sa[i+1] - lcp[i];
  }
  cout << res << endl;
}



Measured memory_bytes: 15592
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        long sum = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            sum += x;
            if (map.containsKey(x)) {
                map.put(x, map.get(x) + 1);
            } else {
                map.put(x, 1);
            }
        }
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (map.containsKey(a)) {
                int x = map.get(a);
                sum += (long)(b - a) * x;
                map.remove(a);
                if (map.containsKey(b)) {
                    map.put(b, map.get(b) + x);
                } else {
                    map.put(b, x);
                }
            }
            sb.append(sum).append("\n");
        }
       System.out.print(sb);
    }
}

Measured memory_bytes: 69332
/**
 * Title: D - Megalomania
 * Url: https://atcoder.jp/contests/abc131/tasks/abc131_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> works;
    for(int i=0; i<n; i++) {
        int ai, bi; cin >> ai >> bi;
        works.push_back(make_pair(bi, ai));
    }
    // O(NlogN)
    sort(works.begin(), works.end());

    // Simulation O(N)
    int t = 0;
    for(auto w:works) {
        if(t>w.first-w.second) {
            cout << "No" << endl;
            return 0;
        }
        t += w.second;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>

using namespace std;


int main(){
    int A, B;
    
    cin >> A >> B;
    
    int x = 0;
    
    x = (A * B) % 2;
    
    if(x == 1){
        cout << "Yes"<< endl;
    } else {
        cout << "No" << endl;
    }
    
    return  0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i=0,s;
  cin>>s;
  set<int> se;
  auto p=se.insert(0);
  cin>>s;
  while(1){
    i++;
    p=se.insert(s);
    if(!p.second)break;
    switch(s%2){
      case 0:
        s/=2;
      break;
      case 1:
        s=s*3+1;
      break;
    }
  }
  cout << i;
  return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int A[n], B[n], C[n - 1];
	for (int i = 0; i < n; i++)
		cin >> A[i];
	for (int i = 0; i < n; i++)
		cin >> B[i];
	for (int i = 0; i < n - 1; i++)
		cin >> C[i];
	int ans = 0;
	for (int i = 0; i < n; i++){
		ans += B[A[i] - 1];
		if (i != n - 1 && A[i + 1] == A[i] + 1)
			ans += C[A[i] - 1];
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int x;
int main(){
	getint(x);
	if (x<1200) puts("ABC");
	else puts("ARC");
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

int X, Y;

bool solve() {
    REP (t, 200) REP (k, 200) {
        if (t+k == X && t * 2 + k * 4 == Y) return true;
    }
    return false;
}

int main() {
    cout << fixed << setprecision(15);
    cin >> X >> Y;
    Yes(solve());
}

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

using namespace std;

//defines
typedef long long ll;

using namespace std;

double pi=1.57079632679489661923;
ll modu=1e9+7;

ll t=1,n=1,q;

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

    cin>>n;
    vector<int> arr(n); for(int i=0; i<n; i++) cin>>arr[i]; sort(arr.begin(), arr.end());
    int ans=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k]){
                    if( arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j] && arr[j]+arr[k]>arr[i]) ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}
/*
10
5 4
8 1 7 2
1 3
2 4
3 3
*/


Measured memory_bytes: 3640
def main():
    import math

    N = int(input())
    
    ans_list = [0 for i in range(N)]
    
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):

                left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                if (left_eq <= N):
                    ans_list[left_eq - 1] += 1
    
    for i in range(N):
        print(ans_list[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rer(i,n) for(int i=max(0,n-1);i<min(10,n+2);i++)
bool t[12][10][10],d[12][10][10];
int dx[12]={-2,-2,-2,-1,0,1,2,2,2,-1,0,1};
int dy[12]={1,0,-1,2,2,2,1,0,-1,-2,-2,-2};
int n,x,y;
int main(){
	while(cin>>y>>x&&x+y){
	cin>>n;
	for(int i=0;i<=n;i++){
		rep(j,10)rep(k,10){
			t[i][j][k]=false;
			d[i][j][k]=false;
		}
	}
	d[0][y][x]=true;
	for(int i=1;i<=n;i++){
		cin>>y>>x;
		rer(j,y)rer(k,x)t[i][j][k]=true;
	}
	for(int u=0;u<n;u++){
		rep(i,10)rep(j,10){
			if(d[u][i][j]){
				rep(k,12){
					y=dy[k]+i,x=dx[k]+j;
					if(y>=0&&y<10&&x>=0&&x<10){
						if(t[u+1][y][x]==true){
							d[u+1][y][x]=true;
						}
					}
				}
			}
		}
	}
	bool ok=false;
	rep(i,10)rep(j,10)if(d[n][i][j])ok=true;
	if(ok)cout<<"OK"<<endl;
	else cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,-1,1,-1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
lol n,m,k,r,q;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol x,y;
  cin >>x>>y;
  for(int i=0;i<=y/2;i++){
    for(int j=0;j<=y/4;j++){
      if(i*2+j*4==y&&i+j==x){
	cout <<"Yes\n";
	return (0);
      }
    }
  }
  cout <<"No\n";
  return (0);
}


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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int a,b,c; cin >> a >> b;
  if(a%2 == 0 or b%2 == 0)
    cout << "Even";
  else cout << "Odd";
  cout << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  int d;
  cin >> d;

  if (d == 25) {
    cout << "Christmas" << endl;
  }
  if (d == 24) {
    cout << "Christmas Eve" << endl;
  }
  if (d == 23) {
    cout << "Christmas Eve Eve" << endl;
  }
  if (d == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
const int INF = 1 << 30;
int main()
{
    int N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    // 左から貪欲
    vector<int> L; // i+1回目に働く日
    for(int i = 0; i < N;)
    {
        if (S[i] == 'o')
        {
            L.push_back(i);
            i += C + 1; // C 日間空ける
        }
        else
        {
            ++i; // 次の日を見る
        }
        
    }
    if (L.size() > K) return 0;
    L.push_back(N);
    // 右から貪欲
    vector<int> R(K+1);
    R[K] = INF;
    for (int i = K-1; i >= 0; --i)
    {
        for (int l = L[i + 1] - 1; l >= L[i]; --l)
        {
            if (S[l] == 'o' && l + C < R[i + 1])
            {
                R[i] = l;
                break;
            }
        }
    }

    vector<int> ans;
    for (int i = 0; i < K; ++i)
    {
        if  (L[i] == R[i]) ans.push_back(L[i]);
    }
    if (ans.size() == 0) return 0;
    for (auto a : ans)
    {
        cout << a + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 4216
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std; 
#define L 14
#define M 1456527
vector<long long int> v(1234);
int a, b; int c; long long int ans[1000];
int main()
{
     int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> c >> a >> b;
        if (!c) {
            long long int mn = v[a];
            for (int j = a + 1; j < b; j++) {
                mn = min(mn, v[j]);
            }
            ans[i] = mn;
        }
        else  {
            long long int mx = v[a];
            for (int j = a + 1; j < b; j++) {
                mx = max(mx, v[j]);
            }
            ans[i] = mx;
        }
    }
    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 3116
#include <stdio.h>

int main(void){
    int H,W,i,j;

    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)
            break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                if(!(i%2)&&j%2||i%2&&!(j%2))
                    putchar('.');
                else
                    putchar('#');
            }
            puts("");
        }
        puts("");
    }
    return 0;
}

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

int inp[10];
int n;
bool canbe = false;

void dfs(int b, int c, int depth) {
  if (depth >= 10) {
    canbe = true; return;
  }
  if (inp[depth] < b && inp[depth] < c) return;
  if (inp[depth] > b) dfs(inp[depth], c, depth+1);
  if (inp[depth] > c) dfs(b, inp[depth], depth+1);
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    canbe = false;
    for (int j = 0; j < 10; j++) cin >> inp[j];
    dfs(0,0,0);
    cout << (canbe ? "YES": "NO") << endl;
  }

  return 0;
}

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

const int MAXN=100005 , MAXM=(MAXN<<1) , INF=(1<<30)-1 ;
int n , first[MAXN] , nexts[MAXM] , to[MAXM] , egnum=1 ;
int num[MAXN] , low[MAXN] , up[MAXN] ;
bool fail=false ;

void add_edge(int a,int b){
	nexts[++egnum]=first[a] , first[a]=egnum , to[egnum]=b ;
}

void dfs_1(int a,int fa){
	if(num[a]!=-1) low[a]=up[a]=num[a] ;
	for(int i=first[a];i;i=nexts[i]){
		int b=to[i] ;
		if(b==fa) continue ;
		dfs_1(b,a) ;
		if(low[b]!=-INF){
			int tl=low[b]-1 , tu=up[b]+1 ;
			if(low[a]!=-INF && (tl&1)!=(low[a]&1)) fail=true ;
			low[a]=max(low[a],tl) , up[a]=min(up[a],tu) ;
			if(low[a]>up[a]) fail=true ;
		}
	}
}

void dfs_2(int a,int fa){
	for(int i=first[a];i;i=nexts[i]){
		int b=to[i] ;
		if(b==fa) continue ;
		if(num[a]-1>=low[b] && num[a]-1<=up[b]) num[b]=num[a]-1 ;
		else num[b]=num[a]+1 ;
		dfs_2(b,a) ;
	}
}

int main(){
	scanf("%d",&n) ;
	for(int i=1;i<n;++i){
		int a,b;
		scanf("%d%d",&a,&b) ;
		add_edge(a,b) , add_edge(b,a) ;
	}
	for(int i=1;i<=n;++i) low[i]=-INF , up[i]=INF ;
	memset(num,-1,sizeof(num)) ;
	int K , t ;
	scanf("%d",&K) ;
	for(int i=1;i<=K;++i) scanf("%d",&t) , scanf("%d",&num[t]) ;
	dfs_1(1,0) ;
	if(fail){
		printf("No\n") ;
		return 0 ;
	}
	printf("Yes\n") ;
	num[1]=low[1] ;
	dfs_2(1,0) ;
	for(int i=1;i<=n;++i){
		printf("%d\n",num[i]) ;
	}
	return 0 ;
}

Measured memory_bytes: 8704
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if ((A + B) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << (A + B) / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long c[200001],n;
long long h[200001],a[200001];
int lowbit(int x)
{
    return x&-x;
}
void update(long long index,long long max_value)
{
    while(index<=n)
    {
        c[index]=max(c[index],max_value);
        index+=lowbit(index);
    }
}
long long maxrange(long long index)
{
    long long maxx=0;
    while(index)
    {
        maxx=max(maxx,c[index]);
        index-=lowbit(index);
    }
    return maxx;
}
int main()
{
    long long maxx=0,t,i;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&h[i]);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(i=1;i<=n;i++)
    {
        t=maxrange(h[i]-1);
        maxx=max(maxx,t+a[i]);
        update(h[i],t+a[i]);
    }
    printf("%lld",maxx);
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main()
{
    int n,m,c,b[20],a[20][20];
    long long ans = 0,buf = 0;

    scanf("%d %d %d",&n,&m,&c);
    for (int i = 0; i < m; i++)
    {
        scanf("%d",&b[i]);
    }
    for (int i = 0; i < n; i++)
    {
        buf = 0;
        for (int j = 0; j < m; j++)
        {
            scanf("%d",&a[i][j]);
            buf += a[i][j] * b[j];
        }
        if(buf + c > 0)
        {
            ans++;
        }
    }
    printf("%lld",ans);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
using namespace std;
int main() {
	while (true) {
		int w;
		scanf("%d", &w);
		if (w == -1) break;
		if (w <= 10) {
			printf("3130\n");
		}
		else if (w <= 20) {
			printf("%d\n", -1150 - (w - 10) * 125 + 4280);
		}
		else if (w <= 30) {
			printf("%d\n", -2400 - (w - 20) * 140 + 4280);
		}
		else {
			printf("%d\n", -3800 - (w - 30) * 160 + 4280);
		}
	}
}


Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l; cin>>n>>l;
  int a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];

  int i=0,r=0; int dp[n];
  dp[0]=0;int c=abs(a[i]-a[i-1])+dp[i-1];
  for(i=1;i<n;i++)
  {
  	dp[i]=INT_MAX; int p;
  	if(i<=l)
  	 p=0;
  	else
  	 p=i-l;
  	for(int k=i-1;k>=p;k--)
  	dp[i]=min(abs(a[i]-a[k])+dp[k],dp[i]);
  	
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
import std.stdio, std.string, std.array, std.conv, std.range, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    int[] b = iota(n).array;
    b[] += 1;
    zip(a, b).sort!((t1, t2) => t1[0] < t2[0]);
    foreach (i, x; b) {
        x.write;
        if (i != n - 1) " ".write;
        else writeln;
    }
}

Measured memory_bytes: 4936
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll H;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> H;
    cin >> N;
    ll sum = 0;
    rep(ni,N){
        cin >> ltmp;
        sum+=ltmp;
    }
    if(sum>=H){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)


def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != p:
        p = par[p]
    return par[p]


n,m = map(int, input().split())
p = list(map(int, input().split()))
par = [i for i in range(n+1)]
cnt = [1 for _ in range(n+1)]

for i in range(m):
    a,b = map(int, input().split())
    aa = get_par(par, a)
    bb = get_par(par, b)
    if aa == bb:
        continue
    # unite
    if cnt[aa] > cnt[bb]:
        par[bb] = aa
        cnt[aa] += cnt[bb]
    else:
        par[aa] = bb
        cnt[bb] += cnt[aa]

ans = 0
for i in range(n):
    a = p[i]
    if get_par(par, a) == get_par(par, i+1):
        ans += 1
print(ans)


Measured memory_bytes: 13812
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    ll res = INF;
    for(int i = 1; i <= 100; i++) {
        ll score = 0;
        rep(j, N) { score += (X[j] - i) * (X[j] - i); }
        res = min(score, res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int w, h;
	int x, y, r;
	int z, a;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	z = w - r;
	a = h - r;

	if (r <= x && x <= z && r <= y && y <= a){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return (0);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int s;
  cin >> s;
int A=s/1000,B=s/100-A*10,C=s/10-A*100-B*10,D=s%10;
if (A+B+C+D==7) cout <<  A << "+" << B << "+" << C << "+" << D << "=7" << endl; 
else if (A-B+C+D==7) cout <<  A << "-" << B << "+" << C << "+" << D << "=7" << endl; 
else if (A+B-C+D==7) cout <<  A << "+" << B << "-" << C << "+" << D << "=7" << endl; 
else if (A-B-C+D==7) cout <<  A << "-" << B << "-" << C << "+" << D << "=7" << endl;  
else if (A+B+C-D==7)  cout <<  A << "+" << B << "+" << C << "-" << D << "=7" << endl; 
else if (A-B+C-D==7) cout <<  A << "-" << B << "+" << C << "-" << D << "=7" << endl; 
else if (A+B-C-D==7)  cout <<  A << "+" << B << "-" << C << "-" << D << "=7" << endl; 
else if (A-B-C-D==7)  cout <<  A << "-" << B << "-" << C << "-" << D << "=7" << endl; 
  }  

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

astr = input().split()
bstr = input().split()

dp = []#b-a, plus
dm = []#minus
for (ai, bj)  in zip(astr, bstr):
    d = int(bj)-int(ai)
    if d < 0:
        dm.append(d)
    else:
        dp.append(d)
    
plus = 0
for d in dp:
    plus += d//2

if plus<abs(sum(dm)):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 4900
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
memory = [1]
dic = {}
cur = 1
count = 0
while True:
    if count == k:
        print(cur)
        exit()
    if a[cur] in dic.keys():
        loop_begin = dic[a[cur]]
        loop_end = count
        break
    else:
        count += 1
        memory.append(a[cur])
        dic[a[cur]] = count
        cur = a[cur]
loop = memory[loop_begin:]
loop_length = loop_end-loop_begin+1
k -= loop_begin
print(loop[k%loop_length])

Measured memory_bytes: 115452
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));


struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5+5;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    ll n, k; cin >> n >> k;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++)cin >> a[i];
    sort(all(a));
    ll sm = 0;
    for (ll i = 0; i < k; i++) sm += a[i];
    cout << sm << endl;
  
    return 0;
}

/*

*/

Measured memory_bytes: 3596
import collections

s = input()
t = input()
s_len = len(s)
s_idx = dict([])
for i, key in enumerate(s):
    try:
        s_idx[key].append(i + 1)
    except KeyError:
        s_idx[key] = [i + 1]

def binary_search(li, tmp, ng, ok):
    mid = (ng + ok) // 2
    if ok - ng < 2:
        if ok == len(li):
            return s_len + li[0]
        else:
            return li[ok]
    if li[mid] <= tmp: return binary_search(li, tmp, mid, ok)
    else: return binary_search(li, tmp, ng, mid)

ans = 0
ex_i = 0
for key in t:
    try:
        i = binary_search(s_idx[key], ex_i, -1, len(s_idx[key]))
        ans += i - ex_i
        ex_i = i % s_len
    except KeyError:
        ans = -1
        break
print(ans)

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#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 all(c) c.begin(),c.end()

int main() {
    string S;
    cin >> S ;

    ll ans = 0;
    int size = S.size();
    rep (i, 1 << (size-1)) {
        ll sum = 0;
        string tmp = "";
        tmp += S.at(0);
        rep (j, (size-1)) {
            if ((i >> j) & 1) {
                sum += stoll(tmp.empty() ? "0" : tmp);
                tmp = "";
                tmp += S.at(j+1);
            } else {
                tmp += S.at(j+1);
            }
        }
        sum += stoll(tmp);
        ans += sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
s=input()
ans=0
if s[0]=="R" and s[1]=="R" and s[2]=="R":
    print(3)
elif s[0]=="R" and s[1]=="R" and s[2]!="R" or s[1]=="R" and s[2]=="R" and s[0]!="R":
    print(2)
elif s[0]=="R" or s[1]=="R" or s[2]=="R":
    print(1)
else:
    print(0)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

char a, b;

int main(void) {
  // Here your code 
  scanf("%c %c", &a, &b);
  
  if (a == b) printf("=\n");
  else if (a < b) printf("<\n");
  else printf(">\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

int a,b ;   //変数を宣言

cin>> a >> b;
if(a < b)cout<<"a < b"<<endl;
else
if(a > b)cout<<"a > b"<<endl;
else
cout<<"a == b"<<endl;
	//面積・空白スペース・州の長さ・改行を出力
//ここに処理を記述していきます（この行は残しておいても、消しても大丈夫です）


return 0;
}


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

signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b*c>=a) cout<<"Yes";
	else cout<<"No"; 
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  int res=-1;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int pro=a[i]*a[j];
      string s=to_string(pro);
      bool isok=true;
      for(int i=0;i+1<s.size();i++){
	if(s[i+1]!=s[i]+1) isok=false;
      }
      if(isok) res=max(res,pro);
    }
  }
  cout<<res<<endl;

  return 0;
  
}

Measured memory_bytes: 3212
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
    
    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    
    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);
    if (T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;
    
    for (i = 0; i < n; i++) {
        cin >> v >> d;
        for (j = 0; j < d; j++) {
            cin >> c;
            if (j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) r = i;
    }
    
    rec(r, 0);
    
    for (i = 0; i < n; i++) print(i);
    
    return 0;
}

Measured memory_bytes: 7796
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long LL;
int n, pos;
LL a[55], k;
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		if(a[pos] < a[i]){
			pos = i;
		}
	}
	while(a[pos] >= n) {
		LL tmp = a[pos] / n;
		a[pos] %= n;
		for(int i = 1; i <= n; i++){
			if(pos != i)a[i] += tmp;
		}
		pos = 1;
		for(int i = 1; i <= n; i++){
			if(a[pos] < a[i])pos = i;
		}
		k += tmp;
	}
	printf("%lld\n", k);
}

Measured memory_bytes: 128
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)
// A
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> a(3); rep(i,3) cin >> a[i];
    sort(a.begin(),a.end());
    if((a[0] == a[1] && a[1] != a[2])||(a[0]!=a[1] && a[1]==a[2])) cout << "Yes";
    else cout << "No";
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n;
string s, t;
char ex[] = {'m', 'c', 'x', 'i'};
int _int[] = {1000, 100, 10, 1};

int dec(string s)
{
  int res = 0;
  rep(i, s.size()){
    int tmp = 0;
    if(s[i] >= '2' && s[i] <= '9'){
      tmp += s[i] - '0';
      rep(k, 4) if(ex[k] == s[i+1]) tmp *= _int[k];
      res += tmp;
      i += 1;
    }
    else{
      rep(k, 4) if(ex[k] == s[i]) res += _int[k];
    }
  }
  return res;
}

string enc(int n)
{
  string s = "";
  rev(k, 4){
    int tmp = n % 10;
    if(tmp) s += ex[k];
    if(tmp > 1) s += tmp + '0';
    n /= 10;
  }
  reverse(ALL(s));
  return s;
}

int main()
{
  cin >> n;

  while(n--){
    cin >> s >> t;
    cout << enc(dec(s) + dec(t)) << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <list>

using namespace std;

const int MAX = 1e5 + 9;

pair<long long, long long> a[MAX];
int kind[MAX];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i].second >> a[i].first;
	}
	sort(a, a + n, greater<pair<long long, long long>>());
	list<pair<long long, long long>> s, b;
	long long cnt = 0, sum = 0;
	for (int i = 0; i < k; i++) {
		if (!kind[a[i].second]) {
			cnt++;
			s.push_back(make_pair(-1LL, a[i].second));
		} else {
			s.push_front(a[i]);
		}
		kind[a[i].second]++;
		sum += a[i].first * 1LL;
	}
	for (int i = k; i < n; i++) {
		b.push_back(make_pair(a[i].first, a[i].second));
	}
	long long ret = cnt * cnt * 1LL + sum * 1LL;
	while (!b.empty() && s.front().first != -1LL) {
		if (!kind[(*b.begin()).second]) {
			sum -= s.front().first * 1LL;
			sum += b.front().first * 1LL;
			kind[s.front().second]--;
			kind[b.front().second]++;
			s.pop_front();
			cnt++;
			s.push_back(make_pair(-1LL, b.front().second));
			ret = max(ret, cnt * cnt * 1LL + sum * 1LL) * 1LL;
		}
		b.pop_front();
	}
	cout << ret << '\n';
	
	return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val n = cin.nextInt()

  var ct = 0
  for (i in 0 until n) {
    var a = cin.nextInt()
    while (a % 2 == 0) {
      a /= 2
      ct++
    }
  }

  println(ct)
  cin.close()
}

Measured memory_bytes: 39096
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
ll a[MAXN];

vector<double> hull;
vector<pll> dogrular;
ll dp[MAXN];

ll getir(ll deg){
    ll yer = upper_bound(hull.begin(), hull.end(), (double)deg) - hull.begin() - 1;
    return dogrular[yer].ss + deg*dogrular[yer].ff;
}

void ekleee(pll dis){
    if(hull.empty()){
        hull.push_back(0.0);
        dogrular.push_back(dis);
    }else{
        double cur = hull.back();
        pll son = dogrular.back();
        if(dis.ff*cur + dis.ss <= son.ff*cur + son.ss){
            hull.pop_back();
            dogrular.pop_back();
            ekleee(dis);
        }else{
            double yer = (double)(son.ss - dis.ss)/(dis.ff - son.ff);
            //cout<<yer<<endl;
            hull.push_back(yer);
            dogrular.push_back(dis);
        }
    }
}


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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    ll c;
    cin>>n>>c;

    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    
    hull.push_back(0.0);
    dogrular.push_back({-2*a[0], a[0]*a[0]});
    for(int i = 1; i < n; i++){
        //cout<<hull.back()<<endl;
        dp[i] = c + a[i]*a[i] + getir(a[i]);
        ekleee({-2LL*a[i], a[i]*a[i] + dp[i]});
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n - 1]<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 10980
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
int cmp(const void *a, const void *b){return *(int *)a - *(int *)b;}

int n, a[200200], b=0;
int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", a+i);
        b ^= a[i];
    }
    for(int i=0; i<n; i++){
        if(i)putchar(32);
        printf("%d", b^a[i]);
    }putchar(10);
}

Measured memory_bytes: 3280
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e6 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	map<char, int> mc;
	while (n--)
	{
		char c;
		cin >> c;
		mc[c]++;
	}
	if (mc.size() == 3) puts("Three");
	else puts("Four");
	return 0;
}


Measured memory_bytes: 256