akhauriyash/Code-Regression huggingface dataset:
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int n;
	cin >> n;
	int pc[n+2]= {}, f[n+2] = {};
	pc[0]= 0, f[0] = 0;
	int dn = 1;
	REP1(i, n+1){
		if(i == dn * 2) dn = i;
		pc[i] = pc[i-dn] + 1;
		f[i] = f[i%pc[i]] + 1;
	}
	string x;
	cin >> x;
	int xp = 0;
	REP(i, n) if(x[i]=='1') xp++;
	int mi=0, pl=0;
	REP(i, n){
		if(xp>1)mi = (mi * 2 + (x[i]-'0')) % (xp-1);
		pl = (pl * 2 + (x[i]-'0')) % (xp+1);
	}
	//cout << xp << " " << mi << " " << pl << endl;
	int ans[n] = {};
	int sp = 1, sm = 1;
	for(int i = n-1; i >= 0; i--){
		sp = sp % (xp+1);
		if(xp > 1)sm = sm % (xp-1);	
		if(x[i] == '1'){
			if(xp> 1) ans[i] = f[(mi - sm + xp - 1)%(xp - 1)] + 1;
			else ans[i] = 0;
		}
		else ans[i] = f[(pl + sp + xp + 1)%(xp + 1)] + 1;
		sp *= 2;
		sm *= 2;
	}
	REP(i, n)cout << ans[i] << endl;
}

Measured memory_bytes: 6096
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll NUM1 = 999979;
ll NUM2 = 999983;

ll gcd(ll a,ll b){
	if(a < b)swap(a,b);

	if(b == 0){
		return a;
	}else{
		return gcd(b,a%b);
	}
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	if(b == 0){
		x = 1;
		y = 0;
		return a;
	}else{
		ll ret = extgcd(b,(a%b),y,x);
		y -= (a/b)*x;
		return ret;
	}
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    if(extgcd(a,m,x,y) != 1)return 0;
    return (m+x%m)%m;
}

void calc(ll &value1,ll &value2,ll op,ll number){
	switch(op){
	case 1:
		value1 = (value1+number)%NUM1;
		value2 = (value2+number)%NUM2;
		break;
	case 2:
		value1 = (value1-number+NUM1)%NUM1;
		value2 = (value2-number+NUM2)%NUM2;
		break;
	case 3:
		value1 = value1*number%NUM1;
		value2 = value2*number%NUM2;
		break;
	case 4:
		value1 = value1*mod_inverse(number,NUM1)%NUM1;
		value2 = value2*mod_inverse(number,NUM2)%NUM2;
		break;
	}
}

int main(){

	int N;
	scanf("%d",&N);

	ll value1 = 0,value2 = 0,op,number;

	for(int i = 0; i < N; i++){
		scanf("%lld %lld",&op,&number);
		calc(value1,value2,op,number);
	}

	ll X,Y;
	extgcd(NUM1,NUM2,X,Y);

	ll ans = (NUM1*X*value2+NUM2*Y*value1)%(NUM1*NUM2);
	ll check = pow(2,31);

	if(ans >= check){
		ans -= NUM1*NUM2;
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3220
def combi(n,k)
  k=n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

N = gets.to_i
a = gets.split.map(&:to_i)
arr = Array.new(N + 1, 0)
comb = Array.new(N + 1, 0)
sum = Array.new(N + 1, 0)
a.each do |num|
  arr[num] += 1
end

(2..N).each do |i|
  comb[i] =  combi(i, 2)
end

arr.each_with_index do |cnt, i|
  sum[i] = comb[cnt]
end

anser = sum.inject(:+)
a.each do |num|
  puts anser - sum[num] + comb[(arr[num] - 1)]
end


Measured memory_bytes: 26380
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define pdd pair < db , db >
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,m;
    IOS;
    fi>>n>>m;
    static int f[1 << 20];
    function < int(int) > get = [&](int k)
    {
        return k == f[k] ? k : f[k] = get(f[k]);
    };
    for (int i = 1;i <= m;++i)
        f[i] = i;
    static int was[1 << 20];
    for (int i = 1;i <= n;++i)
    {
        int sz;
        fi>>sz;
        vi t;
        while (sz --)
        {
            int v;
            fi>>v;
            t.push_back(v);
        }
        sz = t.size();
        for (auto it : t)
            was[it] = 1;
        for (int i = 1;i < sz;++i)
            f[get(t[i])] = get(t[i - 1]);
    }
    vi s;
    for (int i = 1;i <= m;++i)
        if (was[i])
            s.push_back(i);
    int sz = s.size();
    for (int i = 1;i < sz;++i)
        if (get(s[i]) != get(s[i - 1]))
            return puts("NO") * 0;
    puts("YES");
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}




Measured memory_bytes: 1408
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 425
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre     ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}

void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}



int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
const int inf = 2e9, mod = 1e9 + 7,N=1e5+5;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n;i>n-r;i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
*/
long long dp[1004][100005];
int main()
{
    bizarre
    int n,w;
    cin>>n>>w;
    int arr[n+2],dp[w+5];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    memset(dp,0,sizeof dp);
    for(int i=0;i<=w;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-arr[j]>=0&&dp[i-arr[j]]==0)
                dp[i]=1;
        }
    }
    cout << (dp[w]?"First":"Second");
    return 0;
}


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

//temmplate------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
#define ZERO(a) memset(a, 0, sizeof(a))
typedef long long lint;
//------template

int main(){
    int H;
    int A;
    cin >> H >> A;
    int count = 0;
    while(H>0){
        H = H - A;
        count++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
S = input()
li = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"*10
dic = {}
for i in range(26):
    dic[li[i]] = i
re = []
for i in range(len(S)):
    re.append(li[dic[S[i]]+N])
print("".join(re))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

void out(bool a)
{
	if (a) cout << "YES" << endl;
	else cout << "NO" << endl;
	exit(EXIT_SUCCESS);
}

ll solve(int v, const vi& a, const vector<vi>& tree)
{
	if (tree[v].size() == 0) return a[v];
	vi t;
	for (auto i : tree[v])
	{
		ll tmp = solve(i, a, tree);
		if (tmp == -1) return -1;
		t.push_back(tmp);
	}
	ll sum = 0;
	for (auto i : t)
	{
		sum += i;
		if (sum > a[v] * 2) return -1;
	}
	if (sum < a[v]) return -1;
	ll res = a[v] * 2 - sum;
	ll del = (sum - res) / 2;
	ll mi = sum - *max_element(ALL(t));
	if (mi < del) return -1;
	if (res < 0) res = -1;
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n;
	cin >> n;
	vi a(n);
	for (auto &i : a) cin >> i;
	vector<vi> v(n);
	REP(i, n - 1)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	if (n == 2) out(a[0] == a[1]);
	int root;
	REP(i, n)
	{
		if (v[i].size() > 1) root = i;
	}
	vector<vi> tree(n);
	vector<bool> vis(n);
	vis[root] = true;
	queue<int> que;
	que.push(root);
	while (!que.empty())
	{
		int t = que.front();
		que.pop();
		for (auto u : v[t])
		{
			if (vis[u]) continue;
			vis[u] = true;
			que.push(u);
			tree[t].push_back(u);
		}
	}
	out(solve(root, a, tree) == 0);
	return 0;
}

Measured memory_bytes: 22016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)

int const N = 1000, md = 1e9 + 7;
int dp[N + 1], ch[N + 1][N + 1];

void ad(int &x, int y) { if ((x += y) >= md)x -= md; }

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	f(i, 0, n + 1){
		ch[i][0] = 1;
		f(j, 1, i + 1)ad(ch[i][j] = ch[i - 1][j], ch[i - 1][j - 1]);
	}
	dp[0] = 1;
	f(it, 0, k){
		int a;
		scanf("%d", &a);
		for (int i = n; i >= 0; --i){
			dp[i] = (ll)dp[i] * ch[n][a] % md;
			f(j, max(0, i - a), i)ad(dp[i], (ll)dp[j] * ch[n - j][i - j] % md * ch[n - i + j][a - i + j] % md);
		}
	}
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 4224
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		List<Long> HP = new ArrayList<>();

		for(int i=0; i<N; i++) {
			HP.add(sc.nextLong());
		}
		Collections.sort(HP);
		Collections.reverse(HP);
		
		if(N<K) {
			System.out.println(0);
			return;
		}
		long answer = 0;
		
		for(int i=K; i<N; i++) {
			answer += HP.get(i);
		}
		System.out.println(answer);
	}		
}

Measured memory_bytes: 94836
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
    int h,w,m;cin >> h >> w >> m;
    vector<int> hnum(h),wnum(w);
    vector<map<int,int>> exist(w);
    rep(i,m){
        int h,w;cin >> h >> w;
        --h;--w;
        exist[w][h]=1;
        wnum[w]++;
        hnum[h]++;
    }
    int maxh = 0,maxw = 0;
    rep(i,h) maxh = max(maxh,hnum[i]);
    rep(i,w) maxw = max(maxw,wnum[i]);
    vector<int> hind,wind;
    rep(i,h) if(maxh==hnum[i]) hind.push_back(i);
    rep(i,w) if(maxw==wnum[i]) wind.push_back(i);
    //cout << maxh << maxw << endl;
    int ans = maxh + maxw -1;
    for(auto j:wind)for(auto i:hind){
        //cout <<exist[j][i] <<endl;
        if(exist[j][i] == 0 ){
            //cout << j << i << endl;
            cout << ans+1 << endl;
            return 0;
        }
    }
    //cout << "dsfafd" << endl;
    cout << ans << endl;
    



    
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  
  int count=0;
  int pre=0;
  for(int i=0; i<N; i++){
    if(d.at(i)>pre){
      count++;
    }
    pre=d.at(i);
  }
  cout << count << endl;
}


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

int main() {
    int n, t;
    cin >> n >> t;
    int prev = -t;

    long ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += min(x - prev, t);
        prev = x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3 = map(float,input().split())
    a1,b1,c1 = 2*(x2-x1),2*(y2-y1), (x1**2 - x2 **2 + y1 ** 2 - y2 ** 2)
    a2,b2,c2 = 2*(x3-x1), 2*(y3-y1), (x1**2 - x3 **2 + y1 ** 2 - y3 ** 2)

    p1 = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
    p2 = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
    r = math.hypot(x1-p1, y1-p2)
    temp = [p1,p2,r]
    ans = map(lambda x:round(x,3),temp)
    print("%03.3f %03.3f %03.3f"%(temp[0],temp[1],temp[2]))

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

int main(void){
    int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;

    if(A+B<=2*C) cout << A*X+B*Y << endl;
    else{
        int ans=2*C*min(X,Y);
        int S;
        if(X<Y) S=B; //足りないピザの値段
        else S=A;

        if(S<2*C) ans+=S*(max(X,Y)-min(X,Y));
        else ans+=2*C*(max(X,Y)-min(X,Y));

        cout << ans << endl;
    }
}

Measured memory_bytes: 256
N,M,S,L=map(int,input().split())
s = 0
for i in range(L//N+1):
    for j in range(L//M+1):
        k = (L-N*i - M*j)//S
        if k <0 :break
        if (L-N*i - M*j)//S == int((L-N*i - M*j)/S) and N*i + M*j + S*k == L:
            s+=1

print(s)


Measured memory_bytes: 40940
#include <stdio.h>

long GCD(long a, long b){
  long dividend, divisor;
  if (a >= b) {
    dividend = a;
    divisor = b;
  } else {
    dividend = b;
    divisor = a;
  }
  long remainder;
  while (1) {
    if (divisor == 1) {
      return 1;
    }
    remainder = dividend % divisor;
    if (remainder == 0) {
      break;
    } else {
      dividend = divisor;
      divisor = remainder;
    }
  }
  return divisor;
}

int main(void){

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }

  long hp = a[0];
  for (long i = 1; i < n; i++) {
    hp = GCD(hp,a[i]);
  }
  printf("%ld\n", hp);

  return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(){
    ios::sync_with_stdio(false);

    long long int n, a = 0;

    cin>>n;

    for(long long int i=n; i > 0; i /= 10)
    	a += i%10;

    cout << (n % a == 0 ? "Yes" : "No") << endl;
}

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

int countDiv(int l,int r,int d)
{
    if(l%d==0)
        return (r/d)-(l/d)+1;
    return (r/d)-(l/d);
}

int main()
{
  int l,r,d;
  cin>>l>>r>>d;
  cout<<countDiv(l,r,d)<<endl;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  int64 s = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int q = 1; q <= n; ++q) {
        s += gcd(gcd(i, j), q);
      }
    }
  }
  cout << s;
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int k=0;
  rep(i,n) if(p[i]!=i+1) k++;
  if(k<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pr;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (c >= a && c <= b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int ans =0;
    for(int i=0;i<n;i++){
        if(s[i] == t[i])continue;
        ans ++;
    }
    cout << ans << endl;
}
  

Measured memory_bytes: 3892
#include <iostream>
#include <cmath>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

double amin = 100005;
int ans;
int N, T, A;

int main(void) {
    scanf("%d %d %d", &N, &T, &A);

    REP(i, 0, N) {
    	double x;
    	scanf("%lf", &x);
    	double t = T - (x * 0.006);
    	if (abs(A - t) < amin) {
    		amin = abs(A - t);
    		ans = i + 1;
    	}
    }
    
    printf("%d\n", ans);

	return 0;
}


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

using namespace std;
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

//#define int long long
typedef long long ll;
//constexpr int INF = 1e9;
//constexpr int MOD = 1000000007;

decltype(1) main()
{
    //cin.tie(nullptr);
    //ios_base::sync_with_stdio(false);
    int n, x, y;
    cin >> n >> x >> y;
    int length[2002] = {};

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            const int len_ix = abs(i - x);
            const int len_jx = abs(j - x);
            const int len_iy = abs(i - y);
            const int len_jy = abs(j - y);
            const int len_ij = abs(i - j);

            const int idx = min(len_ij, min(len_ix + 1 + len_jy, len_iy + 1 + len_jx));
            length[idx]++;
        }
    }

    for (int i = 1; i < n; ++i)
    {
        cout << length[i] / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>
#include <stdlib.h>

#define M 100000

int pp[M], yy[M], xx[M];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return pp[i] != pp[j] ? pp[i] - pp[j] : yy[i] - yy[j];
}

int main() {
	static int ii[M];
	int n, m, i, x;

	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &pp[i], &yy[i]);
		ii[i] = i;
	}
	qsort(ii, m, sizeof *ii, compare);
	for (i = 0, x = 0; i < m; i++)
		xx[ii[i]] = x = (i > 0 && pp[ii[i]] != pp[ii[i - 1]] ? 0 : x) + 1;
	for (i = 0; i < m; i++)
		printf("%06d%06d\n", pp[i], xx[i]);
	return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int h,w;
int ans;
char mp[8][8];
char mp2[8][8];
bool check(){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(mp[i][j]!=mp2[i][j])return 0;
        }
    }
    return 1;
}
void dfs(int x,int y){
    if(x<0||x>=h)return ;
    if(y<0||y>w)return ;
    if(mp[x][y]=='.')return ;
    if(ans==1)return ;
    if(x==h-1&&y==w-1&&check()){
        ans=1;
        return ;
    }
    mp2[x+1][y]='#';
    dfs(x+1,y);
    mp2[x+1][y]='.';

    mp2[x][y+1]='#';
    dfs(x,y+1);
    mp2[x][y+1]='.';
}
int main(){
    while(scanf("%d%d",&h,&w)==2){
        ans=0;
        for(int i=0;i<h;i++){
            scanf("%s",mp[i]);
        }
        memset(mp2,'.',sizeof(mp2));
        mp2[0][0]='#';
        dfs(0,0);
        if(ans==1){
            puts("Possible");
        }else puts("Impossible");
    }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>

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

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main() {
    ull n, a, b, c, d, e;
    vector<ull> cities(5);
    cin >> n >> a >> b >> c >> d >> e;
    ll mi = min({a,b,c,d,e});
    ull ans = (n + mi - 1)/mi + 4; // 切り上げテク
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    priority_queue<int> jobs;
    vector<pair<int,int>> ab(n);
    for(int i=0; i<n; i++)
    {
        cin>>ab[i].first>>ab[i].second;
    }
    sort(ab.begin(),ab.end());
    long long int totalReward = 0;
    int dayCount = 0;
    int itr = 0;
    for(int i=0; i<m; i++)
    {
        while(itr<n&&ab[itr].first == (i+1))
        {
            jobs.push(ab[itr].second);
            itr++;
        }
        if(!jobs.empty()){
            totalReward += jobs.top();
            jobs.pop();
        }
    }
    cout<<totalReward<<endl;
    return 0;
}


Measured memory_bytes: 1660
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	rm := map[rune]struct{}{
		'0': {},
		'1': {},
		'2': {},
		'3': {},
		'4': {},
		'5': {},
		'6': {},
		'7': {},
		'8': {},
		'9': {},
	}

	A, B := nextInt(), nextInt()
	S := next()

	if len(S) != A + B + 1 {
		fmt.Println("No")
		return
	}

	for pos, r := range S {
		if pos == A {
			if r != '-' {
				fmt.Println("No")
				return
			} else {
				continue
			}
		}

		_, ok := rm[r]
		if !ok {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

//Prime Factorization
vector<long long> PrimeFact(long long N) {
	vector<long long> ret;
	if (N == 1) ret.push_back(1);
	for (long long i = 2, M = N; i*i <= M; ++i) {
		if (N%i == 0) ret.push_back(i);
		while (N%i == 0) N /= i;
	}
	if (N != 1) ret.push_back(N);
	return ret;
}

int main() {
	ll N,P; cin >> N >> P;
	auto d = PrimeFact(P);
	V<ll> c;
	c.push_back(1);
	for(auto u:d){
		if (u == 1LL) continue;
		ll cnt = 0;
		while(P%u==0){
			P /= u;
			cnt++;
		}
		REP(i, cnt / N) c.push_back(u);
	}
	ll ans = 1;
	for (auto u : c) ans *= u;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    long int a,b,c,d;
    long int max = -9223372036854775807;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);

    
        if(a*c>max){
            max = a*c;
        }
        if(a*d>max){
            max=a*d;
        }
        if(b*c>max){
            max=b*c;
        }if(b*d>max){
            max=b*d;
        }
    



 printf("%ld\n",max);
    
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	int N, W;
	cin >> N >> W;
	vector<int> A;
	for (int i = 0; i < N*1000+1; i++)
	{
		A.push_back(W + 1);
	}
	A[0] = 0;
	for (int i = 0; i < N; i++)
	{
		int w, v;
		cin >> w >> v;
		vector<int> B;
		for (int j = 0; j < N * 1000 + 1; j++)
		{
			B.push_back(W + 1);
		}
		for (int j = 0; j < N * 1000 + 1; j++)
		{
			if (A[j] != W + 1)
			{
				B[j + v] = A[j] + w;
			}
		}

		for (int j = 0; j < N * 1000 + 1; j++)
		{
			A[j] = min(A[j], B[j]);
		}
	}
	for (int i = N * 1000; i >= 0; i--)
	{
		if (A[i] < W + 1)
		{
			cout << i << endl;
			break;
		}
	}
}

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

int main(void){
	int N;
	cin>>N;
	vector<ll> t(N+2),a(N+2);
	rep1(i,N)cin>>t[i];
	rep1(i,N)cin>>a[i];
	ll res=1;
	rep1(i,N){
		bool T = t[i]!=t[i-1];
		bool A = a[i]!=a[i+1];
		if(A||T){
			if((A && a[i]>t[i])||(T && t[i]>a[i]))res=0;
		}else{
			res=(res*min(t[i],a[i]))%1000000007;
		}
	}
	cout<<res<<endl;
	return 0;
}


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

int main() {
  int H , W ;
  cin >> H >> W ;
  string s[H] ;
  for ( int i=0 ; i<H ; i++){
    cin >> s[i] ;
  }
  for (int i=0 ; i<H ;i++){
    cout << s[i] << endl;
    cout << s[i] << endl; 
  }
}

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

int main(){
  ll k,count = 0,sum = 0;
  cin >> k;
  
  for(ll i=0; i<10e8; i++){
    sum += k;
    for(;;){
      if(sum%10 == 7){
        sum/=10;
        count++;
      }else break;
    }
    if(sum == 0) break;
  }
  
  if(sum != 0)cout << -1 << endl;
  else cout << count << endl;
  
}

Measured memory_bytes: 3572
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  string n;
  cin>>n;
  if((n[0]=='9')||(n[1]=='9')) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
#define MOD 1000000007
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 

//階乗
ll Kaijou(int a) {
if (a < 2) return 1;
return a * Kaijou(a - 1)%MOD;
}

//逆元の計算用(pは素数のときb=p-2で逆元)
ll calc(int a, int b, int p) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = calc(a, b / 2, p);
		return (d*d) % p;
	}
	else {
		return (a*calc(a, b - 1, p)) % p;
	}
}


int main(){
  ll n;
  cin>>n;
  int ans=INF;
  for(int i=1;i<n;++i){
    int a=i,b=n-i;
    int s=0;
    rep(j,5){
       s+=a%10;
       s+=b%10;
       a/=10;
       b/=10;
    }
    ans=min(ans,s);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll a[2][n];
	REP(i,2) REP(j,n) cin>>a[i][j];
	for(ll i=n-2; i>=0; i--) a[1][i]+=a[1][i+1];
	ll ans=0;
	ll tmp=0;
	REP(i,n) {
		tmp+=a[0][i];
		ans=max(ans,tmp+a[1][i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
unsigned long long L, R, i, j, ans=2019; cin >> L >> R;
if(R-L+1>673){ cout << 0 << "\n"; return 0; }
for(i=L; i<R; i++){ for(j=i+1; j<=R; j++){ ans=min(ans, (i*j)%2019); } }
cout << ans << "\n"; return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  int n;
  cin>>n;
  int arr[n];
  unordered_set<int> s;
  int total = 0;
  int co = 0;
  for(int i=0; i<n;i++)
  {
    cin>>arr[i];
  }
  ll ans = INT_MAX;
  for(int i=-100; i<= 100; i++)
  {
    ll total = 0;
    for(int j =0;j<n;j++)
    {
      total += (arr[j] - i)*(arr[j] - i);
    }
    ans = min(total, ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if(a > b)
    {
        printf("0\n");
    }
    else if( b / a > c )
    {
        printf("%d\n",c);
    }
    else
    {
        printf("%d\n", b / a );
    }

return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 4893435
using namespace std;
char a[p];
int main()
{
	scanf("%s",a+1);
	int len=strlen(a+1);
	int ans=0,ss=0;
	for(fint i=1;i<=len;i++)
	{
		if(a[i]=='R')
		ss++;
		if(a[i]=='S')
		ans=max(ans,ss),ss=0;
	}
	ans=max(ans,ss);
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3732
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Node {
		double x, y;

		Node(String line) {
			String[] tokens = line.split(" ");
			this.x = Double.parseDouble(tokens[0]);
			this.y = Double.parseDouble(tokens[1]);
		}

		double distance(Node n) {
			return Math.sqrt(Math.pow(this.x - n.x, 2.0) + Math.pow(this.y - n.y, 2.0));
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		List<Node> nodes = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			nodes.add(new Node(in.readLine()));
		}
		List<Double> dists = new ArrayList<>();
		for (int i = 0; i < nodes.size(); ++i) {
			List<Node> list = new ArrayList<>(nodes.size());
			list.addAll(nodes);
			list.remove(i);
			dists.addAll(calcDistance(nodes.get(i), list));
		}
		System.out.println(calcAve(dists));
	}

	static double calcAve(List<Double> doubles) {
		double result = 0.0;
		for (int i = 0; i < doubles.size(); ++i) {
			result += doubles.get(i);
		}
		return result / (double) doubles.size();
	}

	static List<Double> calcDistance(Node first, List<Node> remain) {
		if (remain.size() == 1) {
			List<Double> result = new ArrayList<>();
			result.add(first.distance(remain.get(0)));
			return result;
		} else {
			List<Double> result = new ArrayList<>();
			for (int i = 0; i < remain.size(); ++i) {
				List<Node> list = new ArrayList<>(remain.size());
				list.addAll(remain);
				list.remove(i);
				List<Double> distList = calcDistance(remain.get(i), list);
				double first2next = first.distance(remain.get(i));
				for (int j = 0; j < distList.size(); ++j) {
					distList.set(j, distList.get(j) + first2next);
				}
				result.addAll(distList);
			}
			return result;
		}
	}

}

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

int main()
{
	int x1,x2,x3,x4,y1,y2,y3,y4;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	int x=x2-x1,y=y2-y1;
	x3=x2-y,  y3=y2+x;
	x4=x3-x,  y4=y3-y;
	printf("%d %d %d %d",x3,y3,x4,y4);
}


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

#define M 1000033
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
    if ( ch == 'A') return 1;
    else if ( ch == 'C') return 2;
    else if ( ch == 'G') return 3;
    else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for ( i = 0; i < strlen(str); i++ ){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + key % (M-1); }
int h(int key, int i) { return (h1(key) + i * h2(key)) % M; }

bool find(char str[]){
    int index;
    for (int i = 0;; i++){
        index = h(getKey(str), i);
        if (H[index][0] == '\0') return false;
        if (strcmp(H[index], str) == 0) return true;
    }
}

void insert(char str[]){
    int index;
    for (int i = 0;; i++){
        index = h(getKey(str), i);
        if (H[index][0] == '\0') break;
    }
    strcpy(H[index], str);
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf("%s %s", com, str);

        if (com[0] == 'i'){
            insert(str);
        } else {
            if (find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}



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

using namespace std;
typedef long long ll;
int main() {
  int N, K;
  cin >> N >> K;

  ll a = 0;
  ll b = 0;
  for (int i = 1; i <= N; i++) {
    if (i % K == 0) {
      a++;
    }
    if (i % K == K /2) {
      b++;
    }
  }

  if (K % 2 == 0) {
    cout << a * a * a + b * b * b << endl;
  } else {
    cout << a * a * a << endl;
  }
  return 0;
}

Measured memory_bytes: 256
dic = {}
N = int(input())
for i in range(N):
    tmp = input()
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
m = max(sorted(dic.values()))
ans = []
for i in dic.items():
    if i[1] == m:
        ans.append(i[0])
for i in sorted(ans):
    print(i)


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

int main() {
  ll k;
  int t = 7,cnt = 1;
  cin >> k;
  // if(k%2 == 0){cout << -1 << endl;return 0;}
  while(cnt < 1e6){
    if(t%k == 0){
      cout << cnt << endl;
      return 0;
    }
    t %= k;
    t *= 10;
    t += 7;
    cnt++;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3632
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
	



int main(){
   IOS

   int n; cin>>n;
   vi a(n);
   for(int &x : a)cin>>x;

   ll s1 = 0, s2 = 0;

   for(int i = 0; i < n; i++){
	   s1 += a[i];
	   if(s1 >= mod)s1 -= mod;
	   s2 += (ll)a[i] * a[i] % mod;
	   if(s2 >= mod)s2 -= mod;
   }

	s1 = s1 * s1 % mod;
	
	ll ans = (s1 - s2 + mod) % mod;
	ans = ((ans % mod) * (pwr(2, mod - 2) % mod)) % mod;

	cout<<ans<<'\n';


	







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
	if(b&1) res = res * a % mod;
		a = a * a % mod;
	b >>= 1;
	}

	return res;
}



Measured memory_bytes: 3988
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
if h[0] < K:
    print(0)
    exit()
start = 0
end = N
while start < end-1:
    mid = (end+start)//2
    if h[mid] >= K:
        start = mid
    else:
        end = mid
print(start+1)

Measured memory_bytes: 51440
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int n,a[111],k;
int dp[100005][2];
int solve(int k,int p){
    if(k<0)return p;
    int &ans=dp[k][p];
    if(ans!=-1)return ans;
    ans=1-p;
    for(int i=0;i<n;i++){
        if(p){
            ans=max(ans,solve(k-a[i],1-p));
        }
        else ans=min(ans,solve(k-a[i],1-p));
    }
    return ans;
}
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof dp);
    int x=solve(k,0);
    if(x)cout<<"Second";
    else cout<<"First"<<endl;
    return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n,m,s,c,a[3] = {-1,-1,-1};
bool ok = true;
int main(){
	scanf("%d%d", &n, &m);
	rep(i,m){
		scanf("%d%d", &s, &c);
		if(s == 1 && c == 0 && n > 1) ok = false;
		if(a[2-n+s] != -1){
			if(a[2-n+s] != c) ok = false;
		}else a[2-n+s] = c;
	}
	if(a[3-n] == -1) a[3-n] = n == 1 ? 0 : 1;
	if(ok){
		rep(i,n) printf("%d",a[3-n+i] == -1 ? 0 : a[3-n+i]);
		puts("");
	}else puts("-1");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	long long N, ans = 1;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		ans *= i;
		ans %= 1000000007;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
;; F - Xor Shift

(defun main ()
  (let* ((N (read))
         (a (loop repeat N collect (read-fixnum)))
         (b (loop repeat N collect (read-fixnum))))
    (loop for kx in (solve N a b)
          do (format t "~{~a~^ ~}~%" kx))))

(defun solve (N a-lst b-lst)
  (let ((a (make-array N :initial-contents a-lst))
        (b (make-array N :initial-contents b-lst))
        (a-xor (make-array N)) ; 直前の要素とのxor (循環)
        (b-xor (make-array (1- N)))) ; 〃 (先頭を除く)
    ; (k,x)が解 ⇔ a-xor[k:]がb-xorと一致, x = b[0] XOR a[k]
    ; a-xor, b-xorを構築
    (loop for i below N
      do (setf (aref a-xor i) (logxor (aref a i) (aref a (mod (1+ i) N)))))
    (loop for i below (1- N)
      do (setf (aref b-xor i) (logxor (aref b i) (aref b (1+ i)))))
    ; a-xor * 2中のb-xorと一致する位置をKMP法で探す
    (loop for k in (kmp-search a-xor b-xor)
          for x = (logxor (aref a (mod k N)) (aref b 0))
          when (< k N)
          collect (list k x))))

(defun kmp-search (text pattern)
  "text * 2中のpatternに一致する位置をすべて返す."
  (let ((n (array-dimension text 0))
        (m (array-dimension pattern 0))
        (pref (compute-prefix-function pattern)))
    (loop with q = 0
          for i from 0 below (* 2 n)
          for c = (aref text (mod i n))
          do (loop until (or (zerop q) (eql (aref pattern q) c))
                   do (setf q (aref pref q))) ; next char does not match
          when (eql (aref pattern q) c)
          do (incf q) end ; next char matches
          when (= q m)
          collect (- i (1- m))
          and do (setf q (aref pref q))))) ; look for the next match

(defun compute-prefix-function (pattern)
  "pref : {1,2,...,m} -> {0,1,...,m-1}
   pref[q] = max {k : k < q and P[:q].endswith(P[:k])}"
  (let* ((m (array-dimension pattern 0))
         (pref (make-array (1+ m) :initial-element 0)))
    (loop with k = 0
          for q from 1 below m
          for c = (aref pattern q)
          do (loop until (or (zerop k) (eql (aref pattern k) c))
                   do (setf k (aref pref k)))
          when (eql (aref pattern k) c)
          do (incf k) end
          do (setf (aref pref (1+ q)) k))
    pref))

(defun read-fixnum (&optional (in *standard-input*))
  "readより速い非負整数専用read (整数間に空白または改行1個に限る)
   cf. https://qiita.com/sansaqua/items/0b6417cb541047e29da4"
  (loop with acc = 0
        for byte = (read-byte in)
        if (<= 48 byte 57)
          do (setf acc (+ (* acc 10) (- byte 48)))
        else return acc))

(main)


Measured memory_bytes: 51944
import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
d=[]
k=0
s=0
a=0
b=0
nums = list(range(1,n+1))
d= [ list(balls) for balls in itertools.permutations(nums, n)]
for i in d:
  k+=1
  s+=1
  if i==p:
    a=s
  if i==q:
    b=k
print(abs(a-b))
    

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



int main() {
    int n;
    cin >> n;
    int s[n];
    int acc = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        acc += s[i];
    }
    if (acc % 10) {
        cout << acc << endl;
        return 0;
    }

    int sub = 100;
    for (int i = 0; i < n; i++) {
        if (s[i] % 10) {
            sub = min(sub, s[i]);
        }
    }
    if (sub == 100) {
        cout << 0 << endl;
    } else {
        cout << acc - sub << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i < n;i++){
    cin >> a[i];
  }
  for(int i=n-1;i >= 0;i--){
    cout << a[i];
    if(i == 0) cout << endl;
    else cout << " ";
  }
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    vl A(N);
    rep(i, N) cin >> A[i];
    ll M = *max_element(all(A));

    ll ng = 0, ok = 1e9 + 1;
    while(ok-ng>1){
        ll mid = (ok + ng) / 2, cnt = 0, s = 0;
        if(mid<M){
            ng = mid;
            continue;
        }

        ll ai = 0;
        while(ai<N){
            if(s+A[ai]>mid){
                cnt++, s = A[ai];
            }
            else{
                s += A[ai];
            }
            ai++;
        }
        cnt++;

        (cnt <= K ? ok : ng) = mid;
    }

    cout << ok << endl;
}


Measured memory_bytes: 3576