akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
  public static void main(String[] args)  {
    Scanner sc = new Scanner(System.in);
    String ABCD = sc.next();
    int a = Integer.parseInt(ABCD.substring(0, 1));
    int b = Integer.parseInt(ABCD.substring(1, 2));
    int c = Integer.parseInt(ABCD.substring(2, 3));
    int d = Integer.parseInt(ABCD.substring(3, 4));
    
    if (a + b + c + d == 7) {
			System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
			return;
		}
		if (a + b + c - d == 7) {
			System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
			return;
		}
		if (a + b - c + d == 7) {
			System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
			return;
		}
		if (a + b - c - d == 7) {
			System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
			return;
		}
		if (a - b + c + d == 7) {
			System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
			return;
		}
		if (a - b + c - d == 7) {
			System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
			return;
		}
		if (a - b - c + d == 7) {
			System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
			return;
		}
		if (a - b - c - d == 7) {
			System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
			return;
		}
	}
}

Measured memory_bytes: 39548
dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
field = []
H, W = 0, 0
stack = []

def solver(x, y, symbol):
  global stack, field, H, W
  while True:
    if x < 0 or y < 0 or x >= H or y >= W:
      continue
    for dx, dy in dxy:
      if x+dx < 0 or y+dy < 0 or x+dx >= H or y+dy >= W:
        continue
      if field[x+dx][y+dy] == symbol:
        field[x+dx][y+dy] = '.'
        stack.append([x+dx, y+dy])
    if len(stack) == 0:
      return
    x, y = stack.pop()

while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  field = [list(raw_input()) for i in range(H)]

  ans = 0
  for x in xrange(H):
    for y in xrange(W):
      if field[x][y] != '.':
        solver(x, y, field[x][y])
        ans += 1
  print ans

Measured memory_bytes: 7024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	map<int, int> a;

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

	if (a.size() > k)
	{
		//sort(a.begin(), a.end());

		int w = a.size() - k;
		
		vector<int> b(a.size());
		int i = 0;
		for (map<int, int>::iterator it = a.begin(); it != a.end(); it++)
		{
			pair<int, int> p = *it;
			b.at(i) = p.second;
			i++;
		}

		sort(b.begin(), b.end());
		cout << accumulate(b.begin(), b.begin() + w, 0) << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

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

using namespace std;

#define PI acos(-1)

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	double r ; 
	cin >> r ; 
	cout << (r * 2 * PI) ; 
	
}



Measured memory_bytes: 3804
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] H = new int[N];
        for(int i = 0; i < N; i++) {
            H[i] = scanner.nextInt();
        }
        if(N==1){
            System.out.println("Yes");
            return;
        }

        for(int i = N-1; i > 0; i--) {
            if(H[i] == H[i-1]){
                continue;
            }else if(H[i] > H[i-1]){
                continue;
            }else if(H[i] + 1 == H[i-1]){
                H[i-1]--;
            }else{
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 50232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
  int n,m,x,p=0,q=0;
  cin>>n>>m>>x;
  vector<int> v(n),a(m);
  rep(i,n) v[i]=0;
  rep(i,m){
    cin>>a[i];
    v[a[i]-1]=1;
  }
  for(int i=0;i<x;i++){
    if(v[i]==1) p++;
  }
  for(int i=x;i<=n;i++){
    if(v[i]==1) q++;
  }
  cout<<min(p,q)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(int n);
int main()
{
	int n;
	int sum=0;
	cin >> n ;
	for(int i=1;i<=n;i++){
		if(check(i)) sum++;
	}
	printf("%d\n",sum);
	return 0;
}
bool check(int n)
{
	int s=0;
	while(n){
		n=n/10;
		s++;
	}
	if(s % 2 != 0) return true;
	else return false;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
using ll=long long;
map<ll,int> mp;
int main(){
    int N;cin>>N;
    for(int i{};i<N;++i){
        ll A;cin>>A;
        ++mp[A];
    }
    ll a[2]={},i{};
    for(auto p{mp.rbegin()};p!=mp.rend();++p)
        if(p->second>=2){
            a[i]=p->first;++i;
            if(i>1)break;
            if(p->second>=4){a[i]=p->first;break;}
        }
    cout<<a[0]*a[1]<<endl;
}


Measured memory_bytes: 6528
my $N = <STDIN>;
chomp($N);
my (@X, @Y);
while (my $line = <STDIN>) {
    chomp($line);
    my ($x, $y) = split(" ", $line);
    push(@X, $x);
    push(@Y, $y);
}
my $N1 = $N - 1;
my $tot = 0;
foreach my $i (0..$N1) {
    foreach my $j (($i+1)..$N1) {
        my $tmp = ($X[$i] - $X[$j])**2 + ($Y[$i] - $Y[$j])**2;
        $tot += sqrt($tmp);
    }
}
$tot = 2*$tot/$N;
print $tot;

Measured memory_bytes: 512
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define RREP(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define ALL(vector) vector.begin(), vector.end()
//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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    vector<ll> v;
    ll K;
    cin>>S>>K;
    ll lim = 310;
    if(K >= lim) K = lim - 1;
    ll cnt = 0;
    for(auto x: S){
        if(x=='1'){
            cnt += 1;
        }else{
            v.push_back(cnt);
            cnt=0;
        }
    }
    if(cnt!=0){
        v.push_back(cnt);
    }
    vector<mint> dp(lim*lim*lim,0);//dp[i*lim*lim+j*lim+k];
    //if i == 0 then dp == 1
    REP(j, lim){
        REP(k,lim){
            ll i = 0;
            dp[i*lim*lim+j*lim+k]=1;
        }
    }
    ll vsz = v.size();

    vector<mint> sum(lim+1,0);
    REP(i,vsz){
        if (i==0) continue;

        REP(k, lim){
            REP(j,lim){
                sum[j+1] = sum[j] + dp[(i-1)*lim*lim+j*lim+k];
            }
            REP(j,lim){
                REP(jd, v[i]+1){
                    if (jd == 0) continue;
                    if (k-jd < 0) break;
                    if (j+jd >= lim) break;
                    dp[i*lim*lim+j*lim+k] += dp[(i-1)*lim*lim+(j+jd)*lim+(k-jd)];
                }
                dp[i*lim*lim+j*lim+k] += sum[j+1];
                // REP(jd, j+1){
                //     dp[i*lim*lim+j*lim+k] += dp[(i-1)*lim*lim+(j-jd)*lim+k];
                // }
            }
        }
    }
    mint ans = dp[(vsz-1)*lim*lim+0*lim+K];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 236040
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;};

int main() {
    int a,b,c;
    cin >> a>>b>>c;
    cout << min({a+b,b+c,c+a}) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;
const int maxn = 2e5 + 5;
int n, a[maxn];
ll ans = 0;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", a + i);
        if (a[i - 1] > a[i]) {
            ans += (a[i - 1] - a[i]);
            a[i] = a[i - 1];
        }
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2508
A=list(input())
B=list(input())
C=list()
if len(A)==len(B):
  for i in range(len(A)):
    C.append(A[i]+B[i])
  print(''.join(C))
else:
  for i in range(len(B)):
    C.append(A[i]+B[i])
  C.append(A[-1])
  print(''.join(C))

Measured memory_bytes: 3060
N = int(input())
a = list(map(int,input().split()))
ans = 0
def keta2(n):
    count = 0
    while(1):
        if n % 2 == 0:
            count += 1
            n = n //2
        else:
            break
    return count

for i in range(N):
    if a[i] % 2 == 0:
        ans += keta2(a[i])
print(ans)


Measured memory_bytes: 4148
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n := nextInt()
	mx := math.MinInt32
	mn := math.MaxInt32

	for i := 0; i < n; i++ {
		a := nextInt()
		mn = min(mn, a)
		mx = max(mx, a)
	}
	fmt.Println(mx - mn)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n, k;
  cin >> n >> k;
  int x = 1;
  REP(i,n){
    int xa = x * 2;
    int xb = x + k;
    x = min(xa,xb);
  }

  cout << x << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	static boolean flag = false;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int j = 0; j < n; j++) {
			int[] b = new int[10];
			flag = false;
			for(int i = 0; i < 10; i++) {
				b[i] = sc.nextInt();
			}
			dfs(0, 0, 0, b);
			if(flag) {
				//System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
		sc.close();
	}
	static void dfs(int n, int l, int r, int[] b) {
		if(n == 10) {
			flag = true;
			System.out.println("YES");
			return;
		}
		if(l < b[n] && !flag) {
			dfs(n + 1, b[n], r, b);
		}
		if(r < b[n] && !flag) {
			dfs(n + 1, l, b[n], b);
		}
		return;
	}
}


Measured memory_bytes: 26260
#include<iostream>
#include<queue>
static const int N = 100;
static const int INFTY = (1 << 21);
using namespace std;

int n, M[N][N],d[N];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; i++)d[i] = INFTY;
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front(); q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0) continue;
			if (d[v] != INFTY)continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " "<<((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}

int main()
{
	int u, k, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	bfs(0);

    return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<lint> a(n), b(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
        b[a[i]] = i;
    }
    set<lint> st;
    st.insert(-1);
    st.insert(n);
    lint ans = 0;
    rep(i, n){
        auto it = st.lower_bound(b[i]);
        lint right = *it;
        it--;
        lint left = *it;
        ans += (right - b[i]) * (b[i] - left) * (i + 1);
        st.insert(b[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
// Vicfred
// https://atcoder.jp/contests/abc164/tasks/abc164_b
// simulation
import std.stdio;

void main() {
    int a, b, c, d;
    readf("%s %s %s %s\n", &a, &b, &c, &d);

    int step = 1;
    while(a > 0 && c > 0) {
        if(step%2 == 1)
            c -= b;
        else
            a -= d;
        step += 1;
    }

    if(step%2 == 1) {
        "No".writeln;
    }
    else {
        "Yes".writeln;
    }
}



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

using namespace std;

int a[10000001];

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    long long sum = 0, sum1 = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i < n - 1) {
            sum+=a[i];
        } else {
            sum1+=a[i];
        }
    }
    long long ans = abs(sum-sum1);
    for (int i = n-2; i > 0; --i) {
        sum1+=a[i];
        sum-=a[i];
        ans = min (ans, abs(sum - sum1));
    }
    cout << ans << endl;
    return 0;
}


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


int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int acount=0;
    int bcount=0;
    while(a>0){
        a=a-d;
        acount++;
    }
    while(c>0){
        c=c-b;
        bcount++;
    }
    if(acount>=bcount){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ret = (N // K) ** 3
    if K % 2 == 0:
        tmp = K // 2
        count = 1 + (N - tmp) // K
        ret += count ** 3
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
	
	int N,a[110];
	cin >> N ;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	
	sort(a, a + N, greater<int>());
	
	int Alice=0;
	int Bob=0;
	
	for(int i=0;i<N;i++){
		if(i%2 == 0){
			Alice += a[i];
		}
		else{
			Bob += a[i];
		}
	}
	
	cout << Alice - Bob << endl;
	
	return 0;
}


Measured memory_bytes: 3168
package main

import "fmt"

func intsCopy(a []int) []int { return append([]int(nil), a...) }

func main() {
	var h, w, k int
	fmt.Scan(&h, &w, &k)
	s := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
	}

	ans := make([][]int, h)
	for i := 0; i < h; i++ {
		ans[i] = make([]int, w)
	}

	num := 1
	for i := 0; i < h; i++ {
		rightmostBerry := -1
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				rightmostBerry = j
			}
		}
		if rightmostBerry == -1 {
			continue
		}
		for j := 0; j < w; j++ {
			ans[i][j] = num
			if s[i][j] == '#' && j != rightmostBerry {
				num++
			}
		}
		num++
	}

	for i := 0; i < h; i++ {
		if ans[i][0] != 0 {
			continue
		}
		idx := -1
		for j := i; j < h; j++ {
			if ans[j][0] != 0 {
				idx = j
				break
			}
		}
		if idx == -1 {
			continue
		}
		ans[i] = intsCopy(ans[idx])
	}
	for i := h - 1; i >= 0; i-- {
		if ans[i][0] != 0 {
			continue
		}
		idx := -1
		for j := i; j >= 0; j-- {
			if ans[j][0] != 0 {
				idx = j
				break
			}
		}
		if idx == -1 {
			continue
		}
		ans[i] = intsCopy(ans[idx])
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if j != w-1 {
				fmt.Printf("%d ", ans[i][j])
			} else {
				fmt.Printf("%d\n", ans[i][j])
			}
		}
	}
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int res = 1;
  rep(i, n){
    if(res < k) res += res;
    else res += k;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
int main()
{
    char b[50001];
    char c[100001];
    int i,n;
    scanf("%s",c);
    for(i=0;i<50000;i++)
    {
          b[i]=c[i*2];
    }
    printf("%s",b);
 return 0;
 }


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
const int MOD = 1000000007;
bool custom(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  int ans = 0;
  rep(a, min(n, k)+1) {
    rep(b, min(n, k)-a+1) {
      int total = 0;
      vector<int> minus;
      rep(i, a) {
        total += v[i];
        if(v[i] < 0) minus.emplace_back(v[i]);
      }
      rep(i, b) {
        total += v[n-i-1];
        if(v[n-i-1] < 0) minus.emplace_back(v[n-i-1]);
      }
      int s = minus.size();
      sort(minus.begin(), minus.end());
      rep(i, min(k-a-b, s)) {
        total -= minus[i];
      }
      if(total > ans) ans = total;
    }
  }
  cout << ans << endl;
}




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

class Triangle{
private:
	int a, b, c;
public:
	void Set();
	bool Jugde();
};

void Triangle::Set(){
	cin >> a >> b >> c;
}

bool Triangle::Jugde(){
	int buf;
	if(a < b){
		buf = a;
		a = b;
		b = buf;
	}
	if(a < c){
		buf = a;
		a = c;
		c = buf;
	}
	if(a*a == b*b + c*c) return true;
	else return false;
}

int main(){

	int n;
	bool jugde;
	Triangle* dataset;

	cin >> n;

	dataset = new Triangle[n];

	for(int i = 0; i < n; i++)
		dataset[i].Set();

	for(int i = 0; i < n; i++){
		jugde = dataset[i].Jugde();
		if(jugde == true)
			cout << "YES" << "\n";
		else
			cout << "NO" << "\n";
	}

	return 0;
}

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

#define int 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 (b<a) { a=b; return 1; } return 0; }

int f(int h){
	if(h == 0) return 0;
	int ans = 1;
	ans += f(h/2)*2;
	return ans;
}

signed main(){
	int h;
	cin >> h;

	cout << f(h) << endl;

	return 0;
}


Measured memory_bytes: 256
import math
a, b, c = map(int,input().split())
S = a*b*math.sin(math.radians(c))/2
L = a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c)))
h = b*math.sin(math.radians(c))
print(S)
print(L)
print(h)


Measured memory_bytes: 5708
import numpy

a, b, x = map(int, input().split())
if a * b / 2 < x / a:
    theta = numpy.arctan(2 * (b / a - x / a ** 3))
else:
    theta = numpy.arctan(a * b ** 2 / 2 / x)

theta = numpy.rad2deg(theta)
print(theta)


Measured memory_bytes: 27128
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    cout<<n*n<<'\n';
}


Measured memory_bytes: 256
package main

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

func main() {
	var (
		n, q int
		s    string
	)
	fmt.Scan(&n, &q, &s)
	xs := make([]int, n)
	var sum int
	for i := range s[:len(xs)-1] {
		if s[i] == 'A' && s[i+1] == 'C' {
			sum++
		}
		xs[i+1] = sum
	}

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var l, r int
	for i := 0; i < q; i++ {
		sc.Scan()
		l, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ = strconv.Atoi(sc.Text())
		fmt.Println(xs[r-1] - xs[l-1])
	}
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    int d = N % 10;

    if (d == 3)
        cout << "bon\n";
    else if (d == 0 or d == 1 or d == 6 or d == 8)
        cout << "pon\n";
    else
        cout << "hon\n";

    return 0;
}


Measured memory_bytes: 3652
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a--, c--;
	if (c / b <= a / d) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 3648
s=input()
n=int(input())
q=[]
for _ in range(n):
  q.append(input().split())
sw=True #奇数回文字列の前後を入れ替えているときFalseになる
sl=''
sr=''
for i in range(n):
  if q[i][0]=='1':
    sw = not sw
  else:
    if q[i][1]=='1' and sw==True:
      sl += q[i][2]
    elif q[i][1]=='2' and sw==False:
      sl += q[i][2]
    else:
      sr +=q[i][2]

ans=''
if sw:
  for i in range(len(sl)):
    ans+=sl[len(sl)-1-i]
  print(ans+s+sr)
else:
  for i in range(len(sr)):
    ans+=sr[len(sr)-1-i]
  for i in range(len(s)):
    ans+=s[len(s)-1-i]
  print(ans+sl)


Measured memory_bytes: 40564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

#define SZ(v) ((int) (v).size())
#define ALL(v) (v).begin(), (v).end()

#define vec Vect<T>
#define cvec const vec&
template<typename T> struct Vect { T x, y;
  vec(): x(0), y(0) {}
  vec(T a, T b): x(a), y(b) {};
  template<class D>
  explicit vec(const Vect<D>& v): x(v.x), y(v.y) {};
  vec operator+(const vec& v) const {return vec(x+v.x, y+v.y);}
  vec operator-(const vec& v) const {return vec(x-v.x, y-v.y);}
  vec operator*(T s) const { return vec(x*s, y*s); }
  vec operator/(T s) const { return vec(x/s, y/s); }
  T dot(const vec& v) const { return x * v.x + y * v.y; }
  T cross(const vec& v) const { return x * v.y - y * v.x; }
  T norm() const { return hypot(x, y); }
  vec unit() const { return *this / norm(); }
  vec rotCCW(T ang) const {
    return vec(x*cos(ang) - y*sin(ang), x*sin(ang) + y*cos(ang));
  }
  ll mdis(const vec& v) const {
    return llabs(x - v.x) + llabs(y - v.y);
  }
};

using Vec = Vect<ll>;
inline ll LESS(ll a, ll b) { return a < b; }
bool CCW(Vec a, Vec b, Vec c) { return LESS(0, (b-a).cross(c-b)); }
bool CW(Vec a, Vec b, Vec c) { return LESS((b-a).cross(c-b), 0); }
bool cmp(const Vec& a, const Vec& b) { return LESS(a.x - b.x, 0); }
void ConvexHull(vector<Vec> &pts) {
  sort(ALL(pts), cmp);
  vector<Vec> up, dn;
  for (auto &p: pts) {
    while (SZ(up) > 1 && !CW(up[SZ(up) - 2], up.back(), p))
      up.pop_back();
    while (SZ(dn) > 1 && !CCW(dn[SZ(dn) - 2], dn.back(), p))
      dn.pop_back();
    up.push_back(p);
    dn.push_back(p);
  }
  pts = dn;
  for (int i = SZ(up) - 2; i >= 1; i--) pts.push_back(up[i]);
}


int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
//  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  vector<Vec> pts(n);
  for (auto& p: pts) {
    cin >> p.x >> p.y;
  }
  ConvexHull(pts);

  if (pts.size() <= 10u) {
    ll ans = 0;
    for (auto p1: pts) {
      for (auto p2: pts) {
        ans = max(ans, p1.mdis(p2));
      }
    }
    cout << ans << endl;
    return 0;
  }

  ll ans = 0;
  n = pts.size();
  for (int i = 0, j = 0; i < n; i++) {
    while (true) {
      int jj = (j + 1) % n;
      if (pts[i].mdis(pts[j]) < pts[i].mdis(pts[jj]))
        j = jj;
      else
        break;
    }
    ans = max(ans, pts[i].mdis(pts[j]));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6312
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i,d,s,ans = 0;cin >> n >> k;
  bool a[n] = {};
  while(cin >> d){
    for(i=0;i<d;i++){
      cin >> s;a[s-1] = 1;
    }
  }
  for(i=0;i<n;i++) ans += !a[i];
  cout << ans << endl;
}


Measured memory_bytes: 3636
import math
 
N, M = map(int, input().split())
broken_a = [0] * (N + 1)
for _ in range(M):
  broken_a[int(input())] = 1

dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
  if broken_a[i]:
    dp[i] = 0
    continue
  if i == 1:
    dp[i] = dp[i - 1] % 1000000007
  else:
  	dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007

print(dp[N])

Measured memory_bytes: 7668
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long
int i,j,k;
struct cake{
	LL A,B,C;
}cak[1005];
bool cmp(cake a,cake b)
{
	return a.A*i+a.B*j+a.C*k>b.A*i+b.B*j+b.C*k;
}
int main()
{
	LL n,m,ans=0;
	cin>>n>>m;
	for(i=0;i<n;i++)
	scanf("%lld%lld%lld",&cak[i].A,&cak[i].B,&cak[i].C);
	for(i=-1;i<=1;i+=2)
	{
		for(j=-1;j<=1;j+=2)
		{
			for(k=-1;k<=1;k+=2)
			{
				sort(cak,cak+n,cmp);
				LL s[3]={0,0,0};
				for(int l=0;l<m;l++)
				s[0]+=cak[l].A ,s[1]+=cak[l].B ,s[2]+=cak[l].C ;
				ans=max(ans,s[0]*i+s[1]*j+s[2]*k);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
let () = Scanf.scanf "%d %d" @@ fun k x ->
  let left = max (-1000000) (x - k + 1) in
  let right = min 1000000 (x + k -1) in
  Printf.printf "%d" left;
  for i = (left + 1) to right do
    Printf.printf " %d" i
  done;

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
 
const int mn = 2e5 + 5;
int n;
 
int a[mn];
int d[mn];
int p[mn];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),p[a[i]]=i,d[i]=1;
	int ans=1;
	for(int i=1;i<n;i++){
		if (p[i+1]>p[i]) d[i+1]=max(d[i]+1,d[i+1]),ans=max(ans,d[i+1]);
	}
	printf("%d\n",n-ans);
	return 0;
}

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

int main() {
    int A, B;
    cin >> A;
    cin >> B;
    //cout << A;
    //cout << B;
    if (A % 3 == 0) cout << "Possible" << endl;
    else if (B % 3 == 0) cout << "Possible" << endl;
    else if ((A+B) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


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

using namespace std;

int main()
{
	unsigned long long ans = 0;
	unsigned long long a, b, x;
	cin >> a >> b >> x;
	if(	a == 0 ) {
	 	ans++;	
	}
	ans += (b / x);
	ans -= (a / x);
	if(a != 0 && (a % x == 0)) 
		ans++;

   	cout << ans << endl;

	return 0;
}	

Measured memory_bytes: 256
//Twitter@KonoLv1 2020年春卒で現在就職活動中！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count1,count2,count;   //  カウント用に使用
    int box[10000] = {};
    double box2[10000] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列
    int a,b,c;
    a = b = c = i = 0;
    int mode = 0;
    int max = 0;
    double ans = 0;
    count = count1 = count2 = 0;
    int sum = 0;
    double sum2 = 0;
 
    //  入力処理
    
    scanf("%d",&a);

    for(i = 0; i < a; i++){
        scanf("%d",&box[i]);
        if (max < box[i]){
            max = box[i];
        }
        sum = sum + box[i];
    }



 

    //  計算処理
    for(i = 0; i < a; i++){
        box2[i] = (double)sum / (double)box[i];
        sum2 = sum2 + box2[i];
    }
    
    ans = (double)sum / sum2;
    //  出力処理
 
    if (a == 1){
        printf("%d",box[0]);
    }else{
        printf("%8.14lf",ans);
    }
 
 
}

Measured memory_bytes: 256
//1_2_C ??????????????????3.5
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>

struct card{
	char type;
	int num;
};

//spap??¢??°
void swap(card *a,card *b){
	card temp=*a;
	*a=*b;
	*b=temp;
	return ;
}

//???????????????????????¢??°
int printCardArray(card data[],int num){
	int i;
	for(i=0;i<num;i++){
		if(i!=0)printf(" ");
		printf("%c%d",data[i].type,data[i].num);
	}
	printf("\n");
	return 0;
}
//??????????????????
void bubble(card A[],int n){
	int i,j,k,count=0,flag=1;
	for(j=0;flag;j++){
		flag=0;
		for(i=n-1;i>=j+1;i--){
			if(A[i].num<A[i-1].num){
				swap(&A[i],&A[i-1]);	//??????
				count++;
				flag=1;
			}
			//printArray(A,n);
		}
	}
	return;
}

//???????????????
void selection(card A[],int n){
	int i,j,k,count=0;
	int min,minI;
	//?????????
	for(j=0;j<n-1;j++){
		minI=j;
		for(i=j;i<n;i++){
			if(A[i].num<A[minI].num){
				minI=i;
			}
		}
		swap(&A[j],&A[minI]);	//??????
		if(A[j].num!=A[minI].num)count++;
		//printArray(A,n);
	}
	return;
}
void checkStable(card A1[],card A2[],int n){
	for(int i=0;i<n;i++){
		if(A1[i].type!=A2[i].type){
			std::cout<<"Not stable"<<std::endl;
			return;
		}
	}
	std::cout<<"Stable"<<std::endl;
	return ;
}

int main(){
	int n;
	card A1[37];
	card A2[37];
	
	scanf("%d",&n);
	//??\???
	for(int i=0;i<n;i++){
		std::cin>>A1[i].type>>A1[i].num;
	}
	for(int i=0;i<n;i++)A2[i]=A1[i];	//?§?????????????????????????
	
	bubble(A1,n);
	selection(A2,n);
	
	printCardArray(A1,n);
	std::cout<<"Stable"<<std::endl;
	
	printCardArray(A2,n);
	checkStable(A1,A2,n);
	
	return 0;
}

Measured memory_bytes: 3164
module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";var n=e(1);e(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,r){t.exports=require("fs")},function(t,r,e){"use strict";var n=e(3),i=e(5);t.exports=function(t){var r=new n(t);i(r)}},function(t,r,e){"use strict";var n=e(4);t.exports=class{constructor(t){var r=t.trim().split(/\s+/g);this.inp=new n(r)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,r,e){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,r,e){"use strict";var n=e(6).FindArticulationPoints;t.exports=function(t){for(var r=t.in(),e=t.in(),i=new Array(r),o=0;o<r;o++)i[o]=[];for(var s=0;s<e;s++){var u=t.in(),f=t.in();i[u].push(f),i[f].push(u)}for(var a=n(i),c=0;c<r;c++)1==a[c]&&console.log(c)}},function(t,r,e){"use strict";t.exports={FindArticulationPoints:function(t){for(var r=t.length,e=new Array(r).fill(-1),n=new Array(r).fill(-1),i=new Array(r).fill(0),o=[{v:0,p:-1}],s=[],u=0;o.length>0;){var f=o.pop();-1==e[f.v]?(-1!=f.p&&s.push({from:f.p,to:f.v,isF:!0}),e[f.v]=u++,n[f.v]=e[f.v]):s.push({from:f.v,to:f.p,isF:!1});for(var a=t[f.v].length,c=0;c<a;c++){var l=t[f.v][c];-1==e[l]&&o.push({v:l,p:f.v})}}for(var p=0;s.length>0;){var v=s.pop();v.isF?(0==v.from&&p++,n[v.from]=Math.min(n[v.from],n[v.to]),0!=v.from&&e[v.from]<=n[v.to]&&(i[v.from]=1)):n[v.from]=Math.min(n[v.from],e[v.to])}return p>1&&(i[0]=1),i}}}]);


Measured memory_bytes: 35124
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")

    };
}

fn main() {
    input! {
        a: i64,
        p: i64,
    }
    let k = a * 3 + p;
    let ans = k / 2;
    println!("{}", ans);
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cerr <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}


using namespace std;

int main() {
	make(a);
	cout << 48-a  << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
ll n,k;
cin>>n>>k;
ll ans=0;
if(k%2==0){
    ll t=n/k;
    ans+=t*t*t;
    ll p=n/(k/2)-t;
    ans+=p*p*p;
    cout<<ans<<endl;
}
else{
    ll t=n/k;
    cout<<t*t*t<<endl;
}
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n;
	map<string, int> ss;
	for(i=0;i<n;i++) {
		cin >> s;
		sort(s.begin(),s.end());
		ss[s]++;
	}

	for(auto p : ss) {
		ll cnt = p.second;
		ans += cnt*(cnt-1)/2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int ans = 1;
	rep(i, a) {
		if (i == 0) {
			ans *= b;
		}
		else {
			ans *= b - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
st = [list(map(str,input().split())) for _ in range(n)]
x = input()
ch = 0
for i in range(n):
    if ch == 1:
        cnt += int(st[i][1])
    if st[i][0] == x:
        ch = 1
print(cnt)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n,i=0,j=0,m=1,s;
  cin>>h>>w>>n;
  vector<vector<int>> a;
  a.resize(h);
  for(int k=0;k<h;k++){
    a[k].resize(w);
  }
  for(int k=0;k<n;k++){
    cin>>s;
    for(int l=0;l<s;l++){
      a[i][j]=m;
      j++;
      if(j==w){
        i++;
        j=0;
      }
    }
    m++;
  }
  for(int k=1;k<h;k+=2){
    reverse(a[k].begin(),a[k].end());
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	vector<long long> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}

	long long ans = LLONG_MAX;
	for (int bit = 0;bit < (1 << n);bit++) {

		long long max = a[0];
		long long tmp = 0;
		int count = 1;
		for (int i = 1;i < n;i++) {
			if (bit & (1 << i)) {
				if (max >= a[i]) {
					tmp += max + 1 - a[i];
					max++;
					count++;
				}
			}
			if (max < a[i]) {
				max = a[i];
				count++;
			}
		}

		if (count >= k) {
			if (ans > tmp) ans = tmp;
		}
	}

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


Measured memory_bytes: 3564
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
char str[17][17];
int dx[]={-1,-1,-1,0,0,0,1,1,1};
int dy[]={-1,0,1,-1,0,1,-1,0,1};
int v[17][17];
int u[17][17];
int row[310];
int col[310];
int sz;
int n,m;
struct wolf{
	long long t;
	int s;
	wolf(){t=0;s=0;}
};
inline bool operator<(const wolf&a,const wolf&b){
	if(a.t!=b.t)return a.t<b.t;
	return a.s<b.s;
}
long long pow10[19];
inline int ABS(int a){return max(a,-a);}
int ret=99999999;
int id;
int ir[20];
int ic[20];
map<wolf,int>dp;
int solve(int a,wolf b){
	if(dp.count(b))return dp[b];
//	printf("%d %lld %d\n",a,b.t,c);
	bool dame=false;
	for(int i=0;i<id;i++){
		int cnt=0;
		for(int j=a;j<sz;j++){
			if(ABS(ir[i]-row[j])<=1&&ABS(ic[i]-col[j])<=1)cnt++;
		}
		if(cnt<b.t%pow10[i+1]/pow10[i]){dame=true;break;}
	}
	if(dame){
		return dp[b]=99999999;
	}
	if(a==sz){
		return dp[b]=0;
	}
	int ret=99999999;
	
	b.s++;
	bool ok=true;
	for(int i=0;i<id;i++){
		if(ABS(ir[i]-row[a])<=1&&ABS(ic[i]-col[a])<=1&&b.t%pow10[i+1]/pow10[i]==0)ok=false;
	}
	//printf("%d %lld %d %d\n",a,b.t,ok,c);
	if(ok){
		for(int i=0;i<id;i++){
			if(ABS(ir[i]-row[a])<=1&&ABS(ic[i]-col[a])<=1)b.t-=pow10[i];
		}
		ret=min(ret,solve(a+1,b)+1);
		for(int i=0;i<id;i++){
			if(ABS(ir[i]-row[a])<=1&&ABS(ic[i]-col[a])<=1)b.t+=pow10[i];
		}	
	}
	ret=min(ret,solve(a+1,b));
	b.s--;
	return dp[b]=ret;
}
int main(){
	int a,b;
	pow10[0]=1;
	for(int i=1;i<19;i++)pow10[i]=pow10[i-1]*10;
	while(scanf("%d%d",&a,&b),a){
		n=a;m=b;
		id=0;
		sz=0;
		dp.clear();
		ret=99999999;
		wolf st;
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)v[i][j]=u[i][j]=0;
		//for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(str[i][j]=='.')v[i][j]=-1;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if('0'<=str[i][j]&&str[i][j]<='9'){
					ir[id]=i;
					ic[id++]=j;
					st.t+=pow10[id-1]*(str[i][j]-'0');
					v[i][j]=str[i][j]-'0';
					for(int k=0;k<9;k++){
						if(0<=i+dx[k]&&i+dx[k]<a&&0<=j+dy[k]&&j+dy[k]<b&&str[i+dx[k]][j+dy[k]]!='.'){
							u[i+dx[k]][j+dy[k]]++;
						}
					}
				}
			}
		}
	//	for(int k=1;k<=9;k++)
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(u[i][j]){
			row[sz]=i;col[sz++]=j;
		}
		printf("%d\n",solve(0,st));
	}
}

Measured memory_bytes: 2124
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;


ll dp[100];

int main()
{
	dp[0] = 2;
	dp[1] = 1;
	
	for(int i = 2;i < 87;i++)
	{
		dp[i] = dp[i-1] + dp[i-2];
	}
	
	int n;cin >> n;
	
	cout << dp[n] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int A,B,K;
	cin >> A >> B >> K;
	int count = 0;
	int answer;
	for(int i = 100;i > 0;i--) {
		if(A % i == 0 &&B % i == 0) {
			count++;
		}
		if(count == K) {
			answer = i;
			break;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif




void solve() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll cost = 0;
    if (C * 2 < A + B) {
        ll m = min(X, Y);
        cost += m * C * 2;
        X -= m;
        Y -= m;
    }
    if (C * 2 < A) {
        cost += C * 2 * X;
        Y -= X;
        X = 0;
    }
    if ( Y > 0 && C * 2 < B) {
        cost += C * 2 * Y;
        X -= Y;
        Y = 0;
    }
    if (X > 0){
        cost += A * X;
    }
    if (Y > 0) {
        cost += B * Y;
    }
    cout << cost << '\n';
}


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


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import heapq

N = int(input())
a = list(map(int, input().split()))
heapq.heapify(a)
tmp = 0
tmp2 = 0

for i in range(pow(10,5)):
    tmp = heapq.heappop(a)
    if tmp == 1:
        print(tmp)
        exit()
    a = list(map(lambda x: x % tmp, a))
    if sum(a) == 0:
        print(tmp)
        exit()
    else:
        a = [j for j in a if j != 0]
        heapq.heappush(a, tmp)

Measured memory_bytes: 14180
N, K = map(int, input().split())
lst = []
for i in range(N):
    x = int(input())
    lst.append(x)
lst.sort()
L = []
for i in range(N - K + 1):
    L.append(lst[i + K -1] - lst[i])
L.sort()
print(L[0])

Measured memory_bytes: 11288
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
//namespace mp = boost::multiprecision;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


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


Measured memory_bytes: 256