akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
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;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n, ans = 0, r = 0, xsum = 0, sum = 0; cin >> n;  // r = 0 ではいけない
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    // xorの性質として、a^b <= a+b がある。要するに、桁繰り上げが無ければ等しくなる
    // A_l, ..., A_r までxorと+が等しいならl <= r'<= r における[l, r']で成立 → しゃくとり法
    rep(l, n){
        if(l == r) xsum ^= a[r], sum += a[r], r++;  // インクリメントが後
        while(r < n && (xsum^a[r]) == sum+a[r]) xsum ^= a[r], sum += a[r], r++;  // r' < r まで満たしている状態
        ans += r - l;
        xsum ^= a[l];  // xorは足し算も引き算も同義
        sum -= a[l];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4832
/*
 
dunjen_master
 
*/
 

 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=998244353;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 

inline ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}

  

 
#define all(x) (x).begin(),(x).end()

/* ordered_set A;
   A.insert(x);
   A.erase(x);
   A.order_of_key(x) // no of elements less than (<) x
   *A.find_by_order(k-1) // kth smallest element
*/
// int n;
// ll dp[200005][205];
// ll ans=0;
// int a[200005];
// int req;
// ll neg=-1e15;


// ll fun(int indx,int last){
//    // cout<<indx<<" "<<last<<" "<<req<<endl;
//     if(indx==n){
//         if(last==req){
//             return 0;
//         }else{
//             return neg;
//         }
//     }

//     if(dp[indx][last]!=-1){
//         return dp[indx][last];
//     }
    
//     ll ans=neg;

//     ans=max(ans,fun(indx+1,last));

//     if(last==0)ans=max(ans,1+fun(indx+1,a[indx]));
//     if(last==a[indx])ans=max(ans,1+fun(indx+1,a[indx]));
//     if(a[indx]==req)ans=max(ans,1+fun(indx+1,a[indx]));

//     return dp[indx][last]=ans;


// }









int main(){


    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<"\n";
    }else{
        cout<<"safe"<<"\n";
    }
    
 
    
}

    

    
 
    



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,e=0;
  cin>>a>>b>>c>>d;
  if(a>=b)
    e+=b;
  else
    e+=a;
  if(c>=d)
    e+=d;
  else
    e+=c;
  cout<<e<<endl;
  return(0);
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
jisin = H*30 + M*0.5
funsin = M*6
deg = abs(jisin-funsin)
if deg > 180 :
    deg = 360 - deg
rad = math.radians(deg)
c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad))
print(c)

Measured memory_bytes: 9444
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
   
class Main{
   
static final int INF=Integer.MAX_VALUE/2;
static final PrintWriter out=new PrintWriter(System.out);
   
   
static class Edge{
int from;
int to;
int cost;
Edge(int from,int to,int cost){
this.from=from; this.to=to; this.cost=cost;
}
}
   
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int v=Integer.parseInt(line.split(" ")[0]);
int e=Integer.parseInt(line.split(" ")[1]);
int r=Integer.parseInt(line.split(" ")[2]);
Edge[] es=new Edge[e];
int[] d=new int[v];
for(int i=0;i<e;i++){
line=br.readLine();
int s=Integer.parseInt(line.split(" ")[0]);
int t=Integer.parseInt(line.split(" ")[1]);
int c=Integer.parseInt(line.split(" ")[2]);
es[i]=new Edge(s,t,c);
}
if(BellmanFord(v,e,r,es,d)){
out.println("NEGATIVE CYCLE");
}
else{
for(int i=0;i<v;i++){
out.println((d[i]==INF)?"INF":d[i]);
}
}
out.flush();
}
}
   
private static boolean BellmanFord(int v,int ee,int r,Edge[] es,int[] d){
Arrays.fill(d,INF);
d[r]=0;
for(int i=0;i<v;i++){
boolean update=false;
for(int j=0;j<ee;j++){
Edge e=es[j];
if(d[e.to]>d[e.from]+e.cost&&d[e.from]!=INF){
d[e.to]=d[e.from]+e.cost;
update=true;
if(i==v-1) return true;
}
}
if(!update){
break;
}
}
return false;
}
}

Measured memory_bytes: 41116
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>
#include <random>
#include <ctime>
#include <fstream>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;


const int D = 365;
const int si = 26;
vector<int> c(si);
vector<vector<int>> s(D, vector<int>(si));

struct cand {
    int score;
    int hist[D];
    cand() {
        score = 0;
    }
};

bool operator<(const cand &left, const cand &right) {
	return left.score < right.score;
}

random_device r;
MaxHeap<cand> ans_heap;
const int width = 50, branch = 300, reading = 5;
int times = 1;
cand example = cand();

void input() {
    //ifstream fin("/6f4c9d0cfda6a311fea2d9cf23e4f032/tester/example/sample2.in");
    int n; cin >> n;
    rip(i,si,0) {
        cin >> c[i];
    }
    rip(i,D,0) rip(j,si,0) cin >> s[i][j];
}

cand gen_next(cand now, int day) {
	rip(i, reading, 0) {
		int a = r() % si;
        now.hist[day + i] = a;
        now.score = s[day+i][a] + c[a];
	}
	return now;
}

void beem(int day) {
	MaxHeap<cand> cand_heap;
	rip(i, width, 0) {
		cand now = ans_heap.top();
		ans_heap.pop();
		rip(j, branch, 0) {
			cand next = gen_next(now, day);
			cand_heap.push(next);
		}
    }
    swap(ans_heap, cand_heap);
}

void output(cand ans) {
    rip(i, D, 0) {
        cout << ans.hist[i]+1 << endl;
    }
}

int main() {
    input();
	rip(i, width, 0) {
		ans_heap.push(example);
	}
	rip(i, D/reading, 0) {
		beem(i*reading);
		times++;
	}
	output(ans_heap.top());
	// cout << ans_heap.top().score << endl;
}

Measured memory_bytes: 69720
#include "stdio.h"

int main() {
    int n, a;
    scanf("%d", &n);
    a = n % 100 % 10;
    if ( a == 2 ||a ==  4 ||a ==  5 ||a ==  7 ||a ==  9) {
        printf("hon\n");
    } else if (a == 0 || a == 1 ||a ==  6 || a == 8){
            printf("pon\n");
    } else if (a == 3) {
        printf("bon\n");
    }
    return 0;
}

Measured memory_bytes: 1620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long i64;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const i64 INF_LONG = 1LL << 62;
const i64 INF_LONG_NEG = INF_LONG * -1;

int main()
{
    int N; cin >> N;
    vector<int> a(N + 9);
    i64 sunuke = 0, racoon = 0;
    rep(i, N){
        cin >> a[i];
        racoon += a[i];
    }
    
    sunuke = a[0];
    racoon -= a[0];
    i64 diffMin = racoon - sunuke;
    if (diffMin < 0L) diffMin *= -1L;
    for (int i = 1; i < N - 1; ++i){
        sunuke += a[i];
        racoon -= a[i];
        i64 d2 = racoon - sunuke;
        if (d2 < 0L) d2 *= -1L;
        if (d2 < diffMin) diffMin = d2;
    }

    cout << diffMin << endl;

    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 998244353;
const int MX = 2000010;
inline void add(ll &x, ll y) { x += y; if (x >= MOD) x -= MOD; }

ll inv[MX], fact[MX], ifact[MX];

void init() {
    inv[1] = 1;
    for (int i = 2; i < MX; ++i) {
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    }
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < MX; ++i) {
        fact[i] = fact[i-1] * i % MOD;
        ifact[i] = ifact[i-1] * inv[i] % MOD;
    }
}

ll comb(int n, int r) {
    if (n < 0 || r < 0 || r > n) return 0;
    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

ll calc(int N, int sum, int odd) {
	ll res = 0;
	for (int i = 0; i <= min(N, odd); ++i) {
		if ((sum - i) % 2 == 0) {
			ll val = comb((sum - i) / 2 + N - 1, N - 1);
			val = val * comb(N, i) % MOD;
			add(res, val);
		}
	}
	return res;
}

// count a_1, a_2,..., a_N
// sum a_i = M * 3
// 0 <= a_i <= M * 2
// number of odd elements <= M

int main() {
	init();

	int N, M; cin >> N >> M;

	ll all = calc(N, M * 3, M);
	ll over = (calc(N, M, M) + MOD - calc(N-1, M, M)) * N % MOD;
	all = (all + MOD - over) % MOD;
	cout << all << endl;

	return 0;
}

Measured memory_bytes: 47232
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int N=100005;
const int MOD=998244353;
int n,m;
long long ksm(long long a,long long b)
{
	a%=MOD,b%=(MOD-1);
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
vector<int>G[N];
int sg[N];
int dfs(int u)
{
	if(sg[u]!=-1) return sg[u];
	static int vis[N];
	for(int v:G[u])
	{
		dfs(v);
		vis[sg[v]]=true;
	}
	for(int i=0;;i++)
		if(!vis[i])
		{
			sg[u]=i;
			break;
		}
	for(int v:G[u])
		vis[sg[v]]=false;
	return sg[u];
}
vector<long long> getsg()
{
	for(int i=1;i<=n;i++)
		G[i].clear();
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x>y) swap(x,y);
		G[x].push_back(y);
	}
	memset(sg,-1,sizeof(sg));
	for(int i=n;i>=1;i--)
		dfs(i);
	int Max=*max_element(sg+1,sg+n+1);
	vector<long long>res;
	res.resize(Max+1);
	for(int i=1;i<=n;i++)
		res[sg[i]]=(res[sg[i]]+ksm(1e18,i))%MOD;
	return res;
}
int main()
{
	scanf("%d",&n);
	vector<long long>x=getsg(),y=getsg(),z=getsg();
	long long ans=0;
	for(int i=0;i<x.size();i++)
		for(int j=0;j<y.size();j++)
		{
			int k=i^j;
			if(k>=z.size()) continue;
			ans=(ans+x[i]*y[j]%MOD*z[k]%MOD)%MOD;
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    int n,ans=0;cin>>n;
    vector<int> v(2*n);
    rep(i,2*n)cin>>v[i];
    sort(all(v));
    
    for(int i=0;i < 2*n;i+=2)
    {
        ans+=v[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 384
w, k = [], []
10.times{w << gets.to_i}
10.times{k << gets.to_i}
w.sort!
k.sort!
w_score = w[9] + w[8] + w[7]
k_score = k[9] + k[8] + k[7]
puts "#{w_score} #{k_score}"


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

int main(){
  std::string s;
  int K;
  std::cin >> s >> K;

  std::set<std::string> subS;
  for (int i=0;i<s.size();i++) {
    for (int j=1; j<=5;j++) {
      //std::cout << s.substr(i,j) << '\n';
      if (i+j<=s.size()) subS.insert(s.substr(i,j));
      else break;
    }
  }

  //for (auto itr=subS.begin();itr!=subS.end();itr++) {
  //  std::cout << *itr << '\n';
  //}

  auto itr=subS.begin();
  for (int i=1;i<K;i++) itr++;
  std::cout << *itr << '\n';

  return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S.at(0) != S.at(1) || S.at(1) != S.at(2) || S.at(0) != S.at(2)){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main()
{
	ll N, C, K;
	cin >> N >> C >> K;
	vector<ll> t(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	ll i = 0;
	ll res = 0;
	while (i < N)
	{
		res++;
		ll start = i;
		while (i < N && t[i] - t[start] <= K && i - start < C) i++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace ::std;
int main(){
	
	int n,a,a1,che,b,last,tes;
	b=0;
	last=1;
tes=0;
	che=0;
	cin>>n;
for(b=0;b<n;b++){
	cin>>a;
	cin>>a1;
	if((a==a1)&&(last==0)){
		last=1;
		che=1;
	}
	else if((a==a1)&&(last==1)){
		che++;
	}
	else if(a!=a1){
		last=0;
		che=0;
	}
	if(che==3){
		tes=1;
	}
}
if(tes==1){
	cout<<"Yes"<<endl;
	return 0;
}
cout<<"No"<<endl;
return 0;
}

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

int main(void)
{
  int n,i,j,min;
  int a[200];
  int cost[201];

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

  for(i = 0;i < 201;i++)
    cost[i] = 0;

  for(i = 0;i < 201;i++)
    for(j = 0;j < n;j++)
      cost[i] = cost[i] + (a[j] - i + 100)*(a[j] - i + 100);

  min =  cost[0];
  for(i = 0;i <201;i++)
    if(min > cost[i])
      min = cost[i];

  printf("%d\n",min);

  return 0;
}



Measured memory_bytes: 128
import numpy as np

w, h, n = map(int, input().split())
grid = np.array([[0] * w for _ in range(h)])
# print(grid)


def F(grid, x, y, a):
    if a == 1:
        grid[:, :x] = 1
    elif a == 2:
        grid[:, x:] = 1
    elif a == 3:
        grid[:y, :] = 1
    elif a == 4:
        grid[y:, :] = 1


for i in range(n):
    x, y, a = map(int, input().split())
    F(grid, x, y, a)
    # print(grid)
print(np.count_nonzero(grid == 0))


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    int N;
    int ans=0;
    vector<int> D;
    cin >> N;
    D = fetch_vec<int>(N);
    FOR(i,0,N) FOR(j,i+1,N) ans += D[i]*D[j];
    cout << ans << endl;
    
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(auto & b : a) cin>>b;
    int cur = 0;
    for(int i=k;i<n;++i){
        if(a[cur] < a[i])cout << "Yes" << endl;
        else cout << "No" << endl;
        cur++;
    }
    return 0;
    
}

Measured memory_bytes: 4784
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>

#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;


int main() {
    ll n;
    cin >> n;
    auto cn = n;
    
    ll sn = 0;
    while (cn > 0) {
        sn += cn % 10;
        cn /= 10;
    }
    auto yes = n % sn == 0;
    cout << (yes ? "Yes" : "No");
    
    return 0;
}



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

using namespace std;

typedef unsigned long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

lld gcd(lld x,lld y)
{
	if (y == 0)
	{
		return x;
	}

	return gcd(y,x%y);
}

lld lcm(lld x,lld y)
{
	return x * (y / gcd(x,y));
}

int main()
{
	lld n,t[100] = {0};

	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> t[i];
	}

	if (n == 1)
	{
		cout << t[0] << endl;
		return 0;
	}

	lld sol = lcm(t[0],t[1]);

	for(int i = 2; i < n; i++)
	{
		sol = lcm(t[i],sol);
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	var str string
	s := make(map[string]int)
	t := make(map[string]int)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&str)
		s[str]++
	}

	fmt.Scan(&m)
	for i := 0; i < m; i++ {
		fmt.Scan(&str)
		t[str]++
	}

	var max int
	for i, v := range s {
		if v-t[i] > max {
			max = v - t[i]
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 1836
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()
    ans = []
    for c in S:
        if c == "0":
            ans.append("0")
        elif c == "1":
            ans.append("1")
        else:
            if ans:
                ans.pop()

    print("".join(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  double a, b, x; cin >> a >> b >> x;
  const double pi = 3.14159265358979323846;
  
  if(a*b*a/2 > x) {
    double aa = 2*x/b/a;
    cout << fixed << setprecision(10) << atan(b/aa)/pi*180 << endl;
  } else {
    double bb = (a*a*b-x)*2/a/a;
    cout << fixed << setprecision(10) << atan(bb/a)/pi*180 << endl;
  }

}

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

int main(){
    ll l,r;
    cin >> l >> r;
    ll ans = 2020;
    if(r-l > 2020) cout << 0 << endl;
    else{
        for(ll i = l;i <= r;i++){
            for(ll j = i+1;j <= r;j++){
                ans = min(ans,i*j%2019);
            }
        }
        cout << ans << endl;
    }
}

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


int a,b,c;
std::string S;
bool can=false;


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

	if(a+b==c|| a+c==b || b+c==a){
		can=true;
	}
	

	if(can == true){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}


return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

//ABC122 D

int n,dp[105][4][4][4];

int main(){
	cin>>n;
	dp[0][3][3][3]++;
	for(int I=0;I<n;I++) for(int i=0;i<4;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) for(int l=0;l<4;l++){
		bool B=1;
		if(j==0&&k==1&&l==2) B=0;
		if(k==0&&j==1&&l==2) B=0;
		if(j==0&&l==1&&k==2) B=0;
		if(i==0&&k==1&&l==2) B=0;
		if(i==0&&j==1&&l==2) B=0;
		if(B) (dp[I+1][j][k][l]+=dp[I][i][j][k])%=mod;
	}
	int res=0;
	for(int i=0;i<4;i++) for(int j=0;j<4;j++) for(int k=0;k<4;k++) (res+=dp[n][i][j][k])%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstring>
#include<cstdio>
using namespace std;
void File(){
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
const int maxn=100+10;
int n,m,a[maxn][maxn],cnt0,cnt1;
int main(){
	//File();
	scanf("%d%d",&n,&m);
	REP(i,1,50)REP(j,1,100)a[i][j]=1;
	REP(i,51,100)REP(j,1,100)a[i][j]=0;
	cout<<100<<" "<<100<<endl;
	n--,m--;
	int x,y;
	x=1,y=1;
	while(n){
		a[x][y]=0;
		if(y+2<=100) y+=2;
		else x+=2,y=1;
		n--;
	}
	x=52,y=1;
	while(m){
		a[x][y]=1;
		if(y+2<=100) y+=2;
		else x+=2,y=1;
		m--;
	}
	REP(i,1,100){
		REP(j,1,100)
		if(a[i][j]==1)cout<<"#";
		else cout<<".";
		cout<<endl;
	}
	return 0;
}



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

void CountingSort(int  *A, int *B, int k);

int n;

int main() {

  int i;
  int k = 0;
  int *pA, *pB;

  scanf("%d", &n);

  pA = (int *)malloc((n+1) * sizeof(int));
  pB = (int *)malloc((n+1) * sizeof(int));
  
  for(i=1; i<=n; i++){
    scanf("%d", &pA[i]);
    if(k < pA[i]) k = pA[i];
}
  
  CountingSort(pA,pB,k);

  
  return 0;
}

void CountingSort(int *A, int *B, int k){

  int i,j;
  int C[10001];

  //  C = (int *)malloc(n * sizeof(int));

  for(i=0; i<=k; i++)
    C[i] = 0;

  for(j=1; j<=n; j++)
    C[A[j]]++;
  
  
  for(i=1; i<=k; i++)
    C[i] = C[i] + C[i-1];

  for(j=n; j>=1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1; i<=n; i++){
    if(i == n) printf("%d\n", B[i]);
    else printf("%d ", B[i]);
  }
  
}



Measured memory_bytes: 17496
#include <iostream>

using namespace std;

int main(){
  int n;
  int debt = 100000;

  cin >> n;

  for(int i=0; i<n;i++){
	debt *= 1.05;
	if(debt % 1000) debt += (1000-(debt % 1000));
  }

  cout << debt << endl;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] h = na(n);
		for(int i=n-2;i>=0;i--) {
			if(h[i] <= h[i+1]) {
				continue;
			}else{
				if(h[i] == h[i+1] + 1) {
					h[i]--;
				}else {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 41996
#include <stdio.h>

int main(void)
{
	int H,W,a,b;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(a=1;a<=H/2;a++){
			for(b=1;b<=W/2;b++){
				printf("#.");
			}
			if(W%2==0){
				printf("\n");
			}
			else{
				printf("#\n");
			}
			for(b=1;b<=W/2;b++){
				printf(".#");
			}
			if(W%2==0){
				printf("\n");
			}
			else{
				printf(".\n");
			}
		}
		if(H%2==0){
			printf("\n");
		}
		else{
			for(b=1;b<=W/2;b++){
				printf("#.");
			}
			if(W%2==0){
				printf("\n\n");
			}
			else{
				printf("#\n\n");
			}
		}
	}
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int n, x, y;
	scanf("%d%d%d", &n, &x, &y);
	vi ans(n);
	for (int i = 1; i <= n; i++) {
		for (int j = i+1; j <= n; j++) {
			if (i < x) {
				if (j <= x)
					++ans[j-i];
				else if (j >= y)
					++ans[x-i+j-y+1];
				else {
					int d = min(j - i, x - i + 1 + y - j);
					++ans[d];
				}
			}
			else if (i < y) {
				int d = min(j - i, i - x + 1 + abs(y - j));
				++ans[d];
			}
			else {
				++ans[j-i];
			}
		}
	}
	for (int i = 1; i < n; i++) printf("%d\n", ans[i]);
}


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

#define int long long
using P = pair<int, char>;

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

  char tr;
  while ( cin >> tr, tr != '#' ) {
    P cards[4][13];
    for ( int i = 0; i < 4; i++ ) {
      for ( int j = 0; j < 13; j++ ) {
	string s;
	cin >> s;
	if ( isdigit(s[0]) ) cards[i][j] = {s[0]-'0', s[1]};	  
	else if ( s[0] == 'T' ) cards[i][j] = {10, s[1]};	  
	else if ( s[0] == 'J' ) cards[i][j] = {11, s[1]};	  
	else if ( s[0] == 'Q' ) cards[i][j] = {12, s[1]};	  
	else if ( s[0] == 'K' ) cards[i][j] = {13, s[1]};	  
	else cards[i][j] = {14, s[1]};	        
      }
    }

    int score[2] = {};
    int ldr = 0;    
    for ( int t = 0; t < 13; t++ ) {
      int win = ldr;
      int num = cards[ldr][t].first;      
      char suit = cards[ldr][t].second;      
      for ( int i = 1; i < 4; i++ ) {
	int mem = (ldr+i)%4;	
	int num_ = cards[mem][t].first;
	int suit_ = cards[mem][t].second;
	if ( suit_ == tr ) {
	  if ( suit != suit_ ) num = -1;	  
	  if ( num < num_ ) {
	    num = num_;
	    suit = suit_;
	    win = mem;	    
	  }
	} else if ( suit == suit_ ) {
	  if ( num < num_ ) {
	    num = num_;
	    win = mem;	    
	  }
	}
      }
      ldr = win;      
      score[win%2]++;    
    }

    if ( score[0] > 6 ) cout << "NS " << score[0]-6 << endl;
    else cout << "EW " << score[1]-6 << endl; 
  }
  
  return 0;
}



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

constexpr auto black = '#', white = '.';
string str[123];

bool solve(const int h, const int w)
{
   for (int i = 1; i <= h; ++i)
      for (int j = 1; j <= w; ++j)
         if (black == str[i][j]
            && white == str[i - 1][j]
            && white == str[i + 1][j]
            && white == str[i][j - 1]
            && white == str[i][j + 1])
            return false;

   return true;
}

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

   int h, w;
   cin >> h >> w;

   {
      string s(123, white);
      str[0] = s;
      str[h + 1] = s;
      for (int i = 1; i <= h; ++i)
      {
         cin >> s;
         assert(int(s.size()) == w);
         str[i] = white + s + white;
      }
   }

   auto can = solve(h, w);
   cout << (can ? "Yes" : "No");
   return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a; cin >> a;
  cout << a + a*a + a*a*a << endl;
  

  return 0;
}



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

int main(void){
    string s, p;
    cin >> s >> p;
    s += s;
    int pos = s.find(p);
    if(pos == string::npos) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


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

int main()
{
	long double a,b,c;
	cin>>a>>b>>c;
	if(4*a*b<(c-a-b)*(c-a-b)&&c-a-b>0)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3700
// 与えられた文字列の小文字と大文字を入れ替えた文字列を出力して下さい。アルファベット以外の文字はそのまま出力して下さい。
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		// 文字列読み込み, 文字列型→文字型変換
		char[] c = scan.nextLine().toCharArray();

		for(int i=0; i<c.length; i++){
			if('A'<= c[i] && c[i] <= 'Z'){
				// 小文字変換
				c[i] = Character.toLowerCase(c[i]);
			} else if('a'<= c[i] && c[i] <= 'z'){
				// 大文字変換
				c[i] = Character.toUpperCase(c[i]);
			} else{
				// そのまま
			}
			System.out.print(c[i]);
		}
		System.out.println();

	}
}


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

using namespace std;

typedef long long ll;

#define rep(i,m,n) for(ll i=m;i<n;i++)

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

 ll n;
  cin >> n;
  string s;
  cin >> s;
 ll res=1;
  rep(i,1,n) if(s[i]!=s[i-1]) res++;
  
  cout << res << endl;


}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    int N; 
    cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        cin >> H.at(i);
    }
    int ans = 0;
    int max_ans = 0;
    for(int i=0;i<N-1;i++){
        if(H.at(i) >= H.at(i+1)){
            ans += 1;
        }
        else{
            ans = 0;
        }
        if(max_ans < ans){
            max_ans = ans;
        }
    }
    cout << max_ans << endl;
}



Measured memory_bytes: 640
#!/bin/bash
':' /*
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro node:5.2-slim \
  /bin/bash -c "node /vo/$(basename $0) < /vo/g.inp"; exit $?
exit 0
*/
"use strict";

let main = (input) => {
    let n = Number.parseInt(input.shift());
    let syougen = [];
    for (let i = 0; i < n; i++) {
        let m = input.shift();
        let t = [];
        for (let j = 0; j < m; j++) {
            let c = input.shift().split(" ");
            t.push({
                "hito": Number.parseInt(c[0]) - 1,
                "tf": c[1] === "1"
            });
        }
        syougen.push(t);
    }


    let lc = [];
    for(let i=0; i<Math.pow(2,n); i++) lc.push(i);

    lc.sort((a,b) => {
        let aa = a.toString(2).match(/1/g);
        let la = aa==null ? 0:aa.length;
        let bb = b.toString(2).match(/1/g);
        let lb = bb==null ? 0:bb.length;
        return lb-la;
    });

    outer: for(let i of lc){
        let invest = []
        for(let j=0; j<n; j++) invest.push((i&Math.pow(2,j))>>j);
        for(let j=0; j<n; j++){
            if(invest[j]){
                for(let s of syougen[j]){
                    if(s.tf && invest[s.hito]==0) {
                        continue outer;
                    } else if(!s.tf && invest[s.hito]==1) {
                        continue outer;
                    }
                }
            }
        }
        let ans = i.toString(2).match(/1/g);
        return ans==null ? 0:ans.length;
    }

    return 0;
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf-8').trim().split("\n")));

Measured memory_bytes: 16680
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int d,n,m;
    int P[100001];
    while(1){ 
	int d,n,m;

	cin >> d;
	if(d==0) break;
	cin >> n >> m;

	P[0]=0;
	for(int i=1;i<n;i++){
	    scanf("%d",&P[i]);
	}
	P[n]=d;

	sort(P,P+n);

	int key,index,ans=0;
	int *pos;

	for(int i=0;i<m;i++){
	    scanf("%d",&key);
	    pos=lower_bound(P,P+n+1,key);
	    index=distance(P,pos);
	    ans+=min(P[index]-key,key-P[index-1]);
	}

	cout << ans << endl;

    }	
    return 0;
}

Measured memory_bytes: 3516
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <numeric>
#include <limits>
#include <functional>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100010, P = 1000000007;

int n;
int a[N], h[N];

int main() {
#ifdef LBT
	freopen("test.in", "r", stdin);
	int nol_cl = clock();
#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	h[1] = 1;
	for (int i = 2; i <= n; ++i)
		h[i] = -(P / i) * (ll)h[P % i] % P + P;
	for (int i = 2; i <= n; ++i)
		if ((h[i] += h[i - 1]) >= P)
			h[i] -= P;
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		ans = (ans + a[i] * ((ll)h[i] + h[n - i + 1] - 1)) % P;
	for (int i = 1; i <= n; ++i)
		ans = ans * (ll)i % P;
	printf("%d\n", ans);

#ifdef LBT
	LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
	return 0;
}


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

int main(){
    ll mod = 2019;
    ll L, R;  cin >> L >> R;
    R = min(L + mod, R);
    ll ans = 2019;
    for(ll i=L; i<=R; i++) for(ll j=i+1; j<=R; j++){
        ans = min(ans, (i*j)%mod);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from scipy.misc import comb
# from scipy.special import comb
MOD = 10**9+7
N, K = map(int, input().split())
red, blue = N-K, K
for i in range(1,blue+1):
  print((comb(red+1, i, exact=True) * comb(blue-1, i-1, exact=True)) % MOD)


Measured memory_bytes: 14248
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 5e5 + 5, M = 1e5;
const ll LINF = 1e18 + 5;
int n, a[N];
ll m;
#define complex Complex
struct complex
{
	double x, y;
	complex(){}
	complex(double _x,double _y){ x = _x, y = _y;}
	complex operator + (complex a) { return complex(x+a.x,y+a.y);}
	complex operator - (complex a) { return complex(x-a.x,y-a.y);}
	complex operator * (complex a) { return complex(x*a.x-y*a.y,x*a.y+y*a.x);}
}x[N], y[N];
struct FFT
{
	int up, pos[N];
	const double pi = acos(-1.0);
	void init(int n,int m) 
	{
		up = 1;
		int l = 0;
		while(up<=(n+m)) up <<= 1, l++;
		for(int i=0;i<up;i++) pos[i] = (pos[i>>1]>>1)|((i&1)<<(l-1));
	}
	void fft(complex a[],double mode) 
	{
		for(int i=0;i<up;i++) if(i<pos[i]) swap(a[i],a[pos[i]]);
		for(int i=2,mid=1;i<=up;i<<=1,mid<<=1)
		{
			complex wn(cos(2.0*pi/i), sin(mode*pi/i));
			for(int j=0;j<up;j+=i)
			{
				complex w(1,0);
				for(int k=j;k<j+mid;k++,w=w*wn)
				{
					complex l = a[k], r = w*a[k+mid];
					a[k] = l + r; a[k+mid] = l - r;
				}
			}
		}
		if(mode==-2.0) for(int i=0;i<up;i++) a[i].x /= up;
	}
	void multi(complex a[],complex b[],complex c[])
	{
		fft(a,2.0); fft(b,2.0);
		for(int i=0;i<up;i++) c[i] = a[i]*b[i];
		fft(c,-2.0);
	}
}f;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m;
 	for(int i=1; i<=n; i++) 
 	{
 		cin >> a[i];
 		x[a[i]].x += 1.0, y[a[i]].x += 1.0;
 	}
 	f.init(M, M);
 	f.multi(x, y, x);
 	ll cur = 0, ans = 0;
 	for(int i=2*M; i>=1; i--)
 	{
 		ll tmp = (ll)(x[i].x+0.5);
 		if(cur+tmp<=m)
 		{
 			cur += tmp;
 			ans += tmp*i;
 		}
 		else
 		{
 			ans += (m-cur)*i;
 			break;
 		}
 	}
 	cout << ans;
	return 0;
}


Measured memory_bytes: 13696
#include <stdio.h>
int main(void){
  int n,k,a[1001]={},t,i;
  long ans=1;
  scanf("%d",&n);
  for (i=2;i<=n;i++){
    t=2;
    k=i;
    while (k!=1){
      while (k%t==0){
        a[t]++;
        k/=t;
      }
      t++;
    }
  }
  for (i=2;i<=997;i++) ans=ans*(a[i]+1)%1000000007;
  printf("%ld\n",ans);
  return 0;
}

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

int main(){
    ll k,a,b,ans=1;
    cin >> k >> a >> b;
    if(b-a<=2||a>=k) ans = 1+k;
    else{
        while(ans<a){
            ans ++;
            k --;
        }
        ans += (k/2)*(b-a)+k%2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        if (N % 2 == 0)
        {
            Console.WriteLine(N);
            return;
        }
        Console.WriteLine(N * 2);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
// ABC 118 B
#include<bits/stdc++.h>

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int ab,bc,ca;
  int ans=0;
  cin  >> ab >> bc >>ca;
  ans = min(ab,bc);
  ans *= min(max(ab,bc),ca);
  ans *= 0.5;
  cout << ans << endl;
  return 0;
}


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

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

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

N,Q = map(int,input().split())
class UF():
  def __init__(self,par,rank):
    self.par = par
    self.rank = rank
  def find(self,x):
      if self.par[x] == x:
          return x
      else:
          self.par[x] = self.find(self.par[x]) #経路圧縮
          return self.par[x]
  def same(self,x,y):
      return self.find(x) == self.find(y)
  def unite(self,x,y):
      x = self.find(x)
      y = self.find(y)
      if x == y:
          return 0
      if self.rank[x] < self.rank[y]:
          self.par[x] = y
      else:
          self.par[y] = x
          if self.rank[x]==self.rank[y]:self.rank[x]+=1
uf=UF([i for i in range(N)],[0]*(N+1))
for _ in range(Q):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  uf.unite(a,b)
from collections import Counter
a=[-1]*N
for i in range(N):
  a[i]=uf.find(i)
ca=Counter(a)
ans=0
for c in ca.values():
  ans=max(ans,c)
print(ans)


Measured memory_bytes: 110344