akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

struct node
{
    ll data;
    node *left, *right;
    node(ll data)
    {
        this->data = data;
        left = right = NULL;
    }
};
unordered_map<ll, list<ll>>ma;

ll h(node *head)
{
    if (head == NULL)
        return 0;
    else
    {
        ll lh = h(head->left);
        ll rh = h(head->right);
        return max(lh, rh) + 1;
    }
}
void spiral(node *root, ll level)
{
    if (root == NULL)
        return ;
    if (level & 1)
        ma[level].push_back(root->data);
    else
        ma[level].push_front(root->data);
    spiral(root->left, level + 1);
    spiral(root->right, level + 1);

}

typedef long long ll;


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output12.txt", "w", stdout);
#endif
    ll n;
    cin >> n;
    ll arr[n + 1];
    memset(arr, 0, sizeof(arr));
    for (ll i = 1; i * i <= n; i++)
    {
        for (ll j = 1; j * j <= n; j++)
        {
            for (ll k = 1; k * k <= n; k++)
            {
                if (i * i + j * j + k * k + i * j + j * k + i * k <= n)
                    arr[i * i + j * j + k * k + i * j + j * k + i * k]++;
            }
        }
    }
    for (ll i = 1; i <= n; i++)
        cout << arr[i] << "\n";

    return 0;
}


Measured memory_bytes: 3692
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial

sys.setrecursionlimit(10**7)
N = int(input())
st = [list(input().split()) for _ in range(N)]
X = input()


cnt = 0
flg = False
for sti in st:
    if flg:
        cnt += int(sti[1])
    if sti[0] == X:
        flg = True
print(cnt)


Measured memory_bytes: 3444
#include<stdio.h>
int main(void){
    int n,k,i,half,a,b,ans;
    scanf("%d%d",&n,&k);
    half=(n+1)/2;
    for(i=0; i<k; i++){
        scanf("%d%d",&a,&b);
        if(a>half){
            a = n-a+1;
        }
        if(b>half){
            b = n-b+1;
        }
        if(a>b){
            ans = b%3;
        }else{
            ans = a%3;
        }
        printf("%d\n",(ans==0)?3:ans);
    }
    return 0;
}

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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if

int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,n)cin>>a[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;++i){
    dp[i]=999999999;
    for(int j=1;j<=k&&i-j>=0;++j){
      //debg(i-j);
      dp[i]=min(dp[i],(dp[i-j]+abs(a[i]-a[i-j])));
    }
    //debg(dp[i]);
  }
  cout<<dp[n-1]<<endl;
  
  return 0;
}


Measured memory_bytes: 1792
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Array{Int}(2,n)
	k = 0
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
		k -= a[2,i]
	end
	a = sortcols(a,by=x->-x[1]-x[2])
	for i in 1:n
		if i%2==1
			k += a[1,i]+a[2,i]
		end
	end
	println(k)
end

main()

Measured memory_bytes: 158820
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n)
	total := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
		total += t[i]
	}

	var m, p, x int
	fmt.Scan(&m)
	for i := 0; i < m; i++ {
		fmt.Scan(&p, &x)
		fmt.Println(total - (t[p-1] - x))
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
using namespace std;
int main() {
	int X;
  	int fh, f, ureshisa;
  	cin >> X;
  	fh = X / 500;
  	X = X - (fh * 500);
	f = X / 5;
  	ureshisa = (fh * 1000) + (f * 5);
  	cout << ureshisa;
}

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

const int mod=1e9+7;
const int SIZE=2010;

int C[SIZE][SIZE];

signed main(){
    int N,K; cin>>N>>K;
    
    C[0][0]=1;
    for(int i=1;i<SIZE;i++){
        C[i][0]=C[i][i]=1;
        for(int j=1;j<i;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }

    for(int i=1;i<=K;i++){
        cout<<C[N-K+1][i]*C[K-1][i-1]%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 30336
import math
a, b, x = map(int, input().split())

if a*a*b/2 >= x:
    c = (2 * x) / (a * b)
    print(math.degrees(math.atan2(b, c)))
else:
    d = 2/(a*a) * (a*a*b -x)
    c = b - d
    print(math.degrees(math.atan2((b-c), a)))

Measured memory_bytes: 38512
package main

import "fmt"

func main() {
	var val, min, max int

	fmt.Scan(&val)
	min = val
	max = val

	fmt.Scan(&val)
	if val < min {
		min = val
	} else {
		max = val
	}

	fmt.Scan(&val)
	if val < min {
		fmt.Println(val, min, max)
	} else if max < val {
		fmt.Println(min, max, val)
	} else {
		fmt.Println(min, val, max)
	}
}



Measured memory_bytes: 1128
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;
Vi b;
Vi p;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n;
	a.resize(n);
	b.resize(n);
	p.resize(n);
	ll tmp = 1;
	rep(i,n){
		cin>>p[i];
		p[i]--;
	}
	rep(i,n){
		a[i] = tmp;
		tmp += n;
	}
	rep(i,n){
		b[i] = a[n-1-i];
	}
	rep(i,n){
		ll ida = p[i];
		a[ida] += i;
	}
	rep(i,n){
		princ(a[i]);
	}
	print("");
	rep(i,n){
		princ(b[i]);
	}
	print("");
	return 0;
}

Measured memory_bytes: 1152
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map(fun x -> int x)
let char2String(value) = List.ofSeq value |> List.toArray |> System.String

let H, W = readIntArray() |> fun x -> (x.[0], x.[1])
let h, w = readIntArray() |> fun x -> (x.[0], x.[1])

(H - h) * (W - w)
|> printfn "%d"

Measured memory_bytes: 13916
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten52];
//priority_queue<pair<ll,ll>> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,d,sum=0;
    string s;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        num[i]=m;
        k+=m;
    }
    for(i=1;i<=n;i++)
    {
        k-=num[i];
        sum+=(k%mod)*num[i];
        sum%=mod;
    }
    cout<<sum;
    return 0;
}





Measured memory_bytes: 5188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		if (d>=Math.abs(c-a)){
        	System.out.println("Yes");
        }else if (d>=Math.abs(c-b)){
        	if (d>=Math.abs(b-a)){
            	System.out.println("Yes");
            }else{
            	System.out.println("No");
            }
        }else{
        	System.out.println("No");
        }
      
    }
}

Measured memory_bytes: 23764
def solve(W, a, b):
    if a > b:
        a, b = b, a
    print(max(0, b - (a + W)))

#solve(3, 2, 6)
#solve(3, 1, 3)
#solve(5, 10, 1)

W, a, b = [int(x) for x in input().split()]
solve(W, a, b)


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);   
      // 順列
	  int N = sc.nextInt();
      // Pnの値
      int[] P = new int[N];
      for(int i=0;i<N;i++){
        P[i] = sc.nextInt();
      }
      //カウント
      int count = 0;
      //比べる数で一番小さい数、初期値はP[0]
      int min = P[0];
      
      for(int i=0;i<N;i++){
        if(P[i]<=min){
          count++;
          //最小値はP[i]に変わる
          min=P[i];
        }
      }
      
      System.out.println(count);
    }
}

Measured memory_bytes: 60504
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{

    int n;
    cin >> n;
  
    set<string>r;

    for (int i = 0;i < n;i++) {
        string p;
        cin >> p;
        r.insert(p);
    }
    cout << r.size() << endl;


    return 0;

}

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

const int N = 303;

int arr[N], x, dp[50][2][2][2];


bitset <42> a, ab, z;


int f(int idx, int r, int s, int carryneed) {
	//cout << idx << " " << r << " " << s << " " << carryneed << endl;
	if(idx < 0) {
		if(s && !carryneed) {
			return 0;
		}
		return -1e17;
	}
	if(~dp[idx][r][s][carryneed]) {
		return dp[idx][r][s][carryneed];
	}
	int u = r ? a[idx] : 1;
	int res = -1e17;
	for(int i = 0; i <= u; i++) {
		int y = z[idx];
		int aabb = ab[idx], xx = i, yy = y ^ i, sum = (xx + yy) % 2LL, carry = (xx + yy) / 2LL;
		if(aabb == sum && carryneed == carry) {
			res = max(res, (i << idx) + f(idx - 1, r && i == u, s | i, 0));
		}
		sum = (xx + yy + 1) % 2, carry = (xx + yy + 1) / 2;
		if(aabb == sum && carryneed == carry) {
			res = max(res, (i << idx) + f(idx - 1, r && i == u, s | i, 1));
		} 
	}
	return dp[idx][r][s][carryneed] = res;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
		x ^= arr[i];
	}
	x ^= arr[1] ^ arr[2];

	a = bitset <42> (arr[1]);
	ab = bitset <42> (arr[2] + arr[1]);
	z = bitset <42> (x);

	
	memset(dp, -1, sizeof dp);
	if(f(41, 1, 0, 0) < 0) {
		cout << -1 << endl;
		return 0;
	}
	cout <<arr[1] - f(42, 1, 0, 0)  << endl;

	
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll x,y;
cin>>x>>y;
if(x%y==0){
cout << -1 << endl;}
else{
for(ll i=1; i<1000000000; i++){
if(x*i%y!=0){
cout << x*i << endl;
break;}}
}}


Measured memory_bytes: 3608
// AOJ 1182 Railway Connection
#include <bits/stdc++.h>
using namespace std;

const int N = 100, C = 20, P = 50, INF = 20000;
const int MAXCOST = INF * 100;

typedef pair<int, int> T;

int v[N][N][C], vp[N][N][C];
int fp[C];
int price[INF + 1][C];
int p[P][C];
int r[P + 1][C];

int WF(int s, int g, int n, int c){
	vector<vector<int> > mincost(n, vector<int>(n, MAXCOST));

	for(int l = 0;l < c;++l){
		int idx = 0;
		for(int k = 0;k < n;++k){
			for(int i = 0;i < n;++i){
				for(int j = 0;j < n;++j){
					v[i][j][l] = min(v[i][k][l] + v[k][j][l], v[i][j][l]);
				}
			}
		}
		for(int i = 0;i < n;++i){
			for(int j = i;j < n;++j){
				vp[i][j][l] = v[j][i][l] = price[v[i][j][l]][l];
			}
		}

		for(int i = 0;i < n;++i){
			for(int j = i;j < n;++j){
				mincost[i][j] = mincost[j][i] = min(mincost[i][j], vp[i][j][l]);
			}
		}
	}

	for(int k = 0;k < n;++k){
		for(int i = 0;i < n;++i){
			for(int j = 0;j < n;++j){
				mincost[i][j] = min(mincost[i][j], mincost[i][k] + mincost[k][j]);
			}
		}
	}

	return mincost[s][g] == MAXCOST ? -1 : mincost[s][g];
}

int main(){
	int n, m, c, s, g;
	int x, y, dist, cn;
	while(cin >> n >> m >> c >> s >> g, n){
		--s; --g;
		for(int i = 0;i < N;++i){
			for(int j = i;j < N;++j){
				for(int k = 0;k < C;++k){
					v[i][j][k] = v[j][i][k] = i == j ? 0 : INF;
					vp[i][j][k] = v[j][i][k] = i == j ? 0 : MAXCOST;
				}
			}
		}
		for(int i = 0;i < m;++i){
			cin >> x >> y >> dist >> cn;
			--x; --y; --cn;
			v[x][y][cn] = v[y][x][cn] = min(v[x][y][cn], dist);
		}
		for(int i = 0;i < c;++i){
			cin >> fp[i];
		}
		for(int i = 0;i < c;++i){
			r[0][i] = 0;
			for(int j = 1;j < fp[i];++j){
				cin >> r[j][i];
			}
			r[fp[i]][i] = INF;
			for(int j = 0;j < fp[i];++j){
				cin >> p[j][i];
			}
			price[0][i] = 0;
			for(int j = 0;j < fp[i];++j){
				for(int k = r[j][i] + 1;k <= r[j + 1][i];++k){
					price[k][i] = price[k - 1][i] + p[j][i];
				}
			}
			price[INF][i]  = MAXCOST;
		}
		cout << WF(s, g, n, c) << endl;
	}
	return 0;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 21

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
int mask[MAXN];
int dp[2][(1 << MAXN)];

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, N)
	{
		FOR(j, 0, N)
		{
			int x; cin >> x;
			if (x) mask[i] += (1 << j);
		}
	}
	dp[1][0] = 1;
	FOR(i, 0, N + 1)
	{
		FOR(j, 0, (1 << N)) dp[i & 1][j] = 0;
		FOR(j, 0, (1 << N))
		{
			int x = dp[i & 1 ^ 1][j];
			if (x == 0) continue;
			FOR(k, 0, N)
			{
				if (j & (1 << k)) continue;
				if (!(mask[i] & (1 << k))) continue;
				dp[i & 1][j ^ (1 << k)] += x;
				if (dp[i & 1][j ^ (1 << k)] >= INF) dp[i & 1][j ^ (1 << k)] -= INF;
			}
		}
	}
	cout << dp[N & 1 ^ 1][(1 << N) - 1] << '\n';
	return 0;
}


Measured memory_bytes: 16640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: i32 = read();
    let T: i32 = read();
    let mut c: Vec<i32> = Vec::new();
    let mut t: Vec<i32> = Vec::new();
    for _ in 0..N {
        c.push(read());
        t.push(read());
    }
    let mut ans = 10000;
    
    for i in 0..N as usize {
        if T >= t[i] && ans > c[i]{
            ans = c[i];
        }
    }

    if ans == 10000 {
        println!("TLE");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector <vector<pair<int,int>>> data(n,vector <pair<int,int>>());
    rep(i,n){
        int a; cin>>a;
        rep(j,a){
            int s,d; cin>>s>>d;
            s--;
            data[i].push_back(make_pair(s,d));
        }
    }
    
    int bit=0;
    int ans = 0;
    for(bit=0;bit<(1<<n);bit++){
        bool ok = true;
        int cnt = 0;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                cnt++;
                for(int j=0; j < data[i].size(); j++){
                    if( ( (bit & (1LL << data[i][j].F)) && data[i][j].S == 0 )
                    || ( !(bit & (1LL << data[i][j].F)) && data[i][j].S == 1 )
                    ){
                        ok = false;
                        break;
                    }
                }
            }
            if(!ok) break;
        }
        if(ok) chmax(ans, cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAX 100000
 
void dequeue(char*, int*);
void inqueue(char*, int);
 
char name[MAX][10];
int  time[MAX];
int head=0, tail=1;
 
main(){
  int t=0;
  int i, n, q;
  char tmpName[10];
  int tmpTime;
 
  scanf("%d %d", &n, &q);
  for(i=0; i<n; i++)scanf("%s %d", name[i], &time[i]);
  tail = n;
 
  while(head != tail){
    dequeue(tmpName, &tmpTime);
    if(tmpTime > q){
      t+=q;
      tmpTime -= q;
      inqueue(tmpName, tmpTime);
    }
    else {
      t+=tmpTime;
      printf("%s %d\n", tmpName, t);
    }
  }
  return 0;
}
 
void dequeue(char* tmpName, int* tmpTime){
  strcpy(tmpName, name[head]);
  *tmpTime = time[head];
 
  head = (head+1) % MAX;
}
 
void inqueue(char *tmpName, int tmpTime){
  strcpy(name[tail], tmpName);
  time[tail] = tmpTime;
  
  tail = (tail+1) % MAX;
}

Measured memory_bytes: 1976
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;

int disd(vi&a, vi&b)
{
	int d2=0;
	for(int i=0;i<a.size();i++)
	{
		int d=a[i]-b[i];
		d2+=d*d;
	}
	double d=sqrt(d2);
	int dd=d;

	if(fabs(d-dd)<1e-5) return 1;
	return 0;
}

int main(void)
{
	int n, d;

	while(scanf("%d%d", &n, &d)==2)
	{
		vvi x(n);

		for(int i=0;i<n;i++)
		{
			x[i].resize(d);
			for(int j=0;j<d;j++)
			{
				scanf("%d", &x[i][j]);
			}
		}

		int ans=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				if(disd(x[i], x[j])) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define bs binary_search
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define sll stack<ll>
#define qll queue<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define vc vector <char>
#define vvll vector<vector<ll>>
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
ll mod=1000000007;  double pi=3.1415926535;

void solve()
{
    ll n;   cin>>n;
    ll ans=1,d,flg=0,p=0;
    while(n--)
    {
        cin>>d;
        if(((double)1000000000000000000/ans)<d)    flg=1;
        ans*=d;
        //cout<<ans<<nl;
        if(!d)  p=1;
        if(ans>1000000000000000000 || ans<0)
        {
            flg=1;
        }
    }
    //ll k=1000000000000000000*;
    //cout<<k<<nl;
    if(p)   cout<<"0";
    else if(flg)    cout<<"-1";
    else    cout<<ans;
}

int main() {
	fast_io;
	
	    solve();
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;

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

    long long i = 0;
    long long count = 0;

    string near;
    while(i < s.size()){
        string now;
        now = s[i];
        if(i == s.size()-1 and now == near){
            break;
        }
        
        if(now != near){
            near = now;
        }
        else{
            while(i < s.size()){
                if(near != now){
                    break;
                }
                i++;
                now.push_back(s[i]);
            }
            near = now;
        }
        i++;
        count++;
    }

    cout << count << endl;

    return 0;
}

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

int main(){
    int H, W;
    string S[60];
    int g[8][8];
    cin >> H >> W;
    //S[i] is '#' or '.'
    for(int i = 0; i < H ; i++)  cin >> S[i];

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

    int count;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(S[i][j] == '#') continue;
            count = 0;
            for(int d = 0; d < 8; d++) {
                const int nj = j + dx[d];
                const int ni = i + dy[d];

                if(nj < 0 || nj >= W) continue;
                if(ni < 0 || ni >= H) continue;

                if(S[ni][nj] == '#') count++;
            }
            S[i][j] = '0' + count;
        }
    }

    for(int i = 0; i < H; i++)cout << S[i] << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
	S=input()                                               # 1行1列
	Q=int(input())                                          # 1行1列
	Q_LIST=[input().split() for i in range(Q)]                # N行C列・・・Cは任意
	 
	dir = 0 # 0が正常

	S_HEAD = ''
	S_BACK = ''

	for query in Q_LIST:
		if query[0] == '1':
			if dir == 0:
				dir = 1
			else:
				dir = 0
	 
		if dir == 0:
			HEAD = '1'
			BACK = '2'
		else:
			HEAD = '2'
			BACK = '1'
	 
		if query[0] == '2':
			if query[1] == HEAD:
				S_HEAD = query[2] + S_HEAD
			if query[1] == BACK:
				S_BACK =  S_BACK + query[2]

	S = S_HEAD + S + S_BACK

	if dir == 0:
		print(S)
	else:
		print(S[::-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 40712
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;


int n;
ll ans =0;
char c;
int s[5000];
int sum[3][5000];


ll check_rep(int p)
{
    int ans = 0;
    for (int i=1; i<=n; ++i)
    {
        if (p-i>=1 && p+i<=n)
        {
            if (s[p-i]!=s[p+i] && s[p]!=s[p-i] && s[p]!=s[p+i])
                ans++;
        }else break;
    }
    return ans;
}

ll check_all(int p)
{
    ll ans=0;
    int x,y;
    if (s[p]==0) x=1,y=2;
    if (s[p]==1) x=2,y=0;
    if (s[p]==2) x=1,y=0;

    ans = sum[x][p-1]*(sum[y][n]-sum[y][p]) + sum[y][p-1]*(sum[x][n]-sum[x][p]);
    return ans;
}


ll check(int p)
{
    ll rep = check_rep(p);
    ll all_num = check_all(p);
    return all_num-rep;
}


int main()
{
    cin>>n;
    sum[0][0]=sum[1][0]=sum[2][0]=0;
    for (int i=1; i<=n; ++i)
    {
        cin>>c;
        sum[0][i] = sum[0][i-1];
        sum[1][i] = sum[1][i-1];
        sum[2][i] = sum[2][i-1];
        if (c=='R') {s[i]=0, sum[0][i]=sum[0][i-1]+1;}
        if (c=='G') {s[i]=1, sum[1][i]=sum[1][i-1]+1;}
        if (c=='B') {s[i]=2, sum[2][i]=sum[2][i-1]+1;}
    }
    for (int i=1; i<=n; ++i)
    {
        ans += check(i);
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3680
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int
main(void){  
  ios_base::sync_with_stdio(false);

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //int diff = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
  //cout << x2-diff << " " << y2 << " " << x1-diff << " " << y1 << endl;

  int diff_x = x2-x1;
  int diff_y = y2-y1;

  cout << x2-diff_y << " " << y2+diff_x << " " << x1-diff_y << " " << y1+diff_x << endl;
  
  return 0;
}


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

#define INF 2000000000
#define MOD 1000000007

using namespace std;


int main() {
	int n;
	int arr[50];
	int p;
	cin >> n >> p;
	int odd = 0, even = 0;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if (arr[i] % 2 == 1)
			odd++;
		else
			even++;
	}
	long long ans = (1LL << even);
	if (p == 0) {
		if (odd == 0) {
			cout << ans << endl;
			return 0;
		}
		ans *= (1LL << (odd - 1));
	} else {
		if (odd == 0) {
			cout << 0 << endl;
			return 0;
		}
		ans *= (1 << (odd - 1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main(){
  vector<int> a(3);
  rep(i,3){
    cin >> a[i];
  }
  int k;
  cin >> k;
  while(k--){
    sort(a.begin(),a.end());
    int last = a.back();
    a.pop_back();
    a.push_back(last*2);
  }
  cout << accumulate(a.begin(),a.end(),0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
     
int main() {
    
    int n, x;

    cin >> n >> x;
    
	while(n != 0 || x != 0){
    	int ans = 0;
        
        if(n == 0 && x == 0) break;
        
        for(int i = 1; i <= n; i++){
    		for(int j = i + 1; j <= n; j++){
	    	    for(int k = j + 1; k <= n; k++){
	    	        if(i + j + k == x){
	    	            ans++;
	    	        }
	    	    }
		    }
		}
		cout << ans << endl;
		
		cin >> n >> x;
	}

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin >> s ;
    
    int cnt = 0;
    int cmax = 0;
    int cmin = 101;
    for(char c = 'a'; c <= 'z'; c++){
        cnt = 0;
        cmax = 0;
        for(int ind =0; ind < s.length(); ind++){
            if(s[ind] != c){
                cnt++;
            }else{
                if(cnt > cmax){
                    cmax = cnt;
                }
                cnt = 0;
            }
        }
        if(cnt >cmax){
            cmax = cnt;
        }
        if( cmax < cmin){
            cmin = cmax;
        }
    }
    cout << cmin<< endl;
}


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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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



int main() {
	string s;
	cin>>s;
	char now='a';
	int res=0;
	int count[3]={};
	rep(i,sz(s)){
//debug<<i<<" "<<count[0]<<" "<<count[1]<<" "<<count[2]<<endl;
		if(s[i]=='J'){
			if(now=='J'){
				++count[0];
			}else if(now=='O'){
				count[0]=1;
				count[1]=0;
				count[2]=0;
			}else{
				if(count[0]>=count[1]&&count[1]<=count[2])chmax(res,min(min(count[0],count[1]),count[2]));
				count[0]=1;
				count[1]=0;
				count[2]=0;
			}
		}else if(s[i]=='O'){
			if(now!='I'){
				++count[1];
			}else{
				if(count[0]>=count[1]&&count[1]<=count[2])chmax(res,min(min(count[0],count[1]),count[2]));
				count[0]=0;
				count[1]=1;
				count[2]=0;
			}
		}else{
			if(now!='J'){
				++count[2];
			}else{
				count[0]=0;
				count[1]=0;
				count[2]=1;
			}
		}
		now=s[i];
	}
	if(count[0]>=count[1]&&count[1]<=count[2])chmax(res,min(min(count[0],count[1]),count[2]));
	cout<<res<<endl;
	return 0;
}

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

int V,E;
int d[15][15] = {0};
int dp[1 << 15][15] = {0};
int inf = 1e8;

int rec(int S, int v){
	if(dp[S][v]>=0) return dp[S][v];
	if(S == (1<<V) -1 && v==0) return (dp[S][v] = 0);
	int res = inf;
	for(int u=0;u<V;u++){
		if(!(S>>u & 1)){
			res = min(res, rec(S | 1<<u, u) + d[v][u]);
		}
	}
	return (dp[S][v] = res);
}

int main(){
	cin >> V >> E;
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			d[i][j] = inf;
		}
	}
	for(int i=0;i<E;i++){
		int a,b,w;
		cin >> a >> b >> w;
		d[a][b] = w;
	}
	memset(dp,-1,sizeof(dp));
	int ans = rec(0,0);
	if(ans!=inf) cout << ans << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define LL long long
using namespace std ;
LL calc ( LL n, LL x ) {
	LL s = n-x ;
	LL t = (x-1)/s ;
	if ( (x<<1)==n ) return x<<1 ;
	if (!t) return calc(n-x, n-2*x)+n ;
	return calc(n-s*t, x-s*t)+2*s*t ;
}
int main() {
	LL x, y ;
	scanf ( "%lld%lld", &x, &y ) ;	
	printf ( "%lld\n", calc(x, y)+y ) ;
	return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>	
int main(void){
    int i,n,x,a,d;
    double total,ava,suv,b,c;
    for (d=1 ;d<300;d++) {
	   scanf("%d",&n);
	   if(n==0)break;
   int data[n];
   for(x=0;x<n;x++){
       scanf("%d",&data[x]);
   }
   total=0;
       for(i=0; i<n; i++){
        total += data[i];
    }
    ava=total/n;
    suv=0;
       for(a=0;a<n;a++){
           suv+=(data[a]-ava)*(data[a]-ava);
   }
   b=suv/n;
   c=sqrt(b);
   printf("%f\n",c);
    }
return 0;
}


Measured memory_bytes: 2044
N, M = map(int, input().split())
S = input()
S = list(reversed(S))

# 現在位置
now = 0
_now = 0
ans = []
while now <= N-1:
    for i in range(min(M, N-now), 0, -1):
        if S[now+i] == '0':
            ans.append(i)
            now += i
            break
    if _now == now:
        print(-1)
        exit()
    _now = now
print(*reversed(ans))


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  int k;
  cin >> k;
  int ans = 0;
  for (int a = 1; a < k + 1; a++) {
    for (int b = 1; b < k + 1; b++) {
      for (int c = 1; c < k + 1; c++) {
        ans += __gcd(__gcd(a, b), c);
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
n,a,b=map(int,input().split())
ans=0
if (a-b)%2==0:
  ans=abs(a-b)//2
elif n-b < a:
  ans+=n-b+1
  a+=n-b+1
  ans+=(n-a)//2
else:
  ans+=a
  b-=a
  ans+=b//2
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll n, d; cin >> n >> d;
    d *= d;
    int count = 0;
    FOR(i, 0, n) {
        ll x, y; cin >> x >> y;
        if (x * x + y * y <= d) count++;
    }
    cout << count << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // 税込価格
        int n = Integer.parseInt(sc.next());
        BigDecimal bign = BigDecimal.valueOf(n);
        // 消費税率1.08円
        BigDecimal consumption_tax = BigDecimal.valueOf(1.08);
        // 税抜価格の存在フラグ
        boolean exist_flg = false;
        // 税抜価格をi円と仮定(税込価格がn円のため、税抜価格はn以下の想定)
        for (int i = 1; i <= n; i++) {
            BigDecimal x = BigDecimal.valueOf(i);
            // 税抜価格 * 1.08(小数点以下切り捨て) = 仮定の税込価格
            BigDecimal value = x.multiply(consumption_tax).setScale(0, RoundingMode.DOWN);
            // 仮定の税込価格とnが一致する場合
            if (value.equals(bign)) {
                exist_flg = true;
                out.println(x);
                break;
            }
        }
        // 税抜価格を計算できなかった場合
        if (!exist_flg) {
            out.println(":(");
        }
        sc.close();
        out.close();
    }

}

Measured memory_bytes: 42484
(defun a (s)
  (let ((next-weather '(("Sunny" . "Cloudy")                       
                        ("Cloudy" . "Rainy")
                        ("Rainy" . "Sunny"))))
    (cdr (assoc s next-weather :test #'string=))))

(defun main ()
  (let ((s (read-line)))
    (format t "~A~%" (a s))))

(main)


Measured memory_bytes: 11104
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    ll n, k, q;
    cin >> n >> k >> q;
    ll arr[q + 5], freq[n + 5] = {};
    for(int i = 0; i < q; i++){
        cin >> arr[i];
        freq[arr[i]]++;
    }
    for(int i = 1; i <= n; i++){
        if(k - q + freq[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 5152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int n[101][101];
int W,H,N;

int main(){
  long long a,b,x,tmp=0;
  cin>>a>>b>>x;
  if(a%x==0)tmp=1;
  cout<<b/x-a/x+tmp<<endl;
  return 0;
}

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int tab[1010];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    for (int i = 1 ; i <= n ; i++)
        cin >> tab[i];
    sort(tab + 1,tab + n + 1);
    int ans = 0;
    for (int i = 1 ; i <= k ; i++)
        ans += tab[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int x = 1900 * m + 100*(n-m);
  printf("%d\n", x << m);
  return 0;
}


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

typedef long long lli;

const int MAXN = 500005;
int N; lli P, Q;
lli C[MAXN];

lli sum(lli n) {
  return n * (n + 1) / 2;
}

lli sum(lli a0, lli len) {
  return sum(len) + len * (a0 - 1);
}

int main() {
  while(cin >> N >> P >> Q) {
    for(int i = 0; i < N; ++i) {
      cin >> C[i];
      C[i] -= P * (N - i - 1);
    }
    sort(C, C+N, greater<lli>());
    lli now = sum(Q, N) * P;
    lli res = now;
    for(int i = 0; i < N; ++i) {
      now += C[i];
      now -= ( Q - i + N - (i + 1) ) * P;
      //cout << now << endl;
      res = max(res, now);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 5092
#include <iostream>
#include <cstdio>

using namespace std;

void print_array(int *x, int n)
{
	for (int k = 0; k < n; ++k)
	{
		if (k == n- 1)
		{
			printf("%d\n", x[k]);
		}
		else
		{
			printf("%d ", x[k]);
		}
	}
}

int main(int argc, char const *argv[])
{
	int input_size, swap_count = 0, temp;
	cin >> input_size;
	int array[input_size];

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

	// ==== bubble sort ==== //
	for (int i = 0; i < input_size; ++i)
	{
		for (int j = input_size - 1; j >= i + 1; --j)
		{
			if(array[j] < array[j-1])
			{
				temp = array[j];
				array[j] = array[j-1];
				array[j-1] = temp;
				swap_count++;
			}
		}
	}
	print_array(array, input_size);
	printf("%d\n", swap_count);

	return 0;
}

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

int main(void){
	int N,i,j,c=0;
	scanf("%d",&N);
	int prime[N];
	for(i=0;i<N;i++)
	{
		scanf("%d",&prime[i]);
	}
	
	for(i=0;i<N;i++)
	{
		for(j=2;j<=sqrt(prime[i]);j++)
		{
			if(prime[i]%j==0)
			{
				c=c+1;
				break;
			}
		}
	}
	
	printf("%d\n",N-c);
	
	return 0;
}


Measured memory_bytes: 2028
N = int(input())
A = list(map(int, input().split()))
B = [0] * N
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]
ans = 0
for i in range(N):
    ans += (A[i] * (B[-1] - B[i]))
print(ans % (10 ** 9 + 7))


Measured memory_bytes: 31600
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h,w,k = m()

s = []

for i in range(h):
    s.append(list(map(int,input()[:-1])))

st = [0 for i in range(h)]
dp = [[0,0] for i in range(h)]
ans = mod

for po in range(2 << h):
    de = 0
    tm = 0
    for j in range(h):
        dp[j][0] = 0
        dp[j][1] = 0
    for j in range(h):
        if j == 0:
            st[0] = 0
        else:
            a = (po>>j)&1
            b = (po>>(j-1))&1
            if a != b:
                de += 1
            st[j] = de
            
    tm += de
    
    for kp in range(w):
        fl = 0
        for kk in range(h):
            if s[kk][kp] == 1:
                dp[st[kk]][1] += 1
        if all(dp[x][0] + dp[x][1] <= k for x in range(h)):
            for kk in range(h):
                dp[kk][0] += dp[kk][1]
                dp[kk][1] = 0
        else:
            tm += 1
            for kk in range(h):
                if dp[kk][0] > k:
                    fl = 1
                    break
                dp[kk][0] = dp[kk][1]
                dp[kk][1] = 0
        if fl:
            break
    else:
        ans = min(tm,ans)
print(ans)










Measured memory_bytes: 53084
#include <stdio.h>

#define WIDTH_MAX 50
#define HEIGHT_MAX 50

int field[ WIDTH_MAX + 2 ][ HEIGHT_MAX + 2 ];
const int dx[ 8 ] = { -1, 0, 1, -1, 1, -1, 0, 1 }, dy[ 8 ] = { -1, -1, -1, 0, 0, 1, 1, 1 };

void del( int x, int y );

int main( void ) {
	int w, h, x, y, sum;

	for ( ; scanf( "%d %d", &w, &h ), w + h; printf( "%d\n", sum ) ) {
		for ( y = 1; y <= h; y++ )
			for ( x = 1; x <= w; x++ )
				scanf( "%d", field[ x ] + y );

		sum = 0;
		for ( y = 1; y <= h; y++ )
			for ( x = 1; x <= w; x++ )
				if ( field[ x ][ y ] == 1 ) {
					del( x, y );
					sum++;
				}
	}

	return 0;
}

void del( int x, int y ) {
	int i;

	field[ x ][ y ] = 0;

	for ( i = 0; i < 8; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( field[ nx ][ ny ] == 1 )
			del( nx, ny );
	}
}	

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

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

void run(int case_id = 0) {
  int a;
  std::string s;
  std::cin >> a >> s;
  if (a >= 3200) {
    std::cout << s << std::endl;
  } else {
    std::cout << "red" << std::endl;
  }
}

void multi_cases_main() {
  int num_tests;
  std::cin >> num_tests;
  for (int t = 1; t <= num_tests; ++ t) {
    run(t);
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  run();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//頭がフットーしそうだよぉ

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


	int L, N, X[200001];
	cin >> L >> N;
	rep1(i, N) cin >> X[i];

	ll S1[200001] = {}, S2[200002] = {};
	rep(i, N) {
		S1[i + 1] = S1[i] + X[i + 1];
		S2[N - i] = S2[N - i + 1] + L - X[N - i];
	}

	ll kotae = 0;

	rep1(i, N) {
		ll kari = 0;
		kari += (S1[i + (N - i + 1) / 2 - 1] - S1[i - 1]) * 2;
		kari += S2[N - (N - i) / 2 + 1] * 2;
		if ((N - i) % 2) kari += L - X[i + (N - i) / 2 + 1];
		else kari += X[i + (N - i) / 2];
		kotae = max(kotae, kari);
	}
	rep1(i, N) {
		ll kari = 0;
		kari += (S2[N - i - (N - i + 1) / 2 + 2] - S2[N - i + 2]) * 2;
		kari += S1[(N - i) / 2] * 2;
		if ((N - i) % 2) kari += X[(N - i) / 2 + 1];
		else kari += L - X[(N - i) / 2 + 1];
		kotae = max(kotae, kari);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007
 
int main(){
	ll a,b;
	cin>>a>>b;
	if(b%a==0){
		cout << a+b << endl;
	}
	else{
		cout << b-a << endl;
	}
 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;
vector<ll> A;

int main() {
	cin >> N;
	A.resize(N);
	for (ll n = 0; n < N; n++)cin >> A[n];
	if (A[N - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	ll dp1 = 2, dp2 = 2;
	for (ll n = N - 2; n >= 0; n--) {
		ll bottom = ceil((ld)dp1 / A[n]);
		ll top = floor((ld)(dp2 + A[n + 1] - 1) / A[n]);
		if (bottom > top) {
			cout << -1 << endl;
			return 0;
		}
		dp1 = bottom * A[n];
		dp2 = top * A[n];
	}
	cout << dp1 << " " << dp2+A[0]-1 << endl;
	return 0;
}

Measured memory_bytes: 1024
N=int(input())
S=[input() for _ in range(N)]

from collections import Counter

cnt_s = sorted(sorted(Counter(S).items(), key=lambda t: t[0])[::-1], key=lambda t:t[1])[::-1]
max_s = max(Counter(S).values())
for k,v in cnt_s:
    if v==max_s:
        print(k)
    else:
        break

Measured memory_bytes: 57636
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;

int main(){
  int K,X;
  cin >> K;
  cin >> X;

  int a=X-K+1;
  int b=X+K-1;

  for(int i=a;i<=b;i++){
    cout << i << " ";
  }
return 0;



	

}

Measured memory_bytes: 256