akhauriyash/Code-Regression huggingface dataset:
<?php
list($n) = ints();
$a = ints();
$ans = PHP_INT_MAX;
$sum0 = $sum1 = 0;
$cnt0 = $cnt1 = 0;
for ($i = 0; $i < $n; ++$i) {
    $sum0 += $a[$i];
    $sum1 += $a[$i];
    if ($i % 2 === 0) {
        $d = abs(min(0, $sum0 - 1));
        $sum0 += $d;
        $cnt0 += $d;

        $d = abs(max(0, $sum1 + 1));
        $sum1 -= $d;
        $cnt1 += $d;
    } else {
        $d = abs(max(0, $sum0 + 1));
        $sum0 -= $d;
        $cnt0 += $d;

        $d = abs(min(0, $sum1 - 1));
        $sum1 += $d;
        $cnt1 += $d;
    }
}
echo min($cnt0, $cnt1);

// 偶数盤目の項までの和をプラスにする場合
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16884
#a,b,c=map(int,input().split())
#d=list(map(int,input().split()))
#n=int(input())
#d,x=map(int,input().split())
#a=[int(input()) for i in range(n)]

      
h1,m1,h2,m2,k=map(int,input().split())

t1=h1*60+m1
t2=h2*60+m2

print(t2-t1-k)

Measured memory_bytes: 9164
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def solve(N):
    if N == 1:
        print(Yes)
        print(2)
        print(1, 1)
        print(1, 1)
        return
    K = -1
    for k in range(1, N + 1):
        if (k * (k - 1)) // 2 == N:
            K = k

    if K == -1:
        print(No)
        return

    ans = [[] for _ in range(K)]
    num = 1
    for i in range(0, K):
        for j in range(i + 1, K):
            ans[i].append(num)
            ans[j].append(num)
            num += 1

    print(Yes)
    print(K)
    for v in ans:
        print(len(v), *v, sep=" ")


def main():
    N = int(input())
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14700
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<limits.h>
#define INF 100000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;
typedef pair<int,int> P;
int w,h;
int imap[21][21];
int fin;
int djd[20][2]; // 0->x ,1->y
int mmaapp[20][20];
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int bfs(int sp,int gp){
  int mmap[21][21];
 
  for(int i=0;i<21;i++)for(int j=0;j<21;j++)mmap[i][j] = INF;
  queue<P> que;
  que.push(P(djd[sp][0],djd[sp][1]));
  mmap[djd[sp][1]][djd[sp][0]]=0;

  while(que.size()){
    P p = que.front();que.pop();

    if(p.first == djd[gp][0] && p.second == djd[gp][1])return mmap[djd[gp][1]][djd[gp][0]];

    for(int i=0;i<4;i++){
      int nx = p.first+dx[i],ny = p.second+dy[i];
      if(0<=nx && nx < w && 0<=ny && ny < h && mmap[ny][nx] == INF && imap[ny][nx] != -1){
	que.push(P(nx,ny));
	mmap[ny][nx] = mmap[p.second][p.first] + 1;
      }
    }
  }
  return -1;
}



int main(){
  char in;
  int count;
  int permutationtest[66];
  while(true){
    cin >> w >> h;
    if(w+h == 0)break;
    rep(i,66)permutationtest[i] = 0;  
    count=1;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> in;
	switch(in){
	case '.':
	  imap[i][j]=0;
	  break;
	case 'o':
	  imap[i][j]=0;
	  djd[0][0]=j;
	  djd[0][1]=i;
	  break;
	case 'x':
	  imap[i][j]=-1;
	  break;
	case '*':
	  imap[i][j]=0;
	  djd[count][0]=j;
	  djd[count][1]=i;
	  count++;
	  break;
	default:

	  break;
	}
      }
    }
    fin=INF;
    for(int i=0;i<count;i++){
      for(int j=0;j<count;j++){
	mmaapp[i][j] = bfs(i,j);
	fin = min(fin,mmaapp[i][j]);
      }
   
    }
   
   
   
    for(int i=0;i<count-1;i++){
      permutationtest[i] = i+1;
   
    }
    
    
    
    int sum;
    int ans=INF;
    do{
      sum=0;
      sum+=mmaapp[0][permutationtest[0]];
    
      for(int i=1;i<count-1;i++){
	sum+=mmaapp[permutationtest[i-1]][permutationtest[i]];
      }
    
      ans=min(ans,sum);
    }while(next_permutation(permutationtest,permutationtest+(count-1)));

    if(fin < 0)cout << "-1" << endl;
    else cout << ans << endl;


  }


  return 0;
}

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

int main()
{
int n;
  cin>>n;
  int arr[n];
  vector<int>ans(n+1);
  map<int,int>m;
  for(int i=1;i<=n-1;i++)
  {
     cin>>arr[i];
   ans[arr[i]]++;
  }

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


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


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll x = 1, y = 1;
    rep(i, 0, n){
        int t, a;
        cin >> t >> a;
        ll k = max((x + t -1) / t, (y + a -1) / a);
        x = k * t;
        y = k * a;
        
        //cout << "k = " << k << " x = " << x << " y = " << y << endl;
    }
    cout << x + y << endl;
    
}

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

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

    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else if (s == "Rainy")
    {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
d = [int(input()) for i in range(5)]

mi = 0
for i in range(1, len(d)):
  if (d[mi] - 1) % 10 > (d[i] - 1) % 10:
    mi = i

Ans = d[mi]
for i in range(len(d)):
  if i == mi: continue
  if d[i] % 10 == 0:
    Ans += d[i]
  else:
    Ans += d[i] + 10 - (d[i] % 10)

print(Ans)

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

int main(){
    int n;
    int* p;

    cin >> n;

    p = new int[n];

    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    sort(p, p+n);

    int count, t;
    t = n >> 1;
    count = p[t] - p[t-1];

    cout << count << endl;
}

Measured memory_bytes: 640
open Batteries
let n = Scanf.scanf "%d" (fun x -> x)
let a = List.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))
let rec solve acc sum sign = function
  | [] -> acc
  | (x::xs) ->
      if (sum+x) * sign > 0 then
        solve acc (sum+x) (-sign) xs
      else
        let acc' = acc + abs (sum+x - sign) in
        solve acc' sign (-sign) xs

let () =
  min (solve 0 0 1 a) (solve 0 0 (-1) a)
  |> Printf.printf "%d\n"



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

typedef pair<int, int> P;

bool compare(P v1, P v2){
  if(v1.second > v2.second) return true;
  else if(v1.second < v2.second) return false;
  else{
    if(v1.first < v2.first) return true;
    else return false;
  }
}
  
int main(){
  vector<P> v;
  int n;
  cin >> n;
  P t;
  for(int i = 0 ; i < n ; i++){
    cin >> t.first >> t.second;
    v.push_back(t);
  }

  sort(v.begin(), v.end(), compare);
  
  cout << v[0].first << ' ' << v[0].second << endl;
  return 0;
}

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

vector<long> dp;


int main()
{
    int n;
    cin >> n;
    vector<int> height(n), beauty(n);
    for(int i = 0; i < n; i++)
        cin >> height[i];
    for(int i = 0; i < n; i++)
        cin >> beauty[i];
    dp = vector<long>(n + 1);
    int base = 1;
    while(base <= n)
    {
        base = base*2;
    }

    vector<long long> tree(2*base);
    for(int flower = 0; flower < n; flower++)
    {
        long b = beauty[flower];
        int j = height[flower];
        
        int x = height[flower] + base;
        long long best = 0;
        while(x > 1)
        {
            if(x % 2 == 1)
            {
                best = max(best, tree[x - 1]);
            }
            x = x / 2;
        }

        dp[j] = best + b;
        for(int i = base + j; i>= 1; i /=2)
        {
            if(tree[i] <= dp[j])
                tree[i] = dp[j];
        }
    }
    long long ans = 0;
    for(int i = 0; i <= n; i++)
    {
        if(ans < dp[i])
            ans = dp[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 7552
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll H, W, D;
	cin >> H >> W >> D;
	vvll A(H);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			ll t;
			cin >> t;
			t--;
			A[i].emplace_back(t);			
		}
	}

	ll Q;
	cin >> Q;
	vll L(Q), R(Q);
	for (int i = 0; i < Q; i++)
	{
		cin >> L[i] >> R[i];
		L[i]--;
		R[i]--;
	}


	vpll pos(H * W);
	for (int h = 0; h < H; h++)
	{
		for (int w = 0; w < W; w++)
		{
			pos[A[h][w]] = { h, w };
		}
	}

	vll ans(H * W);
	for (int i = 0; i < H * W; i++)
	{
		if (i < D)
		{
			ans[i] = 0;
		}
		else
		{
			ans[i] = ans[i - D]+ abs(pos[i - D].first - pos[i].first) + abs(pos[i - D].second - pos[i].second);
		}
	}

	for (int i = 0; i < Q; i++)
	{
		cout << - ans[L[i]] + ans[R[i]] << endl;
	}


}





Measured memory_bytes: 6016
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int N; cin >> N;
    cout << (double)((N+1)/2)/N;
    rn 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;

int main() {
    ll n,m;
    cin>>n>>m;
    ll x[n],y[m];
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    ll sy=0;
    for (int i=1;i<m;i++){
        ll num1=(y[i]-y[i-1])%MOD;
        ll num2=(i*(m-i))%MOD;
        sy+=(num1*num2)%MOD;
        sy%=MOD;
    }
    ll ans=0;
    for (int i=1;i<n;i++){
        ll num1=(x[i]-x[i-1])%MOD;
        ll num2=(i*(n-i))%MOD;
        ll num3=(num1*num2)%MOD;
        ll num4=(num3*sy)%MOD;
        ans+=num4;
        ans%=MOD;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
n = int(input())
life = list(map(int,input().split()))
while len(life) != 1:
    life.sort()
    for i in range(len(life)):
        if life[i] != 0:
            life = life[i:]
            break
    min_life = life[0]
    for j in range(len(life)-1):
        life[j+1] = life[j+1]%min_life
print(life[0])

Measured memory_bytes: 14224
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1

1, 2 and 3

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

int main()
{
  int a=0,b=0; char c;
  for(int i=0;i<3;i++)
  {
    cin>>c;
    if(c=='A') a++;
    else b++;
  }
  if(a==1 || b==1) cout<<"Yes";
  else cout<<"No";
    return 0;
}


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


void show_p(pair<int, int> p) {
  cout << '(' << p.first << ' ' << p.second << ')' << endl;
}

bool check_redundant(vector<pair<int, int>>& v) {
  if (v.size() <= 1) return false;
  for (int i = 0; i < v.size() - 1; i++) {
    if (v[i].first == v[i+1].first) return true;
  }
  return false;
}

void fail() {
  cout << -1 << endl;
  exit(0);
}

int digit(int n) {
  if (n == 0) return 1;
  int cnt = 0;
  while (n) {
    cnt++;
    n /= 10;
  }
  return cnt;
}

int build_number(vector<pair<int, int>>& v, int N) {
  vector<int> dig(N, -1);
  for (auto e : v) {
    dig[e.first] = e.second;
  }
  for (int i = 0; i < N; i++) {
    if (dig[i] == -1) {
      if (i == 0) dig[i] = 1;
      else dig[i] = 0;
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    res *= 10;
    res += dig[i];
  }
  return res;
}

int main() {
  int N, M; cin >> N >> M;
  if (N == 1 && M == 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<pair<int, int>> v;
  for (int i = 0; i < M; i++) {
    int s, c; cin >> s >> c;
    s--;
    v.push_back(make_pair(s, c));
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());

  if(check_redundant(v)) fail();
  int res = build_number(v, N);

  if (digit(res) == N) cout << res << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
function f()
    n,k=map(x->parse(Int,x),split(readline()))
    ni=zeros(Int,n)
    for i = 1:k
        d=readline()
        a=map(x->parse(Int,x),split(readline()))
        for j = 1:length(a)
            ni[a[j]]=1
        end
    end
    sum=0
    for i = 1:n
        if ni[i]==0
            sum += 1
        end        
    end
    print(sum)
end  
f()


Measured memory_bytes: 165932
#include <stdio.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	int n,i,d[3],c;
	scanf("%d",&n);

	rep(i,0,n){
		scanf("%d %d %d",&d[0],&d[1],&d[2]);
		if(d[1]<d[2]){
			c=d[1];
			d[1]=d[2];
			d[2]=c;
		}
		if(d[0]<d[1]){
			c=d[0];
			d[0]=d[1];
			d[1]=c;
		}
		if(d[0]*d[0]-d[1]*d[1]-d[2]*d[2]){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}
	return 0;
}

Measured memory_bytes: 576
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "

using namespace std;
///check n=1;
///check corner case;
pair<ll,ll>check[200000];
int main()
{
    ll n,k;
    cin>>n>>k;
    ll cc=0;
    while(n){
        n/=k;
        cc++;
    }
    cout<<cc<<endl;
return 0;
}





Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())


L = I()
N = L.bit_length()
M = 2*(N-1)
ANS = [[i,i+1,0] for i in range(1,N)] + [[i,i+1,2**(N-1-i)] for i in range(1,N)]

a = 1 << (N-1)
for i in range(N-2,-1,-1):
    if (L >> i) & 1:
        ANS.append([1,N-i,a])
        M += 1
        a += 1 << i

print(N,M)
for i in range(M):
    print(*ANS[i])


Measured memory_bytes: 62416
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
struct edge{
	int from,to,cost;
};
bool  find_negative_loop(vector<edge> &e,int s,int v,vector<ll> &res ){//bellmanford
	res = vector<ll>(v,inf);
	res[s] = 0;
	int E = e.size();
	for(int i=0;i<v;i++){
		for(int j=0;j<E;j++){
			if(res[e[j].from] != inf &&res[e[j].to]  > res[e[j].from] + e[j].cost){
				res[e[j].to] = res[e[j].from] + e[j].cost;
				if(i==v-1)return true;
			}
		}
	}
	return false;
}

int main(){
	int v,E,r;
	cin>>v>>E>>r;
	vector<edge> e(E);
	for(int i=0;i<E;i++){
		cin>>e[i].from>>e[i].to>>e[i].cost;
	}
	vector<ll> res;
	if(find_negative_loop(e,r,v,res)){
		cout<<"NEGATIVE CYCLE"<<endl;
	}else{
		for(int i=0;i<v;i++)if(res[i] == inf){
			cout<<"INF"<<endl;
		}else{
			cout<<res[i]<<endl;
		}
	}

	return 0;
}




Measured memory_bytes: 3124
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    a, b = intin()
    print(a * b - a - b + 1)



if __name__ == '__main__':
    main()


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

int main(){
    int n; cin>>n;
    int sum=0;
    for(int i=1; i<=n; i++){
        int sub = 0;
        for (int x=1; true;x++){
            sum = x*x;
            if(sum > i) break;
            else{
                for (int y=x; true; y++){
                    sum = x*x + y*y + x*y;
                    if(sum >i) break;
                    else{
                        for(int z=y; true; z++){
                            sum = x*x + y*y + x*y + z*z + x*z + y*z;
                            if(sum>i) break;
                            if(sum==i){
                                if(x==y && y==z) sub += 1;
                                else if(x==y || y==z || z==x) sub += 3;
                                else sub += 6;
                            }
                        }
                    }
                }
            }
        }
        cout << sub << endl;
    }
}

Measured memory_bytes: 3576
import java.util.Scanner;

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

        int M = sc.nextInt();

        System.out.println(solve(M));

        sc.close();
    }

    static int solve(int M) {
        return 48 - M;
    }
}

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


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    for a in A:
        n = 1
        while a%(2**n)==0:
            n += 1
        ans += n-1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4084
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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 main() {
  int N, K;
  cin >> N >> K;
  int ans = K;
  for (int i = 0; i < (int)N - 1; ++i) ans *= (K - 1);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll  long long
#define ld long double
#define f first
#define s second
#define matrix vector<vector<char>>
#define zero(n,m) matrix(n , vector<char>(m,'0'))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<int,int>
#define point complex<ld>
#define angle(a) (atan2((a).imag() , (a).real() ))
#define pi acos(-1)
#define X real()
#define Y imag()

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int x;
    cin >> x;
    cout << !x << '\n';

    return 0;
}

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

import heapq
MIN=[]
MAX=[]
ANS=0
SCORE=0

Queries=int(input())
for i in range(Queries):
    Q=list(map(int,input().split()))

    if Q[0]==1:
        ANS+=Q[2]
        heapq.heappush(MIN,Q[1])
        heapq.heappush(MAX,-Q[1])

        if MIN[0]<-MAX[0]:
            x=heapq.heappop(MIN)
            y=-heapq.heappop(MAX)

            SCORE+=(y-x)
            heapq.heappush(MIN,y)
            heapq.heappush(MAX,-x)

    else:
        print(-MAX[0],ANS+SCORE)

Measured memory_bytes: 19036
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;
const long long INF = 1e9;
static int N, A, B, C;
static vector<int> l;

long long dfs(int cur, int a, int b, int c) {
  if (cur == N) {
    if (min({a, b, c}) > 0) {
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    } else {
      return INF;
    }
  }
  long long ret0 = dfs(cur + 1, a, b, c);
  long long ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
  long long ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
  long long ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
  return min({ret0, ret1, ret2, ret3});
}

void solve(int N, int A, int B, int C, vector<int> l) {
  long long ans = dfs(0, 0, 0, 0);
  printf("%lld\n", ans);
}

int main() {
  cin >> N >> A >> B >> C;
  l.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  solve(N, A, B, C, l);
  return 0;
}

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

using namespace std;

int main() {
	Int N, D;
	cin >> N >> D;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		Int x, y;
		cin >> x >> y;
		if (x*x + y*y <= D*D) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
#define LL long long
const int nmax = 40, abmax = 10, inf = 1000000;

int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax * abmax + 1][nmax * abmax + 1];

int main(void){
	int n, ma, mb;
	cin >> n >> ma >> mb;
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i = 0; i <= n; ++i){
		for(int ca = 0; ca <= nmax * abmax; ++ca){
			for(int cb = 0; cb <= nmax * abmax; ++cb){
				dp[i][ca][cb] = inf;
			}
		}
	}
	dp[0][0][0] = 0;
	for(int i = 0; i < n; ++i){
		for(int ca = 0; ca <= nmax * abmax; ++ca){
			for(int cb = 0; cb <= nmax * abmax; ++cb){
				if(dp[i][ca][cb] == inf)	continue;
				dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
				dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}
	int ans = inf;
	for(int ca = 1; ca <= nmax * abmax; ++ca){
		for(int cb = 1; cb <= nmax * abmax; ++cb){
			if(ca * mb == cb * ma)	ans = min(ans, dp[n][ca][cb]);
		}
	}
	if(ans == inf)	ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 25984
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint Q,H,S,D;
    lint N;
    cin >> Q >> H >> S >> D >> N;
    lint A[2];
    A[0]=min3(Q*4,H*2,S),A[1]=D;
    if(A[0]*2<A[1]) cout << N*A[0] << endl;
    else cout << N/2*A[1]+(N%2)*A[0] << endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
A = list(map(int, input().split()))
max_prof = 0
cnt = 0
max_after = [0] * N
max_after[-1] = A[-1]
for i in range(N-1)[::-1]:
    max_after[i] = max(max_after[i+1], A[i])
for i in range(N-1):
    prof = max_after[i+1] - A[i]
    if prof == max_prof:
        cnt += 1
    elif prof > max_prof:
        max_prof = prof
        cnt = 1
print(cnt)


Measured memory_bytes: 62960
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
n = I()
li = LI()
ans = 1
if 0 in li:
  print(0)
else:
  for k in li:
    ans *= k
    if ans > 10**18:
      print(-1)
      break
  else:
    print(ans)

Measured memory_bytes: 21648
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  map<int,int> A,B;
  for(int i=1;i<=N;i++){
    int a;
    cin>>a;
    A[i-a]++;
    B[i+a]++;
  }
  int ans=0;
  for(pair<int,int> p:A)
    ans+=p.second*B[p.first];
  cout<<ans<<endl;
}

Measured memory_bytes: 37724
import Control.Monad
import Control.Applicative
import Data.List

main :: IO ()
main = do
        n <- readLn
        ws <- replicateM n getLine
        let a = foldl solve 0 $ map convert ws
        putStrLn $ if a == 0 then "YES" else "NO"

solve :: Int -> Int -> Int
solve a b = if a + b >= 0
                then a + b
                else -100

convert :: String -> Int
convert s = if s == "A" then 1 else -1

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define MAXN 5050
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, k, a[MAXN], ans = 0;
bool g[MAXN], dp[MAXN][MAXN], vis[MAXN][MAXN];

bool go(int x, int m){
	if(m <= 0) return true;
	if(x >= n) return false;
	if(vis[x][m]) return dp[x][m];
	if(go(x + 1, m - a[x])){
		g[x] = true;
		//cout << x << " " << m << endl;
	} 
	go(x + 1, m);
	vis[x][m] = true;
	return dp[x][m] = go(x + 1, m) or go(x + 1, m - a[x]);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n >> k;
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    go(0, k);
    for(int i = 0; i < n; i++){
    	ans += !g[i];
    }
    cout << ans;
}

Measured memory_bytes: 50048
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


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

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

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

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

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

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

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

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

	Optimizer

--------------------------------------------
*/
//#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*
--------------------------------------------
 
	Utility Algorithm

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

template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}
 
template <typename T1>
T1 euclideanAlgorithm(T1 a, T1 b) {
    T1 a_tmp = a;
    T1 b_tmp = b;
 
    if (a_tmp > b_tmp) {
        swapAlgorithm<T1>(a_tmp, b_tmp);
    }
 
    T1 r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

template <typename T2>
T2 getLCM(T2 a, T2 b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vector<LL> H(N);
    REP(N) cin >> H[i];

    sort(ALL(H));

    LL ans = 0;
    for (int i = 0; i < (N - K) ; i++)
    {
        // cout << "DEBUG " << H[i] << endl;
        ans += H[i];
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a,b;
    cin >> a >> b;
    int c[3] = {a,b,a+b};
    bool ok = 0;
    rep(i,3) if(c[i]%3==0)ok = 1;
    if(ok)cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;
const ll MOD = 1000000007;

int main()
{
  int N; scanf("%d", &N);
  string s, t;
  cin >> s >> t;
  ll ans = (s[0] == t[0]) ? 3 : 6;
  // 0: vertical
  // 1: horizontal
  int prev = (s[0] == t[0]) ? 0 : 1;
  for (int i = prev + 1; i < N; ++i) {
    if (prev == 0) {
      // vertical
      if (s[i] == t[i]) {
        // => vertical
        ans = (ans * 2) % MOD;
      }
      else {
        // => horizontal
        ans = (ans * 2) % MOD;
        prev = 1;
        ++i;
      }
    }
    else {
      // horizontal
      if (s[i] == t[i]) {
        // => vertical
        prev = 0;
      }
      else {
        // => horizontal
        ans = (ans * 3) % MOD;
        ++i;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 384
//Is it a Right Triangle?
#include<bits/stdc++.h>
using namespace std;

//slope:3??°????????§???
bool judge(int slope, int x1, int x2){
  if(pow((double)slope, 2.0)==(pow((double)x1, 2.0)+pow((double)x2, 2.0))) return true;
  else return false;
}

int main(){
  int n, a, b, c;
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%d %d %d", &a, &b, &c);
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end(), greater<int>());
    if(judge(v[0], v[1], v[2]))printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 1192
# coding: utf-8
import collections
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
c = collections.Counter(A)
for i in range(1, N+1):
    if K - Q + c[i] >= 1:
        print('Yes')
    else:
        print('No')

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


int main() {
int a,b,c;
cin >> a >> b >> c;
if (a == b && b == c) cout << 1 << endl;
else if (a == b || b == c || a == c) cout << 2 << endl;
else cout << 3 << endl;

return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ls=len(s)
    a=[0]*(ls+1)
    for i in range(ls):
        if s[i]=='<':
            a[i+1]=a[i]+1
    for j in reversed(range(ls)):
        if s[j]=='>':
            a[j]=max(a[j+1]+1,a[j])
    print(sum(a))
resolve()

Measured memory_bytes: 46320
#include <bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, tot=0;

    cin>>n;

    vector<ll> arr(n);
    for(ll &x: arr){
        cin>>x;
        tot ^= x; 
    }

    for(ll x: arr) cout<<(x^tot)<<" ";
    cout<<endl;
}

Measured memory_bytes: 4732
// -*- coding:utf-8-unix -*-

use proconio::input;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: u64, b: u64, g: u64) -> u64 {
    a / g * b
}

fn main() {
    input! {
        n: u64,
        m: u64,
        s: String,
        t: String,
    }

    let vs: Vec<char> = s.chars().collect();
    let vt: Vec<char> = t.chars().collect();
    let g = gcd(n, m);
    let l = lcm(n, m, g);
    for i in 0..g {
        if vs[(i * (n / g)) as usize] != vt[(i * (m / g)) as usize] {
            println!("-1");
            return;
        }
    }

    println!("{}", l);
}


Measured memory_bytes: 3016
from collections import Counter
n = int(input() )

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


odd = Counter(val for i,val in enumerate(v) if i%2==1)
even =Counter(val for i,val in enumerate(v) if i%2==0)
if odd.most_common(1)[0] != even.most_common(1)[0]:
    print(n-odd.most_common(1)[0][1] - even.most_common(1)[0][1])
else:
    try:
        a = n-odd.most_common(2)[1][1] - even.most_common(1)[0][1]
        b= n-odd.most_common(1)[0][1] - even.most_common(2)[1][1]
        print(min(a,b))
    except IndexError:
        print(n//2)

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

int main(){
    int N, flag=0;
    vector<int> box(9);
    cin >> N;

    for(int i=1; i<10; i++){
        if(N/i < 10 && N%i == 0){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }

ll mh[312345];
ll mw[312345];

int main(){
    ll H=ii(), W=ii(), M=ii();
    set<pii> p;
    REP(i,0,M){
        ll h=ii(), w=ii();
        mh[h]++;
        mw[w]++;
        p.insert(make_pair(h,w));
    }
    ll rh=0;
    ll rw=0;
    vector<ll> kh;
    vector<ll> kw;
    REP(i,0,312345){
        if(rh<mh[i]){
            kh.clear();
        }
        if(rh<=mh[i]){
            kh.push_back(i);
            rh=mh[i];
        }
        if(rw<mw[i]){
            kw.clear();
        }
        if(rw<=mw[i]){
            kw.push_back(i);
            rw=mw[i];
        }
    }
    for(ll h:kh){
        for(ll w:kw){
            if(p.find(make_pair(h,w))==p.end()){
                oie(rh+rw);
                return 0;
            }
        }
    }
    oie(rh+rw-1);

    return 0;
}

Measured memory_bytes: 32972
#include <stdio.h>
int p(int m){
  int i;
  if(m<2) return 0;
  else if(m==2) return 1;

  if(m%2==0) return 0;

  for(i=3;i*i<=m;i+=2){
     if(m%i==0) return 0;
  }
  return 1;
}

int main(){
  int i,cnt,cnt2=0,a;
  scanf("%d",&cnt);
  for(i=0;i<cnt;i++){
    scanf("%d",&a);
    if(p(a)==1) cnt2++;
  }
  printf("%d\n",cnt2);
  return 0;
}

Measured memory_bytes: 596
import java.io.*;

public class Main{

    public static void main(String[] args) {
        String line;
        int x;
        int u;

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {

                       line = reader.readLine();
            x = Integer.parseInt(line);
            u = x * x * x;

            System.out.println(u);

        } catch (IOException e) {
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    int N, K;
    vector<int> h(1000);
    cin >> N >> K;
    int sum = 0;
    int d;
    for(int i=1; i <= N; i++){
        cin >> d;
        if(d >= K) sum++;
    }
    cout << sum << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n;
	cin>>n;
	ll ans=0;

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

	cout<<ans<<endl;

	return 0;
}


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


int main() {
 int h,n;
 cin>>h>>n;
 int a[n];
 int sum=0;
 for(int i=0;i<n;i++){
     cin>>a[i];
     sum+=a[i];
 }
 if(sum>=h){
     cout<<"Yes";
 }
 else{
     cout<<"No";
 }
 
  return 0;
}

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

int main() {
  vector<int64_t> L(3); 
  int N;
  
  cin >> N;
  
  L.at(0) = 2;
  L.at(1) = 1;
  
  
  if(N == 1){
    cout << L.at(N) << endl;
  }
  
  else{
    for(int i = 0; i < N-1; i++){
      L.at(2) = L.at(0) + L.at(1);
      L.at(0) = L.at(1);
      L.at(1) = L.at(2);
    }

    cout << L.at(2) << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

ll gcd(ll a,ll b){
  while(b!=0){
    ll tmp=a;a=b;b=tmp%b;
  }
  return a;
}

int main()
{
  ll a,b;cin>>a>>b;
  cout<<a*b/gcd(a,b)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  ll n, m, x;
  cin >> n;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  map<ll, ll> arr;
  fi(0, n) {
    cin >> x;
    arr[x]++;
  }
  cin >> m;
  fi(0, m) {
    cin >> x;
    if(!arr[x]) {
      cout << "NO\n";
      return 0;
    }
    arr[x]--;
  }
    
  cout << "YES\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 12800
#include <stdio.h>
int main()
{
    int i, A, B, zeiA, zeiB, flag=0;
    
    scanf("%d %d", &A, &B);
    
    for(i=13; i<=1000; i++)
    {
        zeiA = i*0.08;
        zeiB = i*0.1;
        if(zeiA==A&&zeiB==B)
        {
            printf("%d", i);
            return 0;
        }
      else
      {
            flag++;
        }
    }
    
    if(flag)
    {
        printf("-1");
    }
    return 0;
}

Measured memory_bytes: 128
### constant

DELTA = 1e-10

### classes

class Pt
  attr_accessor :x, :y

  def initialize() end
  def initialize(_x, _y) @x = _x; @y = _y end

  def ==(pt) @x == pt.x && @y == pt.y end
  def +(pt) Pt.new(@x + pt.x, @y + pt.y) end
  def -(pt) Pt.new(@x - pt.x, @y - pt.y) end
  def -@() Pt.new(-@x, -@y) end
  def *(t) Pt.new(@x * t, @y * t) end
  def /(t) Pt.new(@x / t, @y / t) end
  def dot(v) @x * v.x + @y * v.y end
  def cross(v) @x * v.y - @y * v.x end
  def d2() @x * @x + @y * @y end
  def d() Math.sqrt(d2()) end
  def normalize() self / d() end
  def to_s() "(#{@x},#{@y})" end
  def to_a() [@x, @y] end
end

### subroutines

def calc_cr(c0, r0, pi, vi, ri, lb, ub)
  ci = rit = nil
  loop do
    t = (lb + ub) / 2
    ci = vi * t + pi
    rit = ri * t
    
    if (ci - c0).d > r0 + rit
      lb = t
    else
      ub = t
    end

    break if ub - lb <= DELTA
  end
  [ci, rit]
end

### main

loop do
  x0, y0, x1, y1, x2, y2 = gets.split.map(&:to_i)
  break if (x0 | y0 | x1 | y1 | x2 | y2) == 0

  pts = [
    Pt.new(x0.to_f, y0.to_f),
    Pt.new(x1.to_f, y1.to_f),
    Pt.new(x2.to_f, y2.to_f)
  ]
  #p pts.map{|pt| pt.to_a}

  ls = (0...3).map{|i| (pts[(i + 2) % 3] - pts[(i + 1) % 3]).d}
  lsum = ls.inject(:+)
  ipt = (0...3).map{|i| pts[i] * ls[i]}.inject(:+) / lsum
  r = (pts[1] - pts[0]).cross(pts[2] - pts[0]) / lsum
  
  divvs = []
  rs = []
  cts = []
  
  for i in (0...3)
    iv = ipt - pts[i]
    ivd = iv.d
    divvs << iv / ivd
    rs << r / iv.d
    cts << ivd
  end
  #p divvs.map{|v| v.to_a}
  #p rs

  lb = 0.0
  ub = cts[0]
  r0 = r1 = r2 = nil
  
  loop do
    t0 = (lb + ub) / 2
    c0 = divvs[0] * t0 + pts[0]
    r0 = rs[0] * t0

    c1, r1 = calc_cr(c0, r0, pts[1], divvs[1], rs[1], 0.0, cts[1])
    c2, r2 = calc_cr(c0, r0, pts[2], divvs[2], rs[2], 0.0, cts[2])

    if (c2 - c1).d2 > (r1 + r2) ** 2
      ub = t0
    else
      lb = t0
    end

    break if ub - lb <= DELTA
  end

  puts [r0, r1, r2].map{|r| "%.6f" % r}.join(' ')
end

Measured memory_bytes: 6160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first

int main()
{
   int n,k,sum=0;
   cin>>n>>k;

   int arr[n];

   for(int i=0;i<n;i++)
    cin>>arr[i];

   sort(arr,arr+n);

   for(int i=0;i<k;i++)
    sum+=arr[i];

    cout<<sum;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
  double X;
  cin >> X;
  long long Y=0;
  double val=100;
  while(val<X)
  {
	  val *= 1.01;
	  val = floor(val);
	  Y++;
  }
  cout << Y << endl;
}


Measured memory_bytes: 3720
n = input()

k = len(n)
n = int(n)
ans = n
for i in range(1, k+1):
    if i % 2 == 0:
        if 10 ** i > n:
            ans -= (n + 1) - 10**(i-1)
        else:
            ans -= 10**i - 10**(i-1)

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dp[205005]={0};
ll ans,n,k;
ll a[205005]={0};
int main()
{
	ll i,j,x,y,t;
	cin>>n>>k;
	for(i=1+k;i<=n+k;i++)
	cin>>a[i];
	for(i=0;i<=k;i++)
	{
		a[i]=a[1+k];
	}
	for(i=2+k;i<=n+k;i++)
	{
		dp[i]=2*100000*10005;
		for(j=1;j<=k;j++)
		{
			t=dp[i];
			dp[i]=min(dp[i],(dp[i-j]+abs(a[i]-a[i-j])));
		}
	}
	cout<<dp[n+k];
	return 0;
}


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

int n;
vector<int> a;
vector<bool> seen;
int d;

void dfs(int k, int &d){
    seen[k] = true;
    if(k == 1) return;
    if(!seen[a[k]]) dfs(a[k], ++d);
}

int main(void){
    cin >> n;
    a = vector<int>(n);
    seen = vector<bool>(n, false);
    for(int i = 0; i < n; i++){
        int ai;
        cin >> ai;
        a[i] = ai-1;
    }
    d = 0;
    dfs(0, d);
    if(seen[1]) cout << d << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3768