akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
template<typename T, typename C>
using PQ = priority_queue<T, vector<T>, C>;
using Complex = complex<double>;


int N, K;
int A[100010];
int bitC[40];


signed main(){
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N)
        repif(j, 0, A[i]>>j)
            if((A[i]>>j)&1) bitC[j]++;

    int M = 0;
    repif(i, 0, K>>i)
        if((K>>i)&1) M = i+1;

    int X = 0;
    rep(i, 0, M)
        if(bitC[i] < N-bitC[i]) X |= 1LL<<i;

    repr(i, M, 0){
        if(X <= K) break;
        if(((X>>i)&1) == ((K>>i)&1)) continue;
        X -= 1LL<<i;
    }

    int ans = 0;
    rep(i, 0, N) ans += X^A[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2100
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner; 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] board = new String[2];
		board[0] = sc.next(); board[1] = sc.next();
		ArrayList<Integer> arr = new ArrayList<Integer>();
		for(int i=0; i<n; i++) {
			if(board[0].charAt(i) == board[1].charAt(i)) {
				arr.add(1);
			} else {
				arr.add(2);
				++i;
			}
		}
		long res = (arr.get(0) == 1 ? 3 : 6);
		for(int i=1; i<arr.size(); i++) {
			if(arr.get(i) == 1 && arr.get(i - 1) == 1)
				res *= 2;
			else if(arr.get(i) == 2 && arr.get(i - 1) == 1)
				res *= 2;
			else if(arr.get(i) == 2 && arr.get(i-1) == 2)
				res *= 3;
			res %= 1000000007;
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
template <typename T> void inline read(T &x) {
	T f = 1;
	char ch = getchar();
	for (; '0' > ch || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (x = 0; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	write(x);
	putchar('\n');
}
int n, m;
int col[N];
int len, bl[N];
int ans[N];
struct node{
	int l, r, id;
	friend bool operator < (node a, node b) {
		if (bl[a.l] != bl[b.l]) return bl[a.l] < bl[b.l];
		if (bl[a.l] % 2) return a.r < b.r;
		return a.r > b.r;
	}
}q[N];
int nowl = 1, nowr = 0, nowans;
int cnt[1000010];
void add(int c) {
	if (!cnt[c]) nowans++;
	cnt[c]++;
}
void del(int c) {
	cnt[c]--;
	if (!cnt[c]) nowans--;
}
int main() {
	read(n); read(m);
	for (int i = 1; i <= n; i++) read(col[i]);
	len = pow(n, 1.0 / 2.0);
	for (int i = 1; i <= n; i++) bl[i] = (i - 1) / len + 1;
	for (int i = 1; i <= m; i++) {
		read(q[i].l); read(q[i].r); q[i].id = i;
	}
	sort(q + 1, q + 1 + m);
	for (int i = 1; i <= m; i++) {
		while (nowl > q[i].l) add(col[--nowl]);
		while (nowr < q[i].r) add(col[++nowr]);
		while (nowl < q[i].l) del(col[nowl++]);
		while (nowr > q[i].r) del(col[nowr--]);
		ans[q[i].id] = nowans;
	}
	for (int i = 1; i <= m; i++) print(ans[i]);
	return 0;
}

Measured memory_bytes: 17736
def operand?(e)
  %w[+ - *].include?(e)
end

list = gets.split(' ').map { |g| operand?(g) ? g : g.to_i }

stack = []

list.each do |l|
  unless operand?(l)
    stack << l
  else
    a = stack.pop
    b = stack.pop

    stack << b.send(l, a)
  end
end

puts stack.first


Measured memory_bytes: 6864
#include<stdio.h>
int main(void){
    int n,b,f,r,v,i,j,k;
    int a[4][3][10]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        a[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }if(i!=3){
            printf("####################\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2060
#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 r;
  cin >> r;
  cout << r * r << endl;
  return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    string S;cin>>S;
    char A=S[0],B=S[1];
    bool flag=true;
    for(int i=2;i<S.size();i++){
        if(S[i]!=A&&S[i]!=B){
            flag=false;
        }
    }
    if(flag) cout<<"Second"<<endl;
    else{
        vector<int> T(26,0);
        for(int i=0;i<S.size();i++){
            T[S[i]-'a']++;
        }
        priority_queue<int> PQ;
        for(int i=0;i<26;i++){
            PQ.push(T[i]);
        }
        int a=PQ.top();
        PQ.pop();
        int b=PQ.top();
        PQ.pop();
        int c=PQ.top();
        PQ.pop();
        int d=PQ.top();
        bool e=true;
        if(S[0]==S[S.size()-1]) e=false;
        if(S.size()==3||!(c==1&&d==0)||a-b>=2){
            if((S.size()%2==1&&e)||(S.size()%2==0&&!e)) cout<<"First"<<endl;
            else cout<<"Second"<<endl;
        }else{
            char X;
            for(int i=0;i<26;i++){
                if(T[i]==1) X='a'+i;
            }
            char was=S[0];
            bool check=true;
            bool f=true;
            if(S[0]==X||S[S.size()-1]==X) f=false;
            for(int i=1;i<S.size();i++){
                if(S[i]==X) continue;
                else{
                    if(S[i]==was) check=false;
                    else was=S[i];
                }
            }
            if(!f){
                if(S.size()%2==0) cout<<"Second"<<endl;
                else cout<<"First"<<endl;
            }
            else {
                if(check) cout<<"First"<<endl;
            else cout<<"Second"<<endl;
            }
        }
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define init(a) memset((a),0,sizeof(a))
using namespace std;
typedef double D;
typedef vector<D> P;
const D EPS = 1e-8;

int n,m,r;
P sp[2020],tp[20],ep;
D sr[2020],tb[20];
int rm[20][2020],use[2020];

inline P mul(P p, const D &d){
  rep(i,p.size())p[i] *= d;
  return p;
}

inline P add(P a, const P &b){
  rep(i,a.size())a[i] += b[i];
  return a;
}

inline D dis2(const P &a, const P &b){
  D x = a[0]-b[0], y = a[1]-b[1], z = a[2]-b[2];
  return x*x+y*y+z*z;
}

inline D score(const int &i){
  return tb[i]/dis2(ep,tp[i]);
}

inline int intersect(const int &p, const int &c){
  P l = ep, r = tp[p];
  D r2 = sr[c]*sr[c];
  bool f1 = (dis2(sp[c],l)<r2+EPS), f2 = (dis2(sp[c],r)<r2+EPS);
  if(f1&&f2)return 0;
  if(f1||f2)return 1;

  rep(i,30){
    P m1 = mul(add(mul(l,2),r),1.0/3), m2 = mul(add(l,mul(r,2)),1.0/3);
    D d1 = dis2(sp[c],m1), d2 = dis2(sp[c],m2);
    if(d1<d2)r = m2;
    else l = m1;
  }
  if(dis2(sp[c],l)<r2+EPS)return 1;
  return 0;
}

int main(){
  while(scanf("%d%d%d",&n,&m,&r),n){
    rep(i,n){
      sp[i].resize(3);
      rep(j,3)scanf("%lf",&sp[i][j]);
      scanf("%lf",&sr[i]);
    }
    rep(i,m){
      tp[i].resize(3);
      rep(j,3)scanf("%lf",&tp[i][j]);
      scanf("%lf",&tb[i]);
    }
    ep.resize(3);
    rep(i,3)scanf("%lf",&ep[i]);

    vector<int> rm[20];
    rep(i,m)rep(j,n){
      if(intersect(i,j))rm[i].push_back(j);
    }

    D res = 0.0, p[20];
    rep(i,m)p[i] = score(i);

    rep(bit,1<<m){
      init(use);
      D sum = 0.0;
      rep(i,m){
	if((bit>>i)&1){
	  sum += p[i];
	  rep(j,rm[i].size())use[rm[i][j]] = 1;
	}
      }

      if(accumulate(use,use+n,0)>r)continue;
      res = max(res,sum);
    }
    cout << fixed << setprecision(10) << res << endl;
  }
}

Measured memory_bytes: 1512
#include<stdio.h>

#define Max 100
#define Infty (1<<21)
#define W 0
#define G 1
#define B 2

int n, m[Max][Max];

void dijkstra(){
  int i, u, minv, v;
  int d[Max], color[Max];

   for(i = 0 ; i < n ; i++){
    d[i] = Infty;
    color[i] = W;
  }

  d[0] = 0;
  color[0] = G;

  while(1){
    minv = Infty;
    u = -1;

    for(i = 0 ; i < n ; i++){
      if(minv > d[i] && color[i] != B){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = B;
    for(v = 0 ; v < n ; v++){
      if(color[v] != B && m[u][v] != Infty){
	if(d[v] > m[u][v] + d[u]){
	  d[v] = d[u] + m[u][v];
	  color[v] = G;
	}
      }
    }
  }
  
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n", i, d[i] == Infty ? -1 : d[i]);
  }
}


int main(){
  int i, j, k, c, u, v;
  
  scanf("%d", &n);

   for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      m[i][j] = Infty;
    }
   }

   for(i = 0 ; i < n ; i++){
     scanf("%d %d", &u, &k);
     for(j = 0 ; j < k ; j++){
       scanf("%d %d", &v, &c);
       m[u][v] = c;
     }
   }

   dijkstra();

   return 0;
}


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

int main() {
  int x, y;
  while (true) {
    cin >> x >> y;

    if (x == 0 && y == 0) break;

    if (x > y) {
      cout << y << " " << x << endl;
    } else {
      cout << x << " " << y << endl;
    }
  }
  return 0;
}

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

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

struct UnionFind{
  int n, sets;
  vi p, r, s;
  UnionFind(int N) : n(N), sets(N), 
  r(N), s(N, 1), p(N) { 
    while (--N) p[N] = N; 
  }
  //Find, utiliza compresión de caminos
  int Find(int i) {
    return (i == p[i]) ? i : (p[i] = Find(p[i]));
  }
  //Determina si están en la misma componente
  bool isSameSet(int i, int j) {
    return (Find(i) == Find(j));
  }
  //Union, utiliza rango para un arbol corto y sea O(~1)
  void Union(lli i, lli j) {
    int x = Find(i), y = Find(j);
    if (x == y) return; else sets--;
    (r[x] > r[y]) ? p[y] = x, s[x] += s[y] 
                  : p[x] = y, s[y] += s[x];
    if (r[x] == r[y]) r[y]++;
  }
  //Retorna el tamaño del conjunto del nodo i
  int sizeSet(int i) {
    return s[Find(i)];
  }
  //Retorna el número de componentes conexas
  int numSet() {
    return sets;
  }
};

int main () {
	
	int n=0, m=0, x=0, y=0, w=0, i=0;

	cin >> n >> m;

	UnionFind uf(n);

	for (i=0; i<m; i++) {
		cin >> x >> y >> w;
		x--; y--;
		uf.Union(x, y);
	}

	cout << uf.numSet() << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

string runLength(string s) {
	int cnt = 0;
	char num;
	string ans;
	num = s[0];
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == num) {
			cnt++;
		} else {
			ans += to_string(cnt) + num;
			cnt = 1;
			num = s[i];
		}
	}
	ans += to_string(cnt) + num;
	

	return ans;
}

int main() {
	int i, j, n;
	
	while (1) {
		cin >> n;
		if (n == 0)break;
		string s;
		cin >> s;

		for (i = 0; i < n; i++) {
			s = runLength(s);
		}

		cout << s << endl;
	}






	return 0;
}

Measured memory_bytes: 3332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

int n;
ll sum[100100];

int main() {
	rep(i, 1010) {
		sum[i + 1] = sum[i] + (i + 1);
	}
	while (cin >> n&&n) {
		int ans = 0;
		rep(i, n) {
			FOR(j, i + 1, n) {
				if (sum[j] - sum[i] == n) {
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
}


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

int main() {
    string ans = "NO";
    char c[2][3];
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    char convers[2][3];
    int count = 0;
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 3; j++){
            convers[i][j] = c[1 - i][2 - j];
            if(convers[i][j] == c[i][j]) count++;
        }
    }

    if(count == 6) ans = "YES";

    cout << ans << endl;

}


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

int main() {
  int n;
  cin>>n;
  int h[100005];
  rep(i,n) cin>>h[i];
  bool flag=false;
  for (int i=n-1; i>=1; i--) {
    if (h[i-1]-h[i]>1) {
      puts("No");
      return 0;
    }
    if (h[i-1]-h[i]==1) h[i-1]--;
  }
  puts("Yes");
  return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int S = scan.nextInt();
        int h = S / 3600;
        int d = (S % 3600) / 60;
        int s = (S % 3600) % 60;
        System.out.println(h+":"+d+":"+s);
        scan.close();
    }
}


Measured memory_bytes: 26244
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

colorcnt = [[0] * C for _ in range(3)]

for i_y in range(N):
    for i_x in range(N):
        colorcnt[(i_x + i_y) % 3][c[i_y][i_x] - 1] += 1

# print("#", colorcnt)            
            
pentab = [[0] * C for _ in range(3)]
for grp in range(3):
    for c_dst in range(C):
        penalty = 0
        for c_src in range(C):
            penalty += colorcnt[grp][c_src] * D[c_src][c_dst]
        pentab[grp][c_dst] = penalty

# print("#", pentab)

import itertools

ans = 10 ** 18
for c_ans in itertools.permutations(range(C), 3):
    ans_tmp = sum([pentab[i][c_ans[i]] for i in range(3)])
    if ans > ans_tmp:
        ans = ans_tmp

print(ans)

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

int main(void) {
  int k, s;
  cin >> k >> s;
  
  int num = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int z = s - x - y;
      if (z>=0 and z<=k) num++;
    }
  }
  
  cout << num;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	string s, t;
	cin >> s >> t;
	int c = 0;
	rep(i,s.size()){
		if(s[i] != t[i]){
			c++;
		}
	}
	cout << c << endl; 
	return 0;
}


Measured memory_bytes: 3800
use std::cmp;

fn main(){
  loop {
    let n: usize = read();
    if n == 0 { break; }
    
    let mut rv: Vec<usize> = Vec::new();
    let mut mm: Vec<bool> = vec![false;n];
    
    for x in (1 .. n).map(|e| e * e % n) {
      if !mm[x] {
        rv.push(x);
        mm[x] = true;
      }
    }

    let mut ans: Vec<usize> = vec![0; (n + 1) / 2];

    for i in 0 .. rv.len() {
      for j in 0 .. rv.len() {
        ans[dist(n, rv[i], rv[j])] += 1;
      }
    }

    for i in 1 .. ans.len() {
      println!("{:?}", ans[i]);
    }
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn dist(n: usize, x: usize, y: usize) -> usize {
  let t = cmp::max(x, y) - cmp::min(x, y);
  cmp::min(t, n - t)
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  string str; cin >> str;

  int Abegin;
  bool getA = false;
  int Zend = 0;
  rep(i, str.length()) {
    if( getA ) {
      if( str[i] == 'Z' ) Zend = max(Zend, i);
    }
    else if( str[i] == 'A' ) {
      getA = true;
      Abegin = i;
    }
  }

  int ans = 0;
  getA = false;
  rep(i, str.length()) {
    if( i == Abegin ) getA = true;
    if( getA && i <= Zend ) ++ans;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 720
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double d = 2.0 * x >= a * a * b ? 2.0 * (b - x / a / a) : b;
	double e = 2.0 * x >= a * a * b ? a : 2.0 * x / a / b;
	printf("%f\n", atan(d / e) * 180.0 / M_PI);
}


Measured memory_bytes: 384
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int a, b, c;
    cin >> a >> b >> c;

    cout << c << ' ' << a << ' ' << b << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str

isdelim(x::UInt8, xs::Set{UInt8}) = x in xs

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        if !isdelim(c, delims)
            break
        end
    end
    push!(out, c)
    if eof(s)
        return out
    end
    while !eof(s)
        c = read(s, UInt8)
        if isdelim(c, delims)
            break
        end
        push!(out, c)
    end
    return out
end

delimset = Set([0x0a, 0x20])

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

readvec(tys::Tuple , len::Signed)::Vector{Tuple{tys...}} = @inbounds Tuple{tys...}[reads(tys...) for i in 1:len]

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i = 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

function main()
    N = pread(Int)
    c = sum(filter(x -> x % 3 != 0 && x % 5 != 0, 1:N))
    println(c)
end

main()


Measured memory_bytes: 199872
from bisect import bisect
n,q = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a,x,y,z = a[::-1],[0],[0],[]
for i in range(n):
    x.append(x[-1]+a[i])
    if 1-i%2: y.append(y[-1]+a[i])
    else: y.append(y[-1])
for i in range((n+1)//2): z.append(-1.0*(a[i]+a[2*i])/2)
for i in range(q):
    p = -int(input())
    m = bisect(z,p)
    if m==len(z): print(x[(n+1)//2])
    else: print(x[m]+y[n]-y[2*m])

Measured memory_bytes: 18872
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a

k=int(input())
s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[k-1])

Measured memory_bytes: 2940
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int T[3100];
char in[3010][3010];
int main(void){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	long long ret=0;
	for(int i=a-1;i>=0;i--){
		int tmp=0;
		for(int j=b-1;j>=0;j--){
			if(in[i][j]=='O')tmp++;
			if(in[i][j]=='I')T[j]++;
			if(in[i][j]=='J')
				ret+=tmp*T[j];
		}
	}
	printf("%lld\n",ret);
	return 0;
}



Measured memory_bytes: 11528
x1, y1, x2, y2 = map(int, input().split())

x_ = x2-x1
y_ = y2-y1

x_l = abs(x_)
y_l = abs(y_)

if x_ > 0 and y_ >= 0:
    x3 = x2 - y_l
    y3 = y2 + x_l
    x4 = x3 - x_l
    y4 = y3 - y_l

elif x_ < 0 and y_ <= 0:
    x3 = x2 + y_l
    y3 = y2 - x_l
    x4 = x3 + x_l
    y4 = y3 + y_l

elif x_ <= 0 and y_ > 0:
    x3 = x2 - y_l
    y3 = y2 - x_l
    x4 = x3 + x_l
    y4 = y3 - y_l

elif x_ >= 0 and y_ < 0:
    x3 = x2 + y_l
    y3 = y2 + x_l
    x4 = x3 - x_l
    y4 = y3 + y_l


print(int(x3), int(y3), int(x4), int(y4))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
const int INF = 2e9;
const ll INFLL = 4e18;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n;
	sd(n);
	if(gcd(n,10)!=1){
		pd(-1);
		return 0;
	}
	int gg=0;
	for(int i = 1; i <= n+5; i++){
		gg*=10;gg+=7;gg%=n;
		if(gg==0){
			pd(i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String b = sc.nextLine();

		System.out.println(b.equals("A") ? "T" : b.equals("G") ? "C" : b.equals("C") ? "G" : "A");
	}

}

Measured memory_bytes: 23252
from operator import itemgetter

N = int(input())

wl = [tuple(map(int, input().split())) for _ in range(N)]
wl.sort(key=itemgetter(1))
# (work_time, time_limit)

cur = 0
can = True
for t, lmt in wl:
    cur += t
    if cur > lmt:
        can = False
        break
print('Yes' if can else 'No')


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

int main(){

    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0&&m==0)break;
        vector<int> w(m+1),h(n+1);
        w[0]=0;
        h[0]=0;
        for(int i=0;i<n;i++){
            cin >> h[i+1];
            h[i+1]+=h[i];
        }
        for(int i=0;i<m;i++){
            cin >> w[i+1];
            w[i+1]+=w[i];
        }
        map<int,int> ww,hh;
        for(int i=0;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                hh[abs(h[j]-h[i])]++;
            }
        }
        for(int i=0;i<=m;i++){
            for(int j=i+1;j<=m;j++){
                ww[abs(w[j]-w[i])]++;
            }
        }
        ll ans=0;
        for(auto hit=hh.begin();hit!=hh.end();hit++){
            auto wit=ww.find(hit->first);
            if(wit!=ww.end()){
                ans+=(ll)hit->second*wit->second;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 29876
#include <cstdio>
#include <regex>
#include <list>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mt make_tuple
#define pb push_back
#define sz size()
#define SET(__set, val) memset(__set, val, sizeof(__set))

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto& p: c) os << p << " ";
	return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

constexpr int INF=1e9;
constexpr int MOD=1000000007;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=100001;

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

	int a, b;
	while(cin>>a) {
		cin>>b;
		int now = 1;
		rep(i, a) {
			if(now < b) now*=2;
			else now+=b;
		}
		cout <<now << endl;
	}
	return 0;
}


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

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

int f(int n)
{
    if (n % 2 == 0)
    {
        return n / 2;
    }
    else
    {
        return 3 * n + 1;
    }
}

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

    int s, ans,n;
    n=1000000+1;
    vector<int> A(1);
    cin >> s;
    A[0] = s;
    REP1(i, n - 1)
    {
        int tmp = f(A[i - 1]);
        A.push_back(tmp);
        REP(j, i)
        {
            if (A[i] == A[j])
            {
                ans = i+1;
                goto ANS;
            }
        }
    }
 ANS:
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

LL f(LL l, LL r, LL dv){
    return l/dv - (r-1)/dv;
}

LL g(LL l, LL r, LL k){
    LL res = k*(l-r+1);
    res -= k*(f(l, r, 3)+f(l, r, 5)-f(l, r, 15));
    res += 4*(f(l, r, 3)+f(l, r, 5));
    return res;
}

LL m10(LL p){
    LL x = 1;
    rep(i, p) x *= 10;
    return x;
}

LL dp[20], dp2[20][20];

int main(){
    LL s;
    cin >> s;
    s--;
    dp[0] = 0;
    int k;
    rep(i, 17){
        dp[i+1] = dp[i] + g(m10(i+1)-1, m10(i), i+1);
        if(dp[i+1] > s){
            k = i;
            break;
        }
    }
    LL ans = 0;
    dp2[0][1] = dp[k];
    // cout << dp2[0][1] << " ";
    rep(i, k+1){
        rep(j, 10){
            if(i==0 && j==0) continue;
            dp2[i][j+1] = dp2[i][j] + g(ans+m10(k-i)*(j+1)-1, ans+m10(k-i)*j, k+1);
            // cout << dp2[i][j+1] << " ";
            if(dp2[i][j+1] > s){
                dp2[i+1][0] = dp2[i][j];
                ans += m10(k-i)*j;
                break;
            }
        }
        // cout << " : " << ans << endl;
    }
    // cout << ans << endl;
    int offset = s - dp2[k+1][0];
    // cout << offset << endl;
    string t = "";
    for(LL i=ans; i<ans+20; i++){
        if(!(i%3)) t += "Fizz";
        if(!(i%5)) t += "Buzz";
        if(i%3 && i%5) t += to_string(i);
    }
    REP(i, offset, offset+20) cout << t[i];
    cout << endl;

}


Measured memory_bytes: 3272
#include<stdio.h>
int main(){
    int right,left,i,n,q,a[100010];
    long long int sum,ans=0,x;
    scanf("%d %d\n",&n,&q);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<q;i++){
        right=0,sum=0;
        scanf("%lld",&x);
        for(left=0;left<n;left++){
            while(right<n && sum+a[right]<=x){
                sum=sum+a[right];
                right++;
            }
            ans=ans+(right-left);
            if(right==left){
                right++;
            }
            else{
                sum=sum-a[left];
            }
        }
        printf("%lld\n",ans);
        ans=0;
    }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	if(a[n/2-1]==a[n/2])
	cout<<"0\n";
	else
	{
		//cout<<a[n/2]<<" "<<a[n/2-1]<<"\n";
	for(int i=a[n/2-1];i<=a[n/2];i++)
	{
		if(i>a[n/2-1])
ans++;		   
		
		 } 	
		 cout<<ans<<"\n";
	}

}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double w = sc.nextDouble();
    double h = sc.nextDouble();
    double x = sc.nextDouble();
    double y = sc.nextDouble();
    double max = w * h / 2;
    System.out.println(max);
    int ch = 0;
    if(w/2==x&&h/2==y)ch++;
    System.out.println(ch);

  }
}


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

const int N = 3e2 + 7;

char s[N][N], t[N][N];
int n, res;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin >> s[i][j];
	for (int b = 0; b < n; b++) {
		for (int i = 1; i <= n - b; i++) 
			for (int j = 1; j <= n; j++)
				t[i][j] = s[i + b][j];
		for (int i = n - b + 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				t[i][j] = s[i - (n - b)][j];
		bool ok = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= i; j++) {
				ok &= (t[i][i - j + 1] == t[i - j + 1][i]);
			}
		}
		res += ok * n;
	}
	cout << res;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<double> vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    int m=n/2+1;
    vector<vector<double>> dp(2,vector<double>(m+1));
    dp[0][0]=1.0;
    REP(i,n){
        REP(j,m+1){
            dp[(i+1)%2][j]=0;
        }
        REP(j,m+1){
            dp[(i+1)%2][min(m,j+1)]+=dp[i%2][j]*vec[i];
            dp[(i+1)%2][j]+=dp[i%2][j]*(1.0-vec[i]);
        }
    }
    printf("%.10f\n",dp[n%2][m]);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  
  int ans=0;
  
  rep(i,n) cin >> a[i];
  rep(i,n) {
    cin >> b[i];
    ans += b[i];
  }
  rep(i,n-1) cin >> c[i];
  rep(i,n-1){
    if(a[i]+1 == a[i+1]) ans += c[a[i]-1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
// input vector
template<typename T>
void invec(vector<T> &A){for(T& a : A) cin >> a;}

vector<bool> Eratosthenes_sieve(int MAX){
    vector<bool> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }
    return is_prime;
}

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

int N; cin >> N;

vector<bool> eratos = Eratosthenes_sieve(55556);
VI prime; rep(i, 0, eratos.size()) if (eratos[i]) prime.push_back(i);

int n = 0;
for(int i = 0; i <= 55556 && n < N; ++i)
    if (prime[i]%5 == 1) {
        cout << prime[i] << " ";
        ++n;
    }

cout << "\n";
}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  int rgb = 100*r + 10*g + b;

  if(rgb % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <string>//"reverse(s's it,s's it)"
//#include <functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include <cmath>//"abs" "sqrt"
//#include <numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

#define MAX_N 500000
ll c[MAX_N];

int main(){
	int n;
	ll p,q,s=0;
	cin>>n>>p>>q;
	for(int i=0;i<n;++i){
		cin>>c[i];
		s+=c[i];
		c[i]+=(i*p);
	}
//	cout<<"s: "<<s<<endl;
	sort(c,c+n);
	ll ans=s,t=0;
	for(int k=1;k<=n;++k){
		t+=c[k-1];
		ans=max(ans,s+(p*k*(q+k-1))-t);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7040
N = int(raw_input())
A = map(int, raw_input().split())
 
count = [0]*(N+2)
for i in range(N):
    id = A[i]
    count[id] = count[id]+1
 
sumN = long(0)
for i in range(N+1):
    sumN = sumN + long(long(count[i]*(count[i]-1))/2)
 
for i in range(N):
    id = A[i]
    sumz = sumN - (count[id] - 1)
    print(sumz)

Measured memory_bytes: 20008
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  cout << 0 << endl;
  string res;
  bool frg;
  cin >> res;
  if(res == "Vacant") return 0;
  else if(res == "Male") frg = true;
  else frg = false;
  cout << n-1 << endl;
  cin >> res;
  if(res == "Vacant") return 0;
  // else if(res == "Female") reg = false;
  // else reg = true;
  int l = 0, r = n-1;
  int co = 1;
  while(co < 20){
    co++;
    // cerr << l << " " << r << endl;
    int mid = (l+r)/2;
    bool mig;
    cout << mid << endl;
    cin >> res;
    if(res == "Vacant") return 0;
    else if(res == "Male") mig = true;
    else mig = false;
    int lw = mid - l;
    bool m2 = (lw % 2 == 0);
    bool ge = (frg == mig);
    if((m2 ^ ge) == true){
      r = mid;
    }else{
      frg = mig;
      l = mid;
    }
  }

  return 1;
}

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

int main() {
	int n, k = 1, r = 1;
	cin >> n;
	for (int i = 1; k <= n; i++) {
	    k = k + 2 * i + 1;
	    r++;
	}
	cout << (r - 1) * (r - 1);
	return 0;
}


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

class Main{
	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		int[] suji1,suji2;
		suji1=new int[4];
		suji2=new int[4];
		int hits=0;
		int blow=0;
		while(true) {
			try {
				hits=0;
				blow=0;
				str=bfr.readLine();
				stk=new StringTokenizer(str," ");
				for(int i=0; i<4; i++) {
					suji1[i]=Integer.parseInt(stk.nextToken());
				}
				str=bfr.readLine();
				stk=new StringTokenizer(str," ");
				for(int i=0; i<4; i++) {
					suji2[i]=Integer.parseInt(stk.nextToken());
				}

				for(int i=0; i<4; i++) {
					if(suji1[i]==suji2[i]) {
						hits++;
					}
				}
				suji1=Bubble(suji1);
				suji2=Bubble(suji2);

				for(int i=0; i<4; i++) {
					for(int j=0; j<4; j++) {
						if(suji1[i]==suji2[j]) {
							blow++;
						}
					}
				}
				System.out.println(hits+" "+(blow-hits));
			}catch(IOException e) {

			}
			catch(NullPointerException e) {
			    System.exit(0);
			}
		}
	}

	static int[] Bubble(int[] a) {
		int tmp1,tmp2=0;
		int ookisa=a.length;

		for(int i=0; i<ookisa-1; i++) {
			for(int j=ookisa-1; j>=i+1; j--) {
				if(a[j]<a[j-1]) {
					tmp1=a[j];
					tmp2=a[j-1];
					a[j]=tmp2;
					a[j-1]=tmp1;
				}
			}
		}

		return a;
	}
}


Measured memory_bytes: 24216
import java.io.*;
class Main{
    static int heapSize;
    static long[] heapTree;

    public static void main(String[] args){
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
	String line = new String();

	//read Tree
	try{
	    line = bin.readLine();
	}
	catch(IOException e){
	    System.out.println("Error");
	}
	heapSize=Integer.parseInt(line);
	heapTree = new long[heapSize+1];
	heapTree[0]=-1;
	try{
	    line=bin.readLine();
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//make Tree
	String[] key = line.split(" ");
	for(int i=1; i<heapTree.length; i++){
	    heapTree[i]=Long.parseLong(key[i-1]);
	}

	//buildMaxHeap
	for(int j = (heapSize+1)/2; j>=1; j--)maxHeapify(j);

	//print
	for(int i=1; i<heapTree.length; i++){
	    System.out.print(" "+heapTree[i]);
	}
	System.out.println("");
    }
    

    static int getLeft(int i){
	return 2*i;
    }

    static int getRight(int i){
	return 2*i+1;
    }
    
    static void maxHeapify(int i){
	int l = getLeft(i);
	int r = getRight(i);
	int largest=1;

	if(l<=heapSize && heapTree[l]>heapTree[i])largest=l;
	else largest = i;
	if(r<=heapSize && heapTree[r]>heapTree[largest])largest=r;
	if(largest!=i){
	    long x = heapTree[i];
	    heapTree[i]=heapTree[largest];
	    heapTree[largest]=x;
	    maxHeapify(largest);
	}
    }
}

Measured memory_bytes: 40000
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A,B;
	cin >> A >> B;
	
	out(max({A+B,A-B,A*B}));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

int main(){
	int N;
	ll X;
	cin >> N >> X;

	vector<ll> total(N+1), p(N+1);
	total[0] = 1;
	p[0] = 1;
	for(int i=1; i<=N; i++){
		total[i] = 2*total[i-1]+3;
		p[i] = 2*p[i-1]+1;
		//cout << total[i] << ' ' << p[i] << endl;
	}

	ll ans = 0;
	for(int i=N-1; i>=0; i--){
		if(X >= total[i]+2){
			ans += p[i]+1;
			X -= total[i]+2;
		} else {
			X -= 1;
		}
	}
	if(X>0) ans++;

	cout << ans << endl;

	return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int k = int.Parse(input[0]);
            int n = int.Parse(input[1]);

            string[] location = Console.ReadLine().Split(' ');

            int res = int.MinValue;
            for (int i = 0; i < n - 1; i++)
            {
                res = Math.Max(res, int.Parse(location[i + 1]) - int.Parse(location[i]));
            }
            res = Math.Max(res, int.Parse(location[0]) + k - int.Parse(location[n - 1]));


            Console.WriteLine(k - res);
        }

    }
}


Measured memory_bytes: 28892
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int num, n, i, j;
        int a[][] = new int[4][13];
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        for(i = 0; i < 4; i++){
            for(j = 0; j < 13; j++){
                a[i][j] = j + 1;
            }
        }
        for(i = 0; i < n; i++){
            String ca = scan.next();
            num = scan.nextInt();
            if(ca.equals("S")) a[0][num - 1] = 0;
            if(ca.equals("H")) a[1][num - 1] = 0;
            if(ca.equals("C")) a[2][num - 1] = 0;
            if(ca.equals("D")) a[3][num - 1] = 0;
        }
        for(i = 0; i < 4; i++){
            for(j = 0; j < 13; j++){
                if(a[i][j] != 0){
                    if(i == 0) System.out.printf("S %d\n", a[i][j]);
                    if(i == 1) System.out.printf("H %d\n", a[i][j]);
                    if(i == 2) System.out.printf("C %d\n", a[i][j]);
                    if(i == 3) System.out.printf("D %d\n", a[i][j]);
                }
            }
        }
        scan.close();
    }
}



Measured memory_bytes: 26348