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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

const int N = 2e5 + 20;
vector<int> G[N];
int n;

pie dfs(int v, int p = -1, int d = 0) {
	pie res = MP(d, v);
	for (int u : G[v])
		if (u - p) {
			pie tmp = dfs(u, v, d + 1);
			if (tmp.FF > res.FF)
				res = tmp;
		}
	return res;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0, v, u; i < n - 1; i++) {
		cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	pie tmp = dfs(1);
//	cout << tmp.FF << ' ' << tmp.SS << endl;
	tmp = dfs(tmp.SS);
//	cout << tmp.FF << endl;
	cout << (tmp.FF % 3 == 1 ? "Second" : "First") << endl;
}



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

#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

int a,b,c;


int main(){
cin>>a>>b>>c;
if((a==b)&&(b==c)){
    cout<<"Yes";
}else{
    cout<<"No";
}
}


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

int main(){
    long long int h,w;
    cin >> h >> w;

    long long int count = 0;

    if(w==1 || h == 1){
        cout << 1 << endl;
    }else{
        for(long long int i=1;i<=w;i++){
            if(i%2 == 1){
                count += (h+1)/2;
            }else{
                if(h%2 == 1){
                    count += ((h+1)/2-1);
                }else{
                    count += (h+1)/2;
                }
            }
        }
        cout << count << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int alphaS[26];
int alphaT[26];

vector<int> Snum;
vector<int> Tnum;

int bc[200020];

int main() {
    string S, T;
    cin >> S >> T;

    //a～zまでの数が同じならOK
    //
    rep(i, S.size()) {
        int c = S[i] - 97;
        alphaS[c]++;
    }
    sort(alphaS, alphaS + 26);


    rep(i, S.size()) {
        int c = T[i] - 97;
        alphaT[c]++;
    }
    sort(alphaT, alphaT + 26);

    rep(i, 26) {
        if (alphaS[i] != alphaT[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
N,X,Y=list(map(int,input().split()))
ans=[0]*(N-1)

for i in range(1,N+1):
    for j in range(i+1,N+1):
        straight=j-i
        via=abs(X-i)+1+abs(Y-j)
        d=min(straight,via)
        ans[d-1]+=1

for cnt in ans:
    print(cnt)

Measured memory_bytes: 46556
N = int(input())
d,x = input().split()
D = int(d)
X = int(x)

count = 0
for i in range(N):
	A = int(input())

	j=0
	while(j*A+1<=D):
		count += 1
		j += 1


sum_choco = count + X

print(sum_choco)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
 
  int ans = 0;
  int active = 0;
  for (int i = 0; i < n; i++)
  {
    if (active >= h[i])
    {
      active = h[i];
    }
    else
    {
      ans += h[i] - active;
      active = h[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>

int main(void) {
  int max = 0;
  unsigned long long int l1=2, l2=1, ret = 1;
  std::cin >> max;
  for(int i=0; i<max-1 ; i++){
    ret = l1 + l2;
    l1 = l2;
    l2 = ret;
  }
  std::cout << ret;
    return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const ll mod = 1e9 + 7;



int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int h, w, m; cin >> h >> w >> m;
    set<pii> target;
    vector<int> a(h + 1), b(w + 1);
    FOR(i, 0, m)
    {
        int x, y; cin >> x >> y;
        target.emplace(x, y);
        a[x]++;
        b[y]++;
    }
    int mx = 0;
    trav(i, a) if (i > mx) mx = i;
    vector<int> best_rows, best_cols;
    FOR(i, 1, h + 1) if (a[i] == mx) best_rows.push_back(i);
    mx = 0;
    trav(i, b) if (i > mx) mx = i;
    FOR(i, 1, w + 1) if (b[i] == mx) best_cols.push_back(i);
    int res = a[best_rows.front()] + b[best_cols.front()];
    FOR(i, 0, sz(best_rows))
    {
        FOR(j, 0, sz(best_cols))
        {
            if (target.find(mp(best_rows[i], best_cols[j])) == target.end())
            {
                cout << res;
                return 0;
            }
        }
    }
    cout << res - 1;
    return 0;
}







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

using namespace std;

#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define watch(x) cout << (#x) << " is " << (x) << endl;

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

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MAXN = 200005;

void solve() {
    int n, k; cin >> n >> k;
    vector<int> v(MAXN);
    for(int i=0; i<n; i++) {
        int a; cin >> a;
        v[a]++;
    }
    int ret = 0;
    sort(allof(v)); reverse(allof(v));
    for(int i=k; i<n+1; i++) {
        ret += v[i];
    }
    cout << ret << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



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

namespace Test01
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            if (str == "Sunny") Console.WriteLine("Cloudy");
            else if (str == "Cloudy") Console.WriteLine("Rainy");
            else Console.WriteLine("Sunny");


        }
    }
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int a[maxn],d[maxn],f[maxn],n;

int main() {
    read(n);read(d[0]);
    for(int i=1;i<=n;i++) read(a[i]),d[i]=min(d[i-1],abs(d[i-1]-a[i]));
    for(int i=n;i;i--)
        if(a[i]<=f[i+1]*2+1) f[i]=f[i+1]+a[i];
        else f[i]=f[i+1];
    int q,x;read(q);
    while(q--) read(x),puts(d[x-1]>f[x+1]?"YES":"NO");
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

Int dp[1000001][2];

int main() {
    string s;
    cin >> s;
    Int n = s.size();
    for (Int i = 0; i <= n; i++) {
        dp[i][0] = dp[i][1] = INF;
    }
    dp[0][0] = dp[0][1] = 0;
    for (Int i = 0; i < n; i++) {
        Int x = s[i] - '0';
        dp[i + 1][0] = min({dp[i + 1][0], dp[i][0] + x, dp[i][1] + x});
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 10 - x + 1);
        if (i > 0 and s[i - 1] != '0') {
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 10 - x - 1);
        }
    }
    // for (Int i = 0; i < 2; i++) {
    //     for (Int j = 0; j <= n; j++) {
    //         cout << dp[j][i] << " ";
    //     }
    //     cout << endl;
    // }
    dump(min(dp[n][0], dp[n][1]));
    return 0;
}


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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cout<<#x<<" : "<<x<<endl
#define debug2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

typedef long long ll;
typedef pair<ll,ll> pii;
const ll modd=1e9+7;

ll poww(ll a,ll b){
  ll ans=1;
  while(b>0){
    if(b%2==1) ans=(ans*a);
    a=(a*a);
    b=b/2;
  }
  return ans;
}

/*-----------------------------------------------------------------------*/

ll dp[3001][3001];

int main(){
   fastt;

   ll n;
   cin>>n;

   vector <ll> a(n);

   for(ll i=0;i<n;i++) { 
   	cin>>a[i];
   	if(n%2==1)
       dp[i][i]=a[i];
    else
       dp[i][i]=-a[i];
   }

   for(ll siz=2;siz<=n;siz++)
   	   for(ll start=0;start+siz-1<n;start++){
   	   	   ll check;
   	   	   if(siz%2==n%2)
   	   	   	  check=1;
   	   	   else
   	   	   	  check=0;
   	   	   if(check==1)
   	   	      dp[start][start+siz-1]=max(a[start]+dp[start+1][start+siz-1],a[start+siz-1]+dp[start][start+siz-2]);
   	   	   else
   	   	   	  dp[start][start+siz-1]=min(-a[start]+dp[start+1][start+siz-1],-a[start+siz-1]+dp[start][start+siz-2]);
   	   }

   cout<<dp[0][n-1]<<endl;

   return 0;
}


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

using namespace std;
using ll = long long int;

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

    auto pow = [&](ll a, ll b) {
        ll r = 1;
        while(b) {
            if(b&1) r *= a;
            a *= a;
            b >>= 1;
        }
        return r;
    };

    ll n, p;
    cin >> n >> p;
    ll o = 0, e = 0;
    while(n--) {
        ll x;
        cin >> x;
        (x & 1 ? o : e)++;
    }
    cout << pow(2ll, e) * pow(2ll, max(0ll, o-1)) * (p&&!o ? 0 : 1) << endl;
}


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

int main() {
  string S;
  cin >> S;
  for(int i = 0; i < 3; i++) {
    if(S.at(i) == '1') S.at(i) = '9';
    else S.at(i) = '1';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			double[][] a = new double[n][2];
			final String[] t = new String[n];
			for(int i=0;i<n;i++){
				t[i] = sc.next();
				int p = sc.nextInt();
				int q = sc.nextInt() + sc.nextInt() + sc.nextInt();
				int r = sc.nextInt() + sc.nextInt();
				int f = sc.nextInt();
				int s = sc.nextInt();
				int m = sc.nextInt();
				
				a[i][0] = i;
				a[i][1] = (double)(f*m*s-p)/(m*r+q);
			}
			
			Arrays.sort(a, new Comparator<double[]>(){
				public int compare(double[] o1, double[] o2) {
					if(o1[1]==o2[1])return t[(int)o1[0]].compareTo(t[(int)o2[0]]);
					else if(o1[1]-o2[1]>0) return -1;
					else return 1;
				}
			});
			
			for(int i=0;i<n;i++) System.out.println(t[(int)a[i][0]]);
			System.out.println("#");
		}	
	}	
}

Measured memory_bytes: 37700
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 5; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                System.out.println(i+1);
            }
        }

    }
}


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

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

  map< string, ll > p;

  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(p.find(s) != p.end()) {
      p[s]++;
    } else {
      p[s] = 1;
    }
  }

  ll count = 0;
  for(const auto &s : p) {
    count += s.second * (s.second - 1) / 2;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cmath>

using namespace std;

int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int ans = 0;
	if (C * 2 < A + B)
	{
		ans = C * 2 * min(X, Y);
		if (X < Y)
		{
			if (C * 2 < B)
			{
				ans += C * 2 * (Y - X);
			}
			else
			{
				ans += (Y - X) * B;
			}
		}
		else
		{
			if (C * 2 < A)
			{
				ans += C * 2 * (X - Y);
			}
			else
			{
				ans += (X - Y) * A;
			}
		}
	}
	else
	{
		ans = A * X + B * Y;
	}

	cout << ans << endl;

	return 0;
}

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

#define N_MAX 3000

typedef struct
{
    int x;
    int y;
}Point;

int N;
int K;

Point P[N_MAX];
Point T[N_MAX];

int compX(const void *a, const void *b)
{
    if(((Point *)a)->x == ((Point *)b)->x)
    {
        return ((Point *)a)->y - ((Point *)b)->y;
    }
    return ((Point *)a)->x - ((Point *)b)->x;
}

int compA(const void *a, const void *b)
{
    return ((Point *)b)->x * ((Point *)a)->y - ((Point *)a)->x * ((Point *)b)->y;
}

bool eq(const Point a, const Point b)
{
  return b.x * a.y == a.x * b.y;
}

int check(int p, int M)
{
    int maxl = 1;
    int l = 1;
    Point pre;
    int i;
    
    qsort(T, M, sizeof(Point), compA);
    pre = T[0];
    
    for(i = 1; i < M; i++)
    {
        if(eq(pre, T[i]))
        {
            l++;
            if(maxl > l)
            {
                maxl = maxl;
            }
            else
            {
                maxl = l;
            }
        }
        else
        {
            l = 1;
        }
        pre = T[i];
    }
    return maxl;
}


int solve()
{
    int k = 0;
    int v = 0;
    int i;
    int j;
    
    for (i = 0; i < N; i++)
    {
        k = 0;
        v = 0;
        for (j = i + 1; j < N; j++)
        {
            if ( P[i].x == P[j].x )
            {
                v++;
            }
            else
            {
                T[k] = P[j];
                T[k].x -= P[i].x;
                T[k].y -= P[i].y;
                k++;
            }
        }
        if ( 1 + v >= K ) return 1;
        if ( 1 + check(i, k) >= K ) return 1;
    }
    return 0;
}

int main()
{
    int i;

    scanf("%d%d", &N, &K);

    for(i = 0; i < N; i++)
    {
        scanf("%d%d", &P[i].x, &P[i].y);
    }
    qsort(P, N, sizeof(Point), compX);
    
    printf("%d\n", solve());
    
    return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i,m,n) for(int i = (int)(m) ; i < (int) (n);i++)
#define rep(i,n) REP(i,0,n)

int n;



int main(){
	cin >> n;
	cout << pow(n,3) << endl;

}

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

using namespace std;

const int INF = 0x0fffffff;

int N;
int K;

typedef pair<int, int> ii;

vector< vector<int> > M;
vector<int> V;
vector<bool> B;

int main(int argc, char* argv[]) {
    // for cin
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;

    M.resize(N);

    for (int i = 0; i < N; ++i) {
        M[i].clear();
    }

    for (int i = 0; i < N-1; ++i) {
        int a;
        int b;

        cin >> a >> b;
        a--;
        b--;

        M[a].push_back(b);
        M[b].push_back(a);
    }

    V.resize(N);
    fill(V.begin(), V.end(), INF);

    B.resize(N);
    fill(B.begin(), B.end(), false);

    priority_queue<ii> Q;

    while(!Q.empty()) {
        Q.pop();
    }

    cin >> K;

    for (int i = 0; i < K; ++i) {
        int v;
        int p;

        cin >> v >> p;
        v--;

        V[v] = p;
        B[v] = true;
        Q.push(make_pair(p, v));
    }

    int b = true;

    while (!Q.empty() && b) {
        int v = Q.top().second;
        int p = Q.top().first;
        Q.pop();

        for (int nv: M[v]) {
            if (B[nv] == false) {
                V[nv] = p-1;
                B[nv] = true;
                Q.push(make_pair(p-1, nv));
            } else {
                if (abs(V[nv] - V[v]) != 1) {
                    b = false;
                }
            }
        }
    }

    if (!b) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");

    for (int i = 0; i < N; ++i) {
        printf("%d\n", V[i]);
    }

    return 0;
}


Measured memory_bytes: 7924
fun main(args: Array<String>) {
    abc129d()
}

fun abc129d() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val wall = (1..h).map { readLine()!!.map { it == '#' }.toBooleanArray() }
        .toTypedArray()

    // down,up,right,left
    val cSumD = Array(h) { IntArray(w) }
    val cSumU = Array(h) { IntArray(w) }
    val cSumR = Array(h) { IntArray(w) }
    val cSumL = Array(h) { IntArray(w) }

    for (x in 0 until w) {
        for (y in 0 until h) {
            cSumD[y][x] = if (wall[y][x]) 0 else if (y == 0) 1 else cSumD[y - 1][x] + 1
            cSumR[y][x] = if (wall[y][x]) 0 else if (x == 0) 1 else cSumR[y][x - 1] + 1
        }
    }
    for (x in w - 1 downTo 0) {
        for (y in h - 1 downTo 0) {
            cSumU[y][x] = if (wall[y][x]) 0 else if (y == h - 1) 1 else cSumU[y + 1][x] + 1
            cSumL[y][x] = if (wall[y][x]) 0 else if (x == w - 1) 1 else cSumL[y][x + 1] + 1
        }
    }

    var answer = 0

    for (y in 0 until h) {
        for (x in 0 until w) {
            answer = Math.max(answer, cSumD[y][x] + cSumU[y][x] + cSumR[y][x] + cSumL[y][x] - 3)
        }
    }
    println(answer)
}


Measured memory_bytes: 139868
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n;

	scanf("%d",&n);
	std::vector<int> a(n);

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

	int curr = 0;
	std::vector<int> h(n);
	int ans = 0;
	while(curr<n){
		if(h[curr]==a[curr]){curr++;continue;}
		ans++;
		for(int i = curr;i<n;i++){
			if(h[i]==a[i])break;
			h[i]++;
		}
	}
	printf("%d\n",ans );	
}		



Measured memory_bytes: 256
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>

using namespace std;

#define ll long long

void solve()
{
    ll N, K;
    cin >> N >> K;
    vector<double> kp10x(N); // 期待値の10倍
    for (ll i = 0; i < N; i++)
    {
        ll p;
        cin >> p;
        kp10x.at(i) = ((p + 1) * 10 / 2);
    }

    double kc10x = 0;
    for (ll i = 0; i < K; i++)
    {
        kc10x += kp10x.at(i);
    }

    double kitaiMax10x = kc10x;
    for (ll i = 1; i < N - K + 1; i++)
    {
        kc10x -= kp10x.at(i - 1);
        kc10x += kp10x.at(i - 1 + K);
        kitaiMax10x = max(kc10x, kitaiMax10x);
    }

    printf("%.6lf", (double)kitaiMax10x / 10);

    return;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long
 
const int N = 500001;
const int SZ = 50 * N;
const int A = N;
 
int n, q, x, y, cn, las[A], seg[SZ], lc[SZ], rc[SZ], root[N];
vector <int> a;
 
void build(int l, int r, int pos){
    if(l == r){
        seg[pos] = 1;
        return;
    }
    int mid = (l + r) / 2;
    lc[pos] = cn++;
    rc[pos] = cn++;
    build(l, mid, lc[pos]);
    build(mid + 1, r, rc[pos]);
    seg[pos] = seg[lc[pos]] + seg[rc[pos]];
}
void update(int l, int r, int pos, int pos2, int ind, int val){
    seg[pos] = seg[pos2];
    if(l == r){
        seg[pos] = val;
        return;
    }
    int mid = (l + r) / 2;
    if(ind <= mid){
        rc[pos] = rc[pos2];
        lc[pos] = cn++;
        update(l, mid, lc[pos], lc[pos2], ind, val);
    }
    else{
        lc[pos] = lc[pos2];
        rc[pos] = cn++;
        update(mid + 1, r, rc[pos], rc[pos2], ind, val);
    }
    seg[pos] = seg[lc[pos]] + seg[rc[pos]];
}
int query(int l, int r, int pos, int s, int e){
    if(r < s || l > e) return 0;
    if(s <= l && r <= e) return seg[pos];
    int mid = (l + r) / 2;
    return query(l, mid, lc[pos], s, e) + query(mid + 1, r, rc[pos], s, e);
}
int distinct(int l, int r){
    return query(1, n, root[r], l, r);
}
int main(){
    a.push_back(0);
    memset(las, -1, sizeof las);
    scanf("%d %d", &n, &q);
    for(int i = 1 ; i <= n && scanf("%d", &x) ; i++)
        a.push_back(x);
    root[0] = cn++;
    build(1, n, root[0]);
    for(int i = 1 ; i <= n ; i++){
        root[i] = cn++;
        if(las[a[i]] == -1) update(1, n, root[i], root[i - 1], i, 1);
        else update(1, n, root[i], root[i - 1], las[a[i]], 0);
        las[a[i]] = i;
    }
    while(q-- && scanf("%d %d", &x, &y))
        printf("%d\n", distinct(x, y));
    return 0;
}
 


Measured memory_bytes: 138656
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(3*n);re(i, 3*n) std::cin >> a[i];
  sort(all(a));
  ll ans = 0;
  ll c = 0;
  for(int i=3*n-2;c<n;i-=2, c++) ans += a[i];
  std::cout << ans << '\n';
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll k;cin>>k;
  ll a,b;cin>>a>>b;

  // if((b-a)/7<1&&)out("NG");
  // else out("OK");
  bool e=false;
  rep(i,a,b+1){
    if(i%k==0)e=true;
  }

  if(!e)out("NG");
  else out("OK");

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

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

	if (s == 000) {
		std::cout << '0' << std::endl;
	}
	if (s == 10 || s == 100 || s == 001) {
		std::cout << '1' << std::endl;
	}
	if (s == 110 || s == 11 || s == 101) {
		std::cout << '2' << std::endl;
	}
	if (s == 111) {
		std::cout << '3' << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll X,Y,Z;cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y<<"\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string a,b;
map<int,char> mp;

int main()
{jizz
	ll n,m,g,x,y;
	cin >> n >> m >> a >> b;
	g=n*m/__gcd(n,m),x=g/n,y=g/m;
	for(int i=0;i<a.size();++i)
		mp[x*i]=a[i];
	for(int i=0;i<b.size();++i)
		if(mp[y*i]&&mp[y*i]!=b[i])
			return cout << "-1\n",0;
	cout << g << "\n";
}

Measured memory_bytes: 8192
N = int(input())
testimo_ls = [ [] for i in range(N) ]
rst = 0
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split(' '))
        testimo_ls[i].append([x - 1, y])
for i in range(1 << N):
    honest_ls = []
    for j in range(N):
        if i >> j & 1:
            honest_ls.append(j)
    is_ok_cnt = 0
    is_ok = True
    for s in honest_ls:
        for t in testimo_ls[s]:
            if t[1] == 0 and t[0] in honest_ls:
                is_ok = False
                break
            if t[1] == 1 and t[0] not in honest_ls:
                is_ok = False
                break
    if is_ok:
        rst = max(rst, len(honest_ls))
print(rst)

Measured memory_bytes: 9200
#include<iostream>
#define ll long long int
using namespace std ;



const int maxn = 1e5+10;

int stone ;
int dp[maxn];
int cost[maxn];



int min(int a, int b)
{
    if (a <= b) return a;
    return b;
}

int abs(int x)
{
    if(x<0)
        return (-1*x);
    return x;
}

int fun (int pos)
{
    if( pos > stone )return 0;

    if(dp[pos]!= -1)
        return dp[pos];
    else
    {
        int ans = 0 ;

        if(pos <= stone - 1)
            ans = fun(pos+1) + abs(cost[pos] - cost[pos+1]);
        if(pos <= stone - 2)
            ans = min( ans,  fun(pos+2) + abs(cost[pos] - cost[pos+2]) );
        return dp[pos]=ans ;
    }
}

int main()
{
    cin >> stone ;

    for(int i = 1 ; i<=stone ; i++)
    {
        cin >> cost[i];
        dp[i] = -1;
    }

    cout << fun(1)<<endl;

    return 0 ;
}


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

int tisei[12][12];
void shima(int x, int y) {
	tisei[x][y] = 0;
	if (x < 11 && tisei[x+1][y]) shima(x + 1, y);
	if (x > 0 && tisei[x - 1][y])  shima(x -1, y);
	if (y < 11 && tisei[x][y+1]) shima(x , y+1);
	if (y > 0 && tisei[x][y-1])  shima(x, y-1);
}
int main() {
	vector<int>n;
	while (1) {
		for (int a = 0; a < 12; a++) {
			string c;
			cin >> c;
			if (cin.fail())goto end;
			for (int b = 0; b < 12; b++) {
				tisei[a][b] = c[b] - 48;
			}
		}
		int s = 0;
		for (int d = 0; d < 12; d++) {
			for (int e = 0; e < 12; e++) {
				if (tisei[d][e]) { s++; shima(d, e); }
			}
		}
		n.push_back(s);
	}
end:;
	for (int j : n)cout << j << endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var sushi = new List<int[]>();
            for (int i = 0; i < N; i++)
            {
                input = ReadArrayInt();
                sushi.Add(new int[] { input[0], input[1] });
            }
            sushi = sushi.OrderBy(s => s[0]).ThenByDescending(s => s[1]).ToList();
            for (int i = N - 1; i > 0; i--)
            {
                if (sushi[i][0] == sushi[i - 1][0]) sushi[i][0] = 0;
                else sushi[i][0] = 1;
            }
            sushi[0][0] = 1;
            sushi = sushi.OrderByDescending(s => s[1]).ThenByDescending(s => s[0]).ToList();
            var t = 0L;
            var d = 0L;
            var sta = new Stack<long>();
            for (int i = 0; i < K; i++)
            {
                t += sushi[i][0];
                d += sushi[i][1];
                if (sushi[i][0] == 0) sta.Push(sushi[i][1]);
            }
            var ans = t * t + d;
            for (int i = K; i < N; i++)
            {
                if (sushi[i][0] == 0) continue;
                else if (!sta.Any()) break;
                t += sushi[i][0];
                d += sushi[i][1];
                var s = sta.Pop();
                d -= s;
                var chk = t * t + d;
                if (ans < chk) ans = chk;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 33588
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int res = N;

  for (int i=0;i<=N;i++){
  int cc = 0;
  int t = i;
  while(t>0)cc+= t%6 ,t/=6;
  t = N - i;
  while(t>0)cc+= t%9 ,t/=9;
  if (res > cc)res = cc;
}

  cout << res << endl;
}

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

using namespace std;
struct I{
    I(){
        ios::sync_with_stdio(false);cin.tie(0);
        //cout<<fixed<<setprecision(10);
    }
}init;

typedef long long LL;
const LL MOD=1e9+7;
    
int main(){
    string s;cin>>s;
    map<char,int> m;
    for(auto &it:s)m[it]=1;
    if(m['S']!=m['N']||m['E']!=m['W'])cout<<"No"<<endl;
    else cout<<"Yes"<<endl;


    return 0;
}


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

int i,j,k,n,m;
double tab[150][150],len[150][150],ans,lll;

int main(){
	while(scanf("%d %d",&n,&m)*n*m){
		for(i=0;i<n;i++){
			len[0][i]=1;
			for(j=0;j<n;j++){
				scanf("%lf",&tab[i][j]);
			}
		}

		if(m==1){printf("1.00\n");continue;}

		for(k=1;k<m;k++){
			for(i=0;i<n;i++){
				len[k][i]=0;
				for(j=0;j<n;j++){
					lll=len[k-1][j]*tab[j][i];
					if(len[k][i]<lll)len[k][i]=lll;
				}
			}
		}

		ans=0;
		for(i=0;i<n;i++){if(ans<len[m-1][i])ans=len[m-1][i];}

		printf("%.2lf\n",floor(ans*100+0.5)/100);

	}
	return 0;
}

Measured memory_bytes: 908
n = gets.to_i
ar = gets.split.map(&:to_i)
ar.sort!
a_sum = 0
b_sum = 0
(1..n).to_a.each do |n|
  if (n-1).odd?
    b_sum += ar[n-1]
  else
    a_sum += ar[n-1]
  end
end

puts (b_sum - a_sum).abs


Measured memory_bytes: 3836
#include<stdio.h>
int main()
{
    int n, i, a[100];
    scanf("%d", &n);
    for(i = 0;i < n;i++){
        scanf("%d", &a[i]);
    }
    for(i = n - 1;i >= 0;i--){
        printf("%d", a[i]);
        if(i != 0){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll k, n;
  cin >> k >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll mx = 0;
  REP(i, n-1){
    chmax(mx, a[i+1]-a[i]);
  }
  chmax(mx, a[0]+k-a[n-1]);
  cout << k-mx << endl;
  return 0;
}

Measured memory_bytes: 1792
a,b,c = map(int,input().split())
k = 0
if b+1 >= c:
	print(a+1)
else:
	if b-1 >= a:
		print(a+1)
	else:
		k = a - b - 1
		if k % 2 == 0:
			su = k//2 * (c-b) + c
		else:
			su = k//2 * (c-b) + c + 1
		print(su)


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

void main_()
{
    ll N;
    cin >> N;

    vector<ll> xs, ys, hs;

    ll base_h = 0, base_x = 0, base_y = 0;

    for (ll i = 0; i < N; i++) {
        ll x, y, h;
        cin >> x >> y >> h;
        if (h > 0 && base_h == 0) {
            base_h = h;
            base_x = x;
            base_y = y;
            continue;
        }
        xs.push_back(x);
        ys.push_back(y);
        hs.push_back(h);
    }

    set<pair<ll, ll>> CxCy_candidates;
    for (ll i = 0; i <= 100; i++) {
        for (ll j = 0; j <= 100; j++) {
            CxCy_candidates.emplace_hint(end(CxCy_candidates), i, j);
        }
    }

    for (ll i = 0; i < N - 1; i++) {
        for (auto it = begin(CxCy_candidates); it != end(CxCy_candidates);) {
            ll Cx = it->first;
            ll Cy = it->second;
            ll baseH = base_h + abs(base_x - Cx) + abs(base_y - Cy);
            ll h = baseH - abs(xs[i] - Cx) - abs(ys[i] - Cy);
            if (max(h, 0ll) != hs[i]) {
                it = CxCy_candidates.erase(it);
            } else {
                it++;
            }
        }
    }

    auto it = begin(CxCy_candidates);
    ll cx = it->first;
    ll cy = it->second;
    ll H = base_h + abs(base_x - cx) + abs(base_y - cy);
    cout << cx << " " << cy << " " << H << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    vector <int> a(3);
    cin>>a[0];
    cin>>a[1];
    cin>>a[2];
    sort(a.begin(),a.end());
    cout<<(a[0]*a[1])/2;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  rep(i, s.size()) { cout << "x"; }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

vector<array<int,4> > Q;
int n,m,q;
int an = 0;
vector <int> v;

void dfs(int u){
	if(v.size()==n){
		int ma = 0;
		for(auto z:Q)
			if(v[z[1]] - v[z[0]] == z[2])
					ma += z[3];
		an = max(an, ma);
		return;
	}
	for(int i = u; i<=m ;i++){
		v.pb(i);
		dfs(i);
		v.pop_back();
	}
}

int main(){
  fio();
  cin>>n>>m>>q;
  Q.resize(q);
  forn(i,q){
  	cin>>Q[i][0]>>Q[i][1]>>Q[i][2]>>Q[i][3];
  	Q[i][0]--,Q[i][1]--;
  }
  dfs(1);
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int A, B;
	cin >> A >> B;
	
	int yen = 0;
	
	if(A <= 5)
	{
		cout << "0" << endl;
	}
	else if((6 <= A) && (A <= 12))
	{
		cout << B/2 << endl;
	}
	else
	{
		cout << B << endl;
	}
	
	
	return 0;
}

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

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

int n, m, q;
int a[50], b[50], c[50], d[50];
int ans = 0;

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll tmp;
    if (n >= b - 1) tmp = a * (b - 1);
    else tmp = a * n;
    ll ans = tmp / b;
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
ll dp[101][100001];
int main()
{
	sync;
	ll n, max_weight;
	cin >> n >> max_weight;
	for(ll i = 0; i <= 100; i++)
		for(ll j = 0; j <= 100000; j++)
			dp[i][j] = 1e18;
	dp[0][0] = 0;
	for(ll i = 0; i < n ; i++)
	{
		ll value, weight;
		cin >> weight >> value;
		for(ll j = 0 ; j <= 1e5; j++)
		{
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			if(j + value > 1e5)
				continue;
			dp[i + 1][j + value] = min(dp[i + 1][j + value], dp[i][j + value]);
			dp[i + 1][j + value] = min(dp[i + 1][j + value], dp[i][j] + weight);
		}
	}
	for(ll i = 1e5; i >= 0 ; i--)
		if(dp[n][i] <= max_weight)
			return cout << i , 0;
}
			

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

int main()
{
    string s;
    cin >> s;
    int m = (s[5] - '0') * 10 + s[6] - '0';

    if(m > 4){
        cout << "TBD" ;
    }else{
        cout << "Heisei";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int cnt[2022]={0};
int main()
{
	string str;	
	cin>>str;
	int num=0;
	int t=1;
	for(int i=str.length()-1;i>=0;--i)
	{
		num=(num+((str[i]-'0')*t))%2019;
		++cnt[num];
		t=(t*10)%2019;
	}
	long long ans=0;
	for(int i=0;i<=2019;++i)  ans+=cnt[i]*(cnt[i]-1)/2;
	cout<<ans+cnt[0];
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        int a;
        cin >> a;
        if (a % 2 != 0)
            continue;
        if (a % 3 != 0 && a % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/10 10:58 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();
        int ans = 10000;
        for(int i = 0;i<=s.length()-t.length();i++){
            int x = 0;
            for(int j = 0;j<t.length();j++){
                if(s.charAt(i+j) != t.charAt(j)){
                    x++;
                }
            }
            ans = Math.min(ans,x);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35748
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int x, y; cin >> x >> y;
	Cout(abs(x - y));
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

char buff[512];

int main(){
  while(scanf("%s", buff), buff[0] != '#'){
    int cnt = 0;
    int var[3];
    int neg = 1;
    bool ans = false;

    for(int i = 0; buff[i]; i++){
      if(buff[i] == '~'){
	neg = -1;
      }else if(isalpha(buff[i])){
	var[cnt++] = neg * buff[i];
	neg = 1;

	if(cnt == 3){
	  bool ok = true;
	  cnt = 0;

	  REP(i,3) REP(j,3){
	    if(var[i] == -var[j]){
	      ok = false;
	    }
	  }

	  if(ok) ans = true;
	}
      }
    }

    puts(ans ? "yes" : "no");
  }
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"sort"
)

func main() {
	n := make([]int, 3)
	fmt.Scan(&n[0], &n[1], &n[2])
	sort.Sort(sort.Reverse(sort.IntSlice(n)))
	fmt.Println(n[0]*10 + n[1] + n[2])
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define _USE_MATH_DEFINES
#include<math.h>
#define in(n, m) for (ll i=n; i<m;i++)
#define inj(n, m)for (ll j=n; j<m;j++)
#define ink(n, m)for (ll k=n; k<m;k++)
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 ll N=1e5, M = 1e5;
ll dp[100000][3];
ll a[100000][3];
const ll INF = 1LL << 60;


int main() {
	ll A,B,C,D;
	cin >> A >> B>>C>>D;
	ll t = 0;
	while (C > 0) {
		C=C - B;
		t++;
	}
	ll a = 0;
	while (A > 0) {
		A = A - D;
		a++;
	}

	if (a<t) cout << "No" << endl;
	else if(a>=t) cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int main()
{
    int N,K,X,Y;
    cin >> N >> K >> X>> Y;
    if(N > K)
    {
        cout<<K*X+(N-K)*Y<<endl;
    }
    else{
        cout<<N*X<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::{self, Read};

macro_rules! input {
    ($it: expr) => ($it.next().unwrap().parse().unwrap());
    ($it: expr, $T: ty) => ($it.next().unwrap().parse::<$T>().unwrap());
}

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).unwrap();

    let mut it = buf.split_whitespace();

    let n: usize = input!(it);

    println!("{}", match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        3 => "bon",
        _ => unreachable!(),
    });
}


Measured memory_bytes: 2056
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int cnt = 0;
  FOR(i,0,s.length()) {
    if(s[i] == 'C' && cnt == 0) cnt = 1;
    if(s[i] == 'F' && cnt == 1) cnt = 2;
  }
  puts(cnt == 2 ? "Yes" : "No");
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int m = 0;
  for (int i = 0; i < 3; i++) {
	if (s[i] == 'R') {
      cnt++;
    } else {
      m = max(m, cnt);
      cnt = 0;
    }
  }
  m = max(m, cnt);
  cout << m << endl;
}

Measured memory_bytes: 3620
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 31-May-2020 18:01:25
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const long long inf = 1000000000000000000LL;

int solve() {
    int n; cin >> n;
    vector<long long> a(n);
    for (long long &x : a) {
        cin >> x;
        if (x == 0) {
            return printf("0\n");
        }
    }

    long long mult = 1LL;
    for (int i = 0; i < n; ++i) {
        long long x = a[i];
        if (x > inf / mult) {
            return printf("-1\n");
        }
        mult *= x;
    }
    cout << mult << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 4048