akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 1;

ll A[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> pos, neg;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] >= 0) pos.push_back(A[i]);
        else neg.push_back(A[i]);
    }
    if (N == 1) {
        cout << A[0] << endl;
        return 0;
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    ll ans;
    vector<ll> X, Y;
    if ((int)pos.size() == N) {
        ans = pos[pos.size() - 1];
        ll sub = pos[0];
        for (int i = 1; i < N - 1; i++) {
            X.push_back(sub);
            Y.push_back(pos[i]);
            sub -= pos[i];
        }
        X.push_back(max(ans, sub));
        Y.push_back(min(ans, sub));
        ans = max(ans, sub) - min(ans, sub);
    }
    else if ((int)neg.size() == N) {
        ans = neg[neg.size() - 1];
        for (int i = 0; i < N - 1; i++) {
            X.push_back(ans);
            Y.push_back(neg[i]);
            ans -= neg[i];
        }
    }
    else {
        ll max_pos = pos[pos.size() - 1];
        ll max_neg = neg[neg.size() - 1];
        for (int i = 0; i < pos.size() - 1; i++) {
            X.push_back(max_neg);
            Y.push_back(pos[i]);
            max_neg -= pos[i];
        }
        for (int i = 0; i < neg.size() - 1; i++) {
            X.push_back(max_pos);
            Y.push_back(neg[i]);
            max_pos -= neg[i];
        }
        X.push_back(max_pos);
        Y.push_back(max_neg);
        ans = max_pos - max_neg;
    }
    cout << ans << endl;
    for (int i = 0; i < N - 1; i++) {
        cout << X[i] << ' ' << Y[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6004
// V solo
#include <bits/stdc++.h>

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)2e5 + 7;
const long long INF = 1e18;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, t, a[N];
int main (){
  scanf ("%d %d", &n, &t);
  forn (i, 1, n) scanf ("%d", a + i);
  int ans = t;
  forn (i, 1, n - 1){
    ans += min(t, a[i + 1] - a[i]);
  }
  printf ("%d\n", ans);
  return 0;
}


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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 10000;

ll a[N]; 
ll r[N],l[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll n,k,ans;
	cin>>n>>k;
	for(ll i=1;i<=n;i++) cin>>a[i];
	ll num=0;
	num=(k+1)*k/2;
	num-=k;
	num%=mod;
	ans=0;
	memset(r,0,sizeof(r));
	memset(l,0,sizeof(l));
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<i;j++)
		{
			if(a[i]>a[j])
				l[i]++;//这个数左边小于当前位置的数的个数 
		}
		for(ll j=i+1;j<=n;j++)
		{
			if(a[i]>a[j])
				r[i]++;//这个数右边小于当前位置的数的个数 
		}
	}
//	cout<<num<<endl;
	for(ll i=1;i<=n;i++)
	{
//		cout<<l[i]<<' '<<r[i]<<endl;
		ans=ans+l[i]*num%mod;
		ans=ans+r[i]*(num+k)%mod;
	}
	cout<<ans%mod<<endl;	
	return 0;
}




Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

void Yn(bool f)
{
  cout << (f ? "Yes" : "No") << endl;
}

void yn(bool f)
{
  cout << (f ? "yes" : "no") << endl;
}

void YN(bool f)
{
  cout << (f ? "YES" : "NO") << endl;
}
int k;
int main()
{
  cin >> k;
  cout << (k/2)*((k+1)/2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN], sum[MAXN];
bool mark[MAXN];
string S, T;
vector<int> G[MAXN];

void add(int l, int r){
	G[l].pb(r+1);
	G[r+1].pb(l);
}

int dfs(int node){
	mark[node]=1;
	for (int v:G[node]) if (!mark[v]) sum[node]+=dfs(v);
	return sum[node];
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>S>>m;
	int len=S.size();
	n=len/2;
	for (int i=0; i<n; i++) T+=S.back(), S.pop_back();
	if (len&1) S.pop_back();
	
	for (int i=1; i<=n; i++) A[i]=S[n-i]-T[n-i];
	for (int i=1; i<=n+1; i++) sum[i]=A[i]-A[i-1];
	while (m--){
		cin>>x>>y;
		if (len%2){
			if (x==n+1 && y==n+1) continue ;
			if (x==n+1) x++;
			if (y==n+1) y--;
			if (x>n) x--;
			if (y>n) y--;
		}
		if (x<=n && y<=n) x=n-x+1, y=n-y+1, swap(x, y);
		else if (x>n && y>n) x-=n, y-=n;
		else{
			x=n-x+1;
			y-=n;
			if (x>y) swap(x, y);
			x++;
		}
		add(x, y);
	}
	for (int i=1; i<=n+1; i++) if (!mark[i] && dfs(i)%26) kill("NO")
	kill("YES")
	
	return 0;
}

Measured memory_bytes: 10396
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int trans = A - B;
		int ans = C -trans;
		if(C - trans < 0) {
			ans = 0;
		}
		System.out.println(ans);
		
		

	}

}

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


def read():
    A = input().strip()
    return A,


def solve(A):
    return "a" if A.lower() == A else "A"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9096
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef string ST;
 
 
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 

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

LL modinv(LL a, LL m) {
  LL b = m, u = 1, v = 0;
  while (b) {
    LL t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0){
     u += m;
  }
  return u;
}

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}

void func() {
  LL N;
  LL K;
  cin >> N;
  cin >> K;
  vector<LL> A(N);
  REP(i,N){
    cin >> A[i];
  }

  vector<LL> dp(K+1,-1);
  dp[0]=0;
  for(LL i=1;i<=K; ++i){
    bool can_move = false;
    for(auto a : A){
      if((i-a)< 0){
        break;
      }
      if(dp[i-a]==0){
        can_move=true;
        break;
      }
    }
    if(can_move){
      dp[i]=1;
    }
    else{
      dp[i]=0;
    }
  }
  //PRINTSP(dp);
  if(dp[K]==1){
    cout <<"First";
  }
  else{
    cout <<"Second";
  }
  
  return;
}



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

Measured memory_bytes: 1024
import numpy as np


dp = np.zeros((2, 4), dtype=np.int64)
mod = int(1e9+7)
dp[0][0] = 1
for s in input():
    if s == '?':
        dp[1] = dp[0]*3
        dp[1][1:] += dp[0][:3]
    else:
        dp[1] = dp[0]
        if s == 'A':
            dp[1][1] += dp[0][0]
        elif s == 'B':
            dp[1][2] += dp[0][1]
        elif s == 'C':
            dp[1][3] += dp[0][2]
    dp[0] = np.remainder(dp[1], mod)
print(dp[0][3])

Measured memory_bytes: 14676
s = input()
t = input()

sl = {}
tl = {}

for i, j in zip(s, t):
    if i not in sl:
        sl[i] = j
    else:
        if sl[i] != j:
            print("No")
            break
    if j not in tl:
        tl[j] = i
    else:
        if tl[j] != i:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
            #define ll long long
            #define MOD 1000000007
            #define maxx ((ll)1e6+5)
            #define zuciso ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define test ll t; cin>>t; while(t--)
            #define int long long
            #define INF 1000000000000000005
            #define pb push_back
            #define pi 3.1415926
            #define MAX 300006
            #define MAX_N 1000000
            #define N 15000005
            #define fori(i,a,b) for(int i=a;i<b;i++)
            ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
            ll fact[1000007]={0};
            void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
            ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[r],MOD-2)))%MOD; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(fpow(fact[n-r],MOD-2)))%MOD; return res;}
            ll modmul(ll x, ll y){return (x*y)%MOD;}
            ll modadd(ll x, ll y){return (x+y)%MOD;}
            ll modsub(ll x, ll y){return (x-y+MOD)%MOD;}
            ll xx[4]={1,0,-1,0};
            ll yy[4]={0,1,0,-1};
           using namespace std;



            signed main(){
                zuciso;
                int x,n;
                cin>>x>>n;
                int a[n];
                set<int> s;
                for(int i=-1;i<=10000;i++){
                    s.insert(i);
                }
                for(int i=0;i<n;i++){
                    cin>>a[i];
                    s.erase(a[i]);
                }
                auto it = s.upper_bound(x);
                it--;
                int z=*it;
                it=s.upper_bound(x);
                int zz=*it;
                if(abs(x-z)<=abs(x-zz)){
                    cout<<z<<endl;

                }
                else{
                    cout<<zz<<endl;
                }



            }


Measured memory_bytes: 4124
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int MAX = 101010;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0; is_prime[1] = 0;
  for (int i = 2; i < MAX; i++) {
    if (!is_prime[i]) continue;
    for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
  }

  vector<int> is_like(MAX, 0); 
  for (int i = 2; i < MAX; i++) {
    if (!is_prime[i]) continue;
    if (is_prime[(i + 1) / 2]) is_like[i] = 1;
  }

  vector<int> s(MAX + 1);
  for (int i = 0; i < MAX; i++) s[i + 1] = s[i] + is_like[i]; 

  int Q; cin >> Q;
  vector<int> L(Q);
  vector<int> R(Q);
  for (int i = 0; i < Q; i++) cin >> L[i] >> R[i];

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


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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N%2==1) {
        cout << "No" << endl;
        return 0;
    } else {
        for(int i=0;i<N/2;i++) {
            if(S[i] != S[i+N/2]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Data.Array (Array,listArray,(!),elems,(//),accum)
import Data.Char (digitToInt)
import Data.List (sort,group)
import System.IO (isEOF)

main = do
    quit <- isEOF
    if quit then return () else do
        input >>= return . solve >>= output
        main

input :: IO [Int]
input = do
    line <- getLine
    return (map digitToInt line)

output :: [Int] -> IO ()
output [] = putStrLn "0"
output ns = putStrLn $ unwords $ map show ns

solve :: [Int] -> [Int]
solve ns = filter test' [1..9]
    where
    test' n = test (n:ns)

test :: [Int] -> Bool
test ns = not $ null $
    return (counts ns) >>= maxUnder 4 >>= matchPair >>= matchThree >>=
    matchThree >>= matchThree >>= matchThree

type Counts = Array Int Int

counts :: [Int] -> Counts
counts ns = listArray (1,9) [0,0..] //
            (map (\e->(head e, length e)) $ group $ sort ns)

maxUnder :: Int -> Counts -> [Counts]
maxUnder n cs
    | (maximum $ elems cs) <= n = [cs]
    | otherwise = []

matchPair :: Counts -> [Counts]
matchPair cs = concatMap ($ cs) (map match' [1..9])
    where
    match' n cs
        | cs!n >= 2 = [accum (-) cs [(n,2)]]
        | otherwise = []

matchThree :: Counts -> [Counts]
matchThree cs = concatMap ($ cs) [matchTriple, matchSeries]

matchTriple :: Counts -> [Counts]
matchTriple cs = concatMap ($ cs) (map match' [1..9])
    where
    match' n cs
        | cs!n >= 3 = [accum (-) cs [(n,3)]]
        | otherwise = []

matchSeries :: Counts -> [Counts]
matchSeries cs = concatMap ($ cs) (map match' [1..7])
    where
    match' n cs
        | cs!n >= 1 && cs!(n+1) >= 1 && cs!(n+2) >= 1
            = [accum (-) cs [(n,1),(n+1,1),(n+2,1)]]
        | otherwise = []

Measured memory_bytes: 4100
r, c, k = map(int, input().split())

dp = [[[0,0,0,0] for _j in range(c+1)] for _i in range(2)]
bord = [[0]*(c+1) for _i in range(r)]

for _i in range(k):
    _r, _c, _v = map(int, input().split())
    bord[_r-1][_c-1] = _v
            
for i in range(r):
    for j in range(c):
        dp[1][j][0] = max(dp[0][j])
        dp[1][j][1] = dp[1][j][0] + bord[i][j]
        for x in range(1, 4):
            dp[1][j][x] = max(
                dp[1][j][x],
                dp[1][j-1][x],
                dp[1][j-1][x-1]+bord[i][j],             
            )
    dp[0] = dp[1][::]

print(max(dp[1][c-1]))

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    LL n, m;
    cin >> n >> m;

    DD x = 1. / (4. * m);
    int S = 0;

    int a[mx2];

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

    sort(a, a + n);

    int cnt = 0;
    for(int i = n - 1; i >= 0; i--){
        if((DD)a[i] / (DD)S >= x)
            cnt++;
    }

    if(cnt >= m)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){

  int A, B; cin >> A >> B;

  if (A == B){
    cout << 0 << endl;
  }else if((A + B) % 2 == 0){
    cout << (A + B) / 2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  while(n>0){
    if(n%10==7){
      cout<<"Yes\n";
      return 0;
    }
    else{
      n=n/10;
    }
  }
  cout<<"No\n";
  return 0;
  
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var n int
	var s []string
	m := make(map[string]bool)
	var u []string
	var t string
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		s = append(s, t)
	}
	for _, ele := range s {
		if !m[ele] {
			m[ele] = true
			u = append(u, ele)
		}
	}
	fmt.Println(len(u))
}


Measured memory_bytes: 35408
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;


i32 a[200000];

auto main() -> i32 {
	i32 n, k;
	scanf("%d%d", &n, &k);
	for (i32 i = 0; i < n; ++i) {
		scanf("%d", a + i);
	}
	i64 l = 0;
	i64 r = 1000000000;
	while (r - l > 1) {
		i64 mid = l + (r - l) / 2;
		i64 cut = 0;
		for (i32 i = 0; i < n; ++i) {
			cut += ((i64)a[i] + mid - 1) / mid - 1;
		}
		if (cut <= k) {
			r = mid;
		} else {
			l = mid;
		}
	}
	printf("%ld\n", r);
	return 0;
}


Measured memory_bytes: 2460
import java.util.*;
import java.util.stream.*;
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in;
    in = br.readLine().split(" ");
    int n = Integer.parseInt(in[0]);

    in = br.readLine().split(" ");
    long[] a = Stream.of(in).mapToLong(Long::parseLong).toArray();

    br.close();

    Map<Long, Long> m = new HashMap<>();

    for(int i = 0; i < n; i++){
      m.put(a[i], m.getOrDefault(a[i], 0L) + 1L);
    }

    long ans = 0;

    for(Map.Entry<Long, Long> e : m.entrySet()){
      ans += e.getValue() * (e.getValue() - 1) / 2;
    }

    for(int i = 0; i < n; i++){
      System.out.println(ans - m.get(a[i]) + 1);
    }
    
  }
}

Measured memory_bytes: 93656
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            cout << "No" << endl;
            return (0);
        }
    }
    cout << "Yes" << endl;
    return (0);
}

Measured memory_bytes: 3600
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    System.out.println((H-h)*(W-w));
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S, T; cin >> S >> T;
  ll ls = S.size(), lt = T.size();
  ll result = LLINF;
  rep(i,ls-lt+1) {
    ll count = 0;
    rep(j,lt) count += S[i+j] != T[j];
    result = min(result, count);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
  public static void main(String[] args) { // 入力
    Scanner scanner = new Scanner(System.in);
    final int N = scanner.nextInt();
    final int M = scanner.nextInt();
    //        System.out.println(N);
    //        System.out.println(M);

    int height[] = new int[N];
    for (int i = 0; i < N; i++) {
      height[i] = scanner.nextInt();
      //            System.out.println(height[i]);
    }

    int road[][] = new int[M][2];
    for (int i = 0; i < M; i++) {
      //            System.out.println("i＝" + i);
      road[i][0] = scanner.nextInt();
      //            System.out.println(road[i][0]);
      road[i][1] = scanner.nextInt();
      //            System.out.println(road[i][1]);
    }
    
    int goodnum[] = new int[N];

    for (int i = 0; i < M; i++) {
      if (height[road[i][0] - 1] <= height[road[i][1] - 1]) {
        goodnum[road[i][0] - 1] = 9;
      }
      if (height[road[i][1] - 1] <= height[road[i][0] - 1]) {
        goodnum[road[i][1] - 1] = 9;
      }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (goodnum[i] == 0) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}


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

class Num
{
public:
	int a;
	int b;
	int c;
	void set(int ini_a, int ini_b, int ini_c);
};

void Num::set(int ini_a, int ini_b, int ini_c)
{
	a = ini_a;
	b = ini_b;
	c = ini_c;
}

int main(){
	Num seisu;
	seisu.set(0, 0, 0);
	
	cin >> seisu.a;
	cin >> seisu.b;
	cin >> seisu.c;
	
	if( seisu.a < seisu.b){
		if( seisu.b < seisu.c ){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

long int ans(long int n)
{
    if(n==1)
        return 1;
    else
        return 1+ans(n/2)*2;
}

int main()
{
    long int  H;
    cin >> H;
    cout << ans(H) << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = input().replace(" ","")
Q = input().replace(" ","")

from collections import deque
q = deque()
q.append("")

a = -1
b = -1
cnt = 0
while q:
  cnt += 1
  st = q.popleft()
  if len(st) == N:
    if st == P:
      a = cnt
    if st == Q:
      b = cnt
    continue
  for i in range(1, N + 1):
    if str(i) not in st:
      q.append(st + str(i))

print(abs(a - b))

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

const int maxn = 55;
const int maxv = 2505;
const lld inf = 1e13;

lld dp[maxn][maxv + 1];
vector<pair<int, pll>> adj[maxn];
vector<pii> city(maxn);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m, s;
    cin >> n >> m >> s;

    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        adj[u].emplace_back(v, MP(a, b));
        adj[v].emplace_back(u, MP(a, b));
    }

    for (int i = 1; i <= n; i++) {
        cin >> city[i].X >> city[i].Y;
        for (int j = 0; j <= maxv; j++) {
            dp[i][j] = inf;
        }
    }

    priority_queue<pair<lld, pll>, vector<pair<lld, pll>>, greater<pair<lld, pll>>> pq;
    pq.emplace(0, MP(1, min(maxv, s)));

    while (!pq.empty()) {
        auto top = pq.top();
        pq.pop();

        lld t = top.X;
        int p = top.Y.X;
        int coin = top.Y.Y;

        // cout << t << ' ' << p << ' ' << coin <<  '\n';

        if (dp[p][coin] <= t) {
            continue;
        }
        
        dp[p][coin] = t;

        int nxtv = min(maxv, coin + city[p].X);

        if (dp[p][nxtv] > t + city[p].Y) {
            pq.emplace(t + city[p].Y, MP(p, nxtv));
        }

        for (auto &e : adj[p]) {
            int to = e.X;
            int used_coin = e.Y.X;
            int used_time = e.Y.Y;
            if (coin >= used_coin) {
                pq.emplace(t + used_time, MP(to, coin - used_coin));
            }
        }
    }

    for (int i = 2; i <= n; i++) {
        cout << *min_element(dp[i], dp[i] + maxv) << '\n';
    }

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

Measured memory_bytes: 10452
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define LL long long
LL a[MAXN];
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c,du[MAXN],n;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
LL s[MAXN];
void dfs(int u,int p)
{
	if(du[u]==1)
	{
		s[u]=a[u];
		return;
	}
	LL sum=0;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p)
		{
			dfs(V[i],u);
			sum+=s[V[i]];
		}
	if(sum<a[u]||sum>a[u]*2)
	{
		printf("NO\n");
		exit(0);
	}
	if(sum==a[u])
	{
		s[u]=sum;
		return;
	}
	s[u]=2*a[u]-sum;
	LL left=sum-a[u],ls=0,al=0;
	for(int i=Adj[u];i&&left;i=nxt[i])
		if(V[i]!=p)
		{
			LL k=s[V[i]];
			LL del=min(min(k,ls),left);
			k-=del,left-=del,ls-=del;
			if(k>1&&al&&left)
			{
				LL p=k/2;
				LL ed=min(min(p,al),left);
				left-=ed;
				k-=ed*2;
				al+=ed;
			}
			ls+=k;
			al+=del;
		}
	if(left)
	{
		printf("NO\n");
		exit(0);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		du[u]++,du[v]++;
		AddEdge(u,v);
		AddEdge(v,u);
	}
	if(n==2)
	{
		if(a[1]==a[2])
			printf("YES\n");
		else printf("NO\n");
		return 0;
	}
	int rt=1;
	for(int i=1;i<=n;i++)
		if(du[i]>1)
		{
			rt=i;
			break;
		}
	dfs(rt,0);
	if(s[rt]) printf("NO\n");
	else printf("YES\n");
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int k[26];

string s;
int main(){
	cin>>s;
	bool prime=true;
	int a=s.length();
	for(int i=0;i<a;i++){
		k[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(k[i]==0){
			char c='a'+i;
			cout<<c<<endl;
			prime=false;
			break;
		}
	}
	if(prime)
		cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n-1);
    rep(i,n-1) cin >> b[i];

    a[0] = b[0];
    a[n-1] = b[n-2];
    for(int i = 1; i < n-1; i++) {
        a[i] = min(b[i], b[i-1]);
    }

    int ans = 0;
    rep(i,n) ans += a[i];

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


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

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

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

using namespace std;
typedef long long ll;

int main()
{
	ll x = 0;
	ll i = 0;
	ll j = 0;
	ll ans = 0;

	cin >> x;

	j = ceil( ((double)x - 6) / 11 );
	i = ceil(((double)x - 5*j) / 6);
	ans = i + j;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll sum=0,n,neg=1;
  cin >> n;
  vector<int> v(n);
  for (int i=0; i<n; ++i){
    int a;
    cin >> a;
    v[i]=a;
    sum += a*neg;
    neg *= -1;
  }
  cout << sum;
  sum >>= 1;
  for (int i=1; i<n; ++i){
    sum = v[i-1]-sum;
    cout << ' ' << (sum<<1);
  }
}


Measured memory_bytes: 1664
s=input()
n=len(s)
a=s[:(n-1)//2]
b=s[(n+3)//2-1:]
n=len(s)//2
for i in range(n):
    if s[i]!=s[-i-1]:
        print('No')
        exit()
n=len(a)//2
for i in range(n):
    if a[i]!=a[-i-1]:
        print('No')
        exit()
n=len(b)//2
for i in range(n):
    if b[i]!=b[-i-1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int n, m; cin>>n>>m;
    vector<int> s(m);
    vector<char> c(m);
    for(int i=0; i<m; i++){
        cin>>s[i]>>c[i];
        s[i]--;
    }
    
    if(n == 1){
        for(int i=0; i<=9; i++){
            bool valid = true;
            string ss = to_string(i);
            for(int j=0; j<m; j++){
                if(ss[s[j]] != c[j]) valid = false;
            }
            if(valid){
                cout << i << endl;
                return 0;
            }
        }
    }
    else if(n == 2){
        for(int i=10; i<=99; i++){
            bool valid = true;
            string ss = to_string(i);
            for(int j=0; j<m; j++){
                if(ss[s[j]] != c[j]) valid = false;
            }
            if(valid){
                cout << i << endl;
                return 0;
            }
        }
    }
    else{
        for(int i=100; i<=999; i++){
            bool valid = true;
            string ss = to_string(i);
            for(int j=0; j<m; j++){
                if(ss[s[j]] != c[j]) valid = false;
            }
            if(valid){
                cout << i << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* #pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
typedef long long ll;
const ll MAXN = 6 + 2;
const ll MAXD = 1e3 + 5;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}
int n,m,k;
char g[MAXN][MAXN];
bool vis[6][6];
int all = 0;

vector<pair<int,int> > v;
vector<pair<int,int> > sub;
int ans = 0;
void solve(int i)
{
  if(i == (int)v.size())
    { 
      memset(vis,0,sizeof(vis));
      int ret = 0; 
      for(auto &k : sub)
      {
          if(k.first == 0)
          {
            int u = k.second;
            for(int j = 0 ; j < m ; j++)
               {
                   if(vis[u][j])
                      continue;
                    vis[u][j] = 1;
                    ret+=(g[u][j]=='#');
               }
          }
          else
          {
                int u = k.second;
            for(int j = 0 ; j < n ; j++)
               {
                   if(vis[j][u])
                      continue;
                    vis[j][u] = 1;
                    ret+=(g[j][u]=='#');
               }
          }
      }
       

       ans+=((all - ret) == k);
       return;

    }

    solve(i + 1);
    sub.push_back(v[i]);
    solve(i + 1);
    sub.pop_back();

}


int main(){

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


cin >> n >> m >> k;
for(int i = 0 ; i < n ; i++)
    for(int j = 0 ; j < m ; j++){
        cin >> g[i][j];
        if(g[i][j] == '#')
            ++all;
      }

  for(int i = 0 ; i < n ; i++)
      v.push_back({0,i});
  for(int i = 0 ; i < m ; i++)
      v.push_back({1,i});


  solve(0);

  cout << ans << '\n';
 
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

char a[1234][1234];
int dis[1234][1234];
int main()
{
	int n, m;
	cin >> n >> m;
	queue<pii> q;
	for(int i = 1; i <= n; i ++)
	for(int j = 1; j <= m; j ++)
	{
		cin >> a[i][j];
		if(a[i][j] == '#')
			q.push(M(i, j)),
			dis[i][j] = 0;
	}
	int ans = 0;
	while(q.size())
	{
		int x = q.front().F, y= q.front().S;
		q.pop();
		for(int dx = -1; dx <= 1; dx ++)
		for(int dy = -1; dy <= 1; dy ++)
		{
			if(abs(dx - dy) == 1)
			{
				if(a[x + dx][y + dy] == '.')
				{
					dis[x + dx][y + dy] = dis[x][y] + 1;
					a[x + dx][y + dy] = '#';
					umax(ans, dis[x + dx][y + dy]);
					q.push(M(x + dx, y + dy));
				}
			}
		}
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 15632
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}
// https://algo-logic.info/divisor/
/// 約数の配列を返す
func divisor(_ n:Int) -> [Int] {
    var ret = [Int]()
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            ret.append(i)
            if i * i != n {
                ret.append(n / i)
            }
        }
        i += 1
    }
    return ret.sorted()
}

func main() {
    let n = readInt()
    let aryA = readInts().sorted()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var (left, right, ans) = (0, 0, 0)
    
    while right < n {
        while right < n && aryA[left] == aryA[right] {
            right += 1
        }
        let count = right - left
        
        if count < aryA[left] {
            ans += count
        } else {
            ans += count - aryA[left]
        }
        
        left = right
    }
    print(ans)
}
main()


Measured memory_bytes: 19088
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct node {
    int val, to;
    node(){}
    node(int v, int t):val(v), to(t) {}
};

struct Splice {
    vector<node> L;
    vi ce, ba;
    Splice(int n = 0):ce(n, -1), ba(n, -1) {}
    void insert(int t, int x) {
        if(ba[t] == -1) {
            ce[t] = L.size();
            ba[t] = L.size();
            L.emplace_back(x, -1);
        } else {
            L[ba[t]].to = L.size();
            ba[t] = L.size();
            L.emplace_back(x, -1);
        }
    }
    void dump(int t) {
        int i = ce[t];
        while(i != -1) {
            cout << L[i].val;
            if(i == ba[t]) break;
            cout << ' ';
            i = L[i].to;
        }
        cout << '\n';
    }
    void splice(int s, int t) {
        if(ba[t] == -1) {
            ce[t] = ce[s];
        } else {
            L[ba[t]].to = ce[s];
        }
        ba[t] = ba[s];
        ce[s] = ba[s] = -1;
    } 
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    Splice sp(n);
    while(q--) {
        int i;
        cin >> i;
        if(i == 0) {
            int t, x;
            cin >> t >> x;
            sp.insert(t, x);
        } else if(i == 1) {
            int t;
            cin >> t;
            sp.dump(t);
        } else {
            int s, t;
            cin >> s >> t;
            sp.splice(s, t);
        }
    }
}


Measured memory_bytes: 7128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n, m; cin >> n >> m;
	cout << m * (m - 1) / 2 + n * (n - 1) / 2 << '\n';
	return 0;
}

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

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


int pre[200005];
const int mod=1e9+7;

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int z=(pre[n]-pre[i]+mod)%mod;
        ans+=(z*a[i])%mod;
        ans%=mod;
    }
    cout<<ans;

}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

int N, K;
vector<int> A;

bool check(int x) {
    int cnt = K;
    REP(i, N) {
        int div = A[i] / x;
        if(A[i] % x != 0) { div++; }
        cnt -= (div - 1);
        if(cnt < 0) { return false; }
    }
    return true;
}

int solve() {
    int lb = 0, ub = 1000000001LL;
    while(ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if(check(mid)) { ub = mid; }
        else { lb = mid; }
    }
    if(check(ub)) { return ub; }
    return lb;
}

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> K;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
    }

    int ans = solve();
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4756
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char a[10];
    scanf("%s",a);
    if(a[0]==a[1]&&a[1]!=a[2]&&a[2]==a[3]){printf("Yes\n");}
    else if(a[0]==a[2]&&a[1]!=a[2]&&a[1]==a[3]){printf("Yes\n");}
    else if(a[0]==a[3]&&a[3]!=a[2]&&a[1]==a[2]){printf("Yes\n");}
    else {printf("No\n");}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
   //cin >> tc;
    while (tc--)
    {
        string s, t;
        cin >> s >> t;
        t = t.substr(0, t.size() - 1);
        if(s==t){
            cout << "Yes" << endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long  n,k,b,c,d,q;
    cin >> n;
    map<int,int> m;
    long long  a[n];
    long long  s=0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        s=s+a[i];
        m[a[i]]++;
    }
    cin >> q;
    while(q--)
    {
        cin >> b >> c ;
        if(m[b]>0)
        {  d=c-b;
           m[c]+=m[b];
           s=s+m[b]*d;
           m[b]=0;
        }
        cout << s <<endl;
    }
    return 0;
}

Measured memory_bytes: 8580
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(s, w);
	if (s > w) cout << "safe";
	else cout << "unsafe";
	
}














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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int>> g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};

int main(){
    int n,m; scanf("%d%d",&n,&m);
    vector<vector<int>> a(n);
    rep(i,0,n){
        a[i].resize(m);
        rep(j,0,m)scanf("%d",&a[i][j]);
    }
    int b[110][110],c[110][110];
    rep(rot,0,m){
        bipartite_matching g(2*n);
        rep(i,0,n)rep(j,0,m)if(a[i][j]){
            int val=(a[i][j]-1)/m;
            g.add_edge(i,val+n);
        }
        g.maximum_matching();
        rep(i,0,n){
            int p=g.match[i]-n;
            rep(j,0,m){
                if(a[i][j]>=p*m+1&&a[i][j]<=p*m+m){
                    b[i][rot]=a[i][j];
                    a[i][j]=0; break;
                }
            }
        }
    }
    rep(i,0,m){
        vector<int> s(n);
        rep(j,0,n)s[j]=b[j][i];
        sort(ALL(s));
        rep(j,0,n)c[j][i]=s[j];
    }
    rep(i,0,n){
        rep(j,0,m)printf("%d ",b[i][j]);
        puts("");
    }
    rep(i,0,n){
        rep(j,0,m)printf("%d ",c[i][j]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 640