akhauriyash/Code-Regression huggingface dataset:
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <utility>

namespace n91 {

void main_() {
  usize n;
  std::cin >> n;
  std::vector<usize> p(n);
  for (auto &e : p) {
    std::cin >> e;
  }
  usize ans = 0_z;
  for (const auto i : rep(1_z, n - 1_z)) {
    std::array<usize, 3_z> a = {p[i - 1_z], p[i], p[i + 1_z]};
    std::sort(a.begin(), a.end());
    if (p[i] == a[1_z]) {
      ++ans;
    }
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n==1)cout<<"Hello World";
	else{
		int a,b;
		cin>>a>>b;
		cout<<a+b;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int needswap = 0;
  for (int i = 1;i < n+1;i++) {
    int pi;
    cin >> pi;
    if (pi != i) needswap++;
  }
  if (needswap <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
int arr[mxn];
vector<int> graph[mxn];
int n, m, k;
ll l, r;
string s;

ll POW(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}

void read(){
    cin >> n;
//    for(int i = 0, u, v; i < n; i++){
//        cin >> arr[i];
//    }
}


void solve(){
    map<ll, int> mp;
   for(ll i = -1000; i <= 1000; i++){
        ll res = 1;
        for(int j = 0; j < 5; j++){
            res *= i;
        }
        mp[res] = i;
   }
   for(ll i = -1000; i <= 1000; i++){
        ll res = 1;
        for(int j = 0; j < 5; j++){
                res *= i;
        }
        res -= n;
        if(mp.count(res)){
            cout << i << " " << mp[res] << endl;
            break;
        }
   }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 27180
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

  ll ok=1,ng=K+1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll sum=0;
    ll now=mid;
    for(ll i=1;i<=min(N,62ll);i++){
      sum+=now;
      now/=2;
    }
    if(sum<=K) ok=mid;
    else ng=mid;
  }

  cout<<ok<<endl;

  return 0;
}



Measured memory_bytes: 3100
a,b,c,d=map(int,input().split())
def amari(a):
  return a % 998244353
X0=[[0]*d for i in range(c)]
X1=[[0]*d for i in range(c)]
X2=[[0]*d for i in range(c)]
X0[a-1][b-1]=1
for j in range(b,d):
 X0[a-1][j]=amari(X0[a-1][j-1]*(a-1))
 X1[a-1][j]=amari(X0[a-1][j-1]+X1[a-1][j-1]*(a-1))
 X2[a-1][j]=amari(X1[a-1][j-1]+X2[a-1][j-1]*a)
for i in range(a,c):
 for j in range(b,d+1):
  X1[i][j-1]=amari((X0[i-1][j-1]+X1[i-1][j-1]+X2[i-1][j-1])*j)
  if j>=2:
   X2[i][j-1]=amari(X1[i][j-2]+X2[i][j-2] *(i+1))
print(amari(X0[c-1][d-1]+X1[c-1][d-1]+X2[c-1][d-1]))

Measured memory_bytes: 286192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		int l = reader.nextInt();
		int r = reader.nextInt();
		int d = reader.nextInt();
		int ans = (r/d) - (l/d);
		if((l%d) == 0)
		{
			ans += 1;
		}

		System.out.println(ans);

	}
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}



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

int main() {
  int r, g, b, k;
  cin >> r >> g >> b >> k;
  while (k > 0) {
    if (g > r) break;
    g *= 2;
    k--;
  }
  while (k > 0) {
    if (b > g) break;
    b *= 2;
    k--;
  }
  if (g > r && b > g) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
def gcd(a, b):
  while a:
    a, b = b % a, a
  return b


def g():
  from functools import reduce
  n = int(input())
  vs = list(map(int, input().split()))
  
  while True:
    n = len(vs)
    
    if n < 10:
      mrr = 0
      for i, v in enumerate(vs):
        rr = reduce(gcd, vs[:i]+vs[i+1:])
        mrr = max(rr, mrr)
      return mrr
    
    v1 = vs[:n//2]
    v2 = vs[n//2:]
    
    r1 = reduce(gcd, v1)
    r2 = reduce(gcd, v2)
    if r1 == r2:
      return r1
    if r1 > r2:
      vs = v2
    else:
      vs = v1
  
  
print(g())

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
P=LIST()

cnt=0
for i in range(N):
    if i+1!=P[i]:
        cnt+=1
if cnt<=2:
    YES()
else:
    NO()


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

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

  string A = "";
  string B = "";

  for(int i = 0; i < N;i++){
    B = B + to_string(M);
  }
  for(int i = 0; i < M; i++){
    A = A + to_string(N);
  }

  if(A <= B){
    cout << A << endl;
  }else{
    cout << B << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define int long long
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
const int N = 200010;
int a[N], n, m, cp[N], xp[N];
signed main() {
	n = qread(); m = qread();
	repn(i, n) a[i] = qread();
	int ans = 0, raw = 0;
	repn(i, n - 1) {
	    int t = a[i + 1], s = a[i];
	    if (t < s) t += m;    // we are overflowing the top
	    // we are doing this reversedly so we won't need to deal with negative
	    // numbers (the linear function is originally t - x + 1, and the coeff of x
	    // is negative)
	    raw += t - s;
	    if (s + 1 < t) {
	        // increase 1 to all x-s within the range [s + 1, t]
	        // decrease (s + 1) to all c-s within the range [s + 1, t]
	        // note that it's REVERSED to the f(s, t, x) function
	        xp[s + 1 + 1]++; cp[s + 1 + 1] -= s + 1;
	        xp[t + 1]--; cp[t + 1] += s + 1; 
	    }
	}
	// work the prefix sum
	repn(i, m << 1) {
	    xp[i] += xp[i - 1];
	    cp[i] += cp[i - 1];
	}
//	repn(i, m << 1) {
//	    cerr << i << ": " << xp[i] << ' ' << cp[i] << endl;
//	}
	// get the answer
	repn(i, m) {
	    int tmp = xp[i] * i + xp[i + m] * (i + m) + cp[i] + cp[i + m];
	    ans = max(ans, tmp);
	}
	cout << raw - ans << endl;
	return 0;
}


Measured memory_bytes: 7484
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

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

  long N, M; cin >> N >> M;
  long dmax=1;
  for (long i=1; i*i<=M; i++) {
    if (M%i == 0) {
      if(i*N <= M)
        dmax = max(dmax, i);
      if (M/i*N <= M)
        dmax = max(dmax, M/i);
    }
  }
  cout << dmax << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    Scanner scn = new Scanner(System.in);
      String a = scn.next();
      String b = scn.next();
      String c = scn.next();
    scn.close();
    System.out.println(c+" "+a+" "+b);
    }
}


Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int N;
	double A, B;
	vector<ll> vec;
	cin >> N >> A >> B;
	REP(i, N) {
		ll x;
		cin >> x;
		vec.push_back(x);
	}

	sort(vec.begin(), vec.end(), greater<ll>());
	vector<ll> S;
	int k = -1, l = N;

	

	REP(i, N) {
		if (i == 0) {
			S.push_back(vec[i]);
		}
		else {
			S.push_back(vec[i] + S[i - 1]);
		}
	}
	
	cout << setprecision(22) << ((double)S[A - 1]) / A << endl;

	REP(i, N) {
		if (vec[i] == vec[A - 1]) {
			k = i;
			break;
		}
	}

	REP(i, N) {
		if (vec[i] < vec[A - 1]) {
			l = i;
			break;
		}
	}

	ll ans = 0, t = 1;

	if (k != 0) {
		FOR(i, 1, (int)A - k + 1) {
			t = (t * ((ll)l - (ll)k - (ll)i + 1)) / (ll)i;
		}
		cout << t << endl;
		return 0;
	}

	FOR(i, 1, (int)B + 1) {
		t = (t * ((ll)l - (ll)k - (ll)i + 1)) / (ll)i;
		if (i >= A) {
			ans += t;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n;
	ll ans = 0;

	cin >> n;

	V c(n,0), s(n,0), f(n,0);
	rep(i, n - 1) {
		cin >> c[i] >> s[i] >> f[i];
	}

	ll t;
	rep(i, n) {
		t = 0;
		rep2(j, i, n - 1) {
			if (t < s[j]) {
				t = s[j];
			}
			else if (t % f[j] == 0) {
				;
			}
			else {
				t = t + f[j] - t % f[j];
			}
			t += c[j];
		}
		cout << t << "\n";
	}
}

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

	solve_abc_c();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;


int main()
{
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
  string s;
  cin>>s;
  int mx=s.size();
  int n=s.size();
  for(int i=0;i<n-1;i++)
  {
  	if(s[i]!=s[i+1])
  	mx=min(mx,max(i+1,n-i-1));
  }
  cout<<mx;

}


Measured memory_bytes: 512
import sys
import math

def check(k, w, P):
    i = 0
    for t in range(k):
        p = 0
        while p + w[i] <= P:
            p += w[i]
            i += 1
            if i == len(w):
                return True
    return False

def allocate(k, w):
    t = [0] * k
    le = 0
    ri = 100000 * 10000

    while ri - le > 1:
        P = (ri + le) / 2
        if check(k, w, P):
            ri = P
        else:
            le = P
    return ri

if __name__ == "__main__":
    w = sys.stdin.readlines()
    k = int(w[0].split()[1])
    del w[0]
    w = [int(wi) for wi in w]
    print allocate(k, w)

Measured memory_bytes: 14852
'use strict'

const main = (arg) => {
  const S = arg.split('\n')[0].split('')
  if (S[0] != S[1] || S[0] != S[2] || S[1] != S[2]) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if v := min(b, d) - max(a, c); v > 0 {
		fmt.Println(v)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  cin >> N;
  cin >> K;
  int X = 1;
  for ( int i = 0 ; i < N ; i++ ) {
    if ( ( X + K ) <= ( X * 2 ) ) {
      X = X + K;
    }
    else {
      X = X * 2;
    }
  }
  cout << X << endl;

}

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

int main() {
    ll N;
    cin >> N;
    vector<vector<ll>> graph(N, vector<ll>(0));
    vector<ll> c(N);
    rep(i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    rep(i, N) cin >> c[i];
    sort(c.begin(), c.end(), greater<int>());

    queue<ll> q;
    q.push(0);
    vector<bool> visit(N, false);
    visit[0] = true;
    vector<ll> res(N);
    ll seq = 0;
    while(!q.empty()) {
        ll now = q.front();
        q.pop();
        res[now] = c[seq++];
        for(auto& p: graph[now]) {
            if(visit[p] == false) {
                q.push(p);
                visit[p] = true;
            }
        }
    }

    ll sum = 0;
    for(ll i=1; i<N; i++) {
        sum += c[i];
    }
    cout << sum << endl;
    rep(i, N) cout << res[i] << " ";
    cout << endl;

    return 0; 

}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {
	
	ll N;
	cin >> N;

	ll ans = -1;
	rep(i, 50000) {
		if (floor(i*1.08) == N) ans = i;
	}

	if (ans == -1) cout << ":(";
	else cout << ans;
}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int k = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
        bool flg = false;
        for(int i = a; i <= b; i++)
        {
          if(i%k==0)
          {
            flg = true;
            break;
          }
        }
        Console.WriteLine(flg ? "OK" : "NG");
	}
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,x,t;
  cin>>n>>x>>t;
  ll ans=ceil(ld(n)/ld(x));
  cout<<ans*t<<"\n";
  return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main(){
	int R;
	cin>>R;
	if (R<1200){
		cout<<"ABC";
		return 0;
	}
	if (R<2800){
		cout<<"ARC";
		return 0;
	}
	cout<<"AGC";
	return 0;
}

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

using namespace std;

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	if(a==b+c || b==a+c || c==b+a){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" <<endl;
	}

	return 0;


}

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

int main(){
    int N; cin >> N;
    int A[N]; 
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    int l = 0, r = N-1;  
    bool g = 0;
    int B[N];
    for(int i = N-1; i >= 0; i--){
        if(g) B[r--] = A[i];
        else B[l++] = A[i]; 
        g ^= 1;
    }
    for(int i = 0; i < N; i++){
        cout << B[i] << ' ';
    }
    cout << endl;

    return 0;
}
/*
12345
1
21
312
4213
53124

1234
1
21
312
4213
*/

Measured memory_bytes: 3712
package main

import "fmt"

func pow(b, p int) int {
	if p == 0 {
		return 1
	} else {
		return b * pow(b, p-1)
	}
}

func main() {
	var x int
	fmt.Scan(&x)

	max := 1
	for b := 2; b <= x; b++ {
		for p := 2; ; p++ {
			v := pow(b, p)
			if v > x {
				break
			}
			if v > max {
				max = v
			}
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 1LL << 60;

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

int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }
    long long dp[n];
    for (int i = 0; i < n; i ++){
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 1; i < n; i++){
        for (int j = 1; j < k+1; j++){
            if(i-j > -1) chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1];
    
 
    return 0;
}

Measured memory_bytes: 1408
N=int(input())
p=list(map(int,input().split()))
P=[]
for j in range(len(p)):
    P.append([p[j],j])
P.sort()
a=[]
b=[]

for i in range(1,len(p)+1):
    a.append(str(i*20001+P[i-1][1]))
    b.append(str((len(p)+1-i)*20001+P[i-1][1]))
    
print(" ".join(a))
print(" ".join(b))

Measured memory_bytes: 10488
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    vector<string> s(N);
    for(int i = 0; i < N; i++){
        read(s[i]);
        sort(s[i].begin(), s[i].end());
    }
    map<string, ll> mp;
    for(int i = 0; i < N; i++){
        mp[s[i]]++;
    }
    ll ans = 0;
    for(auto i = mp.begin(); i != mp.end(); i++){
        ans += i->second * (i->second - 1) / 2;
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    string s;
    cin >> n >> s;
    int r = 0, b = 0, g = 0;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'R') ++r;
        if(s[i] == 'G') ++g;
        if(s[i] == 'B') ++b;

    }

    LL res = 0;
    int c = 0;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'R') --r, res += g * b;
        if(s[i] == 'G') --g, res += r * b;
        if(s[i] == 'B') --b, res += r * g;
        for(int j = i + 1, t = 1; i + t * 2 < n; ++j, ++t) {
            if(s[j] != s[i + t * 2] && s[j] != s[i] && s[i] != s[i + t * 2]) --res;

        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    int ans = 0;
    ll diff = 0;
    vint x;
    rep(i,n) { 
        if (b[i] > a[i]) {
            ans++;
            diff += b[i] - a[i];
        } 
        if (a[i] > b[i]) x.push_back(a[i]-b[i]);
    }
    if (x.empty() && diff > 0) {cout << -1 << endl; return 0;}
    sort(rall(x));
    int id = 0;
    while (diff > 0 && id < (int)x.size()) {
        diff -= x[id++];
        ans++;
    }
    if (diff > 0) {cout << -1 << endl; return 0;}
    else cout << ans << endl;
}

Measured memory_bytes: 4444
S = gets.split("").sort

ans = "yes"

for i in 0 .. S.length - 1 # 要素がある分だけ繰り返したいとき
  if S[i] == S[i + 1]
    ans  = "no"
  end
end

puts ans
# https://qiita.com/you8/items/1d25a63a67c10dada128

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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




VB isPrime;

void Eratosthenes(int n){
    if(n + 1 <= SZ(isPrime)) return;
    isPrime.resize(n+1, true);
    isPrime[0] = isPrime[1] = false;

    for(int i = 2; i * i <= n; ++i){
        if(isPrime[i]){
            for(int j = i; i * j <= n; ++j)
                isPrime[i*j] = false;
        }
    }
}

int main(){
    int N, H, W; cin >> N >> H >> W;
    cout << (N-H+1) * (N-W+1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans;
void getpi(string p) {
    int n = p.size();
    vector<int> pi(n);
    int j = 0;
    for(int i=1; i<n; i++) {
        while(j && p[j] != p[i])
            j = pi[j-1];
        if(p[j] == p[i])
            j++;
        pi[i] = j;
        if(j*2 <= i+1) {
        	ans = max(ans, j);
        } else {
        	ans = max(ans, (i+1)/2);
        }
    }
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for(int i=0; i<n; i++) {
		getpi(s.substr(i));
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long n;
	cin>>n;
	long A[n];
	map<long,long> B,C;
	for(long i=0;i<n;i++){
		cin>>A[i];
		B[A[i]]++;
	}
	long ans=0;
	for(auto x:B){
		C[x.first] = ((x.second-1)*(x.second))/2;
		ans+=C[x.first];
	}
	long k=1;
	while(k<=n){
		long tempans = ans-C[A[k-1]];
		long temp = ((B[A[k-1]]-2)*(B[A[k-1]]-1))/2;
		cout<<tempans+temp<<"\n";
		k++;
	}
}

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

int N,Z,W;
vector<int> A;

int main(){
	while(cin >> N >> Z >> W && N>0){
		for(int i=0;i<N;i++){
			int a;
			cin >> a;
			A.push_back(a);
		}
		if(N==1) cout << abs(A[0]-W) << endl;
		else cout << max(abs(A[N-1]-W),abs(A[N-2]-A[N-1]));		
	}
}

Measured memory_bytes: 256
from sys import stdin


def main() -> None:
    n, k = [next_int() for _ in range(2)]
    a = b = 0
    for i in range(n):
        xi = next_int()
        if xi <= k // 2:
            a += xi
        else:
            b += k - xi
    print((a + b) * 2)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
int par[100000];
void init(int n){
	rep(i,n){
		par[i]=i;
	}
}
 
int root(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x] = root(par[x]);
	}
}
 
void unite(int x,int y){
	x=root(x);
	y=root(y);
	if(x==y)return;
	par[x]=y;
}
 
 
 
struct a{
	ll a;
	int num;
	int par;
	bool use;
};
 
bool operator< (const a& left,const a& right){
        return left.a < right.a;
}

/*
rep(i,n){
	cin>>aa[i].a;
	aa[i].num=i;
}*/
 
 
 
int main(void){
	int a[6];
	cin>>a[0]>>a[1];
	cin>>a[2]>>a[3];
	cin>>a[4]>>a[5];
	int count[4];
	rep(i,4){
		count[i] = 0;
	}
	int i;
	rep(i,6){
		count[a[i]-1] += 1;
	}
	rep(i,4){
		if(count[i] == 3){
			cout<<"NO"<<endl;
			return 0;
		}
	}

		cout<<"YES"<<endl;
	
	
 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a,b;
	cin>>n>>a>>b;
	if(n>1&&b>=a||n==1&&a==b)
		cout<<(n-2)*(b-a)+1<<endl;
	else
		cout<<0<<endl;
}

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

int main(){
    int A,B,K,count;
    cin >> A >> B >> K; 
  	//cout << K << endl;
    count = 0;
    for(int i = max(A,B);i>=1;i--){
        if((A%i==0)&&(B%i==0)){
            count++ ;
          	//cout << count <<endl;
            if(count == K){
            cout << i << endl;
          	
            }
            
        }
    }
    
    
}

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

#Nが1桁の場合
if(N<10):
    print(N)
    sys.exit()
#Nが2桁の場合
if(N<100):
    print(9)
    sys.exit()
#Nが3桁の場合
if(N<1000):
    print(N-90)
    sys.exit()
#Nが4桁の場合
if(N<10000):
    print(909)
    sys.exit()
#Nが5桁の場合
if(N<100000):
    print(N-9090)
    sys.exit()
#N=10^5の時
if(N==100000):
    print(90909)
    sys,exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n, a;
  cin >> n;
  int b[n];
  for(int i = 0; i < n; i++){
    cin >> a;
    b[i] = a - i;
  }
  sort(b, b + n);
  long long sum = 0;
  for(int i = 0; i < n; i++) sum += abs(b[i] - b[(n-1)/2]);
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
using namespace std;
int main() {
	int n, a[200000], ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (ans == a[i]) {
			ans++;
		}
	}
	if (ans == 1) {
		cout << "-1" << endl;
		return 0;
	}
	cout << n - ans + 1 << endl;
	return 0;
}

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

int N;
vector<int> A(100);

void print(){
    for(int i = 0; i < N; i++){
        cout << A[i] << (i != N-1 ? " " : "\n");
    }
}

void insertion_Sort(){
    
    for(int i = 1; i < N; i++){
        
        print();
        
        int v = A[i];
        int sort_Already = i - 1;
        while(sort_Already >= 0 && A[sort_Already] > v){
            A[sort_Already + 1] = A[sort_Already];
            A[sort_Already] = v;
            sort_Already--;
        }
    }
    
    print();
}


int main(void){
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    insertion_Sort();
    
}



Measured memory_bytes: 3132
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        s = S()
        if s == '#':
            break

        l = True
        lr = 0
        for i in range(1,len(s)):
            c = s[i]
            p = s[i-1]
            cl = int(c) % 3
            if cl == 0:
                cl = 3
            pl = int(p) % 3
            if pl == 0:
                pl = 3

            if l and cl > pl:
                lr += 1
            elif not l and cl < pl:
                lr += 1
            else:
                l = not l
        l = False
        tr = 0
        for i in range(1,len(s)):
            c = s[i]
            p = s[i-1]
            cl = int(c) % 3
            if cl == 0:
                cl = 3
            pl = int(p) % 3
            if pl == 0:
                pl = 3

            if l and cl > pl:
                tr += 1
            elif not l and cl < pl:
                tr += 1
            else:
                l = not l

        rr.append(min(lr,tr))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9392
n, m = gets.chomp.split.map(&:to_i)

prefs = Array.new(m)

m.times do |i|
  p, y = gets.chomp.split.map(&:to_i)
  prefs[i] = {index: i+1, p: p, y: y, id: ''}
end

prefs.group_by{|pref| pref[:p]}.each do |pr, group|
  group.sort_by{|pref| pref[:y]}.each_with_index do |pref, j|
    pref[:id] = format('%06d', pr) + format('%06d', j+1)
  end
end

prefs.sort_by{|pref| pref[:index]}.each do |pref|
  puts pref[:id]
end


Measured memory_bytes: 56056
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main(void) {
    int A,B,AB,X,Y;
    std::cin >> A >> B >> AB >> X >> Y;
    int smallxy=std::min(X,Y),bigxy=std::max(X,Y);
    
    long long ans=0;
    if(A+B>=2*AB){
        if((X>Y&&A>2*AB)||(X<Y&&B>2*AB)){
            ans+=bigxy*AB*2;
        }else{
            ans+=2*AB*smallxy;
            if(X>Y){
                ans+=(X-Y)*A;
            }
            if(X<Y){
                ans+=(Y-X)*B;
            }
        }  
    }else{
        ans+=X*A+Y*B;
    }
    
    std::cout << ans << std::endl;
    return 0;
}

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

int count = 0;
void dfs(int num, int tempsum, int sum) {
	if (sum < tempsum)
		return;
	if (num == 4) {
		if (tempsum == sum) {
			count++;
		}
		return;
	}

	for (int i = 9; i >= 0; i--) {
		dfs(num+1,tempsum + i,sum);
	}
}  

int main()  
{  
	int iSum = 0;
	while (cin >> iSum) {
		count = 0;
		dfs(0,0,iSum);
		cout << count << endl;
	}

	return 0;
}

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

#define int long long 
#define MOD 1000000007



using namespace std;


signed main(){

	int N,H,W;
	cin>> N>>H>>W;
	
	int A;
	int B;
	int ans = 0;
	
	for(int i=0;i<N;i++){
		cin >> A>>B;
		if(A>=H&&B>=W){
			ans++;
		}
	
	}
	
	cout << ans << endl;
 	
 	return 0;
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)

const ll INF = 1e15;

int main()
{
    int N;
    cin >> N;
    vector<long> A(N);
    int ans = 0;
    REP(i,N){
        cin >> A[i];
    }
    REP(i,N){
        for(int j = 0;j<N;j++){
            ans = max(ans,(int)abs(A[i]-A[j]));
        }
    }
    cout << ans;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

int exp(int base, int e , int mod){
    int result = 1;
    base %= mod;
    while(e){
        if(e & 1 )
        result =  result  * base % mod;

            base = base * base % mod;
            e >>=1 ;
    }
    return result;
}

void solve() {
    int n;
    cin>>n;
    map<int,int> x;
    for(int i = 0 ; i< n; i++){
        int k;
        cin>>k;
        x[k]++;
    }
    if(n % 2 == 0){
        bool is = true;
        for(auto i :x){
            if(i.first % 2 == 0){
                is = false;
                break;
            }
            if(i.second != 2){
                is = false;
                break;
            }
        }
        if(is){
            cout<<exp(2 , n / 2 , MOD)<<endl;
        }else {
            cout<<0<<endl;
        }

    }else {
        bool is = true;
        int c0 = 0 , c2 = 0;
        for(auto i : x){
            if(i.first % 2 == 1){
                is = false;
                break;
            }
            if(i.second == 2){
                c2++;
            }
            if(i.first == 0){
                c0 += i.second;
            }
        }
        if(is){

            if(c0 == 1 && c2 == (n - 1) / 2){
                cout<<exp(2 , (n - 1) / 2  , MOD)<<endl;
            }else cout<<0<<endl;
        }else {
            cout<<0<<endl;
        }
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 4224
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main() { long long a,b,c,d;
    cin >> a>>b>>c>>d;
    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
    return(0);
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int x = sc.nextInt();
        int y = sc.nextInt();

        if(y<(x*2)){
            System.out.println("No");
        }
        else if(y > (x*4)){
            System.out.println("No");
        }
        else{
            int rem = y - (2*x);
            if(rem%2==0){
                if((rem/2)<=x){
                    System.out.println("Yes");
                }
                else{
                    System.out.println("No");
                }
            }
            else{
                System.out.println("No");
            }
        }
        
    }
}

Measured memory_bytes: 32704
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int calc(string s, Int K){

  Int N = s.size();
  vector<vector<Int> > dp(K * N + 1, vector<Int>(3, INF)); //[回数 * 添字][前回の文字(0:同じ, 1:変えた)]

  dp[0][1] = 0;
  for(Int i=0;i<K * N;i++){
    {//k == 0
      if(i == 0 || s[i%N] != s[(i-1 + N)%N]) Min(dp[i+1][0], dp[i][0]); //変えない
      Min(dp[i+1][1], dp[i][0] + 1); //変える
    }
    {//k == 1
      Min(dp[i+1][0], dp[i][1]);
      Min(dp[i+1][1], dp[i][1]+1);
    }
  }
  Int res = min(dp[K * N][0], dp[K * N][1]);
  return res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;

  Int K;
  cin>>K;

  if(K < 10){
    Int ans = calc(s, K);
    cout<<ans<<endl;
    return 0;
  }

  if(K%2 == 0){
    Int a = calc(s, 4);
    Int b = calc(s, 5);
    Int ans = a + (b - a) * (K - 4);
    cout<<ans<<endl;
  }
  else {
    Int a = calc(s, 3);
    Int b = calc(s, 5);
    Int ans = a + (b - a) * ((K - 3)/2);
    cout<<ans<<endl;
  }



  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int A,B,C,D,E;
  int time,t,s,j = 0;

  scanf("%d\n%d\n%d\n%d\n%d",&A,&B,&C,&D,&E);

  int a[5] ={A,B,C,D,E};  
  int h[5]={0,0,0,0,0};
  
  for(t=0;t<5;t++)
    {
      while(a[t]%10 != 0)
	{
	  a[t] = a[t]+1;
	  h[t] = h[t]+1;
	}
      time = time + a[t];
    }
  
   
  for(s=0;s<5;s++)
    { if(h[s]>h[0])
	h[0]=h[s];
    }

  printf("%d",time-h[0]);

  return 0;
}  
     


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

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String[] inArray = in.split(" ");
		int N = Integer.parseInt(inArray[0]);
		int L = Integer.parseInt(inArray[1]);
		List<String> inList = new ArrayList<String>();
		for (int i =0 ; i < N; i++) {
			String inStr = sc.nextLine();
			inList.add(inStr);
		}
		Collections.sort(inList);
		StringBuffer buf = new StringBuffer();
		for (int i = 0; i < inList.size(); i++) {
			buf.append(inList.get(i));
		}
		System.out.println(buf.toString());
		sc.close();
	}
	

}


Measured memory_bytes: 9684
#include<stdio.h>
#include<string.h>
int main(){
	char a[11],b[1001],c[12]="END_OF_TEXT";
	int i,count=0;
	scanf("%s",a);
	while(1){
		scanf("%s",b);
		if(strcmp(b,c)==0) break;
		for(i=0;b[i]!='\0';i++){
			b[i]=tolower(b[i]);
		}
		if(strcmp(b,a)==0) count++;
	}
	printf("%d\n",count);
}


Measured memory_bytes: 2048