akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#define INF (1e9)
#define N 8
using namespace std;
void bfs();
int w,h,d[N][N],data[N][N],sy,sx,gy,gx,ans;
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
struct dat{
  int y,x,life,dis;
};
  
int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) d[i][j]=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
    cin>>data[i][j];
    if(data[i][j]==2) sy=i,sx=j,data[i][j]=1;
    if(data[i][j]==3) gy=i,gx=j,data[i][j]=1;
      }
    ans=INF;
    bfs();
    if(ans!=INF) cout<<ans<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}
  
void bfs(){
  queue<dat> q;
  q.push((dat){sy,sx,6,0});
  d[sy][sx]=6;
  while(!q.empty()){
    dat t=q.front(); q.pop();
    int uy=t.y,ux=t.x,life=t.life,dis=t.dis;
    for(int i=0;i<4;i++){
      int ny=uy+dy[i],nx=ux+dx[i];
      if(ny<0||nx<0||h<=ny||w<=nx) continue;
      if(life==1||!data[ny][nx]||(d[ny][nx]>=life-1)) continue;
      if(ny==gy&&nx==gx) ans=min(ans,dis+1);
      if(data[ny][nx]==4) d[ny][nx]=6,q.push((dat){ny,nx,6,dis+1});
      if(data[ny][nx]==1){
    d[ny][nx]=life-1;
    q.push((dat){ny,nx,life-1,dis+1});
      }
    }
  }
}

Measured memory_bytes: 1200
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}

template<class N> void resiz(N n) {} // empty
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}


ll A;
int B;

void input() {
	cin>>A;
	string b; cin>>b;
	b.erase(b.begin()+b.find('.'));
	B=stoi(b);
}

void solve() {
	cout<<A*B/100<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 3604
import sys
import heapq
my_input = sys.stdin.readline

def main():
    xs, ys, xt, yt = map(int, my_input().split())
    N = int(my_input())
    C = [(xs, ys, 0), (xt, yt, 0)]
    C += [tuple(map(int, my_input().split())) for i in range(N)]

    G = [[] for i in range(N+2)]
    for i in range(N + 2):
        for j in range(i + 1, N + 2):
            cost = max(0, ((C[i][0] - C[j][0]) ** 2 + (C[i][1] - C[j][1]) ** 2) ** 0.5 - (C[i][2] + C[j][2]))
            G[i].append((j, cost))
            G[j].append((i, cost))


    def dijkstra(graph, start, inf=float('inf')):
        import heapq
        n = len(graph)
        distances = [inf] * n
        distances[start] = 0
        visited = [False] * n

        # 距離・頂点
        hq = [(0, start)]
        while hq:
            dist, fr = heapq.heappop(hq)
            visited[fr] = True
            if distances[fr] < dist:
                continue
            if fr == 1:
                return distances


            for to, cost in graph[fr]:
                new_dist = distances[fr] + cost
                if (visited[to]) or (distances[to] <= new_dist):
                    continue

                distances[to] = new_dist
                heapq.heappush(hq, (new_dist, to))

        return distances


    dist = dijkstra(G, 0)
    print(dist[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 167000
var x = require('fs').readFileSync('/dev/stdin', 'utf8');

var array = x.split("\n");

for (var i = 0; i < array.length; i++) {
    var subarray = array[i].split(" ").map(Number);
    if( subarray[0] == 0 && subarray[1] == 0 ) break;
    subarray.sort(
        function(a,b) {
            return a-b;
        }
    )
    console.log(subarray.join(" "));
}


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

using namespace std;


#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)



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

	if (n%k == 0) {
		ANS(0);
	}
	else {
		ANS(1);
	}


	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if  (n%2 != 0) System.out.println((n/2) + 1);
        else System.out.println(n/2);
        sc.close();
    }
}

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

class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return string(t + i + 1);
  }
  string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main() {
	long n,k;
  	string str;
    cin >> n >> k;
    Radix r;
  	str = r.to(n, k);
  	cout << (int)(str.length()) << endl;
  	return 0;
}

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

const int N = 200005;

int n, k, m;
int a[N], b[N];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		a[x]++;
	}
	for (int i = 0; i < N; i++) {
		if (a[i]) b[m++] = a[i];
	}
	sort(b, b + m);
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (k >= m) break;
		k++;
		ans += b[i];
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	//見やすくした
	int N;
	cin >> N;
	int A[300001];
	rep(i, 3 * N) cin >> A[i];

	ll S1[100001] = {}, S2[100001] = {};

	map<int, int> B, C;
	rep(i, N) {
		B[A[i]]++;
		C[A[2 * N + i]]++;
	}

	rep(i, N) S1[0] += A[i];

	rep1(i, N) {
		int K = B.begin()->first;
		if (K < A[N + i - 1]) {
			S1[i] = S1[i - 1] + A[N + i - 1] - K;
			B[K]--;
			if (B[K] == 0) B.erase(K);
			B[A[N + i - 1]]++;
		}
		else {
			S1[i] = S1[i - 1];
		}
	}

	rep(i, N) S2[0] += A[2 * N + i];
	reverse(A + N, A + 2 * N);

	rep1(i, N) {
		int K = (--C.end())->first;
		if (K > A[N + i - 1]) {
			S2[i] = S2[i - 1] + A[N + i - 1] - K;
			C[K]--;
			if (C[K] == 0) C.erase(K);
			C[A[N + i - 1]]++;
		}
		else {
			S2[i] = S2[i - 1];
		}
	}

	ll S[100001];
	rep(i, N + 1) {
		S[i] = S1[i] - S2[N - i];
	}

	co(*max_element(S, S + N + 1));

	Would you please return 0;
}

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

int main() {
  int a, b;
  string ab, ba;
  cin >> a >> b;
  for(int i = 0; i < b; i++)
    ab.push_back(a + '0');
  for(int i = 0; i < a; i++)
    ba.push_back(b + '0');
  if(ab < ba)
    cout << ab << endl;
  else
    cout << ba << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left

def find(a,l):
    i=bisect_left(l,a)
    if(i!=len(l) and l[i]==a):
        return True
    else:
        return False


x,n=map(int,input().split())
l=list(map(int,input().split()))
l.sort()

if(find(x,l)!=True):
    print(x)
else:
    c=1
    f=0
    while(f==0 and x-c>=0):
        if(find(x-c,l)!=True):
            print(x-c)
            f=1
        elif(find(x+c,l)!=True):
            print(x+c)
            f=1
        else:
            c+=1



Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

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

const int N = 100010;
int pd[N];
int h[N];

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", h+i);
	pd[n-1] = 0;
	for (int i = n-2; i >= 0; i--)
	{
		pd[i] = 0x3f3f3f3f;
		for (int j = 1; j <= k and i+j <= n-1; j++)
			pd[i] = min(pd[i], pd[i+j] + abs(h[i] - h[i+j]));
	}
	printf("%d\n", pd[0]);
	return 0;
}



Measured memory_bytes: 1024
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;


void main() {
  int n = readln.chomp.to!int;
  int k = n / 15;

  writeln(n * 800 - k * 200);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i, n,min, max;
  long long int sum;

  min = 1000000;
  max = -1000000;
  sum = 0;

  scanf("%d", &n);

  long int A[n];

  for (i = 0; i < n; i++)
    scanf("%ld", &A[i]);

  for (i = 0; i < n; i++){
    if ((int)A[i] > max)
      max = (int)A[i];
    if ((int)A[i] < (long)min)
      min = (int)A[i];
    sum += A[i];
  }

  printf("%d %d %lld\n", min, max, sum);

  return 0;
}


    

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, K; cin >> N >> K;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < K; i++) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	for(int i = 0; i < h * w; i++){
		string s;
		cin >> s;
		if(s == "snuke") cout << (char)('A' + (i % w)) << (i / w) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <math.h>
//#include <string>


using namespace std;

int main(void){
    int tot, rest, fhund, five;
    cin >> tot;

    fhund = tot/500;
    rest = tot%500;
    five = rest/5;

    cout << fhund*1000+five*5 << endl;
    
    return 0;
}

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

int main() {
        int n;
        scanf("%d", &n);
        vector<long long> h(n);
        rep(i, n) {
                scanf("%lld", &h[i]);
        }
        vector<long long> dp(n + 1);
        dp[0] = 0;
        rep(i, n) if (i) {
                if (i > 1) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
                else dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        }
        printf("%lld\n", dp[n - 1]);
        return 0;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] mochi = new Integer[N];
		int ans = 1;
		
		for(int i =0; i< N; i++) {
			mochi[i] = sc.nextInt();
		}
		Arrays.sort(mochi,Comparator.reverseOrder());
		
		for(int i = 0; i < N; i++) {
			if(i != N - 1) {
				if(mochi[i] > mochi[i+1]) {
					ans++;
					}
				} 
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
s = sum(b)
for i in range(n - 1):
    if a[i + 1] - a[i] == 1:
        s += c[a[i] - 1]
print(s)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n;
    cin >> n;
    vector<ll> p(n * n);
    REP(i, n * n){ cin >> p.at(i); }

    vector<vector<ll>> dist(n, vector<ll>(n, 0));
    // initialize
    REP(x, n){
        REP(y, n){
            dist.at(x).at(y) = min(min(x, n - 1 - x), min(y, n - 1 - y));
        }
    }
    vector<vector<bool>> filled(n, vector<bool>(n, true));

    ll ans = 0;
    for(ll pi : p){
        const ll x = (pi - 1) / n;
        const ll y = (pi - 1) % n;
        ans += dist.at(x).at(y);
        filled.at(x).at(y) = false;

        // update
        queue<pair<ll, ll>> que;
        que.emplace(x, y);
        while(!que.empty()){
            const auto q = que.front(); que.pop();
            const ll u = q.first, v = q.second;

            const ll dx[] = {-1, 1, 0, 0};
            const ll dy[] = {0, 0, -1, 1};
            REP(d, 4){
                const ll u2 = u + dx[d];
                const ll v2 = v + dy[d];
                const ll d2 = dist.at(u).at(v) + filled.at(u).at(v);
                if((u2 <= 0 || u2 >= n - 1 || v2 <= 0 || v2 >= n - 1) ||
                   (dist.at(u2).at(v2) <= d2)){
                    continue;
                }
                dist.at(u2).at(v2) = d2;
                que.emplace(u2, v2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7352
#include<iostream>

int main(){
    int A, B, C;
    std::cin >> A >> B >> C;

    if(A <= C && C <= B){
        std::cout << "Yes";
    }
    else if(A >= C && C >= B){
        std::cout << "Yes";
    }
    else {
        std::cout << "No";
    }

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> dn(N);
    for (int i = 0; i < N; i++) {
        cin >> dn[i];
    }
    sort(dn.begin(), dn.end(), greater<int>());

    int temp = dn[0];
    int ans = 1;
    for (int i = 0; i < N; i++) {
        if (temp > dn[i]) {
            ans += 1;
            temp = dn[i];
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d", &n);
	std::string s; cin >> s;
	scanf("%d", &k);
	
	for(auto v: s) {
		if(v == s[k - 1]) printf("%c", v);
		else printf("*");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
# 169a
# A*Bを整数として出力せよ

# ①入力をプログラムでとらえるように受け取る
a, b = map(int, input().split())
# print(a, b)

# ②受け取った入力値を適切に出力
answer = a * b

# ③結果出力
print(answer)

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int N,tmp,i; cin >> N;
  int ans = 0;
  for(i=1;i<=N;i++){
      cin >> tmp;
      if(i%2==1 && tmp%2==1){ans++;}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] gas = new int[n + 1][n + 1];
		int[][] counts = new int[n + 1][n + 1];
		for (int i = 1; i <= n; i++) {
		    Arrays.fill(gas[i], Integer.MAX_VALUE / 2 - 1);
		    Arrays.fill(counts[i], Integer.MAX_VALUE / 2 - 1);
		    gas[i][i] = 0;
		}
		for (int i = 0; i < m; i++) {
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    gas[a][b] = c;
		    gas[b][a] = c;
		}
		for (int i = 1; i <= n; i++) {
		    for (int j = 1; j <= n; j++) {
		        for (int k = 1; k <= n; k++) {
		            gas[j][k] = Math.min(gas[j][k], gas[j][i] + gas[i][k]);
		        }
		    }
		}
		for (int i = 1; i <= n; i++) {
		    for (int j = 1; j <= n; j++) {
		        if (i == j) {
		            counts[i][j] = 0;
		        } else if (gas[i][j] <= l) {
		           counts[i][j] = 1;
		        }
		    }
		}
		for (int i = 1; i <= n; i++) {
		    for (int j = 1; j <= n; j++) {
		        for (int k = 1; k <= n; k++) {
		            counts[j][k] = Math.min(counts[j][k], counts[j][i] + counts[i][k]);
		        }
		    }
		}
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int s = sc.nextInt();
		    int t = sc.nextInt();
		    if (counts[s][t] == Integer.MAX_VALUE / 2 - 1) {
		        sb.append(-1);
		    } else {
		        sb.append(counts[s][t] - 1);
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}


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

int type(string s){
	if(s == "HIT")return 0;
	if(s == "OUT")return 1;
	if(s == "HOMERUN")return 2;
}
int main(){
	int n;
	string s;
	cin >> n;
	
	while(n--){
		int outCount = 0;
		int base = 0;
		int result = 0;
		while(outCount < 3){
			cin >> s;
			switch(type(s)){
			case 0:
				base <<= 1;
				base++;
				break;
			case 1:
				outCount++;
				break;
			case 2:
				result += __builtin_popcount(base)+1;
				base = 0;
				break;
			}
			if(base & 8)result++;
			base &= 7; // 0b0111
		}
		cout << result << endl;
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    if(a-b==1) cout << "Borys" << endl;
    else cout << ((a-b)%2 ? "Borys" : "Alice") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 100005

using namespace std;

int main()
{
    __

    int n;

    cin >> n;

    cout << ((n%2==0)?n/2:(n/2)+1) << '\n';

    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

const int mod = 1000*1000*1000+7;

int n;
int m;
int cnt[26];
string s;

int main () {
	cin >> n >> s;
	for (int i = 0; i < n; i++) cnt[s[i] - 'a']++;
	int ans = 1;
	for (int i = 0; i < 26; i++) ans = ((ll)ans * (cnt[i] + 1)) % mod;
	ans = (ans + mod - 1) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}

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

int main()
{
    int n,d,i,j,k,x[10][10],flag=0;
    double kyori[10][10];
    scanf("%d %d",&n,&d);
    for(i=0;i<n;i++) 
    {
        for(j=0;j<d;j++)
        {
            scanf("%d",&x[i][j]);
        }
    }

    for(i=0;i<n;i++) 
    {
        for(j=0;j<n;j++)
        {
            kyori[i][j]=0;
        }
    }

    for(i=0;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=0;k<d;k++)
            {
                kyori[i][j]+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            kyori[i][j]=sqrt(kyori[i][j]);
            //printf("%lf %d %lf\n",kyori[i][j],(int)kyori[i][j],kyori[i][j]-(int)kyori[i][j]);
            if(kyori[i][j]-(int)kyori[i][j]==0)flag++;
        }
    }

    /////////////
    //for(k=0;k<1;k++)
    //{
        kyori[3][4]+=((x[2][0]-x[4][0])*(x[2][0]-x[4][0]));
    //}
    //kyori[3][4]=sqrt(kyori[3][4]);
    //printf("%lf %d %lf\n",kyori[3][4],(int)kyori[3][4],kyori[3][4]-(int)kyori[3][4]);
    ///////////////

    printf("%d\n",flag);
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

ll mod = 998244353;
ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; e >>= 1, b *= b, b %= mod, ans %= mod) if (e&1) ans *= b;
  return ans;
}

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

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

  if (p==2 or p==5) {
    vvi dp(n, vi(p));
    dp[0][(s[0]-'0')%p] = 1;
    rep(i,1,n) {
      rep(j,0,p) {
        dp[i][(j*10+(s[i]-'0'))%p] += dp[i-1][j];
      }
      ++dp[i][(s[i]-'0')%p];
    }
  
    ll ans = 0;
    rep(i,0,n) ans += dp[i][0];
    return cout << ans << endl, 0;
  }
  mod = p;

  vi cnt(p);
  cnt[0] = 1;
  int t = 0;
  ll ans = 0;
  for (int i = n-1; i >= 0; --i) {
    t += modpow(10, n-1-i) * (s[i]-'0'); t %= p;
    ans += cnt[t];
    ++cnt[t];
  }
  cout << ans << endl;
}

Measured memory_bytes: 14484
x, n = list(map(int, input().split()))

if n == 0:
  print(x)
  exit()

p = list(map(int, input().split()))

def check(num):
  if num not in p:
    print(num)
    exit()

for i in range(101):
  check(x-i)
  check(x+i)

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

#define FOR(i,a,b) for(int i = (a);i < (b);++i)
typedef long long ll;

int main(){
    int n; cin >> n;
    if(n == 7||n == 5||n == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int p,q,r;
    cin >> p >> q >> r;
    cout << min(p+q,min(r+q,p+r)) << "\n";
    return 0;
}

Measured memory_bytes: 256
//30
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int a=0,b=0;
    for(int i=0;i<n;i++){
      int ta,tb;
      cin>>ta>>tb;
      if(ta>tb){
	a+=ta+tb;
      }else if(ta==tb){
	a+=ta;
	b+=tb;
      }else{
	b+=ta+tb;
      }
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e15;

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

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<iostream>
#include<iomanip>
using namespace std;
typedef long long LL;
typedef double db;
double pp[2500001];
int main()
{
	int n, m;
	cin >> n;
	cin >> m;
	cout << n * n - m << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){

	int n;
	int temp;
	int max = Integer.MIN_VALUE;
	int i;

	Scanner scan = new Scanner(System.in);

	n =  scan.nextInt();
	int m[] = new int[n];
	for(i=0; i<n ; i++)
		m[i] = scan.nextInt();

	temp = m[0];
	for(i=1 ; i<n ; i++){
		if(m[i]-temp > max)
			max = m[i]-temp;
		if(temp > m[i])
			temp = m[i];
	}

	System.out.println(max);

	return;

  }

}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int a, b, c;
  cin >> a >> b >> c;

  cout << (a + b >= c ? "Yes" : "No") << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int hyou = 0;
    rep(i,n){
        cin >> a[i];
        hyou += a[i];
    }
    sort(a.rbegin(),a.rend());
    //rep(i,n) cout << a[i];
    //cout << hyou <<endl;
    bool flag = true;
    rep(i,m){
        if(a[i]<((hyou+(4*m)-1)/(4*m))) flag = false;
        else continue;
    }
    //cout <<(hyou/4*m)<<endl;
    if(flag) cout <<"Yes";
    else cout << "No"; 

}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD= 998244353;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}


int main(){
    ll N,M,K;
   
    cin>>N>>M>>K;
    init_nCk(N+1);
    ll ans=0;
    REP(i,K+1){
        ans+=(((nCk(N-1,i)*M)%MOD)*mod_pow(M-1,N-1-i,MOD))%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=anslist.end()?" ":"\n");itr--;}
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll inf = 1e18;


class FermatCombination {
private:
	long long factrial[101010]; //階乗を保持
	long long inverse[101010];  //逆元を保持

public:
	FermatCombination(int size);
	long long combine(int n, int k);
	long long fast_pow(long long x, int n);
};

FermatCombination::FermatCombination(int size) {

	factrial[0] = 1;
	inverse[0] = 1;

	for (int i = 1; i <= size; i++) {
		factrial[i] = (factrial[i - 1] * i) % MOD;  // 階乗を求める
		inverse[i] = fast_pow(factrial[i], (int)MOD - 2) % MOD; // フェルマーの小定理で逆元を求める
	}
}

long long FermatCombination::combine(int n, int k) {
	return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

long long FermatCombination::fast_pow(long long x, int n) { // x^n 計算量O(logn)
	long long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD; // 一周する度にx, x^2, x^4, x^8となる
		n >>= 1;         // 桁をずらす n = n >> 1
	}
	return ans;
}

int main(){
    int K,N;
    cin >> N >> K;
    FermatCombination fc(N);
    REP(i,1,K+1){
        p((fc.combine(K-1,i-1))%MOD*(fc.combine(N-K+1,i)%MOD)%MOD);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}
int main() {
	int N=0,a[100],counto=0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if (a[i] != i) {
			counto++;
		}
	}
	if (counto == 0 || counto == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
local D=io.read"*n"

local c={}
for i=1,26 do c[i]=io.read"*n"end
local s={}
for i=1,D do s[i]={}for j=1,26 do s[i][j]=io.read"*n"end end

local function copy(t)local ret={}for i,v in ipairs(t)do ret[i]=v end return ret end

local function calc(d,t,l)
	local a=0
	l[t]=d
	for j=1,26 do
		a=a-c[j]*(d-l[j])
	end
	return a+s[d][t]
end

local t={}
for i=1,D do t[i]=io.read"*n"end

local last={}
for i=1,26 do
last[i]=0
end

local ret={}
local a=0
--score,contestid,last
local beam={{0,{},last}}
for i=1,D do
	local newbeam={}
	for k,b in ipairs(beam) do
		local lastt={}
		for j=1,26 do
			lastt[j]=copy(b[3])
		end
		for j=1,26 do
			local t=copy(b[2])
			table.insert(t,j)
			table.insert(newbeam,{b[1]+calc(i,j,lastt[j]),t,lastt[j]})
		end
	end
	table.sort(newbeam,function(a,b)return a[1]>b[1]end)
	newbeam[6]=nil
	beam=newbeam
end

for i,v in ipairs(beam[1][2])do
print(v)
end

Measured memory_bytes: 6084
from collections import Counter
from itertools import combinations

N = int(input())
L = map(int, input().split())
c = Counter(L)

P = list(combinations(c.keys(), 3))
cnt = 0
for x, y, z in P:
    if x + y > z and y + z > x and z + x > y:
        cnt += c[x] * c[y] * c[z]

print(cnt)






Measured memory_bytes: 20724
(defun split (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(let ((n (parse-integer (read-line)))
      (a-list (mapcar #'parse-integer (split (read-line)))))
  (let ((b (make-array n)))
    (loop
      :for c :upfrom 0
      :for s = (if (evenp n) 1 -1) :then (* -1 s)
      :for d = 0 :then (+ d (* s c))
      :for i = (+ (truncate n 2) d)
      :for a :in a-list
      :do (setf (aref b i) a))
    (loop :for i :from 0 :below (- n 1)
          :do (format t "~d " (aref b i)))
    (format t "~d~%" (aref b (- n 1)))))


Measured memory_bytes: 62816
N = int(input())

n = {}
n["M"] = 0
n["A"] = 0
n["R"] = 0
n["C"] = 0
n["H"] = 0
heads = ["M","A","R", "C","H"]
for _ in range(N):
  s = input()
  if heads.count(s[0]) == 1:
    n[s[0]] += 1
    
ans = n["M"]*n["A"]*n["R"] + n["M"]*n["A"]*n["C"] + n["M"]*n["A"]*n["H"] \
    + n["M"]*n["R"]*n["C"] + n["M"]*n["R"]*n["H"] + n["M"]*n["C"]*n["H"] \
    + n["A"]*n["R"]*n["C"] + n["A"]*n["R"]*n["H"] + n["A"]*n["C"]*n["H"] + n["R"]*n["C"]*n["H"]
    
  
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  int n,i;
  double x,b;
  char u[3];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf %s",&x,u);
    if(u[0]=='J'){
      b+=x;
    }else{
      x=x*380000.0;
      b+=x;
    }
  }
  printf("%.8f",b);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll ans = 0;
    ll n, m; cin >> n >> m;

    ans = n * (n-1) / 2 + m * (m-1) / 2;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct {int x, y;} p[21], l;
struct {char a; int d;} o[30];
int main()
{
	int n, m, t, i, j, k;
	bool f[21];
	while (cin >> n && n)
	{
		for (i = 0; i < (t = n); f[i] = true, i++)
			cin >> p[i].x >> p[i].y;
		cin >> m;
		for (i = 0; i < m; i++)
			cin >> o[i].a >> o[i].d;
		for (i = 0, l.x = l.y = 10; i < m; i++)
		{
			switch (o[i].a)
			{
			case 'N':
				for (j = 0; j < o[i].d; j++)
				{
					l.y++;
					for (k = 0; k < n; k++)
					{
						if (f[k] && l.x == p[k].x && l.y == p[k].y)
							f[k] = false, t--;
					}
				}
				break;
			case 'E':
				for (j = 0; j < o[i].d; j++)
				{
					l.x++;
					for (k = 0; k < n; k++)
					{
						if (f[k] && l.x == p[k].x && l.y == p[k].y)
							f[k] = false, t--;
					}
				}
				break;
			case 'S':
				for (j = 0; j < o[i].d; j++)
				{
					l.y--;
					for (k = 0; k < n; k++)
					{
						if (f[k] && l.x == p[k].x && l.y == p[k].y)
							f[k] = false, t--;
					}
				}
				break;
			case 'W':
				for (j = 0; j < o[i].d; j++)
				{
					l.x--;
					for (k = 0; k < n; k++)
					{
						if (f[k] && l.x == p[k].x && l.y == p[k].y)
							f[k] = false, t--;
					}
				}
				break;
			}
			if (t <= 0)
			{
				cout << "Yes" << endl;
				break;
			}
		}
		if (t > 0)
			cout << "No" << endl;
	}
}

Measured memory_bytes: 0
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mt make_tuple
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
  int a, b, c , st = 0;
  cin >> a >> b >> c;
  vector<int> v({a,b,c});
  sort(all(v));
  st = (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2; 
  v[0] += 2 * ((v[2] - v[0]) / 2);
  v[1] += 2 * ((v[2] - v[1]) / 2);
  sort(all(v));
  v[2] -= v[0] , v[1] -= v[0] , v[0] = 0;
  if(v[2] == 0){
    cout << st;
  } else if (v[1] == 0) {
  	cout << st + 1; 
  } else {
  	cout << st + 2 ;
  }
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


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

int main(){
  string s,set="abcdefghijklmnopqrstuvwxyz";
  int flag=0;
  cin >> s;
  vector<int> map(26);
  
  for(int i=0; i<s.size(); i++){
    for(int j=0; j<26; j++){
      if(s.at(i) == set.at(j)){
        map.at(j)=1;
      }
    }
  }
  for(int i=0; i<26; i++){
    if(map.at(i) == 0){
      cout << set.at(i) << endl;
      flag=1;
      break;
    }
  }
  
  if(flag == 0){
    cout << "None" << endl;
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;

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




int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll k=26;
    ll subn = n;
    while(k < subn){
        subn -= k;
        k *= 26;
        
    }
    k/=26;
    string ans = "";
    while(k != 1){
        ll x =subn/k;
        if(subn%k == 0 ){
            x--;
        }
        char end = 'a' + x;
        
        subn -= k*x;
        k /= 26;
        ans += end;
    }
    char end = 'a' + subn-1;
    ans += end;

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


Measured memory_bytes: 3612
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Sandglass2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x, t;
  cin >> x >> t;

  printf("%d\n", (x >= t) ? x - t : 0);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vcc;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
    uniform_int_distribution<int> uid(0, lim - 1);
    return uid(rang);
}

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
{
    ll i, j, n, m;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d});
    return;
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10712
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int dp[3][110];
int N=0;
int A[3][110];
int main(void){
	cin>>N;
	for(int i=0;i<2;i++){
		for(int j=0;j<N;j++){
			cin>>A[i][j];
		}
	}
	dp[0][0]=A[0][0];
	for(int i=0;i<2;i++){
		for(int j=0;j<N;j++){
			if(j!=0){dp[i][j]=max(dp[i][j],dp[i][j-1]+A[i][j]);}
			if(i!=0){dp[i][j]=max(dp[i][j],dp[i-1][j]+A[i][j]);}
		}
	}
	cout<<dp[1][N-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<functional>
#include<iterator>
#include<iostream>
#include "bits/stdc++.h"
#define IO ios_base::sync_with_stdio(false);cin.tie(0);
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
using namespace std;

void solu (){

}

int main(void){
	int n,x,t;
	while (cin>>n>>x>>t){
        if(n%x!=0){
            cout<<(n/x+1)*t<<endl;
        }
        else {
            cout<<(n/x)*t<<endl;
        }
	}

	return 0;
}


Measured memory_bytes: 3604
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define MAX 100005

int main(){
	int n, m, d;
	char a[105][105];
	cin >> n >> m >> d;
	for(int i = 0;i < n;i++)
	for(int j = 0;j < m;j++)cin >> a[i][j];
	
	int ans = 0, f;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			f = 0;
			for(int k = 0;k < d && j+k < m;k++){
				if(a[i][j+k] == '.')f++;
			}
			if(f == d)ans++;f = 0;
			for(int k = 0;k < d && i+k < n;k++){
				if(a[i+k][j] == '.')f++;
			}
			if(f == d)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3108