akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

int n;
ll segtree[410410];

ll gcd(ll x, ll y){
	return ((y)?gcd(y,x%y):x);
}

void update(int p, ll v, int i=0, int l=0, int r=n){
	if(!(l<=p && p<r)){
		return;
	}else if(r-l>1){
		update(p,v,2*i+1,l,(l+r)/2);
		update(p,v,2*i+2,(l+r)/2,r);
		segtree[i] = gcd(segtree[2*i+1],segtree[2*i+2]);
	}else{
		segtree[i] = v;
	}
}

ll query(int a, int b, int i=0, int l=0, int r=n){
	ll lv,rv;
	if(r<=a || b<=l){
		return 0ll;
	}else if(a<=l && r<=b){
		return segtree[i];
	}else{
		lv = query(a,b,2*i+1,l,(l+r)/2);
		rv = query(a,b,2*i+2,(l+r)/2,r);
		return gcd(lv,rv);
	}
}

int main(void){
	int i;
	ll ans,a,lv,rv;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a;
		update(i,a);
	}
	for(i=0; i<n; ++i){
		lv = query(0,i);
		rv = query(i+1,n);
		ans = max(ans,gcd(lv,rv));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
 
int main() {
  int N, i;
  
//cout << "debug" << endl;
  cin >> N ;
  vector<long> vec(N+1);
  
  vec.at(0) = 0;
  for(i = 1; i < N+1; i++){
  	cin >> vec.at(i);
  }
//cout << "N= " << N << endl;
  //右から順にみて、1より大きく高いならアウト
  for(i=N; i>0; i--){
    if( vec.at(i-1) > vec.at(i)+1 ){
      cout << "No" << endl;
      break;
    }else if( vec.at(i-1) == vec.at(i)+1 ){
  	//1だけ高いなら下げる
      vec.at(i-1)--;
//      cout << "doun" << endl;
    }
  }
  if(i<=1)  cout << "Yes" << endl;
  
}//endmain

Measured memory_bytes: 1152
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    auto cnt1 = new long[](N);
    auto cnt2 = new long[](N);
    foreach (i; 0 .. N)
    {
        cnt1[abs(i - (N - 1 - i))]++;
        cnt2[A[i]]++;
    }
    if (zip(cnt1, cnt2).any!"a[0] != a[1]"())
    {
        writeln(0);
        return;
    }
    long ans = 1;
    foreach (i; 0 .. N)
    {
        foreach (x; 1 .. cnt1[i] + 1)
            ans *= x, ans %= MOD;
    }
    writeln(ans);

}
/// x^^n % m
T powmod(T = long)(T x, T n, T m = 10 ^^ 9 + 7)
{
    if (n < 1)
        return 1;
    if (n & 1)
        return x * powmod(x, n - 1, m) % m;
    return tmp = powmod(x, n / 2, m), tmp * tmp % m;
}


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

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

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

    int count = 0;
    for(int i=0; i<n; i++){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n

for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if ac[p]==0:
    if s=='AC':
      ac[p]=1
    else:
      wa[p]+=1

wasum=0
for i in range(n):
  if ac[i]==1:
    wasum+=wa[i]

print(sum(ac),wasum)

Measured memory_bytes: 45528
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll& O)
{
	cout << O;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

int main()
{
	ll N;
	in(N);
	ll K;
	in(K);
	str S;
	in(S);

	S[K - 1] = S[K - 1] - 'A' + 'a';

	cout << S;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define Max 10000
int main(){
  int i,T[Max],S[Max],k,j=0,count=0,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&T[i]);
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d",&S[i]);
  }
  for(i=0;i<k;i++){
    j=0;
    T[n]=S[i];
    while(T[j] != S[i]){
      j++;
    }
    if(j != n) count++; 
  }
  printf("%d\n",count);
  return 0;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;


	int ans = 0 ;
	string s ;
	cin >> s;

	for (int i = 0 ; i < s.length(); i++) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans;












	return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

//Starship Hakodate-maru
public class Main{

	void run(){
		int[] f1 = new int[54];
		for(int i=0;i<54;i++)f1[i]=i*i*i;
		int[] f2 = new int[96];
		for(int i=0;i<96;i++)f2[i]=i*(i+1)*(i+2)/6;
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int max = 0;
			for(int i=0;i<54;i++)for(int j=0;j<96;j++)if(f1[i]+f2[j]<=n)max=Math.max(max, f1[i]+f2[j]);
			System.out.println(max);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
using System;
//using System.Collections.Generic;

public class TestC
{
    public static void Main(){
        string line = Console.ReadLine();
        string[] numbers = line.Split(' ');
        int takahashi_HP = int.Parse(numbers[0]);
        int takahashi_AP = int.Parse(numbers[1]); 
        int aoki_HP = int.Parse(numbers[2]);
        int aoki_AP = int.Parse(numbers[3]); 

        while(takahashi_HP > 0 && aoki_HP > 0)
        {
            aoki_HP = aoki_HP - takahashi_AP;
            takahashi_HP = takahashi_HP - aoki_AP;
        }

        if(aoki_HP <= 0) Console.WriteLine("Yes");
        else  Console.WriteLine("No");
    }
}

Measured memory_bytes: 27452
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int a, b; cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

const int INF = 1LL << 29;

int main() {
    int N, w[300];
    while (true) {
        cin >> N;
        if (N == 0) break;
        for (int j = 0; j < N; ++j) cin >> w[j];

        int dp[305][305];
        for (int j = 0; j < N; ++j) {
            fill(dp[j], dp[j]+N+1, 0);
        }

        for (int j = 0; j+1 < N; ++j) {
            if (abs(w[j] - w[j+1]) <= 1) {
                dp[j][j+2] = 2;
            }
        }

        for (int d = 3; d <= N; ++d) {
            for (int j = 0; j + d <= N; ++j) {
                for (int k = 1; j+k < j+d; ++k) {
                    dp[j][j+d] = max(dp[j][j+d], dp[j][j+k] + dp[j+k][j+d]);
                }

                if (dp[j+1][j+d-1] == d-2 && abs(w[j] - w[j+d-1]) <= 1) {
                    dp[j][j+d] = d;
                }
            }
        }

        cout << dp[0][N] << endl;
    }
    return 0;
}

Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59



int main(){
  ll i,j;
  string s;
  cin>>s;
  set<char> se;
  for(i=0;i<4;i++) se.insert(s[i]);
  if(se.size()==2){
    for(auto it=se.begin();it!=se.end();++it){
      ll c;
      c=0;
      for(i=0;i<4;i++) if(*it==s[i]) ++c;
      if(c!=2) {
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;  
}

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

#pragma GCC optimize "trapv"
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define drep(i,a,b) for(int i=a; i>b; i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define inf 1e+18L
#define mod 1000000007

const auto pi = 3.14159265358979;

template <typename T>
T numdigits(T n)
{
    return (floor(log10(n)) + 1);
}

template <typename T>
T modpower(T x, T y, T m=mod)
{
    T res = 1;
    x %= m;
    if(x == 0) return 0;
    while(y > 0)
    {
        if(y&1) res = (res*x)%m;
        y >>= 1;
        x = (x*x)%m;
    }
    return res;
}

void solve()
{
    //code
    int n;
    cin >> n;
    vi a(n-1);
    rep(i,0,n-1) cin >> a[i];
    map<int, int> m;
    rep(i,1,n+1) m[i] = 0;
    for(auto x : a) m[x]++;
    for(auto x : m)
    {
        cout << x.se << "\n";
    }
}

int main()
{
    FASTIO
//    int t;
//    cin >> t;
//    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 13508
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(3*n**2)
    return

#B
def B():
    n,d = LI()
    f = [1]*(n+2*d+2)
    ans = 0
    for i in range(n):
        if f[i]:
            for j in range(i,i+2*d+1):
                f[j] = 0
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    a = IR(n)
    mi = max(a)
    if a.count(mi) > 1:
        for i in range(n):
            print(mi)
    else:
        b = [a[i] for i in range(n)]
        b.sort()
        b = b[::-1]
        for i in range(n):
            if mi != a[i]:
                print(mi)
            else:
                print(b[1])

    return

#D
def D():
    n = I()
    a = LI()
    b = [0]*(n+1)
    for i in range(1,n+1)[::-1]:
        j = 2*i
        k = 0
        while j <= n:
            k ^= b[j]
            j += i
        if a[i-1]^k:
            b[i] = 1
    ans = []
    for i in range(n+1):
        if b[i]:
            ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)
    return

#E
def E():
    n = I()
    a = IR(n)
    mi = []
    ans = 0
    for i in range(n):
        j = bisect.bisect_right(mi,-a[i])
        if j == len(mi):
            mi.append(-a[i])
        else:
            mi[j] = -a[i]
    print(len(mi))
    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 49116
# https://atcoder.jp/contests/abc064/tasks/abc064_d

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    need_left = 0
    need_right = 0
    for s in S:
        if s == '(':
            need_right += 1
        else:
            if need_right == 0:
                need_left += 1
            else:
                need_right -= 1

    ans = '(' * need_left + S + ')' * need_right
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
x = int(input())
cnt = 0
if x <= 6:
    cnt = 1
else:
    if 7 <= x <= 11:
        cnt = 2
    else:
        p = x // 11
        q = x % 11
        if q == 0:
            cnt = 2 * p
        elif 1 <= q <= 6:
            cnt = 2 * p + 1
        else:
            cnt = 2 * p + 2

print(cnt)

Measured memory_bytes: 3060
N, M, X = map(int, input().split())
C = []*N
A = []
for i in range(N):
    b = list(map(int, input().split()))
    C.append(b[0])
    A.append(b[1:])
ans = -1
for i in range(2**N):
    t = [0] * M
    c = 0
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        if ans == -1:
            ans = c
        else:
            ans = min(ans, c)
print(ans)

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e16;

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

  char ans;
  char X, Y;
  cin >> X >> Y;

  if (X < Y) {
    ans = '<';
  } else if (X > Y) {
    ans = '>';
  } else {
    ans = '=';
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){ 
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		char[] let = str.toCharArray();
		for (int i = 0 ; i<let.length ; i ++ ) {
			if (Character.isUpperCase(let[i])) {
				let[i] = Character.toLowerCase(let[i]);
			}else{
				let[i] = Character.toUpperCase(let[i]);
			}
			System.out.print(let[i]);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 27112
#include<cstdio>
#include<algorithm>
using namespace std;
char a[5];
int main()
{
    int res=0;
    scanf("%s",a);
    for(int i=0;i<3;i++)
    if(a[i]=='1')
    res++;
    printf("%d\n",res);
    return 0;
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] count = new int[26];
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) break;
                for (int i = 0; i < line.Length; i++)
                {
                    int c = (int)line.ToLower()[i];
                    if (c >= 97 && c <= 122)
                    {
                        count[c - 97]++;
                    }
                }
            }
            
            for (int i = 0; i < 26; i++)
            {
                char alp = (char) (i + 97);
                Console.WriteLine("{0} : {1}",alp, count[i]);
            }
        }
    }
}


Measured memory_bytes: 17892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
int main(void){
    string s; cin>>s;
    int L = s.size();
    vector <vector<ll>> dp(100010 ,vector <ll>(4,0));
    dp[0][0] = 1;
    for(int i=0;i<L;i++){
        if(s[i]=='?'){
            dp[i+1][0] += 3*dp[i][0]%MOD;
            dp[i+1][1] += 3*dp[i][1]%MOD;
            dp[i+1][2] += 3*dp[i][2]%MOD;
            dp[i+1][3] += 3*dp[i][3]%MOD;
        }
        else{
            dp[i+1][0] += dp[i][0]%MOD;
            dp[i+1][1] += dp[i][1]%MOD;
            dp[i+1][2] += dp[i][2]%MOD;
            dp[i+1][3] += dp[i][3]%MOD;
        }
        if(s[i]=='A'||s[i]=='?') {dp[i+1][1]+= dp[i][0]; dp[i+1][1]%=MOD;}
        if(s[i]=='B'||s[i]=='?') {dp[i+1][2]+= dp[i][1]; dp[i+1][2]%=MOD;}
        if(s[i]=='C'||s[i]=='?') {dp[i+1][3]+= dp[i][2]; dp[i+1][3]%=MOD;}
        
                    
    }
    cout<<dp[L][3]<<endl;
}


Measured memory_bytes: 7424
#include <iostream>

using namespace std;

long long MAX = 1e18;

int main(){

    //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    int N;

    cin >> N;
    long long A[N];
    long long sum = 1;
    bool overflow = false;
    bool hasZero = false;

    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i] == 0) hasZero = true;
        if( !overflow && A[i] > MAX/sum ){
            overflow = true;
        }else{
            sum *= A[i];
        }
        //if(overflow) break;
    }

    if (hasZero){
        cout<<"0\n";
    }else if (overflow){
        cout<<"-1\n";
    }else{
        cout<<sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 3936
# encoding: utf-8
N, M = map(int, input().split())

N_tmp = N
M_tmp = M

ans = 0
if 2 * N < M:
    ans += N
    N_tmp -= N
    M_tmp -= 2 * N
    # print("#", N_tmp, M_tmp)
    print(ans + M_tmp // 4)
else:
    ans += M // 2
    N_tmp -= M // 2
    M_tmp -= M
    # print("#", N_tmp, M_tmp)
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MIN / 2 + 1;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<pair<ll, ll>> pa(n);
    rep(i, n) pa[i] = make_pair(a[i], i);
    sort(all(pa), greater<pair<ll, ll>>());
    // dp[見た数][左においた数]
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, inf));
    dp[0][0] = 0;
    rep(i, n) {
        ll val = pa[i].first;
        ll idx = pa[i].second;
        rep(j, n) {
            if (dp[i][j] == inf) continue;
            ll left = j, right = n - 1 - (i - j);
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + abs(right - idx) * val);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + abs(left - idx) * val);
        }
    }
    ll ans = inf;
    rep(i, n + 1) ans = max(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 34624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll n, ans = inf;

ll func(ll a)
{
    ll r = 0;
    while (a > 0)
    {
        r++, a /= 10;
    }
    return r;
}

int main()
{
    cin >> n;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i != 0)
            continue;
        ans = min(ans, max(func(i), func(n / i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

if __name__ == '__main__':
    n = int(input())
    ans_div = 0
    limit = math.ceil(math.sqrt(n))
    for i in range(1, limit + 1):
        if n % i == 0:
            ans_div = max(ans_div, i)
    print(ans_div + n // ans_div - 2)


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




int main(){

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

	vector<int> V;

	int tmp;

	for(int loop = 0; loop < N; loop++){

		scanf("%d",&tmp);
		V.push_back(tmp);
	}

	sort(V.begin(),V.end());

	int ans = 0,pre = -1;

	for(int i = 0; i < V.size(); i++){

		if(pre != V[i]){

			ans++;
		}
		pre = V[i];
	}

	printf("%d\n",ans);

	return 0;
}


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

int main() {
  string N;
  cin >> N;
  int x = 0;
  for (int i = 0; i < N.size(); i++) {
    x += (int)(N.at(i) - '0');
  }
  int y;
  y = stoi(N);
  if(y % x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include<iomanip>

int main() {

	int D,N;
	std::cin >> N >> D;

	std::vector<std::vector<double>> A(N, std::vector<double>(D));
	for (auto& a : A) {
		for (auto& x : a) {
			std::cin >> x;
		}
	}

	int num = 0;

	for (int n = 0; n < N-1; n++) {
		for (int i = n + 1; i < N; i++) {
			double distance = 0;
			for (int d = 0; d < D; d++) {
				distance += (A[n][d] - A[i][d]) * (A[n][d] - A[i][d]);
			}
			distance = std::sqrt(distance);

			//std::cout << n << " " << i << " " << distance << std::endl;

			if ((int)distance - distance == 0) {			
				num++;
			}
		}
	}

	std::cout << num << std::endl;

	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a-b), 0);   
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

vector<int> buildSt(const vector<ll>& S, ll A) {
  int N = S.size();
  vector<int> res(N);
  int j = 0;
  for (int i = 0; i < N; i++) {
    while (j < N && S[j] - S[i] < A) ++j;
    res[i] = j;
  }
  return res;
}

vector<int> buildEn(const vector<ll>& S, ll A) {
  int N = S.size();
  vector<int> res(N);
  int j = 1;
  for (int i = 0; i < N; i++) {
    j = max(j, i + 1);
    while (j < N && S[j] - S[j - 1] >= A) ++j;
    res[i] = j;
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  ll A, B;
  while (cin >> N >> A >> B) {
    vector<ll> S(N);
    for (ll& x : S) cin >> x;
    auto stA = buildSt(S, A);
    auto stB = buildSt(S, B);
    auto enA = buildEn(S, A);
    auto enB = buildEn(S, B);
    vector<ll> dpA(N + 1), dpB(N + 1);
    dpA[N] = dpB[N] = 1;
    vector<ll> sumA(N + 2, 0), sumB(N + 2, 0);
    sumA[N] = sumB[N] = 1;
    for (int i = N - 1; i >= 0; i--) {
      //ll vA = 0;
      //for (int x = (i > 0 ? stB[i - 1] : 0); x <= enA[i]; x++) (vA += dpB[x]) %= MOD;
      //ll vB = 0;
      //for (int x = (i > 0 ? stA[i - 1] : 0); x <= enB[i]; x++) (vB += dpA[x]) %= MOD;
      int a0 = max(i > 0 ? stB[i - 1] : 0, i + 1), a1 = enA[i];
      int b0 = max(i > 0 ? stA[i - 1] : 0, i + 1), b1 = enB[i];
      if (a1 >= a0) dpA[i] = (sumB[a0] - sumB[a1 + 1] + MOD) % MOD;
      if (b1 >= b0) dpB[i] = (sumA[b0] - sumA[b1 + 1] + MOD) % MOD;
      sumA[i] = (sumA[i + 1] + dpA[i]) % MOD;
      sumB[i] = (sumB[i + 1] + dpB[i]) % MOD;
    }
    ll res = (dpA[0] + dpB[0]) % MOD;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

ll n, sum, squ, a;

int main() {
   
   cin >> n;
   rep(i, n) {
	  cin >> a;
	  sum += a;
	  squ += a * a;
   }
   cout << (sum*sum - squ) / 2 << endl;
}

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



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

    vector<int> a(n);
    vector<int> ans(n);
    for (size_t i = 0; i < a.size(); ++i) {
        cin >> a[i];
        ans[a[i]-1] = i+1;
    }

    //vector<int> ans(n);
    /*
    for (int i=0; i<n; i++){
        vector<int>::iterator minIt = min_element(a.begin(), a.end());
        size_t minIndex = distance(a.begin(), minIt);
        ans[i] = minIndex;
        a[minIndex] = INF;
    }    
    */
    for(int i=0; i<n; i++){
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 1536
#include <stack>
#include <iostream>
 
using namespace std;
 
int main(void){
        int tem;
        stack<int> st;
        cin >> tem;
        st.push(tem); 
        while(true){
                cin >> tem;
                if( cin.eof())
                        break;
                if(tem)
                        st.push(tem);
                else{
                        cout <<st.top()<<endl;
                        st.pop(); 
                }
        }
return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define INF (ll)1e16

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    if (n == 2) {
        cout << max(a[0], a[1]) << endl;
        return 0;
    }
    vector<ll> dp[3];
    rep(i,3) dp[i] = vector<ll>(n, -INF);
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    rep(i,n){
        rep(k,3){
            if (i < k) continue;
            rep(j,3){
                if (k+j <= 2 && i+j+2 < n){
                    dp[k+j][i+j+2] = max(dp[k+j][i+j+2], dp[k][i] + a[i+j+2]);
                }
            }
        }
    }
    if (n % 2 == 0){
        cout << max({dp[1][n-1], dp[0][n-2]}) << endl;
    } else {
        cout << max({dp[2][n-1], dp[1][n-2], dp[0][n-3]}) << endl;
    }

    return 0;
}


Measured memory_bytes: 9596
using System;
using System.Linq;

namespace _0138
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[8];
            int[] b = new int[8];
            int[] c = new int[8];
            for (int i = 0; i < 8; i++)
            {
                double[] x = Console.ReadLine().Split().Select(double.Parse).ToArray();
                a[i] = (int)(x[0] + x[1] * 10000000);
            }
            for (int i = 0; i < 8; i++)
            {
                double[] x = Console.ReadLine().Split().Select(double.Parse).ToArray();
                b[i] = (int)(x[0] + x[1] * 10000000);
            }
            for (int i = 0; i < 8; i++)
            {
                double[] x = Console.ReadLine().Split().Select(double.Parse).ToArray();
                c[i] = (int)(x[0] + x[1] * 10000000);
            }
            Array.Sort(a);
            Array.Sort(b);
            Array.Sort(c);
            Console.WriteLine(a[0] % 10000 + " " + ((double)a[0] / 10000000).ToString().Substring(0, 5));
            Console.WriteLine(a[1] % 10000 + " " + ((double)a[1] / 10000000).ToString().Substring(0, 5));
            Console.WriteLine(b[0] % 10000 + " " + ((double)b[0] / 10000000).ToString().Substring(0, 5));
            Console.WriteLine(b[1] % 10000 + " " + ((double)b[1] / 10000000).ToString().Substring(0, 5));
            Console.WriteLine(c[0] % 10000 + " " + ((double)c[0] / 10000000).ToString().Substring(0, 5));
            Console.WriteLine(c[1] % 10000 + " " + ((double)c[1] / 10000000).ToString().Substring(0, 5));
            int[] nokori = new int[18];
            for (int i = 0; i < 6; i++)
            {
                nokori[i] = a[i + 2];
            }
            for (int i = 0; i < 6; i++)
            {
                nokori[i + 6] = b[i + 2];
            }
            for (int i = 0; i < 6; i++)
            {
                nokori[i + 12] = c[i + 2];
            }
            Array.Sort(nokori);
            Console.WriteLine(nokori[0] % 10000 + " " + ((double)nokori[0] / 10000000).ToString().Substring(0, 5));
            Console.WriteLine(nokori[1] % 10000 + " " + ((double)nokori[1] / 10000000).ToString().Substring(0, 5));
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9652
#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              (x).begin(), (x).end()
#define rall(x)             (x).rbegin(), (x).rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

const ll Mod = 998244353;
inline ll md(ll x, ll M = Mod)
{
    x %= M;
    return ((x < 0) ? (x + M) : x);
}

void solve(int &T)
{
    ll n, k;
    cin >> n >> k;

    set<ll> a;
    loop(j, k)
    {
        ll l, r;
        cin >> l >> r;
        loop(i, l, r + 1) {
            a.insert(i);
        }
    }
    a.insert(n + 2);
    d(a);

    vector<pair<ll, ll>> b;
    ll first = *a.begin(), last = *a.begin();

    for(ll x : a) {
        if(x != last) {
            b.push_back({first, last});
            first = last = x;
        }
        last++;
    }
    d(b);

    vector<ll> dp(2 * n + 5, 0);
    ll cur = 1;

    loop(i, 1, n + 1)
    {
        cur = md(cur + dp[i]);
        if(i == 2) cur -= 1;
        for(auto &r : b) {
            dp[i + r.first] += cur;
            dp[i + r.second] -= cur;
        }
    }
    cout << cur << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

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

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 15532
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]+=1
mod=10**9+7
iro=[0]*(10**5+3)
iro[0]=3
ans=1
for i in range(n):
    ans%=mod
    # print(iro[a[i]-1])
    # print(iro[a[i]])
    if iro[a[i]]==0:
        if iro[a[i]-1]==0:
            print(0)
            quit()
        else:
            ans*=iro[a[i]-1]
    elif iro[a[i]]==1:
        if iro[a[i]-1]<=1:
            print(0)
            quit()
        else:
            ans*=iro[a[i]-1]-1
    elif iro[a[i]]==2:
        if iro[a[i]-1]<=2:
            print(0)
            quit()
        else:
            ans*=1
    else:
        print(0)
        quit()
    iro[a[i]]+=1
print(ans%mod)


Measured memory_bytes: 52868
#include <bits/stdc++.h>
using namespace std;
int k;
const int N=1e5+10;
int f[N][3];
int memo[N][3];
 
int dp(int pos, int now){
    if(pos==k) return 0;
    if(memo[pos][now]!=-1) return memo[pos][now];
    else{
        for(int i=0;i<3;i++){
            if(now==i) continue;
            else{
            memo[pos][now]=max(memo[pos][now],dp(pos+1,i)+f[pos][i]);
            }
        }
    }
    return memo[pos][now];
    
}
 
int main(){
    cin>>k;
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<k;i++){
        for(int j=0;j<3;j++){
            cin>>f[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(ans,dp(0,i));
    }
    cout<<ans<<'\n';
}

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

int main(void){
    map<string, int> zohe;
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string a;
        cin >> a;
        if (zohe[a] == 0) zohe[a] = 1;
        else zohe[a]++;
    }
    for (map<string, int>::iterator it = zohe.begin(); it != zohe.end(); it++) {
        int a = stoi(it->first);
        if (a > it->second) ans += it-> second;
        else ans += it -> second - a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12160
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = I()

    return n**2 - a


print(main())






Measured memory_bytes: 73068
n = int(input())
arr = list(map(int,input().split()))
ans = 0

def div(x):
    cnt = 0
    while x % 2 == 0:
        x = x // 2
        cnt += 1
    return cnt

for i in arr:
    if i % 2 == 0:
        ans += div(i)
print(ans)

Measured memory_bytes: 4148
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

class StaticRMQ {
public:
  vector <ll> dat;
  int N;

  StaticRMQ(int n) {
    init(n);
  }

  void init(int n) {
    N = 1;

    while (N < n) N *= 2;

    for (int i = 0; i < 2 * N - 1; ++i) {
      dat.push_back(0);
    }
  }

  void update(int k, ll a) {
    k += N - 1;
    dat[k] = a;

    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  ll find_max(int l, int r) {
    return query(l, r, 0, 0, N);
  }

private:

  ll query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;

    if (a <= l && r <= b) {
      return dat[k];
    } else {
      ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

      return max(vl, vr);
    }
  }
};

struct Flower {
  int h;
  int a;
  int idx;

  Flower(int a = -1, int h = -1, int idx = -1) {
    this->a = a;
    this->h = h;
    this->idx = idx;
  }

  bool operator<(const Flower &f) const {
    return h < f.h;
  }
};

int main() {
  int N;
  cin >> N;
  vector<int> H;
  vector<int> A;
  map<int, int> idx;

  int a, h;
  for (int i = 0; i < N; ++i) {
    cin >> h;
    H.push_back(h);
    idx[h] = i + 1;
  }

  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
  }

  ll dp[N + 1];
  vector<Flower> flowers;

  for (int i = 0; i < N; ++i) {
    int h = H[i];
    int a = A[i];

    flowers.push_back(Flower(a, h, i + 1));
  }

  sort(flowers.begin(), flowers.end());
  StaticRMQ rmq(N + 1);

  for (int i = 0; i < N; ++i) {
    Flower flower = flowers[i];

    ll v = flower.a + rmq.find_max(1, flower.idx);
    rmq.update(flower.idx, v);
  }

  cout << rmq.find_max(1, N + 1) << endl;

  return 0;
}


Measured memory_bytes: 21740
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    ll num_remain_0 = 0;
    ll num_remain_k_s_2 = 0;
    for (int i=1; i<=n; ++i)
    {
        if (i % k == 0) ++num_remain_0;
        if (i % k == k/2) ++num_remain_k_s_2;
    }
    
    if (k%2==1)
    {
        cout << ll(pow(num_remain_0, 3)) << endl;
    }
    else
    {
        cout << ll(pow(num_remain_0, 3) + pow(num_remain_k_s_2, 3)) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
def n():
    A, B, C, X, Y = map(int, input().split())
    ab = A + B
    cc = C * 2
    cost = 0
    if ab > cc:
        minn = min(X, Y)
        cost += minn * cc
    else:
        minn = min(X, Y)
        cost += minn * A + minn * B

    if X > Y:
        diff = X - Y
        aaa = A * diff
        ccc = cc * diff
        cost += min(aaa, ccc)
    else:
        diff = Y - X
        bbb = B * diff
        ccc = cc * diff
        cost += min(bbb,ccc)

    return cost


print(n())


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
const long long mod = 1000000007;
int main() {
    int n;
    scanf("%d", &n);
    int x[n];
    int y[n];
    int i;
    int z[n];
    int w[n];
    int z_max = 0,z_min = 0;
    int w_max = 0, w_min = 0;
    for(i = 0; i < n; i ++){
        scanf("%d %d", &x[i], &y[i]);
        z[i] = x[i] + y[i];
        w[i] = x[i] - y[i];
        if(i == 0){
            z_max = z[i];
            z_min = z[i];
            w_max = w[i];
            w_min = w[i];
        }
        if(z_max<z[i]){
            z_max = z[i];
        }
        if(z_min>z[i]){
            z_min = z[i];
        }
        if(w_max<w[i]){
            w_max = w[i];
        }
        if(w_min>w[i]){
            w_min = w[i];
        }
    }
    if(z_max - z_min > w_max - w_min){
        printf("%d", z_max - z_min);
    }else{
        printf("%d", w_max - w_min);
    }
    return 0;
}

Measured memory_bytes: 4832
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int c = Integer.parseInt(str[2]);
    System.out.println(b/a>=c?c:b/a);
  }
}

Measured memory_bytes: 23504
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;


int main(){

	int L,A,B,C,D,day_kokugo,day_sansu;

	scanf("%d",&L);
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);

	day_kokugo = A/C;
	if(A%C > 0)day_kokugo++;

	day_sansu = B/D;
	if(B%D > 0)day_sansu++;

	printf("%d\n",L-max(day_kokugo,day_sansu));

	return 0;
}

Measured memory_bytes: 2708
import java.util.*;

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

        String[] nk = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nk[0]);
        long k = Long.parseLong(nk[1]);

        long kCopy = k;
        int kBits = 0;
        while (kCopy > 0) {
            kCopy /= 2;
            kBits++;
        }

        int[] numBit0 = new int[kBits];
        int[] numBit1 = new int[kBits];

        String[] line = scanner.nextLine().split(" ", n);
        long[] A = new long[n];
        for (int i = 0; i < n; i++) {
            A[i] = Long.parseLong(line[i]);

            long a = A[i];
            for (int j = 0; j < kBits; j++) {
                if (a % 2 == 0) {
                    numBit0[j]++;
                } else {
                    numBit1[j]++;
                }
                a /= 2;
            }
        }

        if (kBits == 0) {
            long sum = 0;
            for (int i = 0; i < n; i++) {
                sum += A[i];
            }
            System.out.println(sum);
            return;
        }

        long x = 0;

        long placeholder = 1;
        for (int i = 0; i < kBits - 1; i++) {
            placeholder *= 2;
        }

        for (int i = kBits - 1; i >= 0; i--) {
            if (numBit1[i] < numBit0[i] && x + placeholder <= k) {
                x += placeholder;
            }
            placeholder /= 2;
        }

        long result = 0;
        for (int i = 0; i < n; i++) {
            result += x ^ A[i];
        }
        System.out.println(result);
    }
}


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

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

	vector<double> p(N);
	for(uint32_t i=0; i<N; i++) cin >> p[i];
	
	vector<vector<double>> dp(N+1, vector<double>(N+1, 1));
	
	for(uint32_t i=1; i<=N; i++) {
		dp[i][0] = dp[i-1][0] * (1 - p[i-1]);
	}
	
	for(uint32_t i=1; i<=N; i++) {
		for(uint32_t j=1; j<i; j++) {
			dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j] * (1 - p[i-1]);
		}
		dp[i][i] = dp[i-1][i-1] * p[i-1];
	}

	double ans = accumulate(dp[N].begin() + N/2 + 1, dp[N].end(), (double)0);
	cout << setprecision(10) << ans << endl;
	
	return 0;

}

Measured memory_bytes: 70784
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
import sys

INF = 1145141919
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, D: int):
    while A > 0 and C > 0:
        C -= B
        if C <= 0:
            return YES
        A -= D
        if A <= 0:
            return NO


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    print(solve(A, B, C, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61928
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

ll vs[2020][2020];

int main() {
  int N;
  ll x;
  while (cin >> N >> x) {
    for (int i : range(N)) cin >> vs[0][i];

    for (int j : range(1, N + 1)) {
      for (int i : range(N)) {
        vs[j][i] = min(vs[j - 1][(i - 1 + N) % N], vs[j - 1][i]);
      }
    }

    ll res = 1LL << 60;
    for (int j : range(N + 1)) {
      ll cand = j * x;
      for (int i : range(N)) {
        cand += vs[j][i];
      }
      res = min(res, cand);
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 31872
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let b: Vec<usize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    let mut a = vec![0; n];
    a[0] = b[0];
    a[n - 1] = b[n - 2];
    for i in 1..(n - 1) {
        a[i] = std::cmp::min(b[i], b[i - 1]);
    }

    println!("{}", a.iter().sum::<usize>());
}


Measured memory_bytes: 4352