akhauriyash/Code-Regression huggingface dataset:
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;

using namespace std;

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

    int n; cin >> n;
    vector<ll> a(n + 1);
    ll cumSum[n + 1];
    cumSum[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cumSum[i] = cumSum[i - 1] + a[i];
    }
    ll ans = 1LL<<60;
    for (int i = 2; i <= n - 2; i++) {
        ll lsum = cumSum[i];
        ll rsum = cumSum[n] - lsum;

        int lb = lower_bound(cumSum, cumSum + i, lsum / 2) - cumSum;
        ll p;
        if (lb == 0 || abs(lsum - 2 * cumSum[lb]) < abs(lsum - 2 * cumSum[lb - 1])) p = cumSum[lb];
        else p = cumSum[lb - 1];
        ll q = lsum - p;

        int rb = lower_bound(cumSum + i, cumSum + n, lsum + rsum / 2) - cumSum;
        ll r;
        if (rb == i || abs(rsum - 2 * (cumSum[rb] - cumSum[i])) < abs(rsum - 2 * (cumSum[rb - 1] - cumSum[i]))) r = cumSum[rb] - cumSum[i];
        else r = cumSum[rb - 1] - cumSum[i];
        ll s = rsum - r;

        ll mx = p;
        ll mn = p;
        for (auto& x : { q, r, s }) {
            mx = max(mx, x);
            mn = min(mn, x);
        }
        ans = min(ans, mx - mn);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
def test(map, x, y, height, width)
  return true if map[y].chars[x] == '.'
  w = x - 1 >= 0 && map[y].chars[x - 1] == '#'
  e = x + 1 < width && map[y].chars[x + 1] == '#'
  n = y - 1 >= 0 && map[y - 1].chars[x] == '#'
  s = y + 1 < height && map[y + 1].chars[x] == '#'

#  puts "x: #{x}, y:#{y}, w: #{w}, e:#{e}, n:#{n}, s:#{s}"
  return w || e || n || s
end

def solve(h, w, map)
  for i in 0...h
    for j in 0...w
      if !test(map, j, i, h, w)
        puts "No"
        return
      end
    end
  end
  puts "Yes"
end

h, w = gets.split(" ").map{|v|v.to_i}
map = []
h.times{|t|
  map << gets.strip
}
solve(h, w, map)


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
"""
stack
"""
from collections import deque

aN = list(map(str, input().split()))

stack = deque()
for i in range(len(aN)):
    if aN[i] in ('+', '-', '*'):
        b = stack.pop()
        a = stack.pop()
        stack.append(str(eval(a + aN[i] + b)))
    else:
        stack.append(aN[i])
print(stack.pop())



Measured memory_bytes: 5980
#include <cctype>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e5+5, INF = 0x3f3f3f3f;
struct Edge
{
    int next, to; 
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[N<<1];
int tot, head[N], in[N];
void add(int x, int y) { edge[++tot] = Edge(head[x], y); head[x] = tot; ++in[y]; }
int val[N<<2];
void change(int x, int l, int r, int pos, int d)
{
    val[x] = min(val[x], d); if(l == r) return;
    int mid = (l+r)>>1;
    if(pos <= mid) return change(x<<1, l, mid, pos, d);
    else return change(x<<1|1, mid+1, r, pos, d);
}
int query(int x, int l, int r, int ql, int qr)
{
    if(ql > qr) return INF;
    if(ql <= l&&r <= qr) return val[x];
    int ret = INF, mid = (l+r)>>1;
    if(ql <= mid) ret = min(ret, query(x<<1, l, mid, ql, qr));
    if(qr > mid) ret = min(ret, query(x<<1|1, mid+1, r, ql, qr));
    return ret;
}
int n, m, k, ans[N], p[N];
priority_queue<pair<int, int> > q;
int main()
{
    memset(val, 0x3f, sizeof(val)); 
    n = read(), k = read();
    for(int i = 1; i <= n; ++i) p[read()] = i;
    for(int x = n, y; x; --x)
    {
        y = query(1, 1, n, max(p[x]-k+1, 1), p[x]-1); if(y != INF) add(x, y);
        y = query(1, 1, n, p[x]+1, min(p[x]+k-1, n)); if(y != INF) add(x, y);
        change(1, 1, n, p[x], x);
    }
    for(int x = 1; x <= n; ++x) if(!in[x]) q.push(make_pair(-p[x], x));
    while(q.size())
    {
        int x = q.top().second; q.pop();
        ++m; ans[p[x]] = m;
        for(int i = head[x]; i; i = edge[i].next)   
        {
            int y = edge[i].to;
            if(--in[y] == 0) q.push(make_pair(-p[y], y));
        }
    }
    for(int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 28908
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define int long long
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define str string
#define all(v) v.begin(),v.end()
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	str s;
	cin>>s;
	str A="AAA",B="BBB";
	if(s==A){cout<<"No";}
	else if(s==B){cout<<"No";}
	else{
		cout<<"Yes";
	}
}


Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(1,10):
    if 6**i<=100000:
        A.append(6**i)
    if 9**i<=100000:
        A.append(9**i)
L=[i for i in range(100001)]
A.sort()

for i in range(len(A)):
    for j in range(1,100001):
        if j>=A[i]:
            L[j]=min(L[j],L[j-A[i]]+1)
print(L[N])

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

int main()
{
        int K, N;
        cin >> K >> N;
        vector<int> a(N), b(N);
        rep(i,N) cin >> a[i];

        int tmp = 0;
        int min = 10000000;
        int max = 0;
        int diff, index, ans, i;

        rep(i,N) {
                if (i == N -1) {
                        b[N-1] = K - a[N-1] + a[0];
                } else {
                        b[i] = a[i+1] - a[i];
                }
        }

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

        rep(i,N-1) {
                tmp += b[i];
        }
        cout << tmp << endl;

        return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

int main()
{
  fastio;
  int a, b; cin >> a >> b;
  for (int x = 1; x <= 100000; x++){
    int A = trunc(x * 0.08); 
    int B = trunc(x * 0.1);
    if (A == a && B == b) return cout << x, 0;
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 2e5 + 10;
const int INF = 1e9 + 10;
char st[105];

int main(){
	scanf("%s", st);
	int l = 0, r = strlen(st) - 1;
	bool f = true;
	while(l < r) {
		if(st[l] != st[r])	f = false;
		l++,r--;
	}
	if(!f)	puts("No");
	else	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

#undef LG
#define LG(...)

vv<vll> gr;
vll indeg;
vll vis;
vll dp;
auto &dis=dp;
void dfs(ll a){
	assert(!vis[a]);
	for(auto& b: gr[a]){
		dp[b] = max(dp[b], dp[a]+1);
		indeg[b]--;
		if(indeg[b]==0)
			dfs(b);
	}
}

int main(){
	fastio;
	ll n,m;
	cin>>n>>m;
	gr = vv<vll>(n+1);
	indeg = vll(n+1);
	vis = vll(n+1, 0);
	dp = vll(n+1,0);
	for(ll i=0; i<m; i++){
		ll x,y;
		cin>>x>>y;
		gr[x].push_back(y);
		indeg[y]++;
	}
	for(ll i=1; i<=n; i++){
		gr[0].push_back(i);
		indeg[i]++;
	}
	dfs(0);
	LG(max_element(all(dp)) - dp.begin());
	for(ll i=0; i<dp.size(); i++){
		LG(i,dp[i]);
	}
	cout<<*max_element(all(dp)) -1;
}

Measured memory_bytes: 13384
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<long> a = Console.ReadLine().Split().Select(i => long.Parse(i)).ToList();

        long sum = a.Sum();
        long x = 0;
        long ans = long.MaxValue;

        for (int i = 0; i < n; i++)
        {
            x += a[i];
            if (i + 1 < n) ans = Math.Min(ans, Math.Abs(sum - 2 * x));
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 32964
def main():
    n = int(input())
    a = list(map(int, input().split()))
    color = [False] * 8
    sub_color = 0
    for score in a:
        for i in range(8):
            if i*400 <= score <= 399+(i*400):
                color[i] = True
        if score >= 3200:
            sub_color += 1
    cnt = len([x for x in color if x])
    if cnt == 0:
        print(1, sub_color, sep=" ")
    else:
        print(cnt, cnt+sub_color, sep=" ")

if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
#include<stdio.h>
#include<math.h>

int main() {

	int A, B, K = 0;

	scanf("%d %d", &A, &B);

	if ((A + B) % 2 == 0){
		K = (A + B) / 2;
	printf("%d\n", K);
  }
    else {

     printf("IMPOSSIBLE\n");
		}
	return 0;
}


Measured memory_bytes: 128
let () =
  let m = Scanf.scanf "%d\n" (fun x -> x) in
  let minv = ref (Scanf.scanf "%d\n" (fun x -> x)) in
  let n, d = Scanf.scanf "%d\n" (fun x -> x , x - !minv) in
  let maxv = ref d in
  if n < !minv then minv := n else ();
  for i = 1 to m - 2 do
    let num, diff = Scanf.scanf "%d\n" (fun x -> x, x - !minv) in
    if !maxv < diff then maxv := diff else ();
    if num < !minv then minv := num else ();
  done;
  Printf.printf "%d\n" !maxv;;


Measured memory_bytes: 4548
#include <iostream>
#include <string>
#include <set>

int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::set<std::string> set;
  for (int i = 0; i < n; ++i) {
    std::cin >> s;
    set.insert(s);
  }
  std::cout << (set.size() == n ? "YES" : "NO") << std::endl;
  
  return 0;
}

Measured memory_bytes: 21632
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  string s;

  cin >> s;

  for (int i = 0; i < sizeof(s)/sizeof(string); i++){
    if (i = 3){
      s.at(i) = '8';
    }
  }
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
import Data.List.Split

distance x y = abs (x - y)

main = do
	first <- getLine
	let nums = map (\x -> read x :: Int) (splitOn " " first)
	let a = nums !! 0
	let b = nums !! 1
	let c = nums !! 2
	let d = nums !! 3
	let judge = ((distance a c) <= d) || ((distance a b) <= d && (distance b c) <= d)
	putStrLn $ if judge then "Yes" else "No"


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


int main() {
  int a,b,c,d; cin >> a >> b >> c >> d;
  if ((d >= abs(c -a))|| (d >= abs(b - a) && d >= abs(c - b)) ) {
    cout << "Yes";
  }
  else cout << "No";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    lint n, k;
    cin >> n >> k;

    constexpr int m = 2000001;

    vector<int> a(n);
    vector< vector<int> > id(m);
    rep(i, n){
        cin >> a[i];
        id[a[i]].emplace_back(i);
    }

    vector< vector<lint> > ne(61, vector<lint>(n, LLINF));
    rep(i, n){
        auto it = upper_bound(id[a[i]].begin(), id[a[i]].end(), i);
        if(it == id[a[i]].end()){
            it = id[a[i]].begin();
        }
        if(*it == i) ne[0][i] = n + 1;
        else ne[0][i] = (*it + 1LL - i + n) % n;
    }

    rep(i, 60){
        rep(j, n){
            if(ne[i][j] < LLINF - ne[i][(j + ne[i][j]) % n]) ne[i + 1][j] = ne[i][j] + ne[i][(j + ne[i][j]) % n];
            else ne[i + 1][j] = LLINF;
        }
    }

    // rep(i, 3){
    //     cout << i << endl;
    //     rep(j, n){
    //         cout << ne[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    lint cnt = 0;
    rrep(i, 61){
        while(cnt + ne[i][cnt % n] < k * n){
            cnt += ne[i][cnt % n];
        }
    }

    vector<lint> ans;
    set<lint> st;
    for(lint i = cnt ; i < k * n ; ++i){
        if(st.count(a[i % n])){
            while(st.count(a[i % n])){
                st.erase(ans.back());
                ans.pop_back();
            }
        }else{
            ans.emplace_back(a[i % n]);
            st.insert(ans.back());
        }
    }

    rep(i, ans.size()){
        if(i) cout << ' ';
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 161764
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int d, n;
	cin >> d >> n;
	int sum = 0;
	for (int i = 1;; i++) {
		int res = 0, k = i;
		while (k % 100 == 0) {
			k /= 100;
			res++;
		}
		if (res == d) sum++;
		if (sum == n) {
			cout << i << endl;
			return 0;
		}
	}
}

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

int main() {
  string str;
  int res = 0;
  cin >> str;
  if(str.find('R') >= 0 && str.find('R') < 3) {
      for(int i = str.find('R'); i < 3; i++) {
      if(str.at(i) == 'R') res++;
      else break;
    }
  } else {
      cout << 0 << endl;
      return 0;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
	int n,m;
	int sumh,sumt;
	int i1,i2;

	int min;
	int mint,minh;

	while(1){
		cin>>n>>m;
		if(n+m==0) break;

		vector<int> t(n);
		vector<int> h(m);
		sumh=0;
		sumt=0;
		min=300000;
		mint=300;
		minh=300;

		for(i1=0;i1<n;i1++){
			cin>>t[i1];
			sumt+=t[i1];
		}
		for(i1=0;i1<m;i1++){
			cin>>h[i1];
			sumh+=h[i1];
		}

		for(i1=0;i1<n;i1++){
			for(i2=0;i2<m;i2++){
				int tempt=sumt;
				int temph=sumh;
				tempt+=(h[i2]-t[i1]);
				temph+=(t[i1]-h[i2]);

				if(temph==tempt){
					if(min>temph){
						mint=i1;
						minh=i2;
						min=temph;
					}
				}
			}
		}

		if(mint==300 && minh==300) cout<<-1<<endl;
		else cout<<t[mint]<<" "<<h[minh]<<endl;
	}
	return 0;
}

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

int n, k;

int main()
{
	int min = 1;
	cin >> n >> k;
	int a[n];
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int i = 0;
	while(1){
		i += k;
		if(i >= n)
		{
			res++;
			break;
		}
		else {
			i--;
			res++;
		}
	}
	
	cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
		using namespace std;
		typedef long long ll;
		#define PRINT(x,y) cout<<"Case #"<<(int)x<<": "<<(int)(y)<<endl;
		ll exp(ll x, ll y) {
			if(y==0) return 1;
			if(y==1) return x;
			if(y%2==0) return exp(x,y/2)*exp(x,y/2);
			else return x*exp(x,y/2)*exp(x,y/2);
		}
		ll gcd(ll a , ll b) {
			if(b==0) return a;
			return gcd(b , a%b);
		}
		ll lcm(ll a , ll b) {
			return (a*b)/gcd(a,b);
		}
		#define vec(n) vector<int> v((int)(n),0);
		#define vecl(n) vector<ll> v((ll)(n),0);
		#define sq(a) ((int)(a))*((int)(a));
		#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
		int l;
		ll fact(ll x) {
			if(x==1) return 1;
			else return x*fact(x-1);
		}
		bool isPrime(int x) {
			int ans  = 0;
			for(int i=2;i<=sqrt(x);++i) {
				if(x%i==0) {
					ans = 1; i=x;
				}  
			}
			if(ans==0) return true;
			else return false;
		}
		ll isPerfect(ll x) {
			double y = sqrt(x);
			return (floor(y)==ceil(y));
		} 

		int z = 0;
		void ask(int x, int y) {
			cout<<"? "<<x<<" "<<y<<endl;
			}

		void solve() {
			ll n; cin>>n;
			if(n<=1) {
				cout<<0; exit(0);
			} else if(n==2) {
				cout<<2;
				exit(0);
			}
			ll modulo = 1000000007;
			ll ans1 = 1;
			for(ll i=1;i<=n;++i) {
				ans1 = ans1 * 10;
				if(ans1>modulo) ans1 = ans1%modulo;
			}
			ll ans2 = 1;
			for(ll i=1;i<=n;++i) {
				ans2 = ans2 * 8;
				if(ans2>modulo) ans2 = ans2%modulo;
			}
			ll ans3 = 1;
			for(ll i=1;i<=n;++i) {
				ans3 = ans3 * 9;
				if(ans3>modulo) ans3 = ans3%modulo;
			}
			ll x = ans1+ans2-2*ans3;
			while(x<modulo) {
				x+=modulo;
			}
			cout<<(x)%modulo;
		}			




		int main() {
			io
			
			 solve();
		}
		    
		

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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<100;i+=4){
    for(int j=0;j<100;j+=7){
      if(i+j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,k;
  scanf("%d%d%d",&a,&b,&c);
  scanf("%d",&k);
  
  for(int i=1;i>0;i++){
    if(a>=b){
      k-=1;
      b*=2;
      if(k<0){printf("No");return 0;}
    }else{break;}
  }
  
  for(int i=1;i>0;i++){
    if(b>=c){
      k-=1;
      c*=2;
      if(k<0){printf("No");return 0;}
    }else{break;}
  }
  
  printf("Yes");
  return 0;
}

Measured memory_bytes: 2148
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;

int main()
{
    fastio;
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,i;
        cin>>n;
        ll c=0,l,r;
        bool ok=false;
        vector<pair<ll,ll>>v(n);
        for(i=0;i<n;i++)
        {
            cin>>l>>r;
            v[i]=mp(l,r);
        }
        ll same=0,j;
        for(i=0;i<n;i++)
        {
            for(j=i,c=0,same=0;;j++)
            {
                if(v[j].fi==v[j].se)
                {
                    same++;
                }
                if(same==3)
                {
                    ok=true;
                    break;
                }
                c++;
                if(c==3)
                    break;
            }

        }

        if(ok)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;


    }

}


Measured memory_bytes: 3656
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
	map <int,int> ev,od; 
    int n,emax=0,omax=0; cin>>n; 
    for (int i=1;i<=n;i++){ 
    	int a;cin>>a; 
    	if (i&1) {
    		od[a]++; 
    		omax=max(omax,od[a]);
    	}
    	else {
    		ev[a]++;  
    		emax=max(emax,ev[a]); 
    	}
    } 
    int a,b,c,d; 
    priority_queue<int> e,o; 
    e.push(0),o.push(0); 
    for (auto &it: ev) e.push(it.ss); 
    for (auto &it: od) o.push(it.ss); 
    for (auto &it: ev) {
    	if (emax==it.ss) {
    		emax=it.ff;break;
    	}
    }
    for (auto &it: od) {
    	if (omax==it.ss) {
    		omax=it.ff;break; 
    	}
    }
    a=e.top();e.pop(); 
    b=e.top();e.pop(); 
    c=o.top();o.pop(); 
    d=o.top();o.pop(); 
    int ans=0;
    if (omax==emax)
    	ans = min(n-a-d,n-b-c);
    else ans = n-a-c; 
    cout << ans << endl;
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 10460
def main():
    N, Y = map(int, input().split())
    for i in range(N+1):
        for j in range(N+1-i):
            if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
                print(i, j, N-i-j)
                return 0
    else:
        print(-1, -1, -1)

main()

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

Measured memory_bytes: 2940
// C++ implementation to find the length of  
// longest increasing contiguous subarray 
#include <bits/stdc++.h> 
using namespace std;

// function to find the length of longest increasing  
// contiguous subarray 
void printLogestIncSubArr(int arr[], int n)
{
	// 'max' to store the length of longest 
	// increasing subarray 
	// 'len' to store the lengths of longest 
	// increasing subarray at diiferent  
	// instants of time 
	int max = 1, len = 1, maxIndex = 0;

	// traverse the array from the 2nd element 
	for (int i = 1; i < n; i++)
	{
		// if current element if greater than previous 
		// element, then this element helps in building 
		// up the previous increasing subarray encountered 
		// so far 
		if (arr[i] >= arr[i - 1])
			len++;
		else
		{
			// check if 'max' length is less than the length 
			// of the current increasing subarray. If true,  
			// then update 'max' 
			if (max < len)
			{
				max = len;

				// index assign the starting index of  
				// longest increasing contiguous subarray.    
				maxIndex = i - max;
			}

			// reset 'len' to 1 as from this element 
			// again the length of the new increasing 
			// subarray is being calculated     
			len = 1;
		}
	}

	// comparing the length of the last 
	// increasing subarray with 'max' 
	if (max < len)
	{
		max = len;
		maxIndex = n - max;
	}

	// Print the elements of longest increasing 
	// contiguous subarray. 
	vector<int>ans;
	for (int i = maxIndex; i < max + maxIndex; i++)
		ans.push_back(arr[i]);
	cout << ans.size() - 1 << endl;
}

// Driver program to test above 
int main()
{
	int n;
	cin >> n;
	int arr[n];

	for (int i = 0; i < n; i++)cin >> arr[i];
	reverse(arr, arr + n);
	printLogestIncSubArr(arr, n);
	return 0;
}
// This code is contributed by Dharmendra kumar 

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << P + Q + R - max(P, max(Q, R)) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

ll dp[3005][3005];

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

    int n; cin>>n;
    vi a = readVector<int>(n);

    int lastp = (n+1)%2;
    FOR(i,n)
        dp[i][i] = lastp ? -a[i] : a[i];

    REV(l,n-1,0)
    RNG(r,l+1,n-1) {
        int p = (r-l+lastp)%2;

        if(p==0) {
            dp[l][r] = max( dp[l+1][r]+a[l], dp[l][r-1]+a[r] );
        } else {
            dp[l][r] = min( dp[l+1][r]-a[l], dp[l][r-1]-a[r] );
        }
    }

    cout<<dp[0][n-1]<<endl;

    return 0;
}



Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	scanf("%d",&n);
	int ok=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x%2==0&&x%3&&x%5)
			ok=0;
	}
	puts(ok?"APPROVED":"DENIED");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::string s;
  cin>>s;
  int x,y;
  cin>>x>>y;

  std::vector<int> xaxis_robot;
  std::vector<int> yaxis_robot;
  int xaxis_initial=0;
  int itr=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='F'){
      xaxis_initial++;
      if(i==s.size()-1){
        itr=i;
        break;
      }
    }else{
      itr=i;
      break;
    }
  }
  const int offset=10000;
  xaxis_robot.push_back(xaxis_initial);
  yaxis_robot.push_back(0);
  bool mode_x=false;
  int count=0;
  for(itr=itr+1;itr<s.size();itr++){
    if(s[itr]=='F'){
      count++;
    }
    if(s[itr]!='F'||itr==s.size()-1){
      if(mode_x){
        bool new_axis_pos[20000]={};
        for(auto v:xaxis_robot){
          new_axis_pos[v+count+offset]=true;
          new_axis_pos[v-count+offset]=true;
        }
        xaxis_robot.clear();
        for(int j=0;j<20000;j++){
          if(new_axis_pos[j]){
            xaxis_robot.push_back(j-offset);
          }
        }
        mode_x=false;
      }else{
        bool new_axis_pos[20000]={};
        for(auto v:yaxis_robot){
          new_axis_pos[v+count+offset]=true;
          new_axis_pos[v-count+offset]=true;
        }
        yaxis_robot.clear();
        for(int j=0;j<20000;j++){
          if(new_axis_pos[j]){
            yaxis_robot.push_back(j-offset);
          }
        }
        mode_x=true;
      }
      count=0;
    }
  }

  bool x_ok=false,y_ok=false;
  for(auto v:xaxis_robot){
    if(v==x){
      x_ok=true;
      break;
    }
  }
  for(auto v:yaxis_robot){
    if(v==y){
      y_ok=true;
      break;
    }
  }
  cout<<(x_ok&&y_ok?"Yes":"No")<<endl;



  return 0;
}

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

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return -*(int*)p + *(int*)q;
}//大きい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int x,p[110],min=101,n,temp;

	scanf("%d%d",&x,&n);
	for(int i=0;i<n;i++){
scanf("%d",&p[i]);
}
if(n==0){
	printf("%d\n",x);
	return 0;
}
	//qsort(p,n,sizeof(int),cmp);

for(int j=101;j>=-1;j--){
  temp=0;
for(int k=0;k<n;k++){
	if(j==p[k]){
      temp=1;
		break;
	}

}
    	if(abs(j-x)<=abs(min-x)&&temp==0){
		min=j;
	}

}

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


Measured memory_bytes: 1724
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>
#define SIZE 100005
#define MOD 1000000007

using namespace std;

class CLowElements {
public:
    static void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin >> n;
        vector<int> vec(n);
        for (int i = 0; i <n; ++i) { cin >> vec[i]; }
        int min = n+1;
        int count = 0;
        for (int j = 0; j < n; ++j) {
            if(min >= vec[j]){
                min = vec[j];
                count++;
            }
        }
        cout << count << endl;
    }
};


int main() {
    CLowElements solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main{
    private static FastScanner fs = new FastScanner();
    public static void main(String[] args) {
        Set<Tuple> set = new HashSet<>();
        int n = fs.nextInt();
        int res =(n-1);
        int temp = n;
        int b =2;
        while(b<n)
        {
            if(n%b==0)
            {
                res +=((n/b)-1);
            }
            else
            {
                res +=(n/b);
            }
            b++;
        }
//        System.out.println(b);
        System.out.println(res );




    }
    static class Tuple
    {
        int a;
        int b;
        int c;

        public Tuple(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    }


    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
        int  gcd(int a,int b)
        {
            while (b > 0)
            {
                int  temp = b;
                b = a % b;
                a = temp;
            }
            return a;
        }
        private int upper(int arr[],int key){
            int low = 0;
            int high = arr.length-1;
            while(low < high){
                int mid = low + (high - low+1)/2;
                if(arr[mid] <= key){
                    low = mid;
                }
                else{
                    high = mid-1;
                }
            }
            return low;
        }
        public int lower(int arr[],int key){
            int low = 0;
            int high = arr.length-1;
            while(low < high){
                int mid = low + (high - low)/2;
                if(arr[mid] >= key){
                    high = mid;
                }
                else{
                    low = mid+1;
                }
            }
            return low;
        }
    }
}

Measured memory_bytes: 32820
from collections import deque

N = int(input())
l = [deque([])]+[deque(map(int, input().split())) for _ in range(N)]

v = 0
ans = 0
t = N*(N-1)//2

last_used = set(range(1, N+1))
while v<t and ans<t:
    used = set()
    for n in last_used:
        if n in used:continue
        if not l[n]:continue
        pair = l[n][0]
        b = l[pair][0]
        if pair in used:continue

        if b==n:
            l[n].popleft()
            l[pair].popleft()
            used|={n,pair}
            v += 1
    last_used = used
    ans += 1

if ans==t and ans!=v:
    print(-1)
else:
    print(ans)

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int res = 0;
  string s; cin >> s;
  REP(i, s.size() - 1) if(s.at(i) != s.at(i + 1)) res++;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 512
S = input()
if S[0] == "A" and not(S.find("C", 2, -1) < 0) and S[1:S.find("C", 2, -1)].islower() and S[S.find("C", 2, -1)+1:].islower():
  print("AC")
else:
  print("WA")


Measured memory_bytes: 2940
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int MX = 131072;
ll bit[MX], cnt[MX];
inline ll sum(ll *bit, int i){
	ll res = 0;
	for(; i; i -= i & -i) res += bit[i];
	return res;
}
inline void add(ll *bit, int i, int x){
	for(; i < MX; i += i & -i) bit[i] += x;
}
inline ll sum(int k){
	int lo = 0, hi = MX, mid;
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		if(cnt[mid] >= k) hi = mid;
		else lo = mid, k -= cnt[mid];
	}
	return sum(bit, lo) + hi * k;
}

int main(){
	int n;
	scanf("%d", &n);
	vector<pi> v;
	rep(i, n){
		int a, b;
		scanf("%d%d", &a, &b);
		v.pb(mp(-b, a));
	}
	sort(all(v));
	int ans = 0, k = 0;
	
	rep(i, n){
		int b = -v[i].first, a = v[i].second;
		add(bit, a, a);
		add(cnt, a, 1);
		
		while(k <= i && sum(k + 1) <= (ll)b * (k + 1)) k++;
		while(k > 0 && sum(k) > (ll)b * k) k--;
		ans = max(ans, k);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6968
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a[n];
    map<int,int> mp;
    vector<int> v;
    rep(i,0,n){
        cin>>a[i];
        if(mp[a[i]]==1){
            v.push_back(a[i]);
            mp[a[i]]=0;
        }
        else mp[a[i]]=1;
    }
    sort(v.begin(),v.end(),greater<int>());
    if(v.size()<=1)cout<<0<<endl;
    else{
        ll ans=(ll)v[0]*v[1];
        cout<<ans<<endl;
    }
}




Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector< vector<int> > E(n);
    for(int i=0; i<n; i++) {
        int u,k;
        cin >> u >> k;
        E[u-1].resize(k);
        for(int j=0; j<k; j++) {
            int v;
            cin >> v;
            E[u-1][j] = v-1;
        }
    }
    int c[n];
    int d[n];
    memset(c, 0, sizeof c);
    memset(d,-1,sizeof d);

    c[0] = 1;
    d[0] = 0;
    queue<int> Q;
    Q.push(0);

    while(!(Q.empty())) {
        int u = Q.front();
        Q.pop();
        for(int v : E[u]) {
            if(c[v] == 0) {
                c[v] = 1;
                d[v] = d[u] + 1;
                Q.push(v);
            }
        }
    }
    for(int i=0; i<n; i++) cout << i+1 << " " << d[i] << endl;
    return 0;
}


Measured memory_bytes: 3088
import { readFileSync } from 'fs'

function main(input: string) {
  const [[N, X], list] = input.trim().split('\n').map(v => v.split(' ').map(Number))

  let pos = 0
  let index = 0
  let count = 0

  while (pos <= X) {
    count += 1
    pos += list[index]

    ++index
  }

  console.log(count)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7500
n = int(input())
a = [int(i) for i in input().split()] 
b = [int(i) for i in input().split()] 

res = 0
for i in range(n)[::-1]:
  if a[i+1] >= b[i]:
    res += b[i]
  else:
    b[i] -= a[i+1]
    res += a[i+1]
    if b[i] < a[i]:
      a[i] -= b[i]
      res += b[i]
    else:
      res += a[i]
      a[i] = 0
print(res)

Measured memory_bytes: 18392
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<iomanip>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;
int s,n,t,m;
long double p;
string weekday,Time;
int WEEKDAY;

int getIndex(string s)
{
  if(s == "All")return -1;
  if(s == "Sun")return 0;
  if(s == "Mon")return 1;
  if(s == "Tue")return 2;
  if(s == "Wed")return 3;
  if(s == "Thu")return 4;
  if(s == "Fri")return 5;
  if(s == "Sat")return 6;
  assert(false);
}

bool check(int startWeek,int startTime,int endWeek,int endTime)
{
  if(!(WEEKDAY == -1 || (WEEKDAY == startWeek && WEEKDAY == endWeek) ))return false;
  if(Time == "All")
    {
      if(0 <= startTime && startTime < 24*60 && 0 <= endTime && endTime < 24*60)
	return true;
    }
  else if(Time == "Day")
    {
      if(6*60 <= startTime && startTime < 18*60 && 6*60 <= endTime && endTime < 18*60)
	return true;
    }
  else if(Time == "Night")
    {
      if(((18*60 <= startTime && startTime < 24*60) || (0 <= startTime && startTime < 6*60))
      && ((18*60 <= endTime   && endTime   < 24*60) || (0 <= endTime   && endTime   < 6*60)))
	return true; 
    }
  else assert(false);  
  return false;
}

int main()
{
  while(true)
    {
      cin >> s >> n >> t >> weekday >> Time >> p >> m;
      if(s+n+t+p+m == 0 && weekday == "None" && Time == "None")break;

      long double mex = 0;
      WEEKDAY = getIndex(weekday);

      rep(i,7)//week
	{
	  rep(j,24*60)//time
	    {
	      int startWeek,startTime,endWeek,endTime;
	      startWeek = i;
	      startTime = j;

	      long double probability = 0;
	      long double cnt = 0;

	      rep(stage,m)
		{
		  endTime = startTime+s;
		  endWeek = startWeek;
		  if(endTime >= 24*60)endTime -= 24*60,endWeek = (endWeek+1)%7;

		  if(check(startWeek,startTime,endWeek,endTime))
		    cnt++; 
		  
		  startTime += t;
		  if(startTime >= 24*60)startTime -= 24*60,startWeek = (startWeek+1)%7;
		}
	      probability = 1.0-pow((p-1.0)/p,n*cnt);
	      mex = max(mex,probability);
	    }
	}
      cout << setiosflags(ios::fixed) << setprecision(10) << mex << endl;
    }
  return 0;
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    set<ll> s;
    s.insert(1), s.insert(2), s.insert(3);
    ll a, b;
    cin>>a>>b;
    s.erase(a), s.erase(b), cout<<*s.begin();
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3836
import sys
N, L =map(int,input().split())
a = list(map(int,input().split()))
for i in range(N-1):
  if a[i]+a[i+1] >= L:
    flag = i+1
    break
else:
  print("Impossible")
  sys.exit()

print("Possible")
for i in range(1,flag):
  print(i)
for i in range(N-1,flag-1,-1):
  print(i)

Measured memory_bytes: 14060
#include<stdio.h>

int main(){
	int n,a,b,c,d,x,y;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;
	if(n%a!=0) x++;
	y=n/c;
	if(n%c!=0) y++;
	x=x*b;
	y=y*d;
	if(x<=y)
	printf("%d\n",x);
	else
	printf("%d\n",y);
	return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int main()
{
	int n,k;
	ll s;
	scanf("%d%d%lld",&n,&k,&s);
	if(s!=1000000000ll)
	{
		//s+1
		for(int i=0;i<k;i++)printf("%lld ",s);
		for(int i=k;i<n;i++)printf("%lld ",s+1);
	}
	else
	{
		for(int i=0;i<k;i++)printf("%lld ",s);
		for(int i=k;i<n;i++)printf("%lld ",1);
	}
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void){
int a,b,d,r,f;
scanf("%d %d",&a,&b);
d = a/b;
r = a%b;
double f2;
f2=1.0*a/b;
printf("%d %d %.5lf\n",d,r,f2);
return 0;
}

Measured memory_bytes: 640
import sys

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return int(a*b / gcd(a,b))

for s in sys.stdin:
    a, b = map(int, s.split())
    
    print(gcd(a,b), lcm(a,b))

Measured memory_bytes: 7684