akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;



//---------- 1000000007 ----------
const int MOD = 1000000007;
int m_add(int a, int b)
{
	return (a + b) % MOD;
}
int m_sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int m_mul(int a, int b)
{
	return (a * b) % MOD;
}
int m_pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = m_pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int m_divide(int a, int b)
{
	return m_mul(a, m_pow(b, MOD - 2));
}


//---------- 組み合わせ ----------
int m_comb(int n, int r)
{
	int i;
	int p = 1;
	for (i = 1; i <= r; i++)
	{
		p = m_mul(p, (n - i + 1));
		p = m_divide(p, i);
	}
	return p;
}

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

	int k = m_divide(2, 2);

	int a = m_comb(N, A);
	int b = m_comb(N, B);

	int ans = m_pow(2, N);
	ans = m_sub(ans, a);
	ans = m_sub(ans, b);

	cout << m_sub(ans, 1) << endl;
}




Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def ketawa(x):
	return sum(map(int, list(str(x))))

N = INT()

ans = INF

for a in range(1, N//2+1):
	b = N-a
	ans = min(ans, ketawa(a)+ketawa(b))
print(ans)


Measured memory_bytes: 5400
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int n;
int p[1001];

void prime_factor(int n)
{
    for(ll i = 2; i*i <= n; i++){
        while(n % i == 0){
            p[i]++;
            n /= i;
        }
    }
    if(n != 1) p[n]++;
}

void init()
{
}

void solve()
{
    ll ans = 1;
    FOR(i, 1, n+1) prime_factor(i);
    REP(i, n+1){
        ans *= p[i]+1;
        ans %= MOD;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
import collections
N, M = map(int, input().split())
A = [int(i)%M for i in input().split()]
B = [0]
sum_ = 0
for a in A:
    sum_ = (sum_ + a) % M
    B.append(sum_)
b = collections.Counter(B)
ans = 0
for c in b.values():
    ans += int(c * (c - 1) / 2)
print(ans)

Measured memory_bytes: 17368
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "Second";
		int n = s.length();
		if(s.charAt(0) == s.charAt(n-1) && n%2 == 0 || s.charAt(0) != s.charAt(n-1) && n%2 != 0) result = "First";
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> l(n);
	rep (i, n) cin >> l[i];
	sort(l.begin(), l.end());
	int res = 0;
	rep (i, n - 2) {
	  FOR (j, i + 1, n - 1) {
		auto p = lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]);
		res += p - (l.begin() + j) - 1;
	  }
	}
	cout << res << endl;
    
    return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;

const int MOD=1e9+7;
const int INF=-1e9;

template<typename T>
struct RMQ{
    const T INF=-1e9;
    int n;
    vector<T> dat;
    RMQ(int n_):n(),dat(n_*4,INF){
        int tmp=1;
        while(n_>tmp){
            tmp*=2;
        }
        n=tmp;
    }

    void update(int k,T a){ //k番目の値をaに変更
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=max(dat[2*k+1],dat[2*k+2]);
        }
    }  

    T query(int a,int b,int k=0,int l=0,int r=-1){ //[a,b)の最小値を求める
        if(r<0) r=n;
        if(r<=a||b<=l) return INF;
        if(a<=l&&r<=b) return dat[k];
        else{
            T vl=query(a,b,2*k+1,l,(l+r)/2);
            T vr=query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
        }
    }
};

int main(){
    int N,K; cin >> N >> K;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    RMQ<int> rmq(600005);
    int tmp=a[0];
    rmq.update(a[0],1);
    for(int i=1;i<N;i++){
        int res=rmq.query(max(-K+a[i],0),min(K+tmp,K+a[i])+1)+1;
        tmp=max(tmp,a[i]);
        if(res<0) rmq.update(a[i],1);
        else rmq.update(a[i],res);
    }
    cout << rmq.query(0,600004) << endl;
}

Measured memory_bytes: 13828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  mat dp(n+1,vec(n+1));
  for(ll i=0;i<n;i++) dp[0][i]=1;
  for(ll i=0;i<n-1;i++) {
    vec sum(3010);
    for(ll j=0;j<=n;j++) {
      sum[j+1]=(sum[j]+dp[i][j])%mod;
    }
    for(ll j=0;j<n;j++) {
      if(s[i]=='>') {
        dp[i+1][j]=sum[j+1];
      }
      else {
        dp[i+1][j]=(sum[n-i]-sum[j+1]+mod)%mod;
      }
    }
  }
  cout << dp[n-1][0] << endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll sub(vector<int>& arr) {
    ll m = INT_MAX, ans = 0;
    int n = arr.size();
    for(int i = 1; i <= n; i++) {
        ans += llabs(arr[i%n] - arr[i-1]);
        m = min(m, llabs(arr[i%n] - arr[i-1]));
    }
    return ans-m;
}

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    vector<int> arr2(n, 0);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    int l = 0, r = n-1;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if (i % 2 == 0)
            arr2[i] = arr[l++];
        else
            arr2[i] = arr[r--];
    }
    ll tmp = sub(arr2);
    l = 0, r = n-1;
    for(int i = 0; i < n; i++) {
        if (i % 2 == 0)
            arr2[i] = arr[r--];
        else
            arr2[i] = arr[l++];
    }
    cout << max(tmp, sub(arr2)) << endl;

    return 0;
}




Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
static const int MAXN = 102;

int n;
char s[MAXN];
bool t[MAXN];

int main()
{
    scanf("%s", s);
    n = strlen(s);

    int ans = n + 10;
    for (char c = 'a'; c <= 'z'; ++c) {
        int cur = 0, last = -1;
        for (int i = 0; i < n; ++i) if (s[i] == c) {
            cur = std::max(cur, i - last - 1);
            last = i;
        }
        cur = std::max(cur, n - 1 - last);
        ans = std::min(ans, cur);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

const ll M = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= M;
	if(k&1LL){ ret *= x; ret %= M; }
	return ret;
}

ll C[4002][2002];
void C_init(){
	C[0][0] = 1;
	for(int i = 0 ; i < 4001 ; i ++){
		for(int j = 0 ; j <= min(i,2000) ; j ++){
			if(C[i][j] >= M)C[i][j] -= M;
			C[i+1][j] += C[i][j];
			C[i+1][j+1] += C[i][j];
		}
	}
}

ll f[8004];
void f_init(){
	f[0] = 1;
	for(int i = 1 ; i < 8004 ; i ++){
		f[i] = f[i-1]*i;
		f[i] %= M;
	}
}
ll CC(ll n,ll k){
	ll ret = f[n];
	ret *= modpow(f[k],M-2); ret %= M;
	ret *= modpow(f[n-k],M-2); ret %= M;
	return ret;
}

int main(){
	C_init();
	f_init();
	static ll N;
	static ll A[200010],B[200010];
	scanf("%lld",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld%lld",&A[i],&B[i]);
	}
	
	static ll D[2002][2002] = {};
	for(int i = 1 ; i <= N ; i ++){
		D[A[i]][B[i]] ++;
	}
	for(int i = 2000 ; i >= 1 ; i --){
		for(int j = 2000 ; j >= 1 ; j --){
			if(D[i][j] >= M)D[i][j] -= M;
			D[i-1][j] += D[i][j];
			D[i][j-1] += D[i][j];
		}
	}
	
	static ll ret = 0;
	ll sum = 0;
	for(int i = 1 ; i <= 2000 ; i ++){
		sum += D[i][0];
	}
	sum %= M;
	sum *= sum; sum %= M;
	ret += sum;
	sum = 0;
	for(int i = 1 ; i <= 2000 ; i ++){
		sum += D[0][i];
	}
	sum %= M;
	sum *= sum; sum %= M;
	ret += sum;
	for(int i = 1 ; i <= 2000 ; i ++){
		for(int j = 1 ; j <= 2000 ; j ++){
			ll r = D[i][0]*D[0][j];
			r %= M;
			r *= C[i+j][j]*2;
			ret += r;
			ret %= M;
		}
	}
	for(int i = 1 ; i <= N ; i ++){
		ret += M-CC(A[i]*2+B[i]*2,B[i]*2);
	}
	ret %= M;
	ret *= modpow(2,M-2);
	cout << ret%M << endl;
}



Measured memory_bytes: 95872
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        int a = sc.nextInt();
        int counter = 0;
        sc.close();
        // 500円玉の使う枚数を確認
        while (n > 499) {
            n -= 500;
        }

        // 1円玉の使う枚数を確認
        while (n > 0) {
            n -= 1;
            counter++;
        }

        if (a >= counter) {
            // 出力
            System.out.println("Yes");
        } else {
            // 出力
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

char s[maxn];
int main(){
	// debug;
	ios;

	cin>>s;
	int cnt = 0,ans = 0;
	for(int i = 0;i<strlen(s);i++){
		if(s[i] == 'R') cnt++,ans = max(ans,cnt);
		else cnt = 0;
	}
	cout<<ans<<'\n';

	
	return 0;
}


Measured memory_bytes: 3652
N = int(input())
XY = []
for n in range(N):
    XY.append([int(i) for i in input().split()])
XY = sorted(XY)
cnt = {}
for n in range(N):
    for nn in range(n+1,N): 
        dist = [XY[n][0]-XY[nn][0],XY[n][1]-XY[nn][1]]
        if str(dist) in cnt:
            cnt[str(dist)] += 1
        else:
            cnt[str(dist)] = 1
if N == 1:
    print(1)
else:
    print(N - max(cnt.values()))


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

int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    long long v[n];
    for(long long i=0; i<n; i++) cin >> v[i];
    sort(v,v+n,greater<long long>());
    long long sum=0;
    for(long long i=0; i<a; i++) sum += v[i];
    long long x,y;
    for(long long i=0; i<n; i++){
        if(v[i]==v[a-1]) {
            x = i;
            break;
        }
    }
    for(long long i=n-1; i>=0; i--){
        if(v[i]==v[a-1]){
            y = i;
            break;
        }
    }
    long long m = y-x+1;
    if(sum == v[a-1]*a){
        cout << v[a-1] << endl;
        long long ans = 0;
        for(long long i = a; i<= min(m,b); i++){
            long long t = 1;
            for(long long j = 1; j<=i; j++){
                t *= m-j+1;
                t /= j;
            }
            ans += t;
        }
        cout << ans << endl;
    }
    else{
        cout << setprecision(20) <<  sum/(double)a << endl;
        long long k = a-x;
        long long ans = 1;
        for(long long i = 1; i<=k; i++){
            ans *= m-i+1;
            ans /= i;
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define MAX_N 100001
#define INF   1000000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll children[MAX_N];

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

    string S;
    cin >> S;

    ll N = S.size();
    ll b1, b2;
    ll l, r;
    fill(children, children + N, 0);
    
    b1 = 0;
    b2 = -1;
    for (ll i = 1; i < N; i++) {
      
      if (S[i-1] == 'R' && S[i] == 'L') { r = i - 1; l = i; }
      if (S[i-1] == 'L' && S[i] == 'R') { b2 = i-1; }
      if (i == N-1) { b2 = i; }

      if (b2 != -1) {
	ll nr = 0;
	nr += (b2 - r)/2 + 1;
	nr += (r - b1)/2 + 1;
	nr--;
	ll nl = (b2 - b1 + 1) - nr;
	
	children[r] = nr;
	children[l] = nl;
	
	b1 = b2 + 1;
	b2 = -1;
      }
     
    }

    for (ll i = 0; i < N; i++) cout << children[i] << " ";
    cout << endl;
    return 0;
}
    




Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pair<int, int>>
#define er(n) cout<<"error "<<n<<endl;
int mod=1000000007;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    string s;
    cin>>s;
    int n=s.size()-1, ans=0;
    for (int i=0 ; i<(1<<n) ; i++){
        int j=i;
        string temp;
        temp+=s[0];
        for (int k=1 ; k<=n ; k++){
            if ((j&1LL)==0) temp+=s[k];
            else {
                ans+=stoll(temp);
                temp=s[k];
            }
            j>>=1;
        }
        ans+=stoll(temp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
from typing import List, Counter, Tuple
from collections import Counter
from itertools import permutations, zip_longest, groupby


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> int:
    # f(n) = 1, n < 2
    # f(n) = n*f(n-2) n>= 2
    N = read_int()
    if N%2 == 1:
        return 0
    answer = 0
    base = 10
    while base <= N:
        answer += N//base
        base *= 5
    return answer


if __name__ == '__main__':
    print(solve())


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

int main(int argc, char *argv[])
{
	char str1[8], str2[8];

	cin >> str1 >> str2;

	if (str2[2] == str1[0] &&
		str2[1] == str1[1] &&
		str2[0] == str1[2])
		cout << "YES\n";
	else
		cout << "NO\n";

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int k; cin >> k;
    vector<int> amari(k+1);
    amari[1] = 7 % k;
    for(int i = 2; i <= k; i++) amari[i] = (amari[i-1] * 10 + 7) % k;
    for(int i = 1; i <= k; i++) {
        if(amari[i] == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7224
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

long double thrt(long double q){
  long double x=q/2.0;
  while(abs(x*x*x-q)>=0.00001*q){
    x-=(x*x*x-q)/(3.0*x*x);
  }
  return x;
}

int main(){
  long double q;
  while(cin>>q&&(q!=-1)){
    cout<<setprecision(10)<<thrt(q)<<endl;
  }

}

Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 998244353
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

long long beki(long long a,int n)
{
  long long s=1LL;
  while(n){
    if(n%2)s=(s*a)%MOD;
    a=(a*a)%MOD;
    n/=2;
  }
  return s;
}

signed main(void) {
    int n;
    cin >> n;
    vi d(n,0);
    int ans = 1;
    rep(i,n){
        int in;
        cin >> in;
        if(i == 0 && in != 0)ans = 0;
        d[in]++;
    }
    if(d[0] > 1)ans = 0;
    loop(i,1,n){
        if(d[i] == 0){
            loop(j,i,n)if(d[j] != 0)ans = 0;
            break;
        }
        ans *= beki(d[i-1],d[i]);
        ans %= MOD;
    }
    cout << ans << endl;
}


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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)

#define L(x) ((x)*2)
#define R(x) ((x)*2+1)

#ifndef __SOULTCH
#define endl '\n'
#define debug(x) 
#else
#define debug(x) cout << " [+] " << #x << " = " << x << endl
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << pai.first << ' ' << pai.second;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    rep(i, sz(v)) cout << v[i] << ' ';
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> s) {
    for (T p : s) cout << p << ' ';
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> s) {
    for (auto p : s) cout << '(' << p << ") ";
    return os;
}

template<typename T, typename V>
istream &operator>>(istream &is, pair<T, V> &pai) {
	is >> pai.first >> pai.second;
	return is;
}

int N;
int last[200001];
ll dp[200001] = {1};
int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N;
    repp(i, N) {
        int C; cin >> C;
        dp[i] = (dp[i-1]+(i-1>last[C]&&last[C]>0?dp[last[C]]:0))%MOD;
        last[C] = i;
    }

    cout << dp[N];
}







Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
int main(){
    int n;cin>>n;
    vector<string>S0(n),S(n);vector<int>P0(n);
    rep(i,n){cin>>S0[i]>>P0[i];S[i]=S0[i];}
    sort(S.begin(),S.end());S.erase(unique(S.begin(), S.end()), S.end());
    vector<vector<pair<int,int>>>A(S.size());
    rep(i,n){
        rep(j,S.size()){
            if(S0[i]==S[j]){
                A[j].push_back(make_pair(P0[i],i));
                break;
            }
        }
    }
    
    rep(i,A.size()){
        sort(A[i].begin(),A[i].end());reverse(A[i].begin(),A[i].end());
    }
    rep(i,A.size()){
        rep(j,A[i].size()){
            cout<<A[i][j].second+1<<endl;
        }
    }
}

Measured memory_bytes: 256
#ABC134 D - Preparing Boxes
N = int(input())
A = [0]+list(map(int,input().split()))
B = []
T = [0]*(N+1)

for i in range(N,0,-1):
    total = 0
    v = i
    while v <= N:
        total += T[v]
        v += i
    if total%2 != A[i]:
        T[i]=1
        B.append(i)

B.sort()
if len(B)>0:
    print(len(B))
    print(*B)
else:
    print(0)


Measured memory_bytes: 14032
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 100005;
int p[N];

void init() {
    p[0] = 1;
    repi (_,100,105) repi (i,_,N-1) p[i] |= p[i-_];
}

void solve() {
    int n;
    scanf(I,&n);
    printf(IN,p[n]);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 640
#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;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 3e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
vector <int> g[N];
struct SegTree{
    vector <ll> tree;
    int n;
    ll DEFAULT_VALUE = 0; // merge(a, DEFAULT_VALUE) = a
    SegTree(vector <ll>& a) {
        n = (int)a.size();
        tree.resize(4 * n + 10);
    }
    ll merge(ll a, ll b){
        return max(a, b);
    }
    // [l, r]
    ll get(int v, int cl, int cr,const int l,const int r) {
        if(l > r)  
            return DEFAULT_VALUE;
        if(l == cl && r == cr)
            return tree[v];
        int md = cl + cr >> 1;
        return merge(get(v * 2, cl, md, l, min(r, md)), 
               get(v*2 + 1, md + 1, cr, max(l, md + 1), r));
    }
    ll get(int l, int r) {
        return get(1, 1, n, l, r);
    }
    void update(int v, int cl, int cr, int pos, ll nval) {
        if(cl == cr){
            tree[v] += nval;
        }
        else{
            int md = cl + cr >> 1;
            if(pos <= md)
                update (v*2, cl, md, pos, nval);
            else    
                update (v*2 + 1, md + 1, cr, pos, nval);
            tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
        }
    }
    void update(int pos, ll nval) {
        update(1, 1, n, pos, nval);
    }
    
};
void solve(){
    int h, w, n;
    cin >> h >> w >> n;
    int mxx =0, mxy = 0;
    vector <ll> c(w + 1);
    SegTree s(c);
    for(int i = 1; i <= n; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
        s.update(y, 1);
    }
    int ans = 0;
    for(int i = 1; i <= h; ++i) {
        for(int v : g[i]) 
            s.update(v, -1);
        ans = max(ans, (int)g[i].size() + (int)s.tree[1]) ;
        for(int v : g[i])
            s.update(v, 1);
    }
    cout << ans;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 31432
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   int d,n;
   cin>>d>>n;
   ll ans=pow(100,d)*n;
   if(ans==100) ans++;
   if(ans==10000) ans+=100;
   if(ans==1000000) ans+=10000;
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long as(long long  a,long long  b){
	if(a<b) swap(a,b);
	long long c;
	while(a%b){
		c=a%b;
		a=b;
		b=c;
	}
	return b;
}
		
int main(){
 
	long long a,b;
	int n;
	cin>>n>>a;
	for(int i=1;i<n;i++){
		cin>>b;
		a=a/as(a,b)*b;
	}
	cout<<a<<endl;
	
	return 0;
	
}

Measured memory_bytes: 3096
/**
>>> In The Name Of GOD
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define bs binary_search
#define smin(x,y) (x) = min((x) ,(y))
#define smax(x,y) (x) = max((x) ,(y))
#define sz(x) (int)(x).size()
#define ssz(x) (int)(x).length()
#define all(x) (x).begin(),(x).end()

//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

///ifstream fin("input.txt");
///ofstream fout("output.txt");


bool cmp_pair_F_2(pair <int,int> x, pair <int,int> y)
{
    return x.F>y.F;
}
bool cmp_pair_S_2(pair <int,int> x, pair <int,int> y)
{
    return x.S>y.S;
}
bool cmp_pair_S_1(pair <int,int> x, pair <int,int> y)
{
    return x.S<y.S;
}

bool cmp(int x, int y)
{
	return x>y;
}

const int N=1e5+100;
ll a[N], b[N], c[N];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int i,j;
	ll n,m;
	cin >> n >> m;
	for (int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    vector <pll> v;
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin >> x >> y;
        v.pb({-y,-x});
    }
    sort(all(v));
    ll p=0;
    for (auto i:v)
    {
        int j=p;
        while (j<min(n,p-i.S))
        {
            if (a[j]<-i.F)
                a[j]=-i.F;
            j++;
        }
        p=j;
    }
    ll ans=0;
    for (int i=0;i<n;i++)
        ans+=a[i];
    cout << ans;
    return 0;
}


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

vector<ll> yakusu(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i++){
        if(n % i != 0) continue;
        ret.push_back(i);
        if(i*i != n) ret.push_back(n/i);
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll N;
    cin >> N;
    auto v = yakusu(N);
    ll ans = 0;
    for(auto e : v){
        if(N / e <= e - 2) ans += e-1;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define dep(i, a, n) for(int (i) = (a); (i) >= (n); (i)--)
#define mod (1e9+7)

__attribute__((constructor))
void initial() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
}

signed main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if (abs(a - b) - w <= 0) {
        cout << 0 << endl;
    } else {
        cout << abs(a - b) - w << endl;
    }
    return 0;
}

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

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int w = Integer.parseInt(br.readLine());
        int n = Integer.parseInt(br.readLine());

        int[] array = new int[w];
        for(int i = 0; i < w; i++){
            array[i] = i+1;
        }

        for(int i = 0; i < n; i++){
           String[] input = br.readLine().split(",");
           int a = Integer.parseInt(input[0]);
           int b = Integer.parseInt(input[1]); 
           
           int tmp = array[a-1];
           array[a-1] = array[b-1];
           array[b-1] = tmp;
        }

        for(int i : array){
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 24052
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

//region TEMPLATE
#define double long double
typedef long long ll;
typedef unsigned long long ull;

template<typename T>
void __read(T &a) { cin >> a; }

template<typename T, typename ... Args>
void __read(T &a, Args &... args) {
    cin >> a;
    __read(args...);
}

#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T>
void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
template<class T>
static auto __super_speed__ = (ios_base::sync_with_stdio(0), cin.tie(
        0)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
//endregion


int32_t main() {
    make(int, n);
    make(string, s);
    int cnt = 0;
    for(int i = 1; i + 1 < n; ++i){
        if (s[i - 1] == 'A' && s[i] == 'B' && s[i + 1] == 'C'){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){

int x, y ;

	while(1){

scanf("%d %d", &x, &y);

if ( x * x + y * y == 0) break;

else if (x <= y) printf("%d %d\n", x, y);

else printf ("%d %d\n", y, x);

}

    return 0;

}


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int md = 998244353;

int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n&1)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
//int n,m,k;

signed main()
{
    showoff;
    //cin >> n >> m >> k;
    int n,p,p1;
    cin >> n >> p;
    if(n == 1){cout << p;return 0;}
    vector<pii >fact;
    p1 = p;
    for(int i = 2;i <= 10000005;++i){
    if(i > p)break;
    if(p%i != 0)continue;
    int c = 0;
    while(p%i == 0){
    p /= i;
    ++c;
    }
    fact.pb({i,c});
    }
    int ans = 1;
    for(auto &x:fact){
    ans *= power(x.f,x.se/n);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int partition(int *,int,int);

int main(){
  int n,A[100001],i,gen;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  gen=partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(gen==i)printf("["); /* gen は基準の要素のインデックスが入っている為 */
    printf("%d",A[i]);
    if(gen==i)printf("]");

    if(i!=(n-1)) printf(" ");
    else printf("\n");
  }

  return 0;
}

int partition(int A[],int p,int r){
  int x,i,j,kari;
  x=A[r];
  i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      kari=A[i];
      A[i]=A[j];
      A[j]=kari;
    }
  }
  kari=A[i+1];
  A[i+1]=A[r];
  A[r]=kari;

  return i+1;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

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

    // 26文字でない場合は未使用の文字を末尾に追加
    // 26文字の場合は後ろから読んで下がったところで切り上げ
    if (S.size() != 26)
    {
        vector<int> cnt(26, 0);
        for (char c : S)
        {
            cnt[c - 'a'] = 1;
        }
        for (int i = 0; i < 26; i++)
        {
            if (cnt[i] == 0)
            {
                cout << S << char('a' + i) << endl;
                return 0;
            }
        }
    }
    if (S == "zyxwvutsrqponmlkjihgfedcba")
    {
        cout << -1 << endl;
        return 0;
    }
    string T = S;
    next_permutation(S.begin(), S.end());
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == T[i])
        {
            cout << S[i];
            continue;
        }
        cout << S[i] << endl;
        return 0;
    }
    cout << S << endl;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin>>x;
  int p=360;
  int t=1;
  while((p*t)%x!=0)
  {
    t++;
  }
    cout<<(p*t)/x<<endl;
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int[] abc = new int[3];
        abc[0] = a;
        abc[1] = b;
        abc[2] = c;
        Array.Sort(abc);
        Console.WriteLine(abc[0] + " " + abc[1] + " " + abc[2]);
    }

    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 5736
import Control.Applicative
import Data.List (sort)

main = do
  [a,b,c] <- map read.words <$> getLine :: IO [Int]
  if any even [a,b,c]
    then print 0
    else
      let [l,m] = take 2 $ sort [a,b,c]
      in print (l*m)


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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n, m;
	cin >> n >> m;
	int m1 = m;
	m = min(n, m);
	vector<int> a(n);
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	long long ans = 0;
	for (int i = 0; i <= m; ++i){
		vector<int> neg1;
		long long sum = 0;
		for (int j = 0; j < i; ++j){
			if (a[j] < 0) neg1.push_back(a[j]);
			sum += a[j];
		}
		for (int j = 0; j <= m - i; ++j){
			long long temp = 0;
			vector<int> neg2;
			for (int k = n - 1; k >= max(i, n - j); --k){
				if (a[k] < 0) neg2.push_back(a[k]);
				temp += a[k];
			}
			temp += sum;
			int cd = m1 - i - j;
			vector<int> neg = neg1;
			neg.insert(neg.end(), neg2.begin(), neg2.end());
			sort(neg.begin(), neg.end());
			for (int k = 0; k <= min(cd - 1, (int)neg.size() - 1); ++k){
				temp -= neg[k];
			}
			ans = max(ans, temp);
		}
	}
	cout << ans;
	return 0;
}



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

ll n,ans,sum1,sum2,a[10010],b[10010];

inline ll read(){
	ll x=0,tmp=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') tmp=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return tmp*x;
}

int main(){
	n=read();
	for(ll i=1; i<=n; i++){
		a[i]=read();
		sum1+=a[i];
	}
	for(ll i=1; i<=n; i++){
		b[i]=read();
		sum2+=b[i];
	}
	if(sum1>sum2) return printf("No\n")&0;
	for(ll i=1; i<=n; i++){
		if(b[i]>a[i]) ans+=(b[i]+1-a[i])/2;
	}
	if(ans>sum2-sum1) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int n;
	cin >> n;

	if (n == 1) cout << "Hello World" << endl;
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
      string str;
      cin>>str;
      ll l=str.size()-1;
      cout<<str;
      if(str[l]!='s')
            cout<<"s"<<endl;
      else
            cout<<"es"<<endl;
      return 0;

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,D;
  cin >> N >> D;
  int count=0;
  long double d=0;
  for(int i=0; i<N; i++){
    long int x,y;
    cin >> x >> y;
    d=sqrt(x*x+y*y);
    if(d<=D){
      count = count + 1;
    }
  }
  cout << count << endl;
  return 0;
}  

Measured memory_bytes: 3676
function Main(input) {
  input=input.split("\n");
  var T=input[0].split(' ')[1]-0;
  var times=input[1].split(' ');
  times=times.map(e=>{
    return e-0;
  });
  var ret=T;
  for(var i=1;i<times.length;i++){
    if(times[i]-times[i-1]>=T){
      ret+=T;
    }else{
      ret+=times[i]-times[i-1];
    }
  }
  console.log(ret);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 49968
#include<stdio.h>
#include<stdlib.h>

int dice[6];
int i,t;

int ue=1;
int hid=4;
int mig=3;
int mae=2;
int usi=5;
int sit=6;

int MoveAll(int ueA,int maeA);
void eMove();
void nMove();
void sMove();
void wMove();

int main(){
	int stmn,ueS,maeS=0;
	
	for(i=0;i<6;i++)scanf("%d",&dice[i]);
	scanf("%d",&stmn);
	for(i=0;i<stmn;i++){
		scanf("%d %d",&ueS,&maeS);
		printf("%d\n",MoveAll(ueS,maeS));
	}
	
	return 0;
}

int MoveAll(ueA,maeA){
	while(!((ueA==dice[ue-1])&&(maeA==dice[mae-1]))){
		int rnd=rand()%4;
		
		if(rnd==0)eMove();
		else if(rnd==1)nMove();
		else if(rnd==2)sMove();
		else wMove();
	}
	return dice[mig-1];
}

void eMove(){
	t=ue;
	ue=hid;
	hid=sit;
	sit=mig;
	mig=t;
	return;
}

void nMove(){
	t=ue;
	ue=mae;
	mae=sit;
	sit=usi;
	usi=t;
	return;
}

void sMove(){
	t=ue;
	ue=usi;
	usi=sit;
	sit=mae;
	mae=t;
	return;
}

void wMove(){
	t=ue;
	ue=mig;
	mig=sit;
	sit=hid;
	hid=t;
	return;
}


Measured memory_bytes: 2052
#include<stdio.h>

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

int main()
{
    int n,d,res,tmp;
    
    scanf("%d %d",&n,&d);
    
    tmp = d * 2 + 1;
    res = n / tmp;
    
    if(n % tmp != 0)
    {
        res = res + 1;
    }
    
    printf("%d\n",res);
    
    return 0;
}


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

int main(){
    vector<int> candy(3);
    for (int i = 0; i < 3 ;i++){
        cin >> candy.at(i);
    }
    std::sort(candy.begin(),candy.end());
    if (candy.at(0)+candy.at(1) == candy.at(2)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n;
    cin>>n;
    vector<int> h(n,inf);
    for(int i=0;i<n;i++)cin>>h[i];
    vector<int> dp(n,inf);
    dp[0] = 0;
    dp[1] = abs( h[1]-h[0] );
    for(int i=2;i<n;i++){
	dp[i] = min( dp[i-1] + abs(h[i]-h[i-1]) , dp[i-2] + abs(h[i] -h[i-2] ) );
    }
    cout<<dp[n-1]<<endl;
    return 0;

}


Measured memory_bytes: 1024
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n := input.NextInt()
  c := make([][]int,n)
  a := make([]Pair,n)
  m := map[int64]int{}
  for i:=0;i<n;i++ {
    c[i] = make([]int,4)
    c[i][0],c[i][1],c[i][2],c[i][3] = input.NextInts()
    a[i] = f(c[i][0],c[i][1],c[i][2],c[i][3])
    m[a[i].x] += a[i].y
  }
  ans := int64(0)
  for i:=0;i<n;i++ {
    m[a[i].x] -= a[i].y
    for j:=i+1;j<n;j++ {
      m[a[j].x] -= a[j].y
      for k:=0;k<4;k++ {
        x := make([]Pair,4)
        tmp := int64(1)
        for l:=0;l<4;l++ {
          x[l] = f(c[i][l],c[j][(k+4-l)%4],c[j][(k+3-l)%4],c[i][(l+1)%4])
          tmp *= int64(m[x[l].x])
          m[x[l].x] -= x[l].y
        }
        for l:=0;l<4;l++ { m[x[l].x] += x[l].y }
        ans += tmp
      }
      m[a[j].x] += a[j].y
    }
  }
  fmt.Println(ans)
}

func f(x,y,z,w int) Pair {
  c := []int64{int64(x),int64(y),int64(z),int64(w)}
  a := make([]int64,4)
  for i:=0;i<4;i++ {
    for j:=0;j<4;j++ { a[i] = 1000*a[i]+c[(i+j)%4] }
  }
  ret := max(max(a[0],a[1]),max(a[2],a[3]))
  cnt := 0
  for i:=0;i<4;i++ {
    if a[i] == ret { cnt++ }
  }
  return Pair{ret,cnt}
}

func max(x,y int64) int64 {
  if x > y { return x }
  return y
}

type Pair struct { x int64;y int }

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextInts() (int,int,int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  w,_ := strconv.Atoi(s[3])
  return x,y,z,w
}

Measured memory_bytes: 78336
a,b,c,d=map(int,input().split())
p=[[0]*(d+2)for i in range(c+1)]
p[a][b]=1
m=998244353
for i in range(a,c+1):
 for j in range(b,d+1):p[i][j]+=(j*p[i-1][j]+i*p[i][j-1]-(i-1)*(j-1)*p[i-1][j-1])%m;p[i][j]%=m
print(p[-1][-2]%m)

Measured memory_bytes: 136660
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
from math import ceil
def main(N, K, A):
    def cut_times(longest):
        return sum(a // longest for a in A if a > longest)
    under = 0
    r = 10**9
    for i in range(100):
        m = (under + r) / 2
        if cut_times(m) > K: under = m
        else: r = m
    print(ceil(r - 10**-10))

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)


Measured memory_bytes: 104796
#include<iostream>
#define m(a) min(X,max(0,a))
using namespace std;int r[200000],X,K,Q,T,A,s,l,k,t,x,d,f=-1;int main(){for(cin>>X>>K;l<K;)cin>>r[l++];l=X;for(cin>>Q;Q--;cout<<m(min(l,max(s,A+x))+f*(T-t))<<endl)for(cin>>T>>A;k<K&T>=r[k];f*=-1)x+=d=f*(r[k]-t),s=m(s+d),l=m(l+d),t=r[k++];return 0;}

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

const int maxn = 1e5 + 10;
int n, p[maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    int _count = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i] == i) {
            _count++;
            swap(p[i], p[i + 1]);
        }
    }
    cout << _count << endl;
    return 0;
}

Measured memory_bytes: 640