akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 1001010;
long long int ans = 0;
int n, a[MAXN], c[MAXN], rem;
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++){
        scanf("%d", &a[i]);
        c[i] = a[i] - i;
    }
    sort(c+1, c+1+n);
    int rem = c[(n+1)/2];
    for(int i = 1; i <= n; i ++)
        ans += abs(c[i] - rem);
    printf("%lld", ans);
}


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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
  int A, P;
  cin >> A >> P;
  P += 3 * A;
  cout << P / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
function MA(h,w){return Array(h).fill(0).map(a=>Array(w).fill(0));}
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var p = o.l();
  var ans = 0;
  for(var i = 0; i < n; i++){
    if(p[i] === i+1){
      i++;
      ans++;
    }
  }
  return ans;
}

Measured memory_bytes: 16716
#include <stdio.h>
int gcd(int a,int b)
{
	int r;
	/* ユークリッドの互除法 */
	r = a % b;
	while( r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int div(int a, int b, int c)
{
	int tmp;
	int d;

	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	d = gcd(a, b);
	if (c < d)
	{
		tmp = c;
		c = d;
		d = tmp;
	}
	return (gcd(c,d));
}

int		main(void)
{
	int k;
	scanf("%d", &k);
	int a,b,c;
	long sum = 0;
	a = 1;
	while (a <= k)
	{
		b = 1;
		while (b <= k)
		{
			c = 1;
			while (c <= k)
			{
				if (div(a,b,c))
					sum += div(a, b, c);
				c++;
			}
			b++;
		}
		a++;
	}
	printf("%ld", sum);
	return (0);
}


Measured memory_bytes: 1736
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
template<class T> 
inline void read(T& x)
{
	char c = getchar(); T p = 1, n = 0;
	while(c < '0' || c > '9'){if(c == '-') p = -1; c = getchar();}
	while(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}
	x = p * n;
}
template<class T, class U>
inline void read(T& x, U& y){read(x), read(y);}
template<class T, class U, class V>
inline void read(T& x, U& y, V& z){read(x), read(y), read(z);}
const int maxn = 1e5 + 5;
char s[maxn];
int main()
{
	scanf("%s", &s);
	int len = strlen(s);
	int i = 0, j = len - 1;
	bool flag = false; 
	while(i < j)
	{
		while(s[i] == 'x') ++i;
		while(s[j] == 'x') --j;
		if(i >= j) break;
		if(s[i] != s[j])
		{
			flag = true; break;
		}
		++i, --j;
	}
	if(flag)
	{
		puts("-1"); return 0;
	}
	int ans = 0;
	while(i >= 0 && j <= len - 1)
	{
		while(i >= 0 && j < len && s[i] == s[j]) --i, ++j;
		if(i < 0 || j == len) break;
		while(i >= 0 && s[i] == 'x') --i, ++ans;
		while(j < len && s[j] == 'x') ++j, ++ans;
	}
	ans += i + 1 + len - j;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int highest=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      if(abs(A[i]-A[j])> highest){
        highest = abs(A[i]-A[j]);
      }
    }
  }
  cout << highest << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=303;
const ll INF=1LL<<50;

int main(){
    
    int N;cin>>N;
    vector<ll> pre(N),sum(N+1,0);//cnt...i個出てきたのがいくつあるか
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        a--;
        pre[a]++;
    }
    
    sort(all(pre));
    reverse(all(pre));
    
    for(int i=N-1;i>=0;i--) sum[i]=sum[i+1]+pre[i];
    
    int nowsee=0;
    for(int q=1;q<=N;q++){
        ll nowsee=0,nowtake=q;
        if(nowtake*pre[nowsee]<=sum[nowsee]){
            cout<<sum[nowsee]/nowtake<<endl;
        }else{
            ll left=nowsee,right=q-1;
            while(right-left>1){
                ll mid=(left+right)/2;
                if((nowtake-mid)*pre[mid]<=sum[mid]) right=mid;
                else left=mid;
            }
            cout<<sum[right]/(nowtake-right)<<endl;
        }
        /*while(nowtake&&nowsee<N&&nowtake*pre[nowsee]>sum[nowsee]){
            nowsee++;
            nowtake--;
        }
        if(nowsee==N) cout<<0<<endl;
        else cout<<sum[nowsee]/nowtake<<endl;*/
        //else cout<<min(pre[nowsee-1],sum[nowsee]/nowtake)<<endl;
    }
    
}





Measured memory_bytes: 7040
#include <stdio.h>

int arry[50];

int finabocci(int n)
{
	if (n == 0 || n == 1) return arry[n] = 1;
	if (arry[n] != -1) return arry[n];
	return arry[n] = finabocci(n - 1) + finabocci(n - 2);
}


int main()
{
	int n, i;
	for (int i = 0; i < 50; i++)
	{
		arry[i] = -1;
	}
	scanf("%d", &n);
	printf("%d\n", finabocci(n));
	
	return 0;
}


Measured memory_bytes: 2104
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ans := make([][]int, 0)
	for i := 1; i < N; i++ {
		for j := i + 1; j <= N; j++ {
			if j != N-i+1-(N%2) {
				ans = append(ans, []int{i, j})
			}
		}
	}
	fmt.Println(len(ans))
	for _, ary := range ans {
		fmt.Println(ary[0], ary[1])
	}
}


Measured memory_bytes: 2516
n,m = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map{|i|i.to_i-1}
edge = m.times.map{gets.chomp.split(" ").map{|i|i.to_i-1}}
ans = Array.new(n){|i|i}
mori = Hash.new{|h,k|h[k] = [k]}
edge.each do |i,j|
  if ans[i] != ans[j]
    if mori[ans[i]].size < mori[ans[j]].size
      k,l = i,j
    else
      k,l = j,i
    end
    temp = ans[k]
    mori[ans[k]].each do |o|
      ans[o] = ans[l]
      mori[ans[l]] << o
    end
    mori.delete(temp)
  end
end
temp = 0
mori.each do |k,arr|
  count = Hash.new(0)
  arr.each do |i|
    if p[i] != i
      count[i] += 1
      count[p[i]] += 1
    end
  end
  temp += count.values.count(2)
end
for i in 0..n-1
  if p[i] == i
    temp += 1
  end
end
puts temp

Measured memory_bytes: 30076
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
//int mod(int a,int b,int d);

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() {
  int n,d;
  cin >> n >> d;
  vector<ll> x(n),y(n);
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  
  double d1;
  int c=0;
  rep(i,n){
    d1 = pow((double)(x[i]*x[i]+y[i]*y[i]),0.5);
    if(d1<=d) c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 6488
// Use gradient descent
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<double,double> pi;
vector<pi> point;
int n;

double dis(pi A,pi B){
    return sqrt((A.X - B.X)*(A.X - B.X) + (A.Y - B.Y)*(A.Y - B.Y));
}

double f(pi p){
    double res = 0;
    for (pi x: point) res = max(res,dis(p,x));
    return res;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    point.resize(n);
    for (int i = 0; i < n; i++) cin >> point[i].X >> point[i].Y;
    
    double ans = 200000;
    double px = 0, py = 0, alpha = 1e2, delta = 1e-7;
    for (int Loop = 0; Loop < 20000; Loop++){
        double dx = (f(pi(px + delta,py)) - f(pi(px - delta,py)))/(2*delta);
        double dy = (f(pi(px,py + delta)) - f(pi(px,py - delta)))/(2*delta);
        px -= alpha*dx;
        py -= alpha*dy;
        alpha *= 0.999;
    }
    cout << fixed << setprecision(8) << f(pi(px,py));

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

x = []
y = []
for a, b in ab:
    if a == 1:
        x.append(b)
    if b == n:
        y.append(a)

if len(set(x) & set(y)) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

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

int main(){
    int n, ans = 0;
    long long d;
    cin >> n >> d;
    for (int i = 0; i < n; ++i){
        long long x, y;
        cin >> x >> y;
        if (d * d >= x * x + y * y){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)
#define ff first
#define ss second

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

using vi = vector<int>;

constexpr int N = 1 << 17;
int M, f[N], h[N];
vi g[N];

void down(int u, int p) {
	f[u] = 1;
	g[u].erase(find(all(g[u]), p));
	trav(v, g[u]) {
		down(v, u);
		f[u] = 1ll * f[u] * (1 + f[v]) % M;
	}
}

void up(int u) {
	int c = sz(g[u]); vi s(c, 1); int x = 1;
	per(i, 1, c) s[i - 1] = 1ll * s[i] * (1 + f[g[u][i]]) % M;
	rep(i, 0, c) {
		int v = g[u][i];
		h[v] = 1ll * x * s[i] % M * (1 + h[u]) % M;
		x = 1ll * x * (1 + f[v]) % M;
		up(v);
	}
}

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

	int n; cin >> n >> M;
	rep(i, 1, n) {
		int u, v; cin >> u >> v; --u; --v;
		g[u].eb(v); g[v].eb(u);
	}
	g[0].eb(0); down(0, 0); up(0);
	rep(u, 0, n) cout << 1ll * f[u] * (1 + h[u]) % M << '\n';
}

Measured memory_bytes: 15232
import static java.lang.Math.log10;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); 
        
       int sum = 0 ;
        for(int i = 1 ; i<=n ; i++){
            
          int temp = i ;
     /*      double j =0;
           j = (int)log10(i)+1;
           
            if(j%2==1){
                sum++;
            }
        }
       */     
           int count =0;
            while(temp!=0){
                temp=temp/10;
                count++;
            }
            if(count%2==1){
                sum++ ;
            }
                 }
        System.out.println(sum);
          
    }
}


Measured memory_bytes: 23124
def main():
   n = int(input())
   a = list(map(int,input().split()))
   b = [(0,0) for i in range(n)]
   for i in range(n):
       b[i] = (a[i],i + 1)
   b.sort()
   for i in range(n):
       if i != n - 1:
           print(b[i][1],end = " ")
       else:
           print(b[i][1])

main()

Measured memory_bytes: 86132
import math

def Sieve_of_Eratosthenes(n):
    if n < 2:
        raise ValueError('n is more than 2.')
    prime = []
    limit = math.sqrt(n)
    can = [i for i in range(2, n+1)]
    while True:
        p = can[0]
        if limit <= p:
            return prime + can
        prime.append(p)
        can = [x for x in can if x%p != 0]

q = int(input())
l_r = []
for _ in range(q):
    l, r = map(int, input().split())
    l_r.append((l,r))

can = Sieve_of_Eratosthenes(10**5)
like_2017 = []

for m in can:
    limit = (max(can)//2)
    if m > limit :
        break
    if 2*m-1 in can:
        like_2017.append(2*m-1)

count = 0
can_count = []
for i in range(10**5):
    if i in like_2017:
        count += 1
    else:
        pass
    can_count.append(count)

for pair in l_r:
    l = pair[0]
    r = pair[1]
    ans = can_count[r] - can_count[l-1]
    print(ans)

    


Measured memory_bytes: 63064
import java.util.*;

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

    int h = sc.nextInt();
    int w = sc.nextInt();
    String[] p = new String[h];
    for(int i = 0; i < h; i++) {
      p[i] = sc.next();
    }

    for(int i = 0; i < h + 2; i++) {
      for(int j = 0; j < w + 2; j++) {
        if(i == 0 || i == h + 1) {
          System.out.print("#");
        } else if(j == 0 || j == w + 1) {
          System.out.print("#");
        } else if(i > 0 && i < h + 1 && j == 1){
          System.out.print(p[i - 1]);
        }
      }
      System.out.println();
    }

  }
}


Measured memory_bytes: 26408
def solve(N):
    ret = 0
    counter = [[0 for _ in range(10)] for _ in range(10)]
    for n in range(1, N + 1):
        i, j = map(int, [str(n)[0], str(n)[-1]])
        counter[i][j] += 1

    for i in range(10):
        for j in range(10):
            ret += counter[i][j] * counter[j][i]
    return ret


if __name__ == '__main__':
    N = int(input())
    ret = solve(N)
    print(ret)

Measured memory_bytes: 40428
#include<stdio.h>
#include<string.h>
int main(void){
    char s1[]="Sunny";
    char s2[]="Cloudy";
    char s3[]="Rainy";
    char s[100];
    scanf("%s",s);
    if(strcmp(s,s1)==0){
        printf("%s\n",s2);
    }else if(strcmp(s,s2)==0){
        printf("%s\n",s3);
    }else if(strcmp(s,s3)==0){
        printf("%s\n",s1);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string n;
	cin >> n;
	for(auto c:n) {
		if(c == '7') return cout << "Yes\n", 0;
	}
	cout << "No\n";
}


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

class Program
{
    static void Main()
    {
        Solve();
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int r = input[0];
        int D = input[1];
        long x = input[2];
        for (int i = 0; i < 10; i++)
        {
            x = r * x - D;
            Console.WriteLine(x);
        }
        return "";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11220
#include <stdio.h>

#define MAX 2000001

void insert(int);
void heapIncreaseKey(int, int);
int extract(void);
void maxHeapify(int);

int H=0, A[MAX];

int main()
{
  int key, Out[MAX], i, j;
  char input[10];

  while( 1 ){
    scanf("%s", input);
    if( input[0] == 'e' && input[1] == 'n' ) break;
    if( input[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    }
    else {
      Out[j] = extract();
      j++;
    }
  }

  for( i = 0 ; i < j ; i++ ) printf("%d\n", Out[i]);
  
  return 0;
}

void insert(int key)
{
  H++;
  A[H] = -1000000000;
  heapIncreaseKey(H, key);
}

void heapIncreaseKey(int i, int key)
{
  int tmp;
  
  if( key < A[i] ) return;
  A[i] = key;
  while( i > 1 && A[i/2] < A[i] ){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i / 2;
  }
}

int extract()
{
  int max;

  if( H < 1 ) return -1000000000;
  max = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return max;
}

void maxHeapify(int i)
{
  int l, r, largest, tmp;
  
  l = 2 * i;
  r = 2 * i + 1;
  
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if( r <= H && A[r] > A[largest] ) largest = r;
  
  if( largest != i ){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

Measured memory_bytes: 6912
// verify(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A)
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;

struct Dinic{
    using flow_t = int;
    const flow_t INF = 1e9;
    struct Edge{int to; flow_t cap; int rev;};
    int n;
    vector<vector<Edge>> g;
    vector<int> iter,level;

    Dinic(int n):n(n),g(n),level(n),iter(n){}

    void add_edge(int from,int to,flow_t cap){
        g[from].push_back(Edge{to,cap,(int)g[to].size()});
        g[to].push_back(Edge{from,0,(int)g[from].size()});
    }

    void bfs(int s){
        fill(begin(level),end(level),-1);
        queue<int> que;
        level[s] = 0; que.push(s);
        while(!que.empty()){
            int v = que.front(); que.pop();
            for(auto& e:g[v]){
                if(e.cap>0 && level[e.to]<0){
                    level[e.to]=level[v]+1;
                    que.push(e.to);
                }
            }
        }
    }

    flow_t dfs(int v,int t,flow_t f){
        if(v == t) return f;
        for(int&i = iter[v]; i < (int) g[v].size(); i++){
            Edge& e = g[v][i];
            if(e.cap>0 && level[v]<level[e.to]){
                flow_t d = dfs(e.to, t, min(f,e.cap));
                if(d>0) {
                    e.cap-= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    flow_t run(int s,int t){
        flow_t ret = 0,f;
        while(bfs(s),level[t]>=0){
            fill(begin(iter),end(iter),0);
            while((f=dfs(s,t,INF))>0) ret += f;
        }
        return ret;
    }
};
int main(){
    int V,E;
    cin>>V>>E;
    Dinic dinic(V);
    for(int i=0;i<E;i++){
        int u,v,c;
        cin>>u>>v>>c;
        dinic.add_edge(u,v,c);
    }
    cout<<dinic.run(0,V-1)<<endl;
    return 0;
}



Measured memory_bytes: 3196
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashSet;
import java.util.*;

public class Main {
		public static void main(String[] args) throws Exception{
			Scanner sc=new Scanner(System.in);
			PrintWriter pw= new PrintWriter(System.out);
			int n=sc.nextInt();
			int k=sc.nextInt();
			int count=0;
			int temp=1;
			while(n>=Math.pow(k, temp)) {
				temp++;
			}
			pw.println(temp);
			sc.close();
			pw.close();
			
		}
	
	
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int X, Y;
    cin>>X>>Y;
    string ans = "No";
    REP(i, 0, X+1){
        int foot = i*2 + (X-i)*4;
        if(foot == Y) ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

using namespace std;

void solve()
{
  int a[3][2],d;
  cin>>a[0][0]>>a[1][0]>>a[2][0]>>d;

  a[0][1]=1;
  a[1][1]=0;
  a[2][1]=-1;
  int ans=0;
  int i=0;
  while(d)
  {
    // cout<<d<<endl;
    int j = min(d,a[i][0]);
    ans+=a[i][1]*j;
    d-=j;
    i++;

  }
  cout<<ans<<endl;




}
signed main()

{
  FAST_IO;
  int t = 1;

  // cin>>t;

  while(t--)
  {
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3592
import math
N = int(input())

list_aaa = [1,2,3,4,5,6,7,8,9]

ans = 0
_not = 0
yes =0

for i in list_aaa:
    ans = math.ceil(N/i)
    if ans >=10 or N%i >=1 :
        _not +=1
    else:
       yes +=1

if yes >=1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define GODSPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;
int add(int a,int b){return (a%mod + b%mod)%mod;}
int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a,int b){return (a%mod * b%mod)%mod;}
int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
signed main()
{
    GODSPEED;
    int n;
    cin>>n;
    vi v(n);
    in(v,n);
    int res=1e18;
    FOR(x,-100,100)
    {
         int ans=0;
         for(auto y:v)
          ans+=(y-x)*(y-x);
         res=min(ans,res);
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!
#-*- coding: utf-8 -*-#
test = input()
a, b, c = map(int, test.split())  # 変数a,b,cにそれぞれN、A、Bをint型にして入力する　
x = []
e = []
for i in range(1,a+1):  # list型の変数xに１からNまでの要素を入れる
    x.append(i)
len_x = len(x)  # リスト型の変数xの要素数を獲得
d = 0  # リストの各行の和を入れるための変数
f = []  # 各行がA以上B以下の要素を入れるための変数
x = map(str, x) # リストxの各要素をstr型に変換
x = list(x)
e_number = 0
for i in range(len_x):
    e = x[i]           # xのi番目の要素を抽出
    e = list(e)  # xのi番目の要素を一文字ずつのstr型としてリスト型の変数に入れる
    e = map(int, e)# xのi番目の要素をint型に変換
    e = list(e)
    e_number = len(e)   # リスト型の変数eの要素数を取得
    d = 0              # 位の合計の判定用の変数
    for g in range(e_number):
        d += e[g-1]  # 位の合計
    if b <= d <= c:  # 位の合計がA以上B以下ならリストfに要素を追加
        f.append(x[i])
answer = 0  # 条件位合う要素の合計を入れる変数
f = map(int, f)
for h in f:
    answer += h  # 要素に合う要素の合計
print(answer)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=INF;
 
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<ll,ll> m;
    rep(i,n){
        m[i+a[i]]++;
    }
    map<ll,ll> mm;
    rep(i,n){
        mm[i-a[i]]++;
    }
    ll ans=0;
    for (auto it=m.begin();it!=m.end();++it){
        ll u=it->second*mm[it->first];
        ans+=u;
        // cout << it->second << it->first << mm[it->first] << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 38244
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
}
int main() {
	int a, b;
	cin >>a >> b;
	if (b % 2 == 0 && a * 2 <= b && b <= a * 4)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {
    ll N,K,R,S,P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    ll out = 0;
    rep(i,N){
        if(i>=K&&T[i-K]==T[i]) T[i] = 'a';
        else{
            if(T[i]=='r') out += P;
            else if(T[i]=='s') out += R;
            else out += S;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	c := 0
	for i := 100; i >= 1; i-- {
		if A%i == 0 && B%i == 0 {
			c++
			if c == K {
				fmt.Println(i)
				break
			}
		}
	}
}


Measured memory_bytes: 512
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//The Code A Doctor Loved
public class Main {

	public static void main(String[] args) {
		Map<Character, String> t = new HashMap<Character, String>();
		t.put(' ', "101");
		t.put('\'', "000000");
		t.put(',', "000011");
		t.put('-', "10010001");
		t.put('.', "010001");
		t.put('?', "000001");
		t.put('A', "100101");
		t.put('B', "10011010");
		t.put('C', "0101");
		t.put('D', "0001");
		t.put('E', "110");
		t.put('F', "01001");
		t.put('G', "10011011");
		t.put('H', "010000");
		t.put('I', "0111");
		t.put('J', "10011000");
		t.put('K', "0110");
		t.put('L', "00100");
		t.put('M', "10011001");
		t.put('N', "10011110");
		t.put('O', "00101");
		t.put('P', "111");
		t.put('Q', "10011111");
		t.put('R', "1000");
		t.put('S', "00110");
		t.put('T', "00111");
		t.put('U', "10011100");
		t.put('V', "10011101");
		t.put('W', "000010");
		t.put('X', "10010010");
		t.put('Y', "10010011");
		t.put('Z', "10010000");
		Map<String, Character> r = new HashMap<String, Character>();
		r.put("00000", 'A');
		r.put("00001", 'B');
		r.put("00010", 'C');
		r.put("00011", 'D');
		r.put("00100", 'E');
		r.put("00101", 'F');
		r.put("00110", 'G');
		r.put("00111", 'H');
		r.put("01000", 'I');
		r.put("01001", 'J');
		r.put("01010", 'K');
		r.put("01011", 'L');
		r.put("01100", 'M');
		r.put("01101", 'N');
		r.put("01110", 'O');
		r.put("01111", 'P');
		r.put("10000", 'Q');
		r.put("10001", 'R');
		r.put("10010", 'S');
		r.put("10011", 'T');
		r.put("10100", 'U');
		r.put("10101", 'V');
		r.put("10110", 'W');
		r.put("10111", 'X');
		r.put("11000", 'Y');
		r.put("11001", 'Z');
		r.put("11010", ' ');
		r.put("11011", '.');
		r.put("11100", ',');
		r.put("11101", '-');
		r.put("11110", '\'');
		r.put("11111", '?');
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] s = sc.nextLine().toCharArray();
			StringBuilder sb = new StringBuilder();
			for(char c:s)sb.append(t.get(c));
			while(sb.length()%5!=0)sb.append('0');
			String u = sb.toString();
			StringBuilder v = new StringBuilder();
			for(int i=0;i<u.length();i+=5)v.append(r.get(u.substring(i, i+5)));
			System.out.println(v);
		}
	}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n; cin >> n; 
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int cur = 0;
		for (int j = 0; j <= i; j++) cur += a[j];
		for (int j = i; j < n; j++) cur += b[j];
		ans = max(ans, cur);
	}
	cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
dp = [0] * (N+1)
dp[0] = 1
a = set()
for _ in range(M):
    a.add(int(input()))
if 1 in a:
    if 2 in a:
        print(0)
        exit()
    dp[2] = 1
    start = 3
else:
    dp[1] = 1
    start = 2
for i in range(start, N+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= MOD
print(dp[N])


Measured memory_bytes: 12652
N = int(input())
A = list(map(int, input().split()))

stock = 1000

num = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        num += stock // A[i]
        stock %= A[i]
    elif A[i] > A[i+1]:
        stock += num * A[i]
        num = 0

print(stock+A[-1]*num) 

Measured memory_bytes: 9172
N = gets.to_i
h_array = gets.split.map(&:to_i)
count = 0

N.downto(1){|diff_num|
  start_array = [*1..((h_array.length)-(diff_num-1))]

  start_array.each do |start|
    last_flag = false

    loop do
      (start..(start+(diff_num-1))).each do |seq|
        if h_array[seq-1] == 0
          last_flag = true
          break
        end
      end

      unless last_flag
        (start..(start+(diff_num-1))).each do |seq|
          h_array[seq-1] -= 1
        end

        count += 1
      end

      break if last_flag
    end
  end
}

puts count


Measured memory_bytes: 3836
import java.util.Arrays;
import java.util.Scanner;

//Space Coconut Crab II
public class Main{

	int t, c;
	boolean[] prime;
	int[] p;
	int[] a = new int[3];

	void f(int k, int sum, int x){
		if(t<=sum)return;
		if(k==2){
			if(prime[t-sum]&&p[x]<=t-sum && a[0]+a[1]>t-sum){
				c++;
			}
			return;
		}
		for(int i=x;i<3245;i++){
			a[k] = p[i];
			f(k+1, sum+p[i], i);
		}
	}

	void run(){
		prime = new boolean[30001];
		Arrays.fill(prime, true);
		prime[0] = prime[1] = false;
		for(int i=2;i<30001;i++)if(prime[i])for(int j=i*2;j<30001;j+=i)prime[j]=false;
		p = new int[3245];
		int id = 0;
		for(int i=2;i<30001;i++)if(prime[i])p[id++] = i;
		Scanner sc = new Scanner(System.in);
		while(true){
			t = sc.nextInt();
			if(t==0)break;
			c = 0;
			f(0,0,0);
			System.out.println(c);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
Edge = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)][::-1]
uf = UnionFind(N)
cnt = N*(N-1)//2
ans=[]
for a, b in Edge:
    ans.append(cnt)
    if uf.same(a, b):
        continue
    cnt -= uf.size(a) * uf.size(b)
    uf.union(a, b)
print(*ans[::-1], sep='\n')

Measured memory_bytes: 34176
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int cnt = 0;
    while (a[i] % 2 == 0) {
      cnt++;
      a[i] /= 2;
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(int argc, char **argv)
{
  vector<string> wday = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", };
  int mond_nr[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,};

  int m, d, yday;
  for (;;) {
    cin >> m >> d;
    if (m == 0 && d == 0)
      break;

    yday = 0;
    for (int i = 0; i < m; i++) {
      yday += mond_nr[i];
    }
    yday += (d - 1);
    cout << wday[yday % 7] << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a;
if(n%2==0)a=n/2;
if(n%2==1)a=(n/2)+1;
double d=(double)n;
double e=(double)a;
double c=e/d;
printf("%.10lf",c);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
int main() {
    ll N;
    cin>>N;
    cin>>s;
    vc l;
    vc stk;
    REP(i,N){
        if(s[i]=='(')stk.push_back('(');
        else{
            if(stk.size()>0){
                stk.pop_back();
            }else l.push_back('(');
        }
    }
    REP(i,l.size()){
        cout<<'(';
    }
    cout<<s;
    REP(i,stk.size()){
        cout<<')';
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a.at(i);
    vector<ll> acc(N+1, 0);
    rep(i, N){
        acc.at(i+1) = acc.at(i) + a.at(i);
    }
    vector<vector<ll>> beauty(N, vector<ll>(N, 0));
    rep(i, N){
        rep2(j, i, N){
            beauty.at(i).at(j) = acc.at(j+1) - acc.at(i);
        }
    }
    ll ans = 0;
    ll cnt = 0;
    rep(i, 40){
      rep(j, N){
        rep2(k, j, N){
          bitset<41> s(ans + (1LL<< (39-i)));
          bitset<41> r(beauty.at(j).at(k));
          if((s & r) == s){
            cnt++;
          }
        }
      }
      if(cnt >= K){
        ans += (1LL<< (39-i));
      }
      cnt = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11144
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int a,b,x,i;
  for(;scanf("%d%d",&a,&b),a|b;){
    vector<int> v;
    v.push_back(0);
    for(i=a+b;i;i--)
      scanf("%d",&x),v.push_back(x);
    sort(v.begin(),v.end());
    for(x=0,i=a+b;i;i--)
      if(v[i]-v[i-1]>x)x=v[i]-v[i-1];
    printf("%d\n",x);
  }
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}
//--------------------------------------------------//

int main() {
  use_cio();
  int n, m;
  cin >> n >> m;
  vector<int> va(n);
  vector<pii> vbc;
  rep(i, n) cin >> va[i];
  rep(i, m) {
    int b, c;
    cin >> b >> c;
    vbc.push_back({b, c});
  }
  sort(all(va));
  sort(all(vbc), [](pii a, pii b) { return a.second > b.second; });
  int l = 0, r = n;
  ll ans = 0;
  for (auto x : vbc) {
    auto b = x.first;
    auto c = x.second;
    int lb = lower_bound(va.begin() + l, va.begin() + r, c) - va.begin();
    if (lb - l <= b) {
      ans += 1LL * (lb - l) * c;
      l = lb;
    } else {
      repp(i, lb, r) ans += va[i];
      ans += 1LL * b * c;
      l = l + b;
      r = lb;
    }
  }
  repp(i, l, r) ans += va[i];
  cout << ans;
}


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

#define ll long long

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	
	if (a == b) {
		cout << "Draw";
	}
	else if (a == 1) {
		cout << "Alice";
	}
	else if (b == 1) {
		cout << "Bob";
	}
	else if (a > b) {
		cout << "Alice";
	}
	else {
		cout << "Bob";
	}
	
	return 0;
}


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

#define pi 3.1415926535898
int main()
{
    double a,b,x;
    cin>>a>>b>>x;
    double ans;
    if(x<a*a*b/2)
        ans=90-atan(2*x/(a*b*b))/pi*180;
    else
        ans=90-atan(a*a*a/(2*(a*a*b-x)))/pi*180;
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    int64_t X, x[200001];
    cin >> N >> X;
    for(int i=1; i<=N; i++) cin >> x[i];
    int64_t accum[200001] = {0};
    for(int i=1; i<=N; i++) accum[i] = x[i] + accum[i-1];
 
    int64_t ans = 2e15;
    for(int k=1; k<=N; k++){
        int64_t result = (N+k) * X;
        for(int j=0; j<(N-1)/k+1; j++){
            int M = N - j*k;
            int m = max(0, M-k);
            int c = j==0 ? 5 : 2*j+3;
            result += c * (accum[M] - accum[m]);
            if(result >= ans) break;
        }
        ans = min(ans, result);
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    long long A;
    string B;
    cin >> A >> B;
    long long BB = B[0] - '0';
    int size = B.size();
    for (int i = 1; i < size; i++) {
        if (B[i] == '.') {
            continue;
        }
        BB *= 10;
        BB += B[i] - '0';
    }
    long long ans = A * BB / 100;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3716
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
    int i,j,n,m,a[101][101],b[101],x,c[101];
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)    {
        for(j=1;j<=m;j++)    {
            scanf("%d",&a[i][j]);
        }
    }
    for(j=1;j<=m;j++)    scanf("%d",&b[j]);
    for(i=1;i<=n;i++)    {
        c[i]=0;
        for(j=1;j<=m;j++)    {
            c[i]+=a[i][j]*b[j];
        }
    }
    for(i=1;i<=n;i++)    printf("%d\n",c[i]);
    return 0;
}


Measured memory_bytes: 2796
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int a = sc.nextInt();
    int count = 0;
    while(h > 0){
      h -= a;
      count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 22996
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

struct UnionFind{
	vector<int> par,rnk,numele;

	UnionFind(int n) : par(n), rnk(n,0), numele(n,1){
		REP(i,n){
			par[i] = i;
		}
	}
	
	int find(int x){
		if(par[x]==x){
			return x;
		}else{
			return par[x]=find(par[x]);
		}
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x==y) return;
		if(rnk[x] < rnk[y]){
			numele[y] += numele[x];
			par[x] = y;
		}else{
			numele[x] += numele[y];
			par[y] = x;
			if(rnk[x]==rnk[y]) rnk[x]++;
		}
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	int count(int x){
		return numele[find(x)];
	}
};

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(m),b(m);
	for(int i=m-1; i>=0; i--){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	UnionFind uf(n);
	vector<ll> ans(m);
	ans[0] = (ll)n*(n-1)/2;
	REP(i,m-1){
		if(uf.same(a[i],b[i])){
			ans[i+1] = ans[i];
		}else{
			ll diff = (ll)uf.count(a[i])*(ll)uf.count(b[i]);
			uf.unite(a[i],b[i]);
			ans[i+1] = ans[i]-diff;
		}
	}
	
	for(int i=m-1; i>=0; i--) cout << ans[i] << endl;
	
	return 0;
}

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

using namespace std;

int main(){
	int n; cin >> n;

	long long sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		if( i % 3 != 0 && i % 5 != 0 )
			sum = sum + i;
	}
	cout << sum << endl;

}


Measured memory_bytes: 3620
n = int(input())
h = list(map(int, input().split()))

ans = "Yes"

if n != 1:
  for i in range(n-1):
    if h[i]-1>h[i+1]:
      ans = "No"
      break
    elif h[i]-1==h[i+1]:
      h[i+1] += 1
      
print(ans)

Measured memory_bytes: 63936
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

vector<string>S;

struct INFO {
	int l, r, len;
};

int main() {
	ll N, L; cin >> N >> L;
	//N = 1;
	//L = 1e18;


	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		//s = string(1e5, '1');
		//for (int j = 0; j < 1e5; j += 2)s[j] = '0';
		S.push_back(s);
	}
	sort(S.begin(), S.end());

	ll ans = 0;

	queue<INFO>que;
	que.push(INFO({ 0, (int)S.size(), 0 }));
	while (que.size()) {
		INFO info = que.front(); que.pop();
		int l = info.l, r = info.r, len = info.len;

		bool flag1 = false, flag0 = false;
		int l0 = -1, r0, l1 = -1, r1;
		for (int i = l; i < r; i++) {
			if (S[i].size() == len);
			else if (S[i][len] == '0') {
				flag0 = true;
				if (l0 == -1)l0 = i;
				r0 = i + 1;
			}
			else if (S[i][len] == '1') {
				flag1 = true;
				if (l1 == -1)l1 = i;
				r1 = i + 1;
			}
		}

		if (l0 != -1)que.push(INFO({ l0, r0, len + 1 }));
		if (l1 != -1)que.push(INFO({ l1, r1, len + 1 }));

		if (flag0 && (flag1 == false)) {
			//cerr << S[l].substr(0, len) + "1" << endl;
			ll x = L - len;
			ll tmp = 1;
			while (x % 2 == 0) {
				tmp *= 2;
				x /= 2;
			}
			ans ^= tmp;
		}
		if ((flag0 == false) && flag1) {
			//cerr << S[l].substr(0, len) + "0" << endl;
			ll x = L - len;
			ll tmp = 1;
			while (x % 2 == 0) {
				tmp *= 2;
				x /= 2;
			}
			ans ^= tmp;
		}
	}

	cout << (ans ? "Alice" : "Bob") << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n-1);

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

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

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

  int result = 0;


  int i = 0;
  while (i < n) {
    int j = A[i] - 1;
    int b = B[j];
    result += b;
    i++;
    if (i >= n) {
      break;
    }
    int k = A[i] - 1;
    if (k == j + 1) {
      // cout << "Adding" << to_string(C[j]) << endl;
      result += C[j];
    }
    // cout << "result = " << result << endl;
  }

  cout << result << endl;
  
  return 0;
}


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

class UnionFind {
  public:
  vector<int> par;

  UnionFind(int n) {
    par = vector<int>(n, -1);
  }

  int root(int x) {
    return (par[x] < 0) ? x : par[x] = root(par[x]);
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return ;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  int p[N];
  UnionFind uf(N);
  rep(i, N) {
    cin >> p[i];
    p[i]--;
  }
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    uf.unite(x-1, y-1);
  }

  int ans = 0;
  rep(i, N) {
    if (uf.same(i, p[i])) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
	ll n; scanf("%lld", &n);
	ll a[n + 1], b[n];
	for (int i = 0; i <= n; ++i) scanf("%lld", &a[i]);
	for (int i = 0; i < n; ++i) scanf("%lld", &b[i]);

	ll ans = 0;
	// 最後の町から倒せるだけ倒していく
	for (int i = n - 1; i >= 0; --i) {
		if (a[i + 1] >= b[i]) {
			ans += b[i];
			a[i + 1] -= b[i];
			b[i] = 0;
		}
		else {
			ans += a[i + 1];
			b[i] -= a[i + 1];
			a[i + 1] = 0;
		}

		if (a[i] >= b[i]) {
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}
		else {
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
		}
	}
	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	float a,b,c,d,e,f,x,y;
	while(cin>>a){
	cin>>b>>c>>d>>e>>f;
	x=(c*e-b*f)/(a*e-b*d);
	y=(c*d-a*f)/(b*d-a*e);
	if(x>-0.0005&&x<=0.0005){
		x=0;
	}
	if(y>-0.0005&&y<=0.0005){
		y=0;
	}
	printf("%.3f %.3f",x,y);
	cout<<endl;
	}
	return 0;
	}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
 cin>>n;
 if(n%1000==0)
 {
     cout<<"0"<<endl;
 }
 else
 {
    int x=n%10;
    n=n/10;
    int y=n%10;
    n=n/10;
    int z=n%10;
    int l=(z*100)+(y*10)+(x*1);
    l=1000-l;
    cout<<l<<endl;

 }



    return 0;

}


Measured memory_bytes: 3584
String = input()
t = ['dream', 'dreamer', 'erase', 'eraser']

N=len(String)
index =0 
flag = 'True'
count = 0
while flag=='True':
    count = 0
    for i in t:
        count+=1
        if String.rfind(i)==N-len(i) and String.rfind(i)!=-1:
            String=String[0:N-len(i)]
            N=N-len(i)

            if N==0:
                flag = 'Complete'
            break


        if count==4:
            flag = 'Never'

if flag=='Complete':
    print('YES')
if flag=='Never':
    print('NO')



Measured memory_bytes: 3188
function main(input) 
{
    input = input.split("\n").map(Number);
    var count = 0

    for (i = 0; i < input[0] + 1; i++)
    {
        for (j = 0; j < input[1] + 1; j++)
        {
            for (k = 0; k < input[2] + 1; k++)
            {
                if ((500*i+100*j+50*k) == input[3])
                {
                    count++;
                }
                else continue;
            }
        }
    }
    console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7756