akhauriyash/Code-Regression huggingface dataset:
/************
* 	@Just Another Source code by: ankit.sangwan1999
*	@created on: 25 May 2020
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) //;cout.tie(NULL)
#define ll long long
const int mod = 1e9+7;
#define endl '\n'

int n,k;
vector<int> arr;
int dp[100000+1][2];
bool fun(int k, bool player){ // player is made to play with k stones left. We always return the winning player.
	
	if(k==0) return player^1;

	if(dp[k][player] != -1) return dp[k][player]; 

	for(int i=0;i<n;i++){
		if(k-arr[i] < 0) break; // Saving Some Calls...
		
		if(dp[k-arr[i]][player^1] == -1){
			dp[k-arr[i]][player^1] = fun(k-arr[i], player^1);
		}

		if(dp[k-arr[i]][player^1] == player){
			return dp[k-arr[i]][player^1];
		}
	}

	return dp[k][player] = player^1;

}


signed main(){

    fastio;
    memset(dp, -1, sizeof(dp));

    cin>>n>>k;
    arr = vector<int>(n);

    for(int i=0;i<n;i++){
    	cin>>arr[i]; // already sorted...
    }

    // tora -> 0 , Jiro -> 1
    if(fun(k, 0) + 1 == 1) cout<<"First";
    else cout<<"Second"; 

    return 0;

}

Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll a[N];
  ll b[N];
  ll temp_a[N], temp_b[N];

  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  for(int i=0; i<N;i++){
    cin >> b[i];
  }
  ll ans = 0;

  for(int k =0; k<30;k++){
    ll t = 1 << k;
    //cout << t <<endl;
    for(int i =0; i<N; i++){
      temp_a[i] = a[i] % (2*t);
      temp_b[i] = b[i] % (2*t);
    }
    sort(temp_b, temp_b+N);
    ll cnt = 0;
    for(int i=0;i<N;i++){
      //ソートされたtemp_bから4t-a[i]以上の値が現れる最初の位置 - 3t-a[i] 以上の値が現れる最初の位置　= 3t-a[i] ~ 4t-a[i]の間にあるbの個数
      cnt += lower_bound(temp_b, temp_b+N, 4*t-temp_a[i]) - lower_bound(temp_b, temp_b+N, 3*t-temp_a[i]);
      cnt += lower_bound(temp_b, temp_b+N, 2*t-temp_a[i]) - lower_bound(temp_b, temp_b+N, 1*t-temp_a[i]);
    }
    //cout<<cnt<<endl;
    ans += (cnt%2)*t;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) == 'p'){
      if(i % 2 == 0) ans--;
    }
    else{
      if(i % 2 != 0) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

struct City
{
	int belongsTo;
	int year;
	int yearOrder;
	int oriOrder;
	
};
City cities[100010];

int n, m;

bool compareYear(const City &a, const City &b)
{
	if (a.belongsTo == b.belongsTo)
		return a.year < b.year;
	else
		return a.belongsTo < b.belongsTo;
}

bool compareOri(const City &a, const City &b)
{
	return a.oriOrder < b.oriOrder;
}


int main()
{
	scanf("%d%d", &n, &m);
	
	for (int i = 0 ; i < m ; i++)
	{
		scanf("%d%d", &(cities[i].belongsTo), &(cities[i].year));
		cities[i].oriOrder = i;
	}
	
	sort(cities, cities + m, compareYear);
	
	int pOrder = 1;
	for (int i = 0 ; i < m ; i++)
	{
		if ((i == 0) || (cities[i].belongsTo != cities[i - 1].belongsTo))
			pOrder = 1;
		else
			pOrder++;
		cities[i].yearOrder = pOrder;
	}

	sort(cities, cities + m, compareOri);
	for (int i = 0 ; i < m ; i++)
		printf("%06d%06d\n", cities[i].belongsTo, cities[i].yearOrder);
	
	return 0;
}



Measured memory_bytes: 2944
<?php
    $str = trim(fgets(STDIN));
    $record_cound = trim(fgets(STDIN));
    
    for($i = 0; $i < $record_cound; $i++){
        $order = explode(" ",trim(fgets(STDIN)));
        $a = $order[1];
        $b = $order[2];

        switch ($order[0]){
            case 'print':
                print substr($str, $a, $b - $a + 1)."\n";
                break;
            
            case 'reverse':
                $str = substr($str, 0, $a).strrev(substr($str, $a, $b - $a + 1)).substr($str, $b + 1);
                break;

            case 'replace':
                $str = substr($str, 0, $a).$order[3].substr($str, $b + 1);
                break;

            default:
                break;
        }
    }

Measured memory_bytes: 15372
#include "math.h"
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
vector<int> p[2000005];
int d[2000015] = {};
int cnt[2200016] = {};
int dfs(int cur, int par)
{
    if (d[cur] != -1)
        return d[cur];
    d[cur] = 0;
    int res = 0;
    for (auto to : p[cur]) {
        if (to == par)
            continue;
        res ^= (dfs(to, cur) + 1);
    }
    return d[cur] = res;
}
int main()
{
    int n;
    cin >> n;
    int x, y;
    rep(i, n) d[i] = -1;
    rep(i, n - 1)
    {
        cin >> x >> y;
        x--, y--;
        p[x].push_back(y);
        p[y].push_back(x);
    }
    int res = dfs(0, -1);
    if (res == 0) {
        cout << "Bob" << endl;
        return 0;
    } else {
        cout << "Alice" << endl;
    }
}


Measured memory_bytes: 58624
round=int(input())
T_pt=0
H_pt=0

for i in range(round):
	pair=raw_input().split(" ")
	T_card=pair[0].lower()
	H_card=pair[1].lower()

	if T_card<H_card:
		H_pt+=3
	elif T_card>H_card:
		T_pt+=3
	else:
		T_pt+=1
		H_pt+=1
print T_pt,H_pt

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

int main() {
  long a,v,b,w,t;
  string ans="NO";
  cin >> a >> v >> b >> w >> t;
  if(a<b&&a+(v*t)>=b+(w*t)) ans="YES";
  if(a>b&&a-(v*t)<=b-(w*t)) ans="YES";
  cout << ans << endl;
}

Measured memory_bytes: 3624
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

S = getN()

# 逆元事前処理ver
# nが小さい場合に
lim = 10 ** 5 + 1
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, lim + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    # 累計
    factinv.append((factinv[-1] * inv[-1]) % mod)

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod

ans = 0
# 長さNの時最低でも3 * N使う
# 残りは分配する
for i in range(1, 2001):
    s = S - (3 * i)
    if s < 0:
        break
    # sをN個に分配する通りがいくつあるか
    # 重複組み合わせ
    # 仕切りの数はi - 1個
    ans += cmb(s + i - 1, i - 1)
print(ans % mod)

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

int f(int x){
	return x*x;
}

int main() {
	int d;
	int x=600;
	while(cin>>d){
		int v=0;
		for(int i=0;i<x;i+=d)
			v+=f(i)*d;
		cout<<v<<endl;
	}
	return 0;
}

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    ll n=in();
    vector<ll> a(n),b(n),c(n);
    for (int i=0;i<n;i++) cin >> a[i];
    for (int i=0;i<n;i++) cin >> b[i];
    for (int i=0;i<n;i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll a_n,c_n;
    ll ans=0;
    for(int i=0;i<n;i++){
        a_n=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        c_n=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans+=a_n*c_n;
    }
    cout << ans << endl;
}

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

long long solve(long long ai, long long aj, long long bi, long long bj)
{
    long long size = 1;
    for (int i = 0; i < 30; ++i)
    {
        size *= 3;
    }

    long long dist = std::abs(ai - bi) + std::abs(aj - bj);
    while (size > 1)
    {
        size /= 3;
        long long nai = ai / size, naj = aj / size, nbi = bi / size, nbj = bj / size;
        if (nai != nbi)
        {
            break;
        }
        if (std::abs(naj - nbj) >= 2 && nai % 3 == 1)
        {
            long long up = ai - nai * size + 1 + bi - nbi * size + 1;
            long long bottom = (nai + 1) * size - ai + (nbi + 1) * size - bi;
            dist = std::abs(aj - bj) + std::min(up, bottom);
            break;
        }
    }

    return dist;
}

int main()
{
    int q;
    std::cin >> q;
    std::vector<std::array<std::array<long long, 2>, 2>> in(q);
    for (int i = 0; i < q; ++i)
    {
        long long ax, ay, bx, by;
        std::cin >> ax >> ay >> bx >> by;
        --ax;
        --ay;
        --bx;
        --by;
        in[i][0][0] = ax;
        in[i][0][1] = ay;
        in[i][1][0] = bx;
        in[i][1][1] = by;
    }

    for (int i = 0; i < q; ++i)
    {
        std::cout << std::max(solve(in[i][0][0], in[i][0][1], in[i][1][0], in[i][1][1]), solve(in[i][0][1], in[i][0][0], in[i][1][1], in[i][1][0])) << '\n';
    }

    return 0;
}

Measured memory_bytes: 640
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n, W;
vector<ll> w, v;

void solve() {
    vector<ll> w0, w1, w2, w3;
    rep(i, n) {
        if (w[i] == w[0]) w0.emplace_back(v[i]);
        else if (w[i] == w[0] + 1) w1.emplace_back(v[i]);
        else if (w[i] == w[0] + 2) w2.emplace_back(v[i]);
        else if (w[i] == w[0] + 3) w3.emplace_back(v[i]);
    }
    sort(w0.begin(), w0.end(), greater<>());
    sort(w1.begin(), w1.end(), greater<>());
    sort(w2.begin(), w2.end(), greater<>());
    sort(w3.begin(), w3.end(), greater<>());
    vector<ll> dp0(w0.size()), dp1(w1.size()), dp2(w2.size()), dp3(w3.size());
    rep(i, dp0.size())dp0[i] = i == 0 ? w0[i] : dp0[i - 1] + w0[i];
    rep(i, dp1.size())dp1[i] = i == 0 ? w1[i] : dp1[i - 1] + w1[i];
    rep(i, dp2.size())dp2[i] = i == 0 ? w2[i] : dp2[i - 1] + w2[i];
    rep(i, dp3.size())dp3[i] = i == 0 ? w3[i] : dp3[i - 1] + w3[i];
    dp0.insert(dp0.begin(), 0);
    dp1.insert(dp1.begin(), 0);
    dp2.insert(dp2.begin(), 0);
    dp3.insert(dp3.begin(), 0);

    ll ans = 0;
    rep(i, w0.size() + 1) {
        rep(j, w1.size() + 1) {
            rep(k, w2.size() + 1) {
                rep(l, w3.size() + 1) {
                    if (i * w[0] + j * (w[0] + 1) + k * (w[0] + 2) + l * (w[0] + 3) <= W) {
                        ans = max(ans, dp0[i] + dp1[j] + dp2[k] + dp3[l]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> n >> W;
    w.resize(n), v.resize(n);
    rep(i, n) cin >> w[i] >> v[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
int n, x;
long long b[200000];
int c[200000];
int y[10];
char s[15];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf(" %s", s);
		for (int j = 0; j < 10; j++) {
			if (s[j] < 'a' || s[j]>'z')s[j] = 'a' - 1;
			b[i] += s[j] - ('a' - 1);
			b[i] *= 30;
		}
		b[i] /= 30;
		for (int j = 0; j < 10; j++)s[j] = 0;
	}
	std::sort(b, b + n);
	for (int i = 1; i < n; i++) {
		if (b[i] == b[i - 1])c[i] = c[i - 1] + 1;
		if (c[i] > x)x = c[i];
	}
	for (int i = 0; i < n; i++) {
		if (c[i] == x) {
			for (int j = 0; j < 10; j++) {
				y[9 - j] = b[i] % 30;
				b[i] /= 30;
			}
			for (int j = 0; j < 10; j++) {
				if (y[j])printf("%c", y[j] + 'a' - 1);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 3456
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            int count = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] arr = new int[count];

            int max = int.MinValue;
            int min = int.MaxValue;
            long sum = 0;

            for (int i = 0; i < count; i++)
            {
                arr[i] = int.Parse(input[i]);
                if(max < arr[i])
                {
                    max = arr[i];
                }

                if(min > arr[i])
                {
                    min = arr[i];
                }

                sum += arr[i];

            }
            
            Console.WriteLine("{0} {1} {2}",min,max,sum);





        }
    }
}

Measured memory_bytes: 9908
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))

A.sort()
F.sort(reverse=True)


MIN=0
MAX=max(A)*max(F)

while MIN!=MAX:
    mid=(MIN+MAX)//2
    score=0

    for i in range(N):
        if A[i]*F[i]>mid:
            score+=A[i]-mid//F[i]

    if score<=K:
        MAX=mid
    else:
        MIN=mid+1

print(MIN)

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

int main(void){
    long long int i, j, k, n, ans=0, po=0, leng=0;
    char name[20];
    scanf("%lld", &n);
    for(i=0; i<20; i++) name[i] = '\0';
    for(i=0; n>0; i++){
        name[i] = n%26;
        if(name[i] == 0) name[i] = 26;
        n = (n-n%26-(n%26==0)*26)/26;
        leng++;
        if(n == 0) break;
    }
    for(i=0; i<leng; i++) printf("%c", name[leng-i-1]+96);
}


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

using namespace std;

int main(){
  int num[]={0,0,0};
  int k;
  cin >> num[0] >> num[1] >> num[2];
  cin >> k ;
  int i,j,max=1;
  int key;

  for(i=0;i<3;i++){
      if(num[i]>=max){
        max = num[i];
        key=i;
      }
  }
  int sum;

  for(i=0;i<3;i++){
    if(i == key){
      for(j=0;j<k;j++){
        num[i] = num[i]*2;
      }
    }
    sum += num[i];
  }

  cout << sum << 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;
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint choose(int n, int a){
        mint x = 1 ,y = 1;
        for(int i = 0; i < a; ++i){
            x *= n-i;
            y *= i+1;
        }
        return x / y;
    }
    friend istream& operator>>(istream& is, mint& m){
        is >> m.x;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

mint dp[100010][4];

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

  dp[0][0]=1;
  for(int i=0; i<n; ++i){
    for(int j=0; j<=3; ++j){
      if(s[i]!='?')dp[i+1][j]+=dp[i][j];
      else dp[i+1][j]+=dp[i][j]*3;
      if(j==0&&(s[i]=='A'||s[i]=='?')){
        dp[i+1][1]+=dp[i][0];
      }
      if(j==1&&(s[i]=='B'||s[i]=='?')){
        dp[i+1][2]+=dp[i][1];
      }
      if(j==2&&(s[i]=='C'||s[i]=='?')){
        dp[i+1][3]+=dp[i][2];
      }
    }
  }
  cout<<dp[n][3]<<endl;
}

Measured memory_bytes: 6884
import math
s = input()
s = s + "R"

ans = [0 for i in range(len(s)-1)]
lp = 0
for i in range(len(s)-1): 
    if s[i] == "R" and s[i+1] == "L":
        p = i

    if s[i] == "L" and s[i+1] == "R":
        rp = i
        
        if (p - lp) % 2 == 0:
            ans[p] = int(math.ceil((rp - lp + 1) / 2))
        else:
            ans[p] = int(math.floor((rp - lp + 1) / 2))

        ans[p+1] = rp - lp + 1 - ans[p]

        lp = i + 1

for j in range(len(ans)):
    print(ans[j], end = " ")

         
        
        
    

        
            
        
    
        




Measured memory_bytes: 6320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  vector<string> A(h);
  map<char, int> cnt;
  rep(i, h) {
    cin >> A[i];
    rep(j, w) cnt[A[i][j]]++;
  }
  int n4=0, n2=0, n1=0;
  for(auto ele: cnt) {
    if(ele.second % 4 == 0) n4++;
    else if(ele.second % 4 == 1) n1++;
    else if(ele.second % 4 == 2) n2++;
    else if(ele.second % 4 == 3) {
      n1++;
      n2++;
    }
  }
  if(h%2==0 && w%2==0) {
    if(n1 || n2) cout << "No" << endk;
    else cout << "Yes" << endk;
  } else if(h%2==0) {
    if(n1 || n2 > h/2) cout << "No" << endk;
    else cout << "Yes" << endk;
  } else if(w%2==0) {
    if(n1 || n2 > w/2) cout << "No" << endk;
    else cout << "Yes" << endk;
  } else {
    if(n1 != 1 || n2 > w/2+h/2) cout << "No" << endk;
    else cout << "Yes" << endk;
  }
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int n, i = 0, j = 0, sum = 0;
	cin >> n;
	int d[n];
	for(i=0; i < n; i++)
		cin >> d[i];
	for(i=0; i < n-1; i++)
		for(j = i+1; j < n; j++)
		{
			sum += d[i] * d[j];
		}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;

ll dp[52][52][2501];

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

  //rep(i,n+1) rep(j,n+1) rep(k,2501) dp[i][j][k] == INF;
  dp[0][0][0] = 1;

  rep(i,n) {
    rep(j,n) {
      rep(k,2501){
          dp[i+1][j+1][k + v[i]] += dp[i][j][k];
          dp[i+1][j][k] += dp[i][j][k];
        } 
      }
    //rep(x,n) {
    //  rep(y,10){
    //    cout << dp[i][x][y];
    //  }
    //  cout << endl;
    //}
    //cout << endl;
  }
  ll ans = 0;
  rep(j,n+1) rep(k,2501){
    if (j*a == k ) ans += dp[n][j][k]; 
  }
  cout << ans-1LL << endl;


 
  
  return 0;
  
}


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

int main(){
  int N;
  cin >> N;
  string N_str = to_string(N);
  int len = N_str.size();
  int n1 = N_str[0] - '0';
  int n2 = N % 10;
  int t = pow(10, len - 1);
  int mid_N = (N % t) / 10;
  if(len == 1){
    cout << N << endl;
  }else if(len == 2){
    ll A = 0;
    ll B = 0;
    ll res = 0;
    for(int x = 1; x < 10; x++){
      for(int y = 1; y < 10; y++){
	A = 0;
	B = 0;
	if(10 * x + y <= N){
	  A++;
	}
	if(10 * y + x <= N){
	  B++;
	}
	if(x == y){
	  A++;
	  B++;
	}
	res += A * B;
      }
    }
    cout << res << endl;
  }else{
    ll A = 0;
    ll B = 0;
    ll tmp  = (pow(10, len - 2) - 1) / 9;
    ll res = 0;
    for(int x = 1; x < 10; x++){
      for(int y = 1; y < 10; y++){
  	A = tmp;
  	B = tmp;
	if(x == y){
	  A++;
	  B++;
	}
  	if(x < n1){
  	  A += pow(10, len - 2);
  	}else if(x == n1){
  	  if(n2 >= y){
	    A += mid_N + 1;
	  }else{
	    A += mid_N;
	  }
  	}
  	if(y < n1){
  	  B += pow(10, len - 2);
  	}else if(y == n1){
  	  if(n2 >= x){
	    B += mid_N + 1;
	  }else{
	    B += mid_N;
	  }
  	}
	res += A * B;
      }
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	N int
	C map[int]int = make(map[int]int)
)

func readVariables() {
	N = nextInt()
}

func main() {
	readVariables()
	var answer bool
	answer = true
	for i := 0; i < N; i++ {
		v := nextInt()
		if C[v] > 0 {
			answer = false
			break
		}
		C[v]++
	}
	// fmt.Println(C)
	if answer {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}


Measured memory_bytes: 12672
//
// Created by 吉川純平 on 2019-12-01.
//

#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
//using ull = unsigned long long;
#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> w(n);
  rep(i,n){
    cin >> w[i];
  }
  //first:can-bound last:cant-bound
  ll first = 0;
  ll last = n * 10000;
  while(last - first > 1){
    //cout << first << " " << last << endl;
    ll mid = (first + last) / 2;
    ll piv = 0;
    ll tmpsum = 0;
    bool can = true;
    rep(i,n){
      if(w[i] > mid){
        can = false;
        break;
      }
      if(tmpsum + w[i] > mid){
        tmpsum = w[i];
        piv++;
      }else{
        tmpsum += w[i];
      }
    }
    if(piv >= k){
      can = false;
    }
    if(can){
      last = mid;
    }else{
      first = mid;
    }
  }
  cout << last << endl;
}



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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int N, a[112345];
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	ll ans = 0;
	REP(i, N) {
		if (a[i] > 2) {
			int now;
			if (a[i] & 1) now = (a[i] - 1) / 2;
			else now = (a[i] - 2) / 2;
			ans += now;
			a[i] -= now * 2;
		}
	}
	
	int pos = 0;
	while (pos < N) {
		if (a[pos] == 2) ans++;
		if (a[pos] == 1) {
			int cnt = 1;
			pos++;
			while (pos < N && a[pos] == 2) pos++, cnt++;
			if (pos == N) cnt--;
			else if (a[pos] != 1) cnt--;
			ans += cnt;
		}
		pos++;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = v[0];
  for(int i = 1; i < n; ++i) ans = (ans+v[i])/2;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  rep(i, n + 1) cin >> a[i];
  vector<int> b(n);
  rep(i, n) cin >> b[i];

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

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

int main(){
  int N;
  cin >> N;
  int D1[N],D2[N];
  for(int i=0; i<N; i++){
    cin >> D1[i] >> D2[i];
  }
  for(int i=0; i<N-2; i++){
    if(D1[i]==D2[i] and D1[i+1]==D2[i+1] and D1[i+2]==D2[i+2]){
      cout << "Yes" << endl;
      return 0;
    }
  }  
  cout << "No" << endl;
  return 0;
}  

Measured memory_bytes: 3632
import java.util.Scanner;

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

Measured memory_bytes: 26996
N,K = map(int,input().split())
okashi=[0] * N
for i in range(K):
  x=input()
  y=input().split()
  for j in y:
    okashi[int(j)-1]=1
counter=0

for i in okashi:
  if i==0:
    counter=counter+1
print(counter)

Measured memory_bytes: 9180
#include <stdio.h>
#include <string.h>
#define MAX 100000
int main() {
	int h,n,i;
	int a;
	int sum;
	sum=0;
	scanf("%d %d",&h, &n);
	for(i=0;i<n;i++){
		scanf("%d ", &a);
		sum+=a;
	}
	if(sum>=h) {
		printf("Yes");
	} else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
using namespace std;
 
int main() {
  string s, c;
  cin >> s;
  
  int l = s.size(), ans = 0, minAns = 1000, p;
  
  for(int i = 0; i < l - 2; ++i)
  {
    c = s.substr(i, 3);
    stringstream str(c);
    str >> ans;
    p = abs(ans - 753);
    if(p < minAns)
      minAns = p;
  }
  cout << minAns;
  return 0;
}

Measured memory_bytes: 3632
s = input()
t = input()
def check(s, t):
    if len(t) - len(s) != 1 or len(s) ==0:
        return False
    for i in range(len(s)):
        if s[i]!= t[i]:
            return False
    return True
if check(s, t):
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 9108
import sys

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def lcm(a, b):
	return a * b // gcd (a, b)

for line in sys.stdin:
	a, b = map(int , line.split())
	print gcd(a,b), lcm(a,b)

Measured memory_bytes: 6292
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	printf("%d\n",(N*(N-1))/2+(M*(M-1))/2);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll get(ll i, ll j, ll l)
{
	if (i < 0 || j < 0 || l < 0)return -100000000;
	return (i / 2) * 4 + (j / 2) * 4 + (l / 2) * 4;
}
int main()
{
	ll i, o, gomi, j, l;
	scanf("%lld%lld%lld%lld%lld", &i, &o, &gomi, &j, &l);
	printf("%lld\n", (o * 2 + max(get(i, j, l), get(i - 1, j - 1, l - 1) + 6)) / 2);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int n, t;
  float a;
  float p;
  a = 1/2;
  scanf("%d", &n);
  if (n % 2 == 0){
    printf("%f\n", 0.5000000000);
  }
  else {
     t = n/2;
     a = t+1;
     p = a/n;
     printf("%f\n", p);
  }
  return 0;
}

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

int main(){
  
  int x;
  cin >> x;
  
  char a;
  int b;
  int card[4][13]={{}};
  
  for(int i=0;i<x;i++){
    cin >> a >> b;
    if(a=='S')
      card[0][b-1]=1;
    else if(a=='H')
      card[1][b-1]=1;
    else if(a=='C')
      card[2][b-1]=1;
    else if(a=='D')
      card[3][b-1]=1;
  }
  
  for(int j=0; j<4; j++){
    for(int k=0; k<13; k++){
      if(card[j][k]!=1){
        if(j==0)
          cout << "S " << k+1 << endl;
        else if(j==1)
          cout << "H " << k+1 << endl;
        else if(j==2)
          cout << "C " << k+1 << endl;
        else if(j==3)
          cout << "D " << k+1 << endl;
      } 
    }
  }
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int year[2],month[2],day[2];
    while(cin>>year[0]>>month[0]>>day[0]>>year[1]>>month[1]>>day[1]){
        bool en=0;
        for(int i=0;i<2;i++)if(year[i]<0||month[i]<0||day[i]<0)en=1;
        if(en)break;
        int ans=0;
        for(int i=year[0];i<=year[1];i++){
            ans+=365;
            if(i%4==0&&i%100!=0||i%400==0)ans+=1;
        }
        ans+=day[1]-day[0]+1;
        for(int i=1;i<month[0];i++){
            if(i==2)ans-=28;
            else if(i==4||i==6||i==9||i==11)ans-=30;
            else ans-=31;
        }
        if((year[0]%4==0&&year[0]%100!=0||year[0]%400==0)&&month[0]>=2)ans-=1;
        for(int i=month[1];i<13;i++){
            if(i==2)ans-=28;
            else if(i==4||i==6||i==9||i==11)ans-=30;
            else ans-=31;
        }
        if((year[1]%4==0&&year[1]%100!=0||year[1]%400==0)&&month[1]<=2)ans+=1;
        cout<<ans-1<<endl;
    }
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n;
  cin >> n;
  ll zero = 0;
  map<pll,P> mp;
  REP(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x==0 && y==0) {
      zero++;
      continue;
    }
    ll g = gcd(x, y);
    x /= g;
    y /= g;
    if (y < 0) x = -x, y = -y;
    if (y == 0 && x < 0) x = -x, y = -y;
    bool rot90 = (x <= 0);
    if (rot90) {
      swap(x, y);
      y = -y;
    }
    if(rot90) mp[{x,y}].first++;
    else mp[{x,y}].second++;
  }

  mint ans = 1;
  for (auto p : mp) {
    int s = p.second.first;
    int t = p.second.second;
    mint now = 1;
    now += mint(2).pow(s) - 1;
    now += mint(2).pow(t) - 1;
    ans *= now;
  }
  ans -= 1;
  ans += zero;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15904
'use strict'
function main(inp) {
  let info = inp.trim().split('\n')
  let input1 = info[0].split(' ');
  let input2 = info[1];
  let K = input1[0]*1;
  let N = input1[1]*1;
  let A = input2.split(' ').map(x => x*1);
  A[N] = K + A[0];
  let ans = 0;
  let max = 0;
  for(let i = 0; i < N; i++){
    ans += A[i+1] - A[i];
    if(max < A[i+1] - A[i]){
    	max = A[i+1] - A[i];
    }
  }
  console.log(ans - max);
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 25620
data = list(map(int,input().split()))
ans = 0
def judge_odd_even(data,ans):
    judge_list=[0,0,0]
    for i in range(3):
        if data[i] % 2 == 0:
            judge_list[i] = 2
        else:
            judge_list[i] = 1
    if judge_list.count(1) == 3 or judge_list.count(2) == 3:
        return data,ans
    else:
        if judge_list.count(1) == 2:
            for i in range(3):
                if judge_list[i] == 1:
                    data[i] += 1
            ans += 1
            return data,ans
        elif judge_list.count(2) == 2:
            for i in range(3):
                if judge_list[i] == 2:
                    data[i] += 1
            ans += 1
            return data,ans
data,ans = judge_odd_even(data, ans)
max_data = max(data)
for i in range(3):
    ans += (max_data-data[i])//2
print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);
		long l = -1000000000000000001L;
		long r = 1000000000000000001L;
		while (l + 1 < r) {
			long m = (l + r) / 2;
			if (ok(a, m, k)) {
				l = m;
			} else {
				r = m;
			}
		}
		System.out.println(l);
	}

	// x 未満の数が k 以下
	private static boolean ok(long[] a, long x, long k) {
		long count = 0;
		for (int i = 0; i < a.length; i++) {
			int l = -1, r = a.length;
			if (a[i] < 0) {
				while (l + 1 < r) {
					int m = (l + r) / 2;
					if (a[m] * a[i] < x) {
						r = m;
					} else {
						l = m;
					}
				}
				count += (a.length - r);
			} else {
				while (l + 1 < r) {
					int m = (l + r) / 2;
					if (a[m] * a[i] < x) {
						l = m;
					} else {
						r = m;
					}
				}
				count += r;
			}
			if (a[i] * a[i] < x) count--;
		}
		count /= 2;
		return count < k;
	}
}


Measured memory_bytes: 82496
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int m = std.nextInt();

        List<PriorityQueue<Long>> queues = new ArrayList<>();
        for (int i = 0; i < 8; i++) {
            queues.add(new PriorityQueue<>(n, Collections.reverseOrder()));
        }

        for (int i = 0; i < n; i++) {
            long x = std.nextLong();
            long y = std.nextLong();
            long z = std.nextLong();

            long t1 = x + y + z;
            queues.get(0).add(t1);

            long t2 = -x + y + z;
            queues.get(1).add(t2);

            long t3 = x - y + z;
            queues.get(2).add(t3);

            long t4 = x + y - z;
            queues.get(3).add(t4);

            long t5 = x - y - z;
            queues.get(4).add(t5);

            long t6 = -x -y -z;
            queues.get(5).add(t6);

            long t7 = -x -y +z;
            queues.get(6).add(t7);

            long t8 = -x +y -z;
            queues.get(7).add(t8);
        }

        long max = 0;
        for (int i = 0; i < 8; i++) {
            long total = 0;
            PriorityQueue<Long> queue = queues.get(i);
            for (int j = 0; j < m; j++) {
                long val = queue.poll();
                total += val;
            }

            max = Math.max(max, total);
        }

        System.out.println(max);
    }
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()

typedef pair<int, int> P;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m, d;
	cin >> n >> m >> d;
	
	int cnt = 0;
	if (d == 0) {
		cnt = n;
	} else {
		FOR(i, 1, n + 1) {
			if (i + d <= n) cnt++;
			if (i - d >= 1) cnt++;
		}
	}
	
//	cout << cnt << endl;

//	cout << (double) ((cnt) * pow(n, (m - 1))) / pow(n, m) << endl;
//	cout << (double) (cnt) / n << endl;
//	if (d == 0) cnt = cnt / 2;
//	cout << ((long double) (m - 1) / (long double) n) * ((long double) cnt / (long double) n) << endl;
	printf("%.6f\n",((double) (m - 1) / (double) n) * ((double) cnt / (double) n));
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <ostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define ll long long
#define dd double
#define mes(x,y) memset(x,y,sizeof(y))
using namespace std;

int main(){
	double a[100],b,n;
	while(cin>>n&&n!=0){
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		ll sum=0;
		for(int i=0;i<n;i++){
			cin>>b;
			sum+=a[i]-b>0?a[i]-b:0;
		}
		cout<<sum<<endl;
	} 
}

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

int main() {
    int N, K, a;
    cin >> N >> K;
    vector<int> d(K);
    vector<vector<int>> A(K);
    for (int i=0; i<K; i++) {
        cin >> d[i];
        for (int j=0; j<d[i]; j++) {
            cin >> a;
            A[i].push_back(a-1);
        }
    }

    vector<int> vec(N,0);
    for (int i=0; i<K; i++) {
        for (int j=0; j<d[i]; j++) {
            vec[A[i][j]]++;
        }
    }

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

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
int h[100010];

int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h, h + n);
	int ans = 1e9;
	for (int i = 0; i < n - k+1; i++) {
		ans = min(h[i + k-1] - h[i], ans);
	}
	cout << ans << endl;
	return 0;
}

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

function main()
	mod = 10^9+7
	l = parseMap(split(chomp(readline()), ""))
	n = length(l)
	dp = zeros(Int,2,n)
	dp[1,1] = 1
	dp[2,1] = 2
	for i in 2:n
		dp[1,i] = dp[1,i-1]*3%mod
		if l[i]==0
			dp[2,i] = dp[2,i-1]
		else
			dp[1,i] = (dp[1,i]+dp[2,i-1])%mod
			dp[2,i] = dp[2,i-1]*2%mod
		end
	end
	println((dp[1,n]+dp[2,n])%mod)
end

main()

Measured memory_bytes: 124308
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
vector<int> G[50];
int  main() {
	int N,M;
	scanf("%d %d",&N,&M);
	for(int i=0;i<M;i++) {
		int a,b;
		scanf("%d %d",&a,&b);a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for(int i=0;i<N;i++) {
		printf("%d\n",G[i].size());
	}
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    var count = 0
    var answer = 0
    for (i in s.indices) {
        if (Regex("A|C|T|G").matches(s[i].toString())) {
            count++
        } else {
            if (answer < count) answer = count
            count = 0
        }
        if (i == s.length - 1) if (answer < count) answer = count
    }
    println(answer)
}


Measured memory_bytes: 33664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
    
    
//defines
typedef long long ll;
typedef long double ld;
  
ll a,b,c,n,m,k,t=1;


void solve()
{
  cin>>a;
  cout<<(a+(a*a)+(a*a*a));
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A, B, C;
    char a, b;
    cin >> A >> a >> B >> b >> C;
    if (B > 4)
        cout << "TBD";
    else
        cout << "Heisei";
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;
#include <boost/optional.hpp>

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

typedef pair<ll, vector<ll>> myElem;

vector<ll> sz(3);
vector<vector<ll>> vec(3);
ll K;

myElem elem(vector<ll> v) {
  ll sum = 0;
  for (ll p = 0; p < 3; p++) { sum += vec.at(p).at(v.at(p)); }
  return make_pair(sum, v);
}

myElem elem(ll i, ll j, ll k) {
  vector<ll> v = {i, j, k};
  return elem(v);
}

ll diff_at(ll p, vector<ll> v) {
  return vec.at(p).at(v.at(p)-1) - vec.at(p).at(v.at(p));
}

boost::optional<myElem> nextElem(myElem e, ll p) {
  ll idx = e.second.at(p);
  if (idx == sz.at(p) - 1)  return boost::optional<myElem>();
  vector<ll> v = e.second;
  v.at(p)++;
  for (ll q = 0; q < 3; q++) {
    if (q == p)  continue;
    if (v.at(q) == 0)  continue;
    ll diff = diff_at(p, v) - diff_at(q, v);
    if (diff < 0 || (diff == 0 && p > q))  return boost::optional<myElem>();
  }
  return elem(v);
}

int main() {
  cin >> sz.at(0) >> sz.at(1) >> sz.at(2) >> K;
  for (ll p = 0; p < 3; p++) {
    vec.at(p).resize(sz.at(p));
    for (ll i = 0; i < sz.at(p); i++)  cin >> vec.at(p).at(i);
    sort(vec.at(p).begin(), vec.at(p).end(), greater<ll>());
  }
  priority_queue<myElem> pque;
  myElem init = elem(0, 0, 0);
  pque.push(init);
  for (int i = 0; i < K; i++) {
    myElem e = pque.top();
    pque.pop();
    cout << e.first << endl;
    for (ll p = 0; p < 3; p++) {
      boost::optional<myElem> eN = nextElem(e, p);
      if (!eN)  continue;
      pque.push(*eN);
    }
  }
  return 0;
}



Measured memory_bytes: 512
#include <iostream>

int main(void)
{
	using namespace std;

	int m,f,r;
	char grade;
	while(1){
		cin >> m;
		cin >> f;
		cin >> r;
	
		if(m == -1 && f == -1 && r == -1)	break;
	
		if(m == -1 || f == -1)	grade = 'F';
		else{
			int sum = m + f;
			if(sum >= 80)				grade = 'A';
			else if(sum >= 65)	grade = 'B';
			else if(sum >= 50)	grade = 'C';
			else if(sum >= 30){
				if(r >= 50)				grade = 'C';
				else							grade = 'D';
			}
			else 								grade = 'F';
		}
		cout << grade << endl;
	}	

	return 0;
}

Measured memory_bytes: 3084