akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
//ここからメイン
int main()
{
 vi a(3);
  rep(i,3)cin >> a[i];
  SORT(a);
  if(a[1]==a[0]){
  cout << a[2];
  }else{
  cout << a[0];
  }
 }
  

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		boolean flag = true;
		while(flag){
			flag = false;
			for(int i = 2; i < X; i++){
				if(X % i == 0){
					flag = true;
					break;
				}
			}
			if(flag)X++;
		}
		System.out.println(X);
	}
}

Measured memory_bytes: 22996
N,D=map(int,input().split())

X=[list(map(int,input().split())) for i in range(N)]

S=[n**2 for n in range(1,130)]

c=0

for i in range(N):
    for j in range(i,N):
        d=0
        for k in range(D):
            d+=(X[i][k]-X[j][k])**2
        for k in range(129):
            if d==S[k]:
                c+=1

print(c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
inline int roundup(int a, int b) { return (((a + (b -1)) / b)); }
using namespace std;

signed main(void) {
    int x;
    cin >> x;
    (x > 29)?cout << "Yes\n" : cout << "No\n";
    return 0;
}

Measured memory_bytes: 3516
import os
import heapq
import sys,threading
import math as mt
import operator
from copy import copy
from collections import defaultdict,deque
from io import BytesIO, IOBase

sys.setrecursionlimit(2*10 ** 5)
#threading.stack_size(2**27)


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


def pw(a,b,md):
    result=1
    while(b>0):
        if(b%2==1):
            result*=a
            result%=md
        a*=a
        a%=md
        b//=2
    return result%md


def inpt():
    return [int(k) for k in input().split()]


n=int(input())
ar=[]
br=[]
for _ in range(n):
    a,b=inpt()
    ar.append((a+b))
    br.append((a-b))

print(max(max(ar)-min(ar), max(br)-min(br)))


BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



Measured memory_bytes: 99440
/*
[jsc2019-qual] A - Takahashi Calendar
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int M, D;

ll solve() {
    int ans = 0;
    for (int m = 1; m <= M; m++) {
        for (int d = 1; d <= D; d++) {
            int d1 = d % 10;
            int d10 = d / 10;
            if (d1 >= 2 && d10 >= 2 && m == d1 * d10) {
                ans++;
            }
        }
    }

    return ans;
}

int main() {
    cin >> M >> D;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main()  {
	var N int
	var R int
	_, _ = fmt.Scan(&N, &R)

	if N >= 10 {
		fmt.Println(R)
		return
	} else {
		tmp := 100 * (10 - N)
		fmt.Println(R + tmp)
		return
	}
}


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

int bubbleSort (int A[], int n) {

    int i = 0, j, v, count = 0;
    bool flag = 1;

    while (flag) {

        flag = 0;

        for (j = n - 1; j >= i + 1; j--) {

            if (A[j] < A[j - 1]) {

                v = A[j];
                A[j] = A[j - 1];
                A[j - 1] = v;


                flag = 1;

                count += 1;

            }

        }

    }

    return count;

}

int main () {
 
    int i, n, count, A[100];
 
    cin >> n;
 
    for (i = 0; i < n; i++) {
 
        cin >> A[i];
 
    }

    count = bubbleSort (A, n);

    for (i = 0; i < n; i++) {

        cout << A[i];

        if (i < n - 1) {

            cout << " ";

        }

    }

    cout << endl;
    cout << count << endl;

    return 0;

}

Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
  int i,stu[31],num;
  for(i=0;i<31;i++) stu[i]=0;
  for(i=0;i<28;i++)
  {
    scanf("%d",&num);
    stu[num]=1;
  }
  for(i=1;i<31;i++)
  {
    if(stu[i]==0) printf("%d\n",i);
  }
  return 0;
}



Measured memory_bytes: 2100
// D - Banned K

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[200000];
unordered_map<ll, ll> ball_count;
unordered_map<ll, ll> comb;

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

	for (int i=0; i<N; i++) {
		cin >> A[i];
		ball_count[A[i]]++;
	}

	ll comb_total = 0;
	for (auto itr=ball_count.begin(); itr!=ball_count.end(); itr++) {
		ll ball_n = itr->first;
		ll ball_c = itr->second;
		ll c = ball_c * (ball_c - 1) / 2;
		comb[ball_n] = c;
		comb_total += c;
	}

	ll ans;
	for (int i=0; i<N; i++) {
		ll ball_c = ball_count[A[i]];
		ll c = (ball_c - 1) * (ball_c - 2) / 2;
		ans = comb_total - comb[A[i]] + c;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 16072
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 64
using namespace std;
typedef long long LL;
int digit[2][MAXN+5],len[2];
bool vis[MAXN+5];
void Work(LL x,int id)
{
	while(x)
	{
		digit[id][++len[id]]=x%2LL;
		x/=2LL;
	}
}
int main()
{
//	freopen("or.in","r",stdin);
//	freopen("or.out","w",stdout);
	LL a,b;
	scanf("%lld %lld",&a,&b);
	swap(a,b);
	Work(a,0);
	Work(b,1);
	int bg=0;
	for(int i=len[0];i>=1;i--)
		if(digit[0][i]!=digit[1][i])
		{
			bg=i;
			break;
		}
	LL ans=0;
	bool Find=false,first=false;
	for(int i=bg-1;i>=1;i--)
	{
		if(digit[0][i]==0)
		{
			if(Find==true)
				ans+=(1LL<<(i-1));
			else if(Find==false&&digit[1][i]==0&&first==false)
				ans+=(1LL<<(i-1));
			else if(Find==false&&digit[1][i]==1&&first==false)
			{
				LL ansn=(1LL<<i)-b%(1LL<<i);
				ans+=ansn;
				first=true;
			}
		}
		if(digit[0][i]==1)
			Find=true;
	}
	ans+=a-b+1LL;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
  
int main(){
    int A,B,C,D,E;
    cin>>A>>B;
    C=A+B;
    D=A*B;
    E=A-B;
    if(C>D&&C>E){
        cout<<C<<endl;
        
    }
    else if(D>E&&D>C){
        cout<<D<<endl;
    }
    else{
        cout<<E<<endl;
    }
}

Measured memory_bytes: 256
#coding: UTF-8

def Swap(a):
    for i in range(len(a)):
        if a[i] == "0 0":
            break
        x = int(a[i].split(" ")[0])
        y = int(a[i].split(" ")[1])
        box = 0
        if x > y:
            box = x
            x = y
            y = box
        print(str(x)+" "+str(y))

if __name__=="__main__":
    a = []
    for i in range(3000):
        a.append(input())
        if a[i] == "0 0":
            break
    Swap(a)

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

int main()
{
    string s; cin >> s;
    for (int i = 0, n = s.length(); i < n; i ++)
    {
        if (s[i] == ',')
        {
            s[i] = ' ';
        }
    }
    std::cout << s << std::endl;
    return 0;
}


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

int main() {
  int N, K;
  scanf("%d%d", &N, &K);

  vector<int> h(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &h.at(i));
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (h.at(i) >= K) ans++;
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 640
from collections import deque

n = int(input())
L = deque()

for i in range(n):
    com = input()
    if com[0] == 'i':
        C = com.split()
        L.appendleft(int(C[1]))
    else:
        if com[6] == 'F':
            L.popleft()
        elif com[6] == 'L':
            L.pop()
        else:
            C = com.split()
            x = int(C[1])
            try:
                L.remove(x)
            except:
                pass

print(*L)



Measured memory_bytes: 45884
#include <iostream>
using namespace std;
int N;
int A[200005];
long long ans;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i];
}

void Solve()
{
    for(int i = 1; i <= N; i++)
    {
        if(A[i] > i - 1 || A[i] - A[i - 1] > 1)
        {
            cout << "-1\n";
            return;
        }
    }
    for(int i = 2; i <= N; i++)
    {
        if(A[i] < A[i - 1] + 1)
        {
            ans += A[i];
        }
        else
            ans++;
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println("ABC" + in.nextInt());
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
package main

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

func main() {
	scan_init()
	n := scanInt()
	memo := make([]int,n+1)
	for i:= 1; i<=n; i++ {
		for j:=1; j*i<=n; j++ {
			memo[j*i] ++
		}
	}
	sum := 0
	for i:=1; i<=n; i++ {
		sum += memo[i]*i
	}
	fmt.Println(sum)
}
func primeFactorizate (number int ) map[int]int{
	var N int
	N = number
	var memo map[int]int
	memo = map[int]int{}
	// fmt.Println(N)
	for i:=2; i * i <= N; i++ {
		if N % i == 0{
			target := i
			check := true
			for check {
				check = false
				for j, value := range memo {
					if target%j == 0 {
						target = target / j
						memo [j] = value + 1
						check = true
						break
					}
				}
			}
			if target != 1 {
				// fmt.Println(target)
				memo[target] = 1
			}
			N = N/i
		}
	}
	target := N
	check := true
	for check {
		check = false
		// fmt.Println(memo,target)
		for j, value := range memo {
			// fmt.Println(j,value,target)
			if target%j == 0 {
				target = target / j
				memo [j] = value + 1
				check = true
				break
			}
		}
	}
	if target != 1 {
		// fmt.Println("check",target)
		memo[target] = 1
	}
	return memo
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 82492
#include <iostream>
#include <algorithm>

int main(){
    std::string str;
    std::cin >> str;

    int inputSize = str.size();

    std::sort(str.begin(), str.end());
    str.erase(std::unique(str.begin(), str.end()), str.end());

   if(inputSize == str.size()){
       std::cout << "yes" << std::endl;
   }else{
       std::cout << "no" << std::endl;
   }

   return 0;
}


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

int main(){
    ll x,y;
    cin>>x>>y;
    int ans=0;
    while(x<=y){
        ans++;
        x*=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<vector<int>> sch(n,vector<int>(3));
  for(int i=0;i<n;i++)
    cin>>sch[i][0]>>sch[i][1]>>sch[i][2];
  vector<vector<int>>dp(n,vector<int>(3));
  dp[0][0]=sch[0][0];
  dp[0][1]=sch[0][1];
  dp[0][2]=sch[0][2];
  for(int i=1;i<n;i++)
  {
    dp[i][0]=sch[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=sch[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=sch[i][2]+max(dp[i-1][1],dp[i-1][0]);
  }
  cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  
}

Measured memory_bytes: 11136
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define INF 1000000000
int K[32][32];
int N, M, A, B, C, D, x1, x2, y1, y2;
int main(void) {
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            K[i][j] = INF;
        }
    }
    for (int i = 0; i < M; i++) {
        scanf("%d,%d,%d,%d", &A, &B, &C, &D);
        K[A][B] = C;
        K[B][A] = D;
    }
    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (K[i][j] > K[i][k] + K[k][j]) {
                    K[i][j] = K[i][k] + K[k][j];
                }
            }
        }
    }
    scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
    cout << y1 - (K[x1][x2] + K[x2][x1]) - y2 << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;

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

	int ans = 0;
	int active = 0;
	for (int i = 0; i < n; i++)
	{
		if (active >= h[i]) {
			active = h[i];
		}
		else {
			ans += h[i] - active;
			active = h[i];
		}
	}
	
	cout << ans << endl;
	
}



Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
    sys.exit(0)

ans = a
k = k - a

if k <= b:
    print(ans)
    sys.exit(0)

k = k - b
ans = ans - k
print(ans)


Measured memory_bytes: 61640
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    W = list(map(int, input().split()))
    result = abs(sum(W[:1]) - sum(W[1:]))
    for n in range(N):
        if result > abs(sum(W[:n]) - sum(W[n:])):
            result = abs(sum(W[:n]) - sum(W[n:]))
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
num = [int(i) for i in input().split()]
kou1 = [min(num)]
kou2 = [max(num)]
for i in range(2,min(num)):
    if min(num)%i==0:
        kou1.append(i)

for i in range(2,max(num)):
    if max(num)%i==0:
        kou2.append(i)
mav =1
for i in kou2:
    for j in kou1:
        if i ==j:
            if mav <i:
                mav = i
    
print(num[0]*num[1]//mav)

Measured memory_bytes: 40796
using System;
using System.Linq;
namespace ABC156
{
    class D
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long n = input[0];
            long a = input[1];
            long b = input[2];
            long mod = 1000000007;

            long total = modPow(2, n, mod) - 1;
            long ca = modCombination(n, a, mod) % mod;
            long cb = modCombination(n, b, mod) % mod;
            Console.WriteLine((total + mod - (ca + cb) % mod) % mod);
        }

        public static long modPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) > 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res % mod;
        }
        public static long modInv(long a, long mod)
        {
            return modPow(a, mod - 2, mod) % mod;
        }

        public static long modMul(long a, long b, long mod)
        {
            return ((a % mod) * (b % mod)) % mod;
        }

        public static long modDiv(long a, long b, long mod)
        {
            return modMul(a, modInv(b, mod), mod);
        }

        private static long modCombination(long n, long k, long mod)
        {
            long answer = 1;
            for (long i = n; i > n - k; i--)
            {
                answer = modMul(answer, i, mod);
            }
            for (long i = 1; i <= k; i++)
            {
                answer = modDiv(answer, i, mod);
            }
            return answer;
        }

    }
}


Measured memory_bytes: 13396
#include <iostream> // cout, endl, cin
using namespace std;

int main(){
    int N;
    cin>>N;
    if(N%2==0){
        cout<<N/2-1<<endl;
    }
    else if(N==1){
        cout<<0<<endl;
    }
    else{
        cout<<(N+1)/2-1<<endl;
    }
}

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

int n, m, k, ans, temp;

int main() {
  ans = 0;
  cin >> n >> m;
  vector<int> a;
  rep (i, n) {
    cin >> k;
    rep (j, k) {
      cin >> temp;
      a.push_back(temp);
    }
  }
  sort(a.begin(), a.end());
  int counter = 1;
  int prev = -1;
  rep (i, a.size()) {
    if (prev == a[i]) {
      counter++;
      if (counter == n) ans++;
    }else{
      counter = 1;
      prev = a[i];
    }
  }
  cout << (n == 1 ? a.size() : ans) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

long long gcd2(long long x ,long long  y){
long long r;
if(x<y)swap(x,y);
while(y>0){
    r=x%y;
    x=y;
    y=r;
}
return x;
}

int main(){
    int N;
    cin >> N;
    long long  t;
    long long   answer=1;
    long long g;
    for(int i=0;i<N;i++){
        cin >> t;
        g=gcd2(answer,t);
        answer=(t/g)*answer;

    }
    cout <<answer <<endl;
    

 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))

using namespace std;

#define MOD 1000000007


int main(int argc, char* argv[])
{
    char str[200]={0};
    scanf("%s", str );

    long len=strlen(str);
    long lenadd=len-7;
    if(lenadd<0) {
        printf("NO\n");
        return 0;
    }
    if(lenadd==0) {
        if(strcmp(str, "keyence")==0) {
            printf("YES\n");
            return 0;
        }
        else {
            printf("NO\n");
            return 0;
        }
    }

    long i,j;
    for(i=0; i<=len; i++) {
        char str2[200]={0};
        strcpy(str2, str);
        for(j=i+lenadd; j<=len; j++) {
            str2[j-lenadd]=str[j];
        }
        if(strcmp(str2, "keyence")==0) {
            printf("YES\n");
            return 0;
        }
    }

    printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

struct node{
	int to;
	string str;
};

struct state{
	int cur;
	string str;
	bool  operator<(const state &a)const{ return str < a.str;}
	bool  operator>(const state &a)const{ return str > a.str;}
};


int main(void){
	int n;
	while(cin >> n,n){
		string dp[500][40];
		vector <node> graph[40];
		int a,s,g;
		cin >> a >> s >> g;
		rep(i,500)rep(j,40) dp[i][j]="";
		rep(i,a){
			int f,t;
			string tmp;
			cin >> f >> t >> tmp;
			node n; 
			n.to=t; n.str=tmp;
			graph[f].pb(n);
		}
		
		priority_queue<state,vector<state>,greater<state> > q;

		state init; init.cur=s; init.str="";

		q.push(init);
		string ans="";

		while(!q.empty()){
				state now=q.top(); q.pop();
				if(now.str.size()>=500)
					continue;

				if(now.cur==g){
					ans=now.str;
					break;
				}

				rep(i,graph[now.cur].size()){
					state next;	
					next.cur=graph[now.cur][i].to;
					next.str=now.str+graph[now.cur][i].str;
					if(next.str.size()>=500) continue;
					if(dp[next.str.size()][next.cur]!=""&&dp[next.str.size()][next.cur]<=next.str) continue;
					dp[next.str.size()][next.cur]=next.str;
					q.push(next);
				}
		}
		if(ans!=""&&ans.size()<=300)
			cout << ans << endl; 
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

void solve(long long X, long long K, long long D) {
    if (X < 0LL) {
        X = -X;
    }
    if (X / D < K) {
        long long hoge = X / D;
        K -= hoge;
        X -= hoge * D;
        if (K % 2 == 0) {
            cout << X << endl;
        } else {
            cout << -(X - D) << endl;
        }
    } else {
        cout << X - D * K << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long X;
    scanf("%lld", &X);
    long long K;
    scanf("%lld", &K);
    long long D;
    scanf("%lld", &D);
    solve(X, K, D);
    return 0;
}


Measured memory_bytes: 3660
N = int(input())
H = list(map(int, input().split()))

max_length = length = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        length += 1
    else:
        if max_length < length:
            max_length = length
        length = 0
print(max(max_length, length))

Measured memory_bytes: 15020
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()

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

using namespace std;
typedef long long ll;
const int INF = 10000000;

ll modpow(ll m, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1){                  //奇数の場合
            res = res * m % mod;
        }
        m = m * m % mod;
        n >>= 1;                    //累乗の数を2で割ってる
    }
    return res;

}

int main() {
    ll m, n;
    cin >> m >> n;
    cout << modpow(m, n, 1000000007) << endl;
}


Measured memory_bytes: 3104
while(1):
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        s=[0]*(n+1)
        top=0
        for i in range(1,n+1):
            b=int(input())
            
            s[i]=s[i-1]+b

        for i in range(n-k+1):
            v=s[k+i]-s[i]
            if v>top:
                top=v
        print(top)


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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second
#define endl '\n'

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    int n, a, b;
    cin >> n >> a >> b;

    string res;
    if (a==1 && b==2) {
        res = "Borys";
    } else {
        int diff = abs(a-b);

        if (diff&1) {
            res = "Borys";
        } else {
            res = "Alice";
        }
    }

    cout << res << endl;
}}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int max = 0;
		for(int i = 0; i < N; i++) {
			int p = sc.nextInt();
			max = Math.max(max, p);
			sum += p;
		}
		sc.close();
		sum -= max / 2;
		System.out.println(sum);
	}
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();
		long x = 0;

		if(n >= b -1) {
			x = b-1;
		}else {
			x = n;
		}

		System.out.println((a * x) / b - a * (x / b));
	}

}


Measured memory_bytes: 35716
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

int n;
vi adj[N];
int visited[N],arr[N];
int deg[N];


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    cin>>n;
    forn(i,1,n-1)
    {
        int a,b;
        cin>>a>>b;
        deg[a]--;
        deg[b]--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vi vs;
    forn(i,1,n){cin>>arr[i];vs.pb(arr[i]);}
    
    sort(all(vs));
    reverse(all(vs));
    //return 0;
    multiset<pair<int,int>>dc;
    
    //
    forn(i,1,n)dc.insert({deg[i],i});
    int ans = 0;
    
    while(dc.size())
    {
        
        int val = vs.back();
        vs.pop_back();
        auto cur = *dc.rbegin();
        dc.erase(cur);
        int x = cur.X , y = cur.Y;
        visited[y] = val;
        int t = 0;
        for(auto i : adj[y])
        {
            
            if(visited[i]==0)
            {
                t++;
                dc.erase(mp(deg[i],i));
                deg[i]++;
                if(deg[i] != 0)dc.insert({deg[i],i});
            }
        }
        ans += t*val;
       // cout<<t<<" "<<val<<" "<<y<<"\n";
    }
    forn(i,1,n)if(visited[i]==0){visited[i]=vs.back();vs.pop_back();}
    cout<<ans;nl;
    forn(i,1,n)cout<<visited[i]<<" ";


    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 14208
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
using namespace std;


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

  int x[100010];
  int y[100010];
  int t[100010];

  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  
  for(int i=1;i<N+1;++i){
    cin >> t[i] >> x[i] >> y [i];
  }

  bool can = true;

  for(int i=0;i<N;++i){
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    int delta_t = t[i+1]-t[i];

    if(dist>delta_t || dist%2 != delta_t%2){
      can = false;
      break;
    }
    
    
  }



  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;


}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C;u.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>ww,cc,u;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL ar[100];
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m>>o;
        k=n/m;
        if(n%m!=0)
        {
            k++;
        }
        cout<<k*o<<endl;


    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int   i, j , a[100][100], r, c, sum, tem ;
	
	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	
	for (i = 0; i < r; i++) {
		sum = 0;
		for (j = 0; j < c; j++) {
			printf("%d ", a[i][j]);
			sum = sum + a[i][j];
			if (j == c - 1) {
				printf("%d", sum);
			}
		}
		printf("\n");
	}


	tem = 0;
	for (i = 0; i < c; i++) {
		sum = 0;
		for (j = 0; j < r; j++) {
			sum = sum + a[j][i];
		}
		printf("%d ", sum);
		tem = tem + sum;
	}
		printf("%d\n", tem);
		
	return 0;
}


Measured memory_bytes: 2020
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int a, b, c, x, r = 0;
  cin >> a >> b >> c >> x;
  rep(i, a + 1) {
    rep(j, b + 1) {
      rep(k, c + 1) {
        if ((i * 500 + j * 100 + k * 50) == x) r++;
      }
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int64_t N, K;
  cin >> N >> K;

  vector<int64_t> Hs(N);
  for (int64_t n = 0; n < N; ++n) {
    cin >> Hs[n];
  }
  sort(Hs.begin(), Hs.end());
  
  int64_t attack = 0;
  for (int64_t n = 0; n < N - K; ++n) {
    attack += Hs[n];
  }
  cout << attack << endl;
  
  return 0;
}


Measured memory_bytes: 4784
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

int cmp_count = 0;

void merge(int A[], int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1 + 1], R[n2 + 1];

  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = INT_MAX;

  int i = 0, j = 0;
  for (int k = left; k < right; k++){
    if (L[i] < R[j]) {
      A[k] = L[i++];
      cmp_count++;
    } else {
      A[k] = R[j++];
      cmp_count++;
    }
  }
}

void mergeSort(int A[], int left, int right){
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

  mergeSort(S, 0, n);

  for (int i = 0; i < n - 1; i++) printf("%d ", S[i]);
  printf("%d\n", S[n - 1]);
  printf("%d\n", cmp_count);
}


Measured memory_bytes: 6616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
int n,x,y;
int cnt[2010];
void MAIN() {
	cin>>n>>x>>y;
	rng(i,1,n) {
		rng(j,i+1,n) {
			int d=j-i;
			d=min(d,abs(j-x)+1+abs(i-y));
			d=min(d,abs(j-y)+1+abs(i-x));
			cnt[d]++;
		}
	}
	rng(i,1,n-1) {
		cout<<cnt[i]<<'\n';
	}
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    dp = [-1 for _ in range(n)]
    for _ in range(n):
        x = int(input()) - 1
        if x > 0 and dp[x - 1] != -1:
            dp[x] = dp[x - 1] + 1
        else:
            dp[x] = 1
    print(n - max(dp))

main()


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

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(false);
    vector<int>seive(2000001);
    long int n,k;
	cin >> n;
	for(int i=0;i<n;i++){
	   cin >> k; 
	   seive[k]++;
	}
	long int not_divisible=0;
	vector<int> divisible(2000001,0);
	for(int i=1;i<=2000000;i++){
	    if(seive[i] == 0 || divisible[i])
	        continue;
	    if(seive[i]==1 && !divisible[i])
	        not_divisible++;
	    for(int j=i;j<2000000;j+=i)
	        divisible[j] = 1;
	}
	cout << not_divisible;
	return 0;
}

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

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

  if (n < num.length()) {
    for (int i = 0; i < n; i++) {
      cout << num[i];
    }
    cout << "..." << endl;
  } else {
    cout << num << endl;
  }
}

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

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

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


int main(void)
{
    int64_t a,b,c,d,k1,k2,k3,k4,ans;

    cin >> a >> b >> c >> d;

    k1 = a*c;
    k2 = a*d;
    k3 = b*c;
    k4 = b*d;

    ans = max(k1,k2);
    ans = max(ans,k3);
    ans = max(ans,k4);

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int N,count=0,ans=0;
    cin>>N;
    vector<int> H(N);
    rep(i,N){
        cin>>H[i];
    }
    rep(i,N) {
        count = 0;
        rep(j,i){
            if (H[i] < H[j]) {
                count = 1;
            }
        }
        if (count==0){
            ans++;
    }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int,int> PII;
#define fi first
#define se second
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
int n;
bool cmp(const PII& a, const PII& b){
    return a.first > b.first;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    vector<PII> a(n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a.begin(), a.end(),cmp);
    //for(int i = 0; i < n; ++i) cout <<a[i].fi << " " << a[i].se << endl;
    vector<vector<LL> > dp(n, vector<LL>(n));
    dp[0][n-1] = 0;
    for(int len = n -1; len >= 1; --len){
        int p = n - len - 1;
        for(int i = 0; i + len - 1 < n; ++i){
            int j = i + len - 1;
            if(j < n - 1) dp[i][j] = max(dp[i][j], dp[i][j+1] + 1ll * a[p].fi * abs(a[p].se - j - 1));
            if(i > 0) dp[i][j] = max(dp[i][j], dp[i-1][j] + 1ll * a[p].fi * abs(a[p].se - i + 1));
        }
    }
    LL ans = 0;
    for(int i = 0; i < n; ++i){
        ans = max(ans, dp[i][i] + 1ll * a[n-1].fi * abs(a[n-1].se - i));
    }
    cout << ans<< "\n";
    return 0;
}



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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	VI sk(3);
	for(auto x:a){
		if(x %4 ==0) sk[0]++;
		else if(x %2 ==0) sk[1]++;
		else sk[2]++;
	}
	//for(auto x :sk) cerr<<x<<" "; dbg("");
	bool ok=false;
	if(sk[0] +1 >= sk[2] + (sk[1] >0) ) ok=true;
	
	puts(ok? "Yes": "No");
	return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
B = []
C = []

count = 0
for a in A:
    if a != 0:
        if count != 0:
            B.append(0)
            C.append(count)
        B.append(a)
        C.append(1)
        count = 0
    else:
        count += 1
if count != 0:
    B.append(0)
    C.append(count)

# print (A)
# print (B)
# print (C)
N = len(B)

count = 0
for l in range(N - 1):
    tmp = C[l] #スタート地点の数
    tmp_count = 0
    total = B[l]
    xor = B[l]
    for r in range(l + 1, N):
        total += B[r]
        xor ^= B[r]
        if total == xor:
            tmp_count += C[r]
        else:
            break
    # print (tmp_count, tmp)
    count += tmp_count * tmp
    count += (tmp * (tmp + 1)) // 2
    # print (count)

count += (C[-1] * (C[-1] + 1)) // 2

print (count)



Measured memory_bytes: 24584
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    ll ans = 0;
    REP(i,n) {
        ans += a[i] / 2;
        if (i != n-1 && a[i] % 2 == 1) {
            if (a[i+1] >= 1) {
                ans++;
                a[i+1]--;
            }
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
// Problem: C - Triangular Relationship
// Contest: AtCoder - AtCoder Regular Contest 102
// URL: https://atcoder.jp/contests/arc102/tasks/arc102_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////

void Solve(){
  LL n,k;
  cin>>n>>k;
  LL ans=0;
  if(k%2==0){
    LL t=(n/k+(n%k>=k/2));
    ans+=t*t*t;
  }
  LL t=n/k;
  ans+=t*t*t;
  cout<<ans<<endl;
} 


Measured memory_bytes: 3664