akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
constexpr int MOD = 1e9 + 7;
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
int arr[200005], inc[200005];
int get_min(int x, int y) { return arr[x] < arr[y] ? x : y; }
int get_max(int x, int y) { return arr[x] > arr[y] ? x : y; }
struct ST_table
{
	int (*func)(int, int);
	int bit[200005], idx[25][200005];
	ST_table(int (*_func)(int, int)) : func(_func) { }
	void init(int n)
	{
		bit[0] = bit[1] + 1;
		for (int i = 2; i <= n; i++)
			bit[i] = bit[i >> 1] + 1;
		for (int i = 0; i < n; i++)
			idx[0][i] = i;
		for (int i = 1; i < 20; i++)
		{
			for (int j = 0; j + (1 << i) <= n; j++)
				idx[i][j] = func(idx[i - 1][j], idx[i - 1][j + (1 << i - 1)]);
		}
	}
	int query(int l, int r)
	{
		int len = bit[r - l + 1];
		return func(idx[len][l], idx[len][r - (1 << len) + 1]);
	}
} ST_min(get_min), ST_max(get_max);
int main()
{
	// freopen("AGC038-B.in", "r", stdin);
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	ST_min.init(n);
	ST_max.init(n);
	for (int i = n - 1; i >= 0; i--)
		inc[i] = arr[i] < arr[i + 1] ? inc[i + 1] + 1 : 1;
	int ans = inc[0] < k;
	for (int i = 0; i + k < n; i++)
	{
		ans += (ST_min.query(i, i + k - 1) != i ||
				ST_max.query(i + 1, i + k) != i + k) &&
			   inc[i + 1] < k;
	}
	for (int i = 0; i + k <= n; i++)
	{
		if (inc[i] >= k)
		{
			ans++;
			break;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 36224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vector<ll> tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

int main() {
  ll m,n;
  cin >> m >> n;
  if(abs(m-n)>1) {
    cout << 0 << endl;
    return 0;
  }
  fact(max(n,m));
  ll ans=tfact[n]*tfact[m]%mod;
  if(m==n) {
    ans=ans*2%mod;
  }
  cout << ans << endl;
}

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

using namespace std;

int n;
long long res;
string s;
map< pair<string, string>, int> cnt;

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> s;
	for (int i = 0; i < (1 << n); ++i) {
		string A, B;
		for (int j = 0; j < n; ++j) {
			if (i >> j & 1) A.push_back(s[j]);
			else B.push_back(s[j]);
		}
		cnt[{A, B}]++;
	}
	for (int i = 0; i < (1 << n); ++i) {
		string A, B;
		for (int j = 0; j < n; ++j) {
			if (i >> j & 1) A.push_back(s[j + n]);
			else B.push_back(s[j + n]);
		}
		reverse(A.begin(), A.end());
		reverse(B.begin(), B.end());
		res += cnt[{A, B}];
	}
	cout << res;
}

Measured memory_bytes: 87040
import sys
sys.setrecursionlimit(4100000)

import logging

# logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

import re

# @profile
def resolve():
    S = sys.stdin.readline().split()[0]

    logger.debug(S)

    dp = [[0] * 13 for i in range(len(S))]
    i = 0
    if S[i] == '?':
        for j in range(10):
            dp[i][j] += 1
    else:
        dp[i][int(S[i])] = 1

    len_S = len(S)
    for i in range(1, len(S)):
        if S[i] == '?':
            for r in range(13):
                dp[i-1][r] %= (10**9 + 7)
                for j in range(10):
                    new_r =  j + r * 10
                    dp[i][new_r % 13] += dp[i-1][r]

        else:
            int_s = int(S[i])
            for r in range(13):
                new_r = int_s + r * 10
                dp[i][new_r % 13] += dp[i-1][r] % (10**9 + 7)

    print(dp[len(S)-1][5] % (10**9 + 7))

if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """??2??5"""
        output = """768"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """?44"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """7?4"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???"""
        output = """153716888"""
        self.assertIO(input, output)


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

int main() {
int n;
cin>>n;
vector<int>a(9,0);
for(int i=0;i<n;i++){
  int x;cin>>x;
  if(x<400)a[0]++;
  else if(x<800)a[1]++;
  else if(x<1200)a[2]++;
  else if(x<1600)a[3]++;
  else if(x<2000)a[4]++;
  else if(x<2400)a[5]++;
  else if(x<2800)a[6]++;
  else if(x<3200)a[7]++;
  else a[8]++;
}
int www=0;
for(int i=0;i<8;i++){
  if(a[i])www++;
}
int maxx=max(www,1);
cout<<maxx<<" "<<www+a[8]<<endl;
  return 0;
}



Measured memory_bytes: 3572
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
// #define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz

    int n, k;
    cin>>n>>k;

    vi v(n);
    for(int &x:v) cin>>x;

    vector<double> psum(n + 1);
    
    for(int i=1;i<=n;i++){
        int x = v[i - 1];
        psum[i] = psum[i - 1] + ((double)x*((double)x + 1))/(2*(double)x);
    }

    double mx = 0;
    for(int i=k;i<=n;i++){
        mx = max(mx, psum[i] - psum[i - k]);
    }

    cout<<fixed<<setprecision(10)<<mx;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a,b[100001];
    memset(b,0,sizeof(b));
    for(int i=0;i<n;i++){
        cin>>a;
        b[a]++;
    }
    int num=0;
    for(int i=1;i<100001;i++){
        if(b[i]>1){
            num+=b[i]-1;
        }
    }
    if(num%2){
        cout << n-num-1<<endl;
    }
    else{
        cout << n-num<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int A[260],H,i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>0) printf("parent key = %d, ",A[i/2]);
    if(i*2<=H) printf("left key = %d, ",A[i*2]);
    if(i*2+1<=H) printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c,d,i,j,t=0,u=0;
   string x,y,z;

 cin>>x>>y;
 cin>>a>>b;
 cin>>z;
 if(z==x)
    t++;
 if(z==y)
    u++;
cout<<a-t<<" "<<b-u<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mk make_pair
int main(){
  int n;
  cin>>n;
  int a[n+10];
  bool ch[n+100];
  for(int i=0;i<n;i++){cin>>a[i];}
  for(int i=n;i<n+10;i++)a[i]=-1;
    for(int i=0;i<n+100;i++)ch[i]=0;
  queue<pair<int,int> >q;
  q.push(mk(0,0));
  ch[0]=1;
  while(!q.empty()){
    pair<int,int>b=q.front();q.pop();
    int d=b.first,c=b.second;
    if(d==n-1){cout<<c<<endl;return 0;}
    for(int i=1;i<7;i++){
      if(a[d+i]+d+i>=n||ch[a[d+i]+d+i])continue;
      if(a[d+i]){if((a[d+i])==-(a[d+i+a[d+i]])){ch[d+i]=1;goto L;}
        int p=a[d+i],dd=d+i;
        while(1){
          if(a[dd+p]==0)break;
          if(ch[dd]){goto L;}
          ch[dd]=1;
          dd=dd+p;p=a[dd];
        }
        q.push(mk(dd+p,c+1));ch[dd+p]=1;
      }
      if(a[d+i]==0){q.push(mk(d+i,c+1));ch[d+i]=1;}
      L:;
    }
  }
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using ll = long long;

int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	int cnt = 0;
	for (int i = 100; i > 0; --i) {
		//cout << A % i << B % i << endl;
		if ((A % i == 0) && (B % i == 0)) {
			//cout << i << endl;
			cnt++;
		}
		if (cnt == K) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int ans = Integer.MAX_VALUE;
    ArrayList<Integer> list = new ArrayList();
    for (int i = 0; i < N; i++) {
      list.add(sc.nextInt());
    }
    Collections.sort(list);
    for (int i = 0; i <= N - K; i++) {
      int minTree = list.get(i);
      int maxTree = list.get(i + K - 1);
      int min = Math.abs(minTree - maxTree);
      ans = Math.min(ans, min);
    }
    System.out.println(ans);
  }
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<char> > c(h, vector<char>(w));
	REP(i, h) REP(j, w) cin >> c[i][j];

	int res = 0;
	REP(y, 1 << h) REP(x, 1 << w) {
		int sum = 0;
		REP(i, h) REP(j, w)
			if ((y >> i & 1) == 0 && (x >> j & 1) == 0 && c[i][j] == '#') sum++;
		if (sum == k) res++;
	}
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 3664
import java.math.BigDecimal;
import java.util.*;

//divisor Number
public class Main {
	public static void main(String args[])
	{
		String[] str = new String[2];
		long [] output = new long [2];
		Scanner sc = new Scanner(System.in);
		str = sc.nextLine().split(" ");
		output[0] = Integer.parseInt(str[0]);
		output[1] = Integer.parseInt(str[1]);
		
		long d = output[0]/output[1];
		long r = output[0]%output[1];
		double f = (double)output[0]/(double)output[1];
		System.out.println(d + " " + r + " " + BigDecimal.valueOf(f).toPlainString());
		sc.close();

	}
}


Measured memory_bytes: 26572
#include <algorithm>
#include <bitset>
#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...)); }
/* clang-format on */

const int lim = 100000 + 100;

int N;
vec<int, 2> G;

ll MOD;
ll dp[lim], ans[lim];

void dfs(int v, int p = -1) {
  dp[v] = 1;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) continue;
    dfs(u, v);
    dp[v] = dp[v] * (1 + dp[u]) % MOD;
  }
}

void dfs2(int v, int p = -1, ll pv = 0) {
  vector<ll> f(G[v].size(), 1);
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) {
      f[i] = (1 + pv) % MOD;
    } else {
      f[i] = (1 + dp[u]) % MOD;
    }
  }
  vector<ll> L(G[v].size() + 1, 1), R(G[v].size() + 1, 1);
  for (int i = 0; i < G[v].size(); i++) L[i + 1] = L[i] * f[i] % MOD;
  for (int i = G[v].size() - 1; i >= 0; i--) R[i] = R[i + 1] * f[i] % MOD;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) continue;
    ll cv = L[i] % MOD * R[i + 1] % MOD;
    dfs2(u, v, cv);
  }
  ans[v] = (1 + pv) * dp[v] % MOD;
}

int main() {
  while (cin >> N >> MOD) {
    G.clear();
    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      G[x].push_back(y);
      G[y].push_back(x);
    }
    dfs(0);
    dfs2(0);
    for (int v = 0; v < N; v++) cout << ans[v] << endl;
  }
  return 0;
}


Measured memory_bytes: 22016
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    ll modnCr(ll n, ll r, ll mod) {
        ll res = 1;
        rep (i, r) {
            res = res * (n - i) % mod * modpow(i + 1, mod - 2, mod) % mod;
        }
        return res;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint
    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string S;
        cin>>S;
        vl v(200000);
        rep(i,200000){
            v[i]=modpow(10,i,2019);
        }
        ll s=Size(S);
        vl n(s);
        rep(i,s){
            ll y=S[s-1-i]-'0';
            ll x=y*v[i];
            x%=2019;
            n[i]=x;
        }
        vl sum(s+1,0);
        rep(i,s){
            sum[i+1]=sum[i]+n[i];
            sum[i+1]%=2019;
        }
        umap<ll,ll> m;
        ll res=0;
        rep(i,s+1){
            m[sum[i]]++;
            if(m[sum[i]]>1)res+=m[sum[i]]-1;
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 8312
import java.io.*;
class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int total_second = Integer.parseInt(br.readLine());
    int second = total_second % 60;
    int minute = total_second / 60 % 60;
    int hour = total_second / 60 / 60 ;
    System.out.println(hour + ":" + minute + ":" + second);
  }
}



Measured memory_bytes: 24420
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		string ans = "Yes";
		for(var i=1;i<N;i++){
			if(A[i]<A[i-1]){
				ans = "No";
			} else if(A[i]>A[i-1]){
				A[i] -= 1;
			}
		}
		Console.WriteLine(ans);
	}
}

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

int main()
{
    int n,k,minn,maxn;
    scanf("%d",&n);
    scanf("%d",&k);
    minn=maxn=k;
    for (int i=1;i<n;i++)
    {
        scanf("%d",&k);
        if (k<minn) minn=k;
        if (k>maxn) maxn=k;
    }
    printf("%d\n",maxn-minn);
    return 0;
}


Measured memory_bytes: 256
import math
a, b, h, m = [int(v) for v in input().split()]

rad = abs(((h * 60 + m) - (m * 12)) / (12 * 60) * math.pi * 2)
hyp = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(rad))
print(hyp)


Measured memory_bytes: 9520
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');

            int N = int.Parse (str[0]);
            int A = int.Parse (str[1]);
            int B = int.Parse (str[2]);

            int ans = 0;

            for (int i = 1; i <= N; i++)
            {
                int sum = 0;
                string temp = i.ToString ();

                for (int j = 0; j < temp.Length; j++)
                {
                    sum += int.Parse (temp[j].ToString ());
                }
                if (sum >= A && sum <= B) ans += i;
            }

            Console.WriteLine (ans);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b,c,sum;
		a = scan.nextInt();
		b = scan.nextInt();
		
		sum = a * b;
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 26080
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

int main(void)
{
    int a,b;
    cin >> a >> b;
    
    if((a+b)%2!=0)
    {
        cout << "IMPOSSIBLE"<<endl;
    }else{
        cout << (a+b)/2<<endl;
    }

    return 0;
}

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

int main()
{
    int N, V, P;
    int64_t M;
    cin >> N >> M >> V >> P;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    sort(A.rbegin(), A.rend());
    int Ab = A.at(P - 1);

    int64_t acc = 0;
    vector<int64_t> diff(N);
    for (int i = P; i < N; i++)
    {
        acc += Ab - A.at(i);
        diff.at(i) = acc;
    }

    int res = 0;
    for (int i = 0; i < N; i++)
    {
        if (i < P)
        {
            res++;
            continue;
        }
        int64_t Ai_mx = A.at(i) + M;
        if (Ai_mx >= Ab && V - P <= N - i - 1)
        {
            res++;
            continue;
        }
        int64_t v = M * (V - P - (N - i - 1));
        int64_t d = diff.at(i - 1);
        int Ab_mn = Ab;
        if (v > d)
        {
            v -= d;
            int n = i - (P - 1);
            Ab_mn += (v + n - 1) / n;
        }
        if (Ai_mx >= Ab_mn)
        {
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1536
using System;

namespace abc159A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            Console.WriteLine((A * (A - 1) / 2) + (B * (B - 1) / 2));
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

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

    int ret = INT_MAX;
    for(int w=1; w<=n; ++w){
        int d = 0;
        for(int i=0; i<2; ++i){
            d += abs(a[2*i] / w - a[2*i+1] / w);
            d += abs(a[2*i] % w - a[2*i+1] % w);
        }
        ret = min(ret, d);
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int a, b, c, d;

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

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

  if(a <= 11){
    if(c == (a+1)){
      cout << 1 << endl;
    } else cout << 0 << endl;
  } else {
    if(c == 1) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll nA = A, nB = B;
    A = max(0LL, A - K);
    K = max(0LL, K - nA);
    B = max(0LL, B - K);
    K = max(0LL, K - nB);
    cout << A << " " << B << endl;
    return 0;
}

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

using namespace std;

int main() {
  long long h, w;
  cin >> h >> w;
  long long ans = h * w;
  if ((h % 3) == 0)
    ans = 0;
  else
    ans = min(ans, w);
  if ((w % 3) == 0)
    ans = 0;
  else
    ans = min(ans, h);
  for (long long i = 1; i < h; i++) {
    long long ma = i * w, mi = i * w;
    long long a = ((w)/2) * (h-i), b = ((w+1)/2) * (h-i);
    ma = max(ma, b);
    mi = min(mi, a);
    ans = min(ans, ma-mi);
  }
  swap(w, h);
  for (long long i = 1; i < h; i++) {
    long long ma = i * w, mi = i * w;
    long long a = ((w)/2) * (h-i), b = ((w+1)/2) * (h-i);
    ma = max(ma, b);
    mi = min(mi, a);
    ans = min(ans, ma-mi);
  }
  cout << ans << endl;
  return 0;
}

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

class Dice {
    public:
    int f[6];
    Dice() {}
    void roll_z() { roll(1, 2, 4, 5);}
    void roll_y() { roll(0, 2, 5, 3);}
    void roll_x() { roll(0, 1, 5, 4);}
    void roll (int i, int j, int k, int l) {
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
    void move(char ch) {
        if (ch == 'E') for (int i = 0; i < 3; i++) roll_y();
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S') for (int i = 0; i < 3; i++) roll_x();
    }
};

int main() {
    Dice d;
    string dir;
    
    for (int i = 0; i < 6; i++) cin >> d.f[i];
    cin >> dir;
    
    for (int i = 0; i < dir.size(); i++) d.move(dir[i]);
    
    cout << d.f[0] << endl;
        
    return 0;
}




Measured memory_bytes: 3216
open System

let input = stdin.ReadLine().Split()|>Array.map int
let N =input.[0]
let D =input.[1]
let X = [|for i in [0..N-1] do yield (stdin.ReadLine().Split()|>Array.map int)|]
[<EntryPoint>]
let main argv =
    let dist i j = 
        [0..D-1]
        |> Seq.sumBy(fun c -> (X.[i].[c]-X.[j].[c])*(X.[i].[c]-X.[j].[c]))
        |>double
        |>sqrt
    let mutable ans = 0
    for i in [0..N-2] do
        for j in [i+1..N-1] do
            ans <- ans + if dist i j =(dist i j |>floor) then 1 else 0
    printfn "%d" ans
    0
   

Measured memory_bytes: 14288
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    set<int> s;
    for(int q=0; q<3; q++){
        int x; cin>>x;
        s.insert(x);
    }
    cout<<(s.size()==2 ? "Yes" : "No");
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	int a,b;cin>>a>>b;
    if(a-2*b>=0) cout<<a-2*b<<endl;
    else cout<<0<<endl;

}

 
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    for(int i = 0; i < n; i++){
        cout << s[i] << t[i];
    }
    cout << endl;

}

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

int main(){
  long long N;
  cin >> N;
  long long x=1;
  
  vector<long long> A(N);
  for (long long i=0 ; i<N ; i++)
    cin >> A.at(i);
  
  sort(A.begin(), A.end());
  for (long long i=0 ; i<N ; i++){
    if (A.at(i)>1000000000000000000/x){
      x=1000000000000000001;
      break;
    }
    x *= A.at(i);
    if (x>1000000000000000000)
      break;
    if (x==0)
      break;
  }
  
  if (x>1000000000000000000)
    cout << -1 << endl;
  else
    cout << x << endl;
}

Measured memory_bytes: 4020
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N = 2e5 + 10;
 
int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cout << n * n * n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, height, oldh = 0, siz = 0, ans = 0;
    cin >> n;
    for(int i = 1;i <= n;i++){
      cin >> height;
      if(oldh < height){
        ans = max(siz-1, ans);
        siz = 0;
      }
      siz++;
      oldh = height;
    }
    ans = max(ans, siz - 1);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ld i,j,t,w,h,a,x,y,r,k,d,s,b,c;
	cin>>a>>b>>c>>d;

	ll t1=ceil(c/b);
	ll t2=ceil(a/d);
	//cout<<t1;
	if(t1<=t2)
	cout<<"Yes";
	else
	cout<<"No";
	
	
	return 0;
	
	
}

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

using namespace std;

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

void solve(int r, int l){
  int p, q;
  p = q = (r + l) / 2;
  if(r + l & 1){
    if(r > l){
      if(r & 1){
        ++p;
      }else{
        ++q;
      }
    }else{
      if(l & 1){
        ++q;
      }else{
        ++p;
      }
    }
  }
  REP(i, r - 1){
    printf("0 ");
  }
  printf("%d %d", p, q);
  REP(i, l - 1){
    printf(" 0");
  }
}

int main(){
  char c;
  int r = 0, l = 0;
  while(cin >> c){
    if(c == 'R'){
      if(l > 0){
        solve(r, l);
        putchar(32);
        r = 1, l = 0;
      }else{
        ++r;
      }
    }else{
      ++l;
    }
  }
  solve(r, l);
  puts("");
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  int ans=0;
  int N=sqrt(n);
  
  for(int i=1;i<=sqrt(n);i++){
    for(int j=sqrt(n)+1;j<=n;j++){
      if(i*j<n){
        ans+=2;
      }
    }
    
  }
  if(N*N==n){
    ans=ans-1;
  }
  cout<<N*N+ans<<endl;
} 

Measured memory_bytes: 3640
N = str(input())

if(N[-1]=='2'or N[-1]=='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9'): print('hon')
if(N[-1]=='0' or N[-1]=='1' or N[-1]=='6' or N[-1]=='8'): print('pon')
if(N[-1]=='3'): print('bon')

Measured memory_bytes: 9072
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pll = pair <ll, ll>;

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

    map <ll, pll> mp;

    for (int i = 0; i < n; i++) {
        ll x, y; cin >> x >> y;
        if (!mp.count(x)) {
            mp[x].first = -2e18;
            mp[x].second = 2e18;
        }

        ll& big = mp[x].first;
        ll& small = mp[x].second;

        big = max(big, y);
        small = min(small, y);
    }

    if (mp.size() == 1) {
        cout << (mp.begin()->second).first - (mp.begin()->second).second << endl;
        return 0;
    }

    set <ll> xpy, xmy;
    int i = 0;

    ll ans = -2e18;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        ll x = it->first;
        ll y1 = it->second.first, y2 = it->second.second;
        if (it == mp.begin()) {
            xpy.insert(x + y1);
            xpy.insert(x + y2);
            xmy.insert(x - y1);
            xmy.insert(x - y2);
        }

        ll sum1 = x + y1, sum2 = x + y2;
        ll sub1 = x - y1, sub2 = x - y2;

        ans = max(ans, sum1 - *xpy.begin());
        ans = max(ans, sum2 - *xpy.begin());
        ans = max(ans, sub1 - *xmy.begin());
        ans = max(ans, sub2 - *xmy.begin());

            xpy.insert(x + y1);
            xpy.insert(x + y2);
            xmy.insert(x - y1);
            xmy.insert(x - y2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 34744
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) {
		//code
		Scanner in=new Scanner(System.in);
		int n;
		long sum=0;
      n=in.nextInt();
      int a[]=new int[n];
      for(int i=0;i<n;i++)
      {
        a[i]=in.nextInt();
        if(i>0&&a[i]<a[i-1])
        {
          sum=sum+(a[i-1]-a[i]);
          a[i]=a[i-1];
        }
      }
      System.out.println(sum);
}
}


Measured memory_bytes: 60980
#include <iostream>

int search(int n, int x, int a) {
	/*
	 * a < b < c < n
	 * a + b + c == x
	 * b < remain/2 < c
	 */
	int remain = x - a;
	int mid = remain / 2;
	int btomid = mid - a - (remain == mid * 2);
	int midtoc = n - mid;
	//std::cout << "a: " << a << ", mid: " << remain / 2. << ", btomid: " << btomid << ", midtoc: " << midtoc << '\n';
	return std::max(0, std::min(btomid, midtoc));
}

int search(int n, int x) {
	int total = 0;
	int imax = std::min(n - 1, x / 3);
	for (int i = 1; i < imax; i++) {
		total += search(n, x, i);
	}
	return total;
}

int main() {
	int n;
	int x;

	while (true) {
		std::cin >> n >> x;
		if (n == 0 && x == 0) {
			break;
		}
		std::cout << search(n, x) << std::endl;
	}
}

Measured memory_bytes: 3092
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	h := nextInt()
	cnt := 1
	ans := 1
	for h > 1 {
		h /= 2
		cnt *= 2
		ans += cnt
	}
	fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 200005;
ll U[MAX_N],cnt[MAX_N],pow10[MAX_N];

/*
ll modpow(ll a, ll p)
{
	if (p == 0) return ll(1);
	if (p == 1) return a%p;
	if (p % 2 == 0)
	{
		ll b = modpow(a,p/2);
		return b * b % p;
	}
	else
	{
		return p * modpow(a,p-1) % p;
	}
}
*/

int main()
{
	ll N,P;
	cin >> N >> P;
	string S;
	cin >> S;

	pow10[0] = 1;
	rep(i,MAX_N-1)
	{
		pow10[i+1] = pow10[i] * 10 % P;
	}
	U[N] = 0;
	cnt[0] = 1;
	ll ans = 0;
	if (P == 2 || P == 5)
	{
		rep(i,N)
		{
			if ((S[i] - '0') % P == 0)
			{
				ans += i+1;
			}
		}
	}
	else
	{
		rep(i,N)
		{
			U[N-1-i] = ((S[N-1-i] - '0') * pow10[i] + U[N-i]) % P;
			ans += cnt[U[N-1-i]];
			cnt[U[N-1-i]]++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6948
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
int t[100005], x[100005], y[100005];
/**********************************************/

int main(){
    cin >> n;
    REP(i, n) cin >> t[i] >> x[i] >> y[i];
    
    int cur_x = 0, cur_y = 0, cur_t = 0;
    REP(i, n){
        int diff_x = abs(x[i] - cur_x);
        int diff_y = abs(y[i] - cur_y);
        int sum = diff_x + diff_y;
        int diff_t = t[i] - cur_t;
        if(t[i] - cur_t < sum){
            cout << "No" << endl;
            return 0;
        }else if((diff_t + sum % 2) % 2 != 0){
            cout << "No" << endl;
            return 0;
        }

        cur_x = x[i]; cur_y = y[i]; cur_t = t[i];
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
import numpy as np


n,m,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.append(X)
y.append(Y)

if np.max(x) < np.min(y):
    print('No War')
else:
    print('War')

Measured memory_bytes: 21904
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rsort(x) sort(x.rbegin(), x.rend())
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define fio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define znit(x) memset(x, 0, sizeof(x))
#define mnit(x) memset(x, -1, sizeof(x))
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db EPS = 1e-7;

const ll mod = 9075135300 + 1;
const ll mod2 = 1e9 + 9;
ll mypow(ll x, ll y, ll p){ll ret = 1;while(y){if(y & 1) ret = (ret * x) % p;x = (x * x) % p; y /= 2;}return ret;}
ll inv(ll x, ll p){return mypow(x, p - 2, p);}
ll gcd(ll x, ll y){return y ? gcd(y, x % y) : x;}
const int MAX = 2e5 + 3;
typedef pair<string ,string> pss;
ll N, ans;
char S[37];
map<pss, ll> mp;

int main(){
    scanf("%lld %s", &N, S);
    for(int i = 0; i < (1 << N); i++){
        string s1, s2;
        for(int j = 0; j < N; j++){
            if(i & (1 << j))    s1.push_back(S[j]);
        }
        for(int j = N - 1; j >= 0; j--){
            if(!(i & (1 << j))) s2.push_back(S[j]);
        }
        mp[{s1, s2}]++;
    }
    for(int i = 0; i < (1 << N); i++){
        string s1, s2;
        for(int j = 0; j < N; j++){
            if(i & (1 << j))    s1.push_back(S[N + j]);
        }
        for(int j = N - 1; j >= 0; j--){
            if(!(i & (1 << j))) s2.push_back(S[N + j]);
        }
        ans += mp[{s2, s1}];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 91904
#include<iostream>
#include<algorithm>
#define NUM 100000
using namespace std;

int main(){
    int N,M,ans = 0;
    int X[NUM];
    int distanceList[NUM-1];

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

    sort(X,X+M);
    for(int i = 0 ; i < M - 1;i++){
        distanceList[i] = X[i + 1] - X[i];
    }
    sort(distanceList,distanceList+M-1,greater<int>());


    for(int i = N -1 ; i < M - 1;i++){
       ans += distanceList[i];
    }
    cout << ans;
}

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

int main(){
  string s, t;
  int a, b;
  string u;
  
  cin >> s >> t ;
  cin >> a >> b;
  cin >> u;
  
  if(s == u)
    cout << a - 1 << " "<< b << endl;
  
  else if (t == u)
    cout << a <<" "<< b -1 <<endl;
  
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n, k, ans;
	cin >> n >> k;
	ans = k;
	for (int i = 1; i < n; i++) {
		ans *= k - 1;
	}
	cout << ans << "\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	hawawa();
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	t, x, y := 0, 0, 0
	for i := 0; i < n; i++ {
		var tv, xv, yv int
		fmt.Scan(&tv, &xv, &yv)
		td := tv - t
		k := d(x, xv) + d(y, yv)
		if td < k {
			fmt.Println("No")
			return
		}
		td -= k
		if td%2 != 0 {
			fmt.Println("No")
			return
		}
		t = tv
		x = xv
		y = yv
	}
	fmt.Println("Yes")
}

func d(a, b int) int {
	v := a - b
	if v < 0 {
		return -v
	}
	return v
}


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

using namespace std;

int n, k, d[100], a[100][100];

int main() {
    int i, j;
    cin >> n >> k;
    int check[n];
    for(i = 0; i < n; i++) check[i] = 0;
    for(i = 0; i < k; i++) {
        cin >> d[i];
        for(j = 0; j < d[i]; j++) {
            cin >> a[i][j];
            check[a[i][j]-1] = 1;
        }
    }
    int ans = 0;
    for(i = 0; i < n; i++) {
        if(check[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

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

    vector<int64_t> s(n + 1);
    for (auto i : irange(1, n + 1)) {
        int64_t a;
        cin >> a;
        s[i] = s[i-1] + a;
    }

    constexpr auto MAX_BIT = 40;
    vector<bitset<MAX_BIT>> sums;
    sums.reserve(n * (n+1) / 2);
    for (int l : irange(0, n)) {
        for (int r : irange(l, n)) {
            // sのindexずらしたので注意
            sums.push_back(s[r + 1] - s[l]);
            cerr << sums.back() << endl;
        }
    }

    int64_t ans = 0;
    for (int i : irange(MAX_BIT, -1, -1)) {
        int count = 0;
        for (auto s : sums) {
            count += (s[i] ? 1 : 0);
        }

        if (count < k) {
            continue;
        }

        ans += 1L << i;
        cerr << i << " " << ans << endl;
        decltype(sums) next;
        next.reserve(sums.size());
        for (const auto& s : sums) {
            if (s[i]) {
                next.push_back(s);
            }
        }
        sums.swap(next);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6912
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

lo, hi = 0, max(a*f for (a, f) in zip(A,F))
while lo < hi:
    mid = (lo + hi)//2
    rsd = K
    possible = True
    for a, f in zip(A,F):
        rsd -= ceil(max(a*f-mid, 0)/f)
        if rsd < 0:
            possible = False
            break
    if possible:
        hi = mid
    else:
        lo = mid+1

print(lo)


Measured memory_bytes: 119628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

struct rolling_hash {
    using ull = unsigned long long int;
    using uint = unsigned int;
    const ull MASK30 = (1ULL << 30) - 1;
    const ull MASK31 = (1ULL << 31) - 1;
    const ull MOD = (1ULL << 61) - 1;
    const ull POSITIVIZER = MOD * ((1ULL << 3) - 1);

    uint base;
    vector<ull> pow_memo, hash;

    rolling_hash(const string& s) {
        random_device rd;
        uniform_int_distribution<uint> dist(129, numeric_limits<int>::max() - 1);
        base = dist(rd);
        init(s);
    }

    rolling_hash(const string& s, uint base) : base(base) { init(s); }

    void init(const string& s) {
        pow_memo.resize(s.size() + 1, 1);
        hash.resize(s.size() + 1);
        for (int i = 0; i < (int)s.size(); ++i) {
            pow_memo[i+1] = calc_mod(mul(pow_memo[i], base));
            hash[i+1] = calc_mod(mul(hash[i], base) + s[i]);
        }
    }

    ull substr(int begin, int length) {
        return calc_mod(hash[begin + length] + POSITIVIZER - mul(hash[begin], pow_memo[length]));
    }

    ull mul(ull a, ull b) {
        ull au = a >> 31;
        ull al = a & MASK31;
        ull bu = b >> 31;
        ull bl = b & MASK31;
        ull mid = au * bl + al * bu;
        ull midu = mid >> 30;
        ull midl = mid & MASK30;
        return ((au * bu) << 1) + midu + (midl << 31) + al * bl;
    }

    ull mul(ull a, uint b) {
        ull au = a >> 31;
        ull al = a & MASK31;
        ull bl = b & MASK31;
        ull mid = au * bl;
        ull midu = mid >> 30;
        ull midl = mid & MASK30;
        return midu + (midl << 31) + al * bl;
    }

    ull calc_mod(ull x) {
        ull xu = x >> 61;
        ull xl = x & MOD;
        ull res = xu + xl;
        if (res >= MOD) res -= MOD;
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s, t;
    cin >> s >> t;

    rolling_hash rs(s);
    rolling_hash rt(t, rs.base);
    auto check = rt.substr(0, t.size());
    for (size_t i = 0; i + t.size() <= s.size(); ++i) {
        if (rs.substr(i, t.size()) == check) cout << i << '\n';
    }
}



Measured memory_bytes: 19756
#include <stdio.h>

int main()
{
    int n, m, l, i, j, k;
    int a[101][101] = {0};
    int b[101][101] = {0};
    long c[101][101] = {0};
    
    scanf("%d%d%d", &n, &m, &l);
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    
    for(i=0; i<m; i++){
        for(j=0; j<l; j++){
            scanf("%d", &b[i][j]);
        }
    }
    
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            for(k=0; k<m; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    for(i=0; i<n; i++){
        for(j=0; j<l; j++){
            printf("%ld", c[i][j]);
            if(j==(l-1)) printf("\n");
            else printf(" ");
        }
    }
    return 0;
}

Measured memory_bytes: 772
N,K=map(int,input().split())
total=0
for i in range(1,N+1):
    if i>=K:
        total+=1
    for j in range(20):
        
        if (2**j)*i<K<=(2**(j+1))*i:
            a=j+1
            total+=(1/2)**a
            break

print((1/N)*total)

Measured memory_bytes: 9364