akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int count=1;
  while(a>0 && c>0)
  {
      if(count%2!=0)
      {
          c-=b;
      }
      else 
      {
          a-=d;
      }
      count++;
  }
  if(a<=0)
  {
      cout<<"No"<<endl;
  }
  else 
  cout<<"Yes"<<endl;


}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };

int n, m;
VI Mayors;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}

int main() {
	while ( ~scanf( "%d %d", &n, &m ) && n && m ) {
		Mayors.resize( n );
		for ( int i = 0; i < n; i++ ) {
			Mayors[ i ] = 0;
		}
		int now = 0;
		int now_stone = m;
		while ( true ) {
			if ( !now_stone ) {
				now_stone += Mayors[ now ];
				Mayors[ now ] = 0;
				now++;
				now %= n;
				continue;
			}
			else {
				Mayors[ now ]++;
				now_stone--;
				if ( !now_stone ) {
					if ( Mayors[ now ] == m ) {
						break;
					}
				}
				now++;
				now %= n;
			}
		}
		printf( "%d\n", now );
	}
	return 0;
}

Measured memory_bytes: 1204
N = int(input())

A = list(map(int,input().split()))

for i in range(1,N+1):
    A[i-1] -= i
    
A = sorted(A)

b = (A[N//2-1]+A[N//2])//2 if N%2==0 else A[N//2]

print(sum(map(lambda x:abs(x-b),A)))

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

int main() {
  int i, N, K, count=0, A=0, B=0;
  vector<ll> a(110);
  ll x;
  
  cin >> N >> x;
  rep(i,N) cin >> a[i];
  

  sort(a.begin(),a.begin()+N);
  
  
  for(i=0;i<N;i++){
    x-=a[i];
    if(x>=0) count+=1;
    else break;
  }
  
  if(x>0)count-=1;
  
  cout << count;
  
}
  
  




Measured memory_bytes: 3572
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

bool f(long long N){
  string s = to_string(N);
  long long slen = s.length();
  slen--;
  for (int i = 0; i < s.length(); i++)
  {
    if(s[i]!=s[slen-i])
      return false;
  }
  return true;
}

int main()
{
  long long A, B;
  cin >> A >> B;
  long long ans = 0;
  for (int i = A; i <= B; i++)
  {
    if(f(i))
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 100000000000;
int gcd(int a, int b)
{
    if (a < b)
        return gcd(b, a);
    if (a % b)
        return gcd(b, a % b);
    return b;
}
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    int ma = -1;
  	s.push_back('B');
    for (int i = 0; i < s.size(); i++)
    {
        cnt = 0;
        for (int j = i; j < s.size(); j++)
        {
            if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C')
            {
                cnt++;
            }
            else
            {
                ma = max(ma, cnt);
                cnt = 0;
            }
        }
    }
    cout << ma << endl;
}


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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

int main() {
    ll x,y;
    cin>>x>>y;

    ll ans=1;
    while(x<y){
        x*=2;
        if(x<=y)ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月08日 星期一 01时32分01秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)



int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	int n;
	cin>>n;
	cout<<48-n<<endl;
    return 0;
}


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

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef vector< int > vi;


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

    int im = a - b;
    int ans = c - im;
    if(ans < 0) {
        ans = 0;
    } 

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a);
  fo(i,a)
    cin>>c[i];
  int d=b,e=1;
  while(d<a){
    d+=b-1;
    e++;
  }
  cout<<e<<endl;
 /* fo(i,a){
    if(c[i]==1)
      break;
    else
      d++;
  }
  int e=c.size()-d-1;*/
}


Measured memory_bytes: 1148
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

void trace(vector<int> v)
{
    for (int i = 0; i < v.size(); i++) {
        if (i) {
            cout << " ";
        }
        cout << v[i];
    }
    cout << endl;

}

int bubbleSort(vector<int>& v)
{
    int count = 0;
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = v.size() - 1; j >= i + 1; j--) {
            if (v[j] < v[j - 1]) {
                swap(v[j], v[j - 1]);
                flag = true;
                count++;
            }
        }
    }

    return count;
}

int main()
{
    int n;
    cin >> n;
    
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int vi;
        cin >> vi;
        v.push_back(vi);
    }

    int count;
    count = bubbleSort(v);

    trace(v);
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
 
#define LL long long
 
const int CP=110;
const int CE=CP*CP*20;
 
const LL INF=0x3f3f3f3f3f3f3f3f;
 
LL read(){
	LL s=0,ne=1; char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') ne=-1;
	for(;c>='0'&&c<='9';c=getchar()) s=(s<<1)+(s<<3)+c-'0';
	return s*ne;
}
 
class fs{
  public:
  	int from,to,nxt; LL cap,flow;
  	void init(int f,int t,int n,LL c,LL fl)
  	{from=f;to=t;nxt=n;cap=c;flow=fl;}
}E[CE];
int hd[CP],ecnt=1;
void add(int x,int y,LL z){
	E[++ecnt].init(x,y,hd[x],z,0);
	hd[x] = ecnt;
	E[++ecnt].init(y,x,hd[y],0,0);
	hd[y] = ecnt;
}
 
//v define
int n;
LL a[CP];
void copy(int *a,int *b,int pos,int sz){
	for(int i=pos;i<pos+sz;i++) b[i] = a[i];
}
 
//dinic
int dep[CP];
bool build(int s,int t){ //构造分层图 
	memset(dep,0,sizeof(dep));
	dep[s] = 1;
	
	queue<int> Q;
	Q.push(s);
	
	while(!Q.empty()){
		int u = Q.front();
		Q.pop(); 
		
		for(int k=hd[u]; k; k=E[k].nxt){
			int v = E[k].to;
			if(!dep[v] && E[k].cap-E[k].flow>0){
				dep[v] = dep[u]+1;
				Q.push(v);
			}
		}
	}
	
	return dep[t];
}
int cur[CP]; //当前弧优化 
LL augment(int u,int t,LL rst){ //多路增广 
	if(u == t) return rst;
	
	LL used = 0;
	for(int k=cur[u]; k; k=E[k].nxt){
		//cur[u] = k;
		fs &e = E[k];
		
		if(dep[e.to] == dep[u]+1){
			LL a = augment(e.to,t, min(rst-used,e.cap-e.flow));
			if(a){
				used += a;
				E[k].flow += a;
				E[k^1].flow -= a;
				if(used == rst) return rst;
			}
		}
	}
	
	return used;
}
LL mf(int s,int t){
	LL _mf = 0;
	while(build(s,t)){
		//copy(hd,cur,1,n+2);
        memcpy(cur, hd, sizeof(int)*(n + 4));
		_mf += augment(s,t,INF);
	}
	return _mf;
}
 
int main()
{
	n = read();
	for(int i=1;i<=n;i++)
	    a[i] = read();
		
	for(int i=1;i<=n;i++)
	    for(int k=2;i*k<=n;k++)
		    add(i,i*k,INF);
	int s = n+1,t = n+2;
	for(int i=1;i<=n;i++)
	    if(a[i] > 0) add(i,t,a[i]);
		    else add(s,i,-a[i]);
	
	LL sum = 0,sigma = 0;
	for(int i=1;i<=n;i++) //求负权的绝对值之和 
	    if(a[i] < 0) sigma -= a[i];
	for(int i=1;i<=n;i++)
	    sum += a[i];
	
	printf("%lld",sum+(sigma-mf(s,t)));	
		    
	return 0;
}

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

int main(void) {
	ll n, k;
	cin >> n >> k;
	vector<int> a(n), f(n);
	rep (i, n) cin >> a[i];
	rep (i, n) cin >> f[i];

	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());


	ll l = -1, r = 1e12;
	while (r - l > 1) {
		ll c = (r + l) / 2;
		bool ok = [&]{
			ll sum = 0;
			rep (i, n) {
				sum += max(0ll, a[i] - c / f[i]);
			}
			return sum <= k;
		}();
		if (ok) r = c; else l = c;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int t;
int A,B,C,D,k;
int read()
{
	char c=getchar();
	int res=0,bj=1;
	while(c<'0'||c>'9'){if(c=='-') bj=-1;c=getchar();}
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res*bj;
}
bool check(int mid)
{
	int a=A-mid/(k+1)*k-mid%(k+1);
	int b=B-mid/(k+1);
	return b<=1ll*a*k;
}
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		A=read(),B=read(),C=read(),D=read();
		k=max((A+B)/(B+1),(B+A)/(A+1));
		int l=0,r=A+B+1;
		while(l<r)
		{
			int mid=(l+r)>>1;
			if(check(mid)) l=mid+1;
			else r=mid;
		}
		int a=A-l/(k+1)*k-l%(k+1);
		int b=B-l/(k+1);
		for(int i=C;i<=min(l,D);i++)
		{
			if(i%(k+1)) printf("A");
			else printf("B");
		}
		r=l+1+b-a*k;
		for(int i=max(l+1,C);i<=D;i++)
		{
			if((i-r)%(k+1)) printf("B");
			else printf("A");
		}
		puts("");
	}
}

Measured memory_bytes: 3748
import sys
sys.setrecursionlimit(10**7)
n = int(input())
B = [[] for _ in range(n+1)]
for i in range(n-1):
    v,w,dist = map(int, input().split())
    B[v].append((w,dist))
    B[w].append((v,dist))
color = [-1]*(n+1)
def dfs(a, col):
    if color[a] == -1:
        color[a] = col
    for next_V, dis in B[a]:
        if color[next_V] == -1:
            tmp = col
            if dis%2 != 0:
                tmp = 1-col
            dfs(next_V, tmp)
dfs(1,0)
[print(color[i]) for i in range(1,n+1)]
            

Measured memory_bytes: 164128
let inputString = '';

process.stdin.on('data', (input) => {
  inputString += input;
});

process.stdin.on('end', () => {
  const input = inputString
    .replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''))
    .map(str => str.split(' '))
    .map(arr => [arr[0], Number(arr[1])]);
    
  roundRobin(input);
});

const roundRobin = (arr) => {
  let total = 0;
  const [n, q] = arr.shift();
  while (arr.length > 0) {
    const [name, time] = arr.shift();
    const rest = time - q;
    total += q;

    if (rest > 0) {
      arr.push([name, rest]);
    } else {
      total += rest;
      console.log(`${name} ${total}`);
    }
  }
};


Measured memory_bytes: 65580
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,z,w,a[2000],dp[2][2010];

int calc(int x,int y,int num,int b,int ar,int bt){
  int ans;
  //printf("%d %d %d %d %d\n",x,y,num,ar,bt);
  if(num==n)
    return abs(x-y);
  if(b==0){
    ans=abs(a[n-1]-y);
    for(int i=n-1;i>=num;i--){
      ans=max(ans,calc(a[i],y,i+1,1,ans,bt));
      if(bt<=ans)
        return ans;
    }
  }
  else{
    ans=abs(a[n-1]-x);
    for(int i=n-1;i>=num;i--){
      ans=min(ans,calc(x,a[i],i+1,0,ar,ans));
      if(ans<=ar)
        return ans;
    }
  }
  return ans;
}
int main(){
  scanf("%d %d %d",&n,&z,&w);
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  dp[0][n-1]=dp[1][n-1]=a[n-1];
  printf("%d\n",calc(z,w,0,0,0,1000000000));
}
  

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)
    {
        cin >> a[i];
        a[i] -= (i+1);
    }
    

    sort(a.begin(),a.end());
    
    int med;
    ll sum_1 = 0;
    ll sum_2 = 0;
    ll sum = 0;
    if (n%2==0)
    {
        med =  (a[n/2]+a[n/2-1])/2;
        rep(i,n)
        {
            sum_1 += abs(a[i] - med);
            sum_2 += abs(a[i] - med-1);
        }
        cout << min(sum_1,sum_2) << endl;
    }else
    {
        med = a[n/2];
        //cout << med << endl;
        rep(i,n)
        {
            sum += abs(a[i]-med);
        }
        cout << sum << endl;
    }
    
    
}

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

int ch[30];

int main() {
	memset(ch, 0, sizeof(ch));

	char c;
	while (cin >> c) {
		ch[c - 'a'] = 1;
	}
	for (int i = 'a'; i <= 'z'; i++) if (!ch[i - 'a']) {
		cout << (char) i << '\n';
		return 0;
	}
	cout << "None\n";
	return 0;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), M = cin.getInt();
    let X = cin.getIntArray(M);
    let P = new Array(M - 1);
    X.sort((a, b) => a - b);
    let ans;
    if (N == 1) ans = X[M - 1] - X[0];
    else if (N == M) ans = 0;
    else {
        for (let n = 0; n < M - 1; n++) P[n] = X[n + 1] - X[n];
        P.sort((a, b) => a - b);
        ans = P.reduce((ac, v, i) => ac + (i < M - N ? v : 0), 0);
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27408
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}

		int dp[][] = new int[N+1][2];
		dp[0][0] = 1;
		dp[0][1] = 0;
		
		for (int i=0;i<N;i++) {
			if (A[i]%2 == 0) {
				dp[i+1][0] += dp[i][0] * 2;
				dp[i+1][1] += dp[i][1] * 2;
				
				dp[i+1][1] += dp[i][0] * 1;
				dp[i+1][1] += dp[i][1] * 1;
			} else {
				dp[i+1][0] += dp[i][0] * 1;
				dp[i+1][1] += dp[i][1] * 1;
				
				dp[i+1][1] += dp[i][0] * 2;
				dp[i+1][1] += dp[i][1] * 2;
				
			}
		}
		
		System.out.println(dp[N][1]);
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

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

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

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

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

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

Measured memory_bytes: 21460
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    double a[1000];
    int i=0;
    while(cin>>a[i])i++;
    sort(a,a+i);
    reverse(a,a+i);
    cout<<a[0]-a[i-1]<<endl;
    //for(int j=0;j<100;j++)
    //{
    //    cout<<"a["<<j<<"]="<<a[j]<<endl;
    //}
    return 0;
}

Measured memory_bytes: 1300
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int mod = 1e9 + 7;

int power(int x, int y) {
    int res = 1;
    while(y) {
        if(y & 1) 
            res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

int findProductSum(int A[], int n) 
{ 
    // calculating array sum (a1 + a2  ... + an) 
    int array_sum = 0; 
    for (int i = 0; i < n; i++) 
        array_sum = array_sum + A[i]; 
    array_sum %= mod;
    // calcualting square of array sum 
    // (a1 + a2 + ... + an)^2 
    int array_sum_square = array_sum * array_sum % mod; 
  
    // calcualting a1^2 + a2^2 + ... + an^2 
    int individual_square_sum = 0; 
    for (int i = 0; i < n; i++) {
        individual_square_sum += A[i]*A[i];
        individual_square_sum %= mod; 
    }
  
    // required sum is (array_sum_square - 
    // individual_square_sum) / 2 
    return (array_sum_square - individual_square_sum + mod) * power(2, mod - 2) % mod; 
} 

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;
        int a[n];
        for (int i =0 ; i < n; i++)
            cin >> a[i];

        int ans = findProductSum(a, n) % mod;
        cout << ans << '\n';
    }
    
    return 0;
}



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

int main()
{    
    string s;
    cin >> s;
    int n = s.size();

    vector<int> ans(n, 0);
    int last_r = 0;
    int r_cnt = 1;
    int l_cnt = 0;

    rep2(i,1,n)
    {
        if(s[i] == 'R')
        {
            if(s[i-1] == 'L')
            {
                ans[last_r  ] = (r_cnt/2 + r_cnt%2) + l_cnt/2;
                ans[last_r+1] = (l_cnt/2 + l_cnt%2) + r_cnt/2;
                l_cnt = r_cnt = 0;
            }

            last_r = i;
            ++r_cnt;
        }
        else
        {
            ++l_cnt;
        }
    }

    ans[last_r  ] = (r_cnt/2 + r_cnt%2) + l_cnt/2;
    ans[last_r+1] = (l_cnt/2 + l_cnt%2) + r_cnt/2;

    rep(i,n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
const ll INFLL = (ll) 1e18 + 1;
struct edge{
    ll to;
    ll a;
    ll b;
};
vector<ll> A,B,C,D;
vector<vector<edge>> edge1,edge2;

vector<ll> dijkstra(ll s){
    priority_queue<l_l, vector<l_l>, greater<l_l>> pq;
    vector<ll> dist(55*3000, INFLL);
    dist[s] = 0;
    pq.push({dist[s], s});
    while(!pq.empty()){
        auto tmp = pq.top();
        pq.pop();
        ll from = tmp.second;
        ll d = tmp.first;
        if(dist[from] < d)continue;
        for(auto p: edge2[from]){
            if(dist[p.to] > dist[from] + p.b){
                dist[p.to] = dist[from] + p.b;
                pq.push(l_l(dist[p.to], p.to));
            }
        }
    }
    return dist;
}
ll f(ll v, ll s){
    return v*3000 + s;
}
int main(){
    ll n, m ,s, u, v;
    cin >> n >> m >> s;
    edge1.resize(n);
    A.resize(m);
    B.resize(m);
    C.resize(n);
    D.resize(n);
    for(ll i = 0;i < m;i++){
        cin >> u >> v >> A[i] >> B[i];
        u--;v--;
        edge1[u].push_back({v,A[i],B[i]});
        edge1[v].push_back({u,A[i],B[i]});
    }
    for (int i = 0; i < n; ++i) {
        cin >> C[i] >> D[i];
    }
    edge2.resize(n*(3000+5));
    for(ll i = 0;i < n;i++){
        for(ll j = 0;j <= 2499;j++){
            ll to = min(j + C[i], 2499ll);
            edge2[f(i,j)].push_back({f(i, to), 0, D[i]});
            for(auto e: edge1[i]){
                if(j - e.a < 0)continue;
                edge2[f(i,j)].push_back({f(e.to, j-e.a), e.a, e.b});
            }
        }
    }
    s = min(s, 2499LL);
    auto dist = dijkstra(f(0,s));
    for(ll i = 1;i < n;i++){
        ll ans = INFLL;
        for(ll j = 0;j < 3000;j++){
            ans = min(ans, dist[f(i, j)]);
        }
        cout << ans << endl;
    }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>

using namespace std;

class Solver {
public:
	static void solve() {
		int n, t;
		cin >> n >> t;
		int cts[1000][2];
		for (int i = 0; i < n; i++) {
			cin >> cts[i][0] >> cts[i][1];
		}
		int cost = 1e9;
		for (int i = 0; i < n; i++) {
			if (cts[i][1] <= t) cost = min(cost, cts[i][0]);
		}

		if (cost == 1e9)cout << "TLE" << endl;
		else cout << cost << endl;
	}
};

int main() {
	Solver::solve();
}

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

int main() {
  int q;
  std::cin >> q;
  std::vector<int> a;

  for (int i = 0; i < q; ++i) {
    int c;
    std::cin >> c;
    switch (c) {
    case 0:
      int x;
      std::cin >> x;
      a.push_back(x);
      break;
    case 1:
      int p;
      std::cin >> p;
      std::cout << a.at(p) << std::endl;
      break;
    case 2:
      a.pop_back();
      break;
    }
  }
}



Measured memory_bytes: 3884
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    
    if(A == B){
        cout << 1 << endl;
        return 0;
    }
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    if(A > B){
        cout << 0 << endl;
        return 0;
    }
    
    ll u_limit = 0, l_limit = 0;
    u_limit = (ll)B * (N - 2);
    l_limit = (ll)A * (N - 2);
    
    ll ans = u_limit - l_limit + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <string.h>
#include<algorithm>
#include <numeric>      // std::accumulate
#include <iomanip>      // std::setprecision


using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define v           vector <int>
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define EPS			 1e-9
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;

bool cmp(const pair<int, int>& a, const pair<int, int>& b)
{
    return (a.second < b.second);
}

int gcd(int a, int b) 
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
long long power(ll n, ll k) 
{
    if (k == 0) return 1;
    ll sq = (power(n, k / 2));
    sq = (sq * sq);
    if (k % 2 == 1)
        sq = (sq * n);
    return sq;
}
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
string to_binary(int x) 
{
    string s;
    while (x > 0) 
    {
        s += (x % 2 ? '1' : '0');
        x /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}
bool isPerfect(ll x)
{
    if (x < 1) 
        return false;
    ll root(round(sqrt(x)));
    return x == root * root;
}
void solve()
{
    int n; cin >> n;
    map<string, int>m;
    string s;
    while (n--)
    {
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << "\n";
    cout << "WA x " << m["WA"] << "\n";
    cout << "TLE x " << m["TLE"] << "\n";
    cout << "RE x " << m["RE"] << "\n";
}

int main()
{
    IOS;    
    
    int tt;
    tt = 1;
    // cin >> tt;
    while (tt--)
    {
        solve();
    }
    
}
       

Measured memory_bytes: 3200
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

static const int MAX = 10;

bool isInt(double n) {
    return n == floor(n);
}

double distance(int x[][MAX], int i, int j, int d) {
    ll sum = 0;
    for (int k = 0; k < d; ++k) {
        sum += pow(x[i][k] - x[j][k], 2);
    }
    return pow(sum, 0.5);
}

int main() {
    int n, d, X[MAX][MAX];
    cin >> n >> d;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin >> X[i][j];
        }
    }

    int cnt = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (isInt(distance(X, i, j, d))) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
import math

S=int(input())
p=10**9+7

ans=0
mi=math.ceil(S/9)
ma=S//3
l=[0,0,0,1,1,1,2,3,4,6]
if S<=9:
    print(l[S])
    exit()
for i in range(10,S+1):
    x=1
    for j in range(3,3000):
        x=(x+l[i-j])%p
        if i-j==3:
            break
    l.append(x)

print(l[-1])


Measured memory_bytes: 64892
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x; cin>>x;
    int q=0;
    if(x%10==1){q++;}
    if((x/10)%10==1){q++;}
    if((x/100)%10==1){q++;}

    cout<<q;

return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n,m;
int main(){
    cin>>n>>m;
    vector<ll> v(m,0);
    rep(i,m) cin>>v[i];
    sort(v.begin(),v.end());
    vector<ll> dis(m-1,0);
    rep(i,m-1) dis[i]=v[i+1]-v[i];
    sort(dis.begin(),dis.end());
    int path=m-n;
    if(path<=0){
        cout<<"0"<<endl;
        return 0;
    }
    ll ans=0;
    //rep(i,m) cout<<dis[i]<<endl;
    rep(i,m-n) ans+=dis[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    // 2部グラフの最大マッチング O(f(N+M)) f:=最大マッチング数で高々N
    class bipartite_matching {
    public:
        int n;
        vector<vector<int>> g;
        vector<int> match;

        bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

        void add_edge(int u, int v) {
            g[u].push_back(v);
            g[v].push_back(u);
        }

        int maximum_matching(void) {
            int res = 0;
            fill(begin(match), end(match), -1);
            for (int v = 0; v < n; ++v) {
                if (match[v] == -1) {
                    fill(begin(used), end(used), false);
                    if (dfs(v)) res++;
                }
            }
            return res;
        }

    private:
        vector<int> used;
        bool dfs(int v) {
            used[v] = true;
            for (int u : g[v]) {
                int w = match[u];
                if (w == -1 || (!used[w] && dfs(w))) {
                    match[v] = u;
                    match[u] = v;
                    return true;
                }
            }
            return false;
        }
    };
    
    int n;
    cin >> n;
    vector<pair<int, int>> red;
    vector<pair<int, int>> blue;
    rep (n) {
        int x, y;
        cin >> x >> y;
        red.emplace_back( pair<int, int> {x, y} );
    }
    rep (n) {
        int x, y;
        cin >> x >> y;
        blue.emplace_back( pair<int, int> {x, y} );
    }
    
    auto isgood = [](pair<int, int> r, pair<int, int> b) -> bool {
        return (r.fst < b.fst) and (r.snd < b.snd);
    };
    
    bipartite_matching bm(2*n);
    
    repeat (i, n) {
        repeat (j, n) {
            if (isgood(red[i], blue[j])) {
                bm.add_edge(i, j+n);
            }
        }
    }
    cout << bm.maximum_matching() << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  
  vi idx(n);
  rep(i,n) idx[a[i]] = i;

  set<int> s;
  ll ans = 0;
  for (int x = n-1; x >= 0; --x) {
    int i = idx[x];
    ll c = 0;
    { // calc c
      s.insert(i);
      vi l(2,-1);
      vi r(2,n);
      { // calc l
        auto it = s.find(i);
        rep(j,2) {
          if (it == s.begin()) break;
          --it;
          l[j] = *it;
        }
      }
      { // calc r
        auto it = s.find(i);
        rep(j,2) {
          ++it;
          if (it == s.end()) break;
          r[j] = *it;
        }
      }
      vi ls(2);
      ls[0] = i - l[0]; ls[1] = l[0] - l[1];
      vi rs(2);
      rs[0] = r[0] - i; rs[1] = r[1] - r[0];
      c = (ll)ls[0]*rs[1] + (ll)ls[1]*rs[0];
    }
    ans += c*(x+1);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	int a, b, c, d, l;
	cin >> l >> a >> b >> c >> d;
	int da = a / c;
	if(a - da * c > 0) da++;
	int db = b / d;
	if(b - db * d > 0) db++;
	cout << l - max(da, db) << endl;
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	int sum1,sum2;
	sum1=B-A;
	sum2=C-B;
	if(sum1==sum2)
	{
		cout<<"YES"<<endl;
		
	}
	else
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

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

void proc() {
	LOAD(int, N);
	LOAD(int, M);
	std::vector<int>A(M), B(M);
	unordered_map<int, int> edge;
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
		cin >> B[i];
		auto regist = [&edge](int aa, int bb) {
			if (aa == bb)return;
			auto itr0 = edge.find(aa);
			auto itr1 = edge.find(bb);
			if (itr0 != edge.end() && itr1 != edge.end()) {
				edge.erase(aa);
				edge.erase(bb);
			}
			else {
				edge[bb] = aa;
				edge[aa] = bb;
			}

		};
		auto f = [&edge, &regist](int aa, int bb)-> bool {
			auto itr = edge.find(aa);
			if (itr == edge.end()) {
				return false;
			}
			else {
				auto a = aa;
				auto b = itr->second;
				edge.erase(a);
				edge.erase(b);
				regist(b, bb);
				return true;
			}
		};
		if (!f(A[i], B[i]) && !f(B[i], A[i])) {
			regist(A[i], B[i]);
		}
	}
	if (edge.size() == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}


#endif


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

typedef long long ll;

int compute(int A,int K){
    int B = A%K;
    int C = 1 + (A - A%K)/K;
    if(B%C==0)
        return C-1;
    else{
        return(compute(A-C*(1+(B-B%C)/C),K));
    }


}


int main()
{
    int N;
    cin>>N;
    int A[N], K[N];
    int x = 0;
    for(int i=0; i<N; i++){
        cin>>A[i]>>K[i];
        x = (x ^ compute(A[i],K[i]));
    }
    if(x==0)
        cout<<"Aoki"<<endl;
    else
        cout<<"Takahashi"<<endl;
    return 0;
}


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

long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

long long dp[310][90010], dp2[310][90010];

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    long long all = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i]; all += a[i];
    }
    dp[0][0] = 1; dp2[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= all; j++) {
            dp[i+1][j] += dp[i][j] * 2 % mod;
            dp2[i+1][j] += dp2[i][j] % mod;
            dp[i+1][j] %= mod; dp2[i+1][j] %= mod;
            if (dp[i][j]) {
                dp[i+1][j+a[i]] += dp[i][j];
                dp[i+1][j+a[i]] %= mod;
            }
            if (dp2[i][j]) {
                dp2[i+1][j+a[i]] += dp2[i][j];
                dp2[i+1][j+a[i]] %= mod;
            }
        }
    }
    long long cnt = 0;
    for (long long i = 0; i <= all; i++) {
        if (i * 2 >= all) cnt = (cnt + dp[n][i]) % mod;
    }
    long long ans = modpow(3, n) - (cnt * 3) % mod;
    ans = (ans + mod) % mod;
    if (all % 2 == 0) ans += (dp2[n][all/2] * 3) % mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

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

int main() {
  vector<int> x(5);
  for(int i=0;i<5;i++){
    cin >> x.at(i);
    if(x.at(i)==0){
      cout << i+1 << endl;
      break;
    }
  }
}


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

using namespace std;

int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n+2);
    
    for (int i = 0 ; i < n-1; i++){
        int b;
        cin >> b;
        
        a[b]++;
        
    }
    
    
    for (int i = 1; i <= n; i++) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, 0, n) {
        ans = min(ans * 2, ans + k);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];

	ll ans = 0ll;
	for(int i = 0; i < n-1; ++i){
		if((x[i+1]-x[i]) >= (double)b/a){
			ans += b;
		}
		else{
			ans += (x[i+1]-x[i])*a;
		}
	}
	ppp(ans);

    return 0;
}


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

using int64 = long long;

int main() {
    int64 N, L, T;
    cin >> N >> L >> T;

    vector<int64> X(N);
    vector<pair<int64, int>> Y(N);
    vector<int> W(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> W[i];
        // T秒後の位置
        // W[i]:=1 (if 時計回り)
        // W[i]:=2 (if 反時計回り)
        int dir = (W[i] == 1) ? 1 : (-1);
        Y[i] = make_pair(((X[i] + dir * T) % L + L) % L, W[i]);
    }
    int id = -1;
    for (int i = 0; i < N; i++) {
        if (W[i] == 1) id = i;
    }

    if (id == -1) {
        for (int i = 0; i < N; i++) {
            cout << Y[i].first << endl;
        }
        return 0;
    }
    // idの持っているゼッケン
    int diff = 0;
    for (int i = 0; i < N; i++) {
        if (i == id or W[i] == 1) continue;
        int64 p = X[i] + (X[id] > X[i] ? L : 0); 

        diff += 2 * T / L + (X[id] + 2 * T % L > p);
        diff %= N;
    }
    cerr << "id: " << id << endl;
    cerr << "diff: " << diff << endl;
    int nid = (id + diff) % N;

    vector<int> ans(N);
    int pos = Y[id].first,
        start = -1;
    sort(Y.begin(), Y.end());
    // Y[id].firstの位置に
    for (int i = 0; i < N; i++) {
        if (Y[i].first == pos and Y[i].second == 1) {
            start = i;
            break;
        }
    }
    for (int i = 0; i < N; i++) {
        ans[(nid + i) % N] = Y[(start + i) % N].first;
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
  int kazu = 0;
  int as,bs,ag,bg;
  cin >> kazu >> as >> bs >> ag >> bg;
  string masu;
  cin >> masu;
  int kotae = 0;
  int iwa = 0;
  for(int i = as - 1;i <= max(ag,bg) - 1;i++){
    if(masu[i] == '#'){
      iwa++;
    }
    else{
      iwa = 0;
    }
    if(iwa >= 2){
      kotae = 1;
      i = max(ag,bg);
    }
  }
  if(kotae == 0 && ag > bg){
    int ikeru = 0;
    int nukeruka = 0;
    for(int i = bs - 2;i <= bg;i++){
      if(masu[i] == '.'){
        ikeru++;
      }
      else{
        ikeru = 0;
      }
      if(ikeru >= 3){
        nukeruka = 1;
        i = ag;
      }
    }
    if(nukeruka == 0){
      kotae = 1;
    }
  }
  if(kotae == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, k;
  cin >> n >> k;
  double ans = 0.0;
  if (n > k)
  {
    for (int i = 1; i < k; ++i)
    {
      int c = i, cnt = 0;
      while (c < k)
      {
        cnt++;
        c *= 2;
      }
      double t = 1.0 / (double)n / pow(2.0, cnt);
      ans += t;
    }
    ans += (double)(n - k + 1) / (double)n;
  }
  else
  {
    for (int i = 1; i <= n; ++i)
    {
      double t = 1.0 / (double)n;
      int c = i;
      while (c < k)
      {
        t /= 2.0;
        c *= 2;
      }
      ans += t;
    }
  }
  cout << fixed << setprecision(12) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,K,R,S,P;
  cin >> N >> K;
  cin >> R >> S >> P;
  string s;
  cin >> s;

  int r=0;
  int tmp=0;
  for(int k=0;k<K;k++){
    tmp=0;

    if(s[k]=='r') r+=P; else if(s[k]=='s') r+=R; else if(s[k]=='p') r+=S;
    //cout << "+";
    
    for(int i=k+K;i<N;i+=K){
      if(s[i]==s[i-K] && tmp==0){
	tmp=1;
	//cout << "-";
      } else {
	tmp=0;
	if(s[i]=='r') r+=P; else if(s[i]=='s') r+=R; else if(s[i]=='p') r+=S;
	//cout << "+";
      }

    }
  }
  cout << r << endl;

  return 0;
  
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int a;
	cin >> a;
	string S;
	cin >> S;
	if (a < 3200) cout << "red" << endl;
	else cout << S << endl;
}

Measured memory_bytes: 3592
int main () {
    int a, b, d, r;
    double f;
    scanf ("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)((double)a / (double)b);
    printf ("%d %d %f\n", d, r, f);
    return 0;
}

Measured memory_bytes: 1812
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef uint32_t u32;
typedef uint64_t u64;

const u32 mod = 998244353;

u32 mod_pow (u32 r, u32 n) {
  u32 t = 1;
  u32 s = r;
  while (n > 0) {
    if (n & 1) t = (u64) t * s % mod;
    s = (u64) s * s % mod;
    n >>= 1;
  }
  return t;
}

void run (void) {
  i32 n;
  scanf ("%" SCNu32, &n);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  i32 sum = 0;
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
    sum += a[i];
  }
  u32 *dp = (u32 *) calloc (sum + 1 + 300, sizeof (u32)) + 300;
  dp[0] = 1;
  for (i32 i = 0, s = 0; i < n; s += a[i++]) {
    for (i32 j = s + a[i]; j >= 0; --j) {
      dp[j] = (2 * dp[j] + dp[j - a[i]]) % mod;
    }
  }
  u32 ans = mod_pow (3, n);
  for (i32 i = (sum + 1)/ 2; i <= sum; ++i) {
    ans = (ans + 3 * (mod - dp[i])) % mod;
  }
  if (sum % 2 == 0) {
    memset (dp, 0, sizeof (u32) * (sum + 1));
    dp[0] = 1;
    for (i32 i = 0, s = 0; i < n; s += a[i++]) {
      for (i32 j = s + a[i]; j >= 0; --j) {
	dp[j] = (dp[j] + dp[j - a[i]]) % mod;
      }
    }
    ans = (ans + 3 * dp[sum / 2]) % mod;
  }
  printf ("%" PRIu32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 512
import collections

def resolve():
    N = int(input())
    A_list = list(map(int, input().split()))
    sum_A_list = sum(A_list)
    # 値と出現個数のリスト
    A_counter_dict = collections.Counter(A_list)
    Q = int(input())
    for i in range(Q):
        B, C = list(map(int, input().split()))
        if B in A_counter_dict.keys():
            changing_count = A_counter_dict.pop(B)
            sum_A_list += (C - B) * changing_count
            if C in A_counter_dict.keys():
                A_counter_dict[C] += changing_count
            else:
                A_counter_dict[C] = changing_count
        print(sum_A_list)

resolve()

Measured memory_bytes: 21464
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b>c*d)
    cout<<a*b;
  else if(a*b==c*d)
    cout<<a*b;
  else
    cout<<c*d;
  
  return 0;
}

Measured memory_bytes: 3136