akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	stack<int> S1;
	stack< pair<int,int> > S2;
	int sum = 0;
	char ch;
	
	for(int i=0; cin >> ch; i++) {
		if (ch == '\\') S1.push(i);
		if (ch == '/' && S1.size() > 0) {
			int j = S1.top();
			S1.pop();
			int a = i-j;
			sum += a;
			while(S2.size() >0 && S2.top().first > j) {
				a += S2.top().second;
				S2.pop();
			} 
		S2.push(make_pair(j,a));
		}
	} 
	
	vector<int> ans;
	while( S2.size() > 0) {
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout << sum << endl;
	cout << ans.size();
	for(int i=0; i < ans.size(); i++) {
		cout << " ";
		cout << ans[i]; 
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 3212
import sys
sys.setrecursionlimit(10**7)

N = int(input())

claim = []

for _ in range(N):
    memo = []
    A = int(input())
    for _ in range(A):
        x, y = input().split()
        memo.append((x,y))
    claim.append(memo)

maximam = 0
for i in range(2**N):
    flag = True
    bin_i = (N - len(str(bin(i))[2:]))*["0"] + list(bin(i))[2:]
    for j, man in enumerate(bin_i):
        if man == "0":
            continue
        for x, y in claim[j]:
            if bin_i[int(x)-1] != y:
                flag = False
    if flag:
        count = 0
        for b in bin_i:
            if b=="1":
                count+=1
        maximam = max(maximam,count)
print(count)

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

string S;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> S;
    for (int i=S.size()-2; i>=2; i-=2) {
        if (S.substr(0, i/2)==S.substr(i/2, i/2)) {
            cout << i << endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int sx = scn.nextInt();
		int sy = scn.nextInt();
		int tx = scn.nextInt();
		int ty = scn.nextInt();
		int x = tx - sx;
		int y = ty - sy;
		for(int i = 0;i < x;i++) {
			System.out.print("R");
		}
		for(int i = 0;i < y;i++) {
			System.out.print("U");
		}
		for(int i = 0;i < x;i++) {
			System.out.print("L");
		}
		for(int i = 0;i < y;i++) {
			System.out.print("D");
		}
		System.out.print("D");
		for(int i = 0;i < x+1;i++) {
			System.out.print("R");
		}for(int i = 0;i < y+1;i++) {
			System.out.print("U");
		}
		System.out.print("L");
		System.out.print("U");
		for(int i = 0;i < x+1;i++) {
			System.out.print("L");
		}for(int i = 0;i < y+1;i++) {
			System.out.print("D");
		}
		System.out.print("R");
	}

}


Measured memory_bytes: 25024
//https://atcoder.jp/contests/abc125/tasks/abc125_c
#include<bits/stdc++.h>
using namespace std;
#define TEMPLATE
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
template<typename T>inline T& unused_var(T& v){return v;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};
using LL = long long;

LL gcd(LL a,LL b){
    return (b==0)?a:gcd(b,a%b);
}

int N;
LL A[212345];
LL B[212345];
LL C[212345];
int main(){
    cin>>N;
    for(int i:range(N)){
        cin>>A[i];
        A[i+N]=A[i];
    }
    for(int i:range(1,N+1)){
        B[i]=gcd(B[i-1],A[i-1]);
    }
    for(int i:!range(1,N+1)){
        C[i]=gcd(C[i+1],A[i-1]);
    }
    LL ret = 1;
    for(int i:range(1,N+1)){
        chmax(ret,gcd(B[i-1],C[i+1]));
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N+2];
    A[0] = 0; A[N+1] = 0;
    int[] cost = new int[N+2];
    int[] cost2 = new int[N+2];
    int total =0;
    for (int i =1; i<=N; i++) {
      A[i] = sc.nextInt();
    }
    for (int i =1; i<=N+1; i++) {
      cost[i] = Math.abs(A[i] - A[i-1]);
      total += cost[i];
      if (i>=2) {
        cost2[i] = Math.abs(A[i] - A[i-2]);
      }
    }
    for (int i =2; i<=N+1; i++) {
      System.out.println(total - cost[i] - cost[i-1] + cost2[i]);
    }
  }
}    

Measured memory_bytes: 61904
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        string S = to_string(N);
        ll sm = 0;
        rep(i, 0, len(S)) {
                sm += S[i] - '0';
        }

        if (N % sm == 0) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}

Measured memory_bytes: 3656
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int[] a = new int[2000000 + 1];
		a[0] = 0;

		while (true) {
			String s = scan.next();
			if (s.equals("end"))
				break;
			if (s.equals("insert")) {
				int k = scan.nextInt();
				insert(a, k);
			}
			if (s.equals("extract"))
				System.out.println(extract(a));
		}

		scan.close();
		System.exit(0);
	}

	private static int extract(int[] a) {
		int r = a[1];
		a[1] = a[a[0]];
		a[0]--;
		maxHeap(a, 1);
		return r;
	}

	private static void insert(int[] a, int k) {
		a[0]++;
		a[a[0]] = k;
		up(a, a[0]);
	}

	private static void up(int[] a, int i) {
		if (i > 1 && a[i] > a[i / 2]) {
			int tmp = a[i];
			a[i] = a[i / 2];
			a[i / 2] = tmp;
			up(a, i / 2);
		}
	}

	private static void maxHeap(int[] a, int i) {
		int l = i * 2;
		int r = i * 2 + 1;
		int max = i;
		if (l <= a[0] && a[l] > a[i])
			max = l;
		if (r <= a[0] && a[r] > a[max])
			max = r;
		if (max != i) {
			int tmp = a[i];
			a[i] = a[max];
			a[max] = tmp;
			maxHeap(a, max);
		}
	}

	private static void print(int[] a, int i) {
		System.out.print("node " + i + ": ");
		System.out.print("key = " + a[i] + ", ");
		if (i > 1)
			System.out.print("parent key = " + a[i / 2] + ", ");
		if (i * 2 < a.length)
			System.out.print("left key = " + a[i * 2] + ", ");
		if (i * 2 + 1 < a.length)
			System.out.print("right key = " + a[i * 2 + 1] + ", ");
		System.out.print("\n");
	}
}

Measured memory_bytes: 556608
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int n, a, b, c;
int l[10];
int f(int cur, int x, int y, int z) {
    if(cur == n) {
        if(min({x, y, z}) > 0) return abs(x - a) + abs(y - b) + abs(z - c) - 30;
        else return INF;
    }
    int res0 = f(cur + 1, x, y, z);
    int res1 = f(cur + 1, x + l[cur], y, z) + 10;
    int res2 = f(cur + 1, x, y + l[cur], z) + 10;
    int res3 = f(cur + 1, x, y, z + l[cur]) + 10;
    return min({res0, res1, res2, res3});
}

int main() {
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++) cin >> l[i];
    cout << f(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REV(i, b, a) for(int i = b; i >= a; i--)
#define show(a) cout << #a << " = " << a << endl
#define mp make_pair
#define pb push_back
#define mset(v, a) memset(v, a, sizeof(v))
#define printv(v, n) for(int i = 0; i < n; i++){ cout << v[i] << " ";} cout << endl;
#define int long long
#define endl "\n"
using namespace std;

int precisa = 0;
int n;
int k;
int dig[20];
int npode[20];
int proxpode[20];
int qtdig(int n){
	int ans = 0;
	while(n){n/=10; ans++;}
	return ans;
}

int pot(int a, int b){
	if(!b) return 1;
	if(b == 1) return a;
	int x = a*a;
	if(b%2 == 1) return pot(x, b/2)*a;
	return pot(x, b/2);
}

main(){
	ios::sync_with_stdio(false);
	mset(npode, 0);
	cin >> n >> k;
	
	REP(i, 0, k){
		cin >> dig[i];
		npode[dig[i]] = 1;
	}
	//show(pot(10, 4));
	REP(i, n, 1000000){
		int dacerto = 1;
		//show(n);
		REP(j, 0, qtdig(i)){
			int dig = (i/pot(10, j))%10;
			//show(j);
			//show(pot(10, j));
			//show(i/pot(10, j));
			if(npode[(i/pot(10, j))%10]) dacerto = 0;
		}
		if(dacerto){
			cout << i << endl;
			return 0;
		}

	}

	return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    g = [1]*(n+1)
    for i in range(2, n+1):
        for j in range(i, n+1, i):
            g[j] += 1
    s = sum(i*g[i] for i in range(n+1))
    print(s)
    return

solve()


Measured memory_bytes: 151792
// -*- coding:utf-8-unix -*-

use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a
fn main() {
    input! {
        s: String,
        t: String,
    }
    let S: Vec<char> = s.chars().collect();
    let T: Vec<char> = t.chars().collect();

    for i in 0..S.len() {
        if S[i] == T[i] {
            continue;
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2120
/* ex 9_1
   KKOO */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//スタックに格納するデータの最大数
#define SIZE 100

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack str;
    char letter[11], decoy;
    int length;
    //スタックを初期化
    initialize_stack(&str);

    scanf("%s", letter);
    length = strlen(letter);

    for(int i=0; i<length; i++){
        //文字が'0'か'1'であればスタックに挿入
        if(letter[i] == '0' || letter[i] == '1'){
            push(&str, letter[i]);
        }
        //文字が'B'でスタックの中身がnullでなければスタックの中身を取り出す
        //decoyはおとり
        else if(letter[i] == 'B' && str.count != 0){
            decoy = pop(&str);
        }
    }

    //スタックはデータが下からたまるので下から出力
    for(int i = SIZE - 1; i >= SIZE - str.count; i--){
        printf("%c", str.data[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1612
<?php

$target_count = intval(trim(fgets(STDIN)));

$target_posi = array_map("intval", explode(" ", trim(fgets(STDIN))));

$command_count = intval(trim(fgets(STDIN)));

$commands = array_map("intval", explode(" ", trim(fgets(STDIN))));

$limit = 2019;

foreach ($commands as $command) {
    if ($target_posi[$command-1] == 2019) {
        continue;
    }
    if ($command == $target_count) {
        $target_posi[$command-1]++;
        continue;
    }
    
    if ($target_posi[$command-1]+1 == $target_posi[$command]) {
        continue;
    }
    $target_posi[$command-1]++;
}

echo implode("\n", $target_posi);
echo "\n";



Measured memory_bytes: 9320
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define l  long
#define ll  long long
int main()
{
    fast
    string s;cin>>s;
    if(s[0]==s[1] && s[1]==s[2] && s[2]==s[0])
       cout<<"No";
       else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
_ = input()
H = list(map(int, input().split()))

max_height = 0
for h1, h2 in zip(H[:-1], H[1:]):
  max_height = max(max_height, h1-1)
  if max_height > h2:
    print("No")
    break
else:
  print("Yes")
  

Measured memory_bytes: 14252
url = "https://atcoder.jp//contests/abc115/tasks/abc115_c"

def main():
    tree_n, sl = list(map(int, input().split()))
    trees = [int(input()) for i in range(tree_n)]
    trees.sort()
    tmp = trees[:sl]
    print(min(trees[i + sl - 1] - trees[i] for i in range(tree_n - sl + 1)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7832
dice = list(map(int, input().split()))
order = input()
for i in range(len(order)):
  c = order[i]
  if c == "E":
    temp = dice[0]
    dice[0] = dice[3]
    dice[3] = dice[5]
    dice[5] = dice[2]
    dice[2] = temp
  elif c == "N":
    temp = dice[0]
    dice[0] = dice[1]
    dice[1] = dice[5]
    dice[5] = dice[4]
    dice[4] = temp
  elif c == "S":
    temp = dice[0]
    dice[0] = dice[4]
    dice[4] = dice[5]
    dice[5] = dice[1]
    dice[1] = temp
  elif c == "W":
    temp = dice[0]
    dice[0] = dice[2]
    dice[2] = dice[5]
    dice[5] = dice[3]
    dice[3] = temp
  else:
    pass
print(dice[0])


Measured memory_bytes: 5604
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Map<Integer, Map<Integer, Integer>> map = new HashMap<>();
        UnionFind unionFind = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            int l = scanner.nextInt() - 1;
            int r = scanner.nextInt() - 1;
            int d = scanner.nextInt();
            map.computeIfAbsent(l, key -> new HashMap<>()).put(r, d);
            map.computeIfAbsent(r, key -> new HashMap<>()).put(l, -d);
            unionFind.unite(l, r);
        }

        Set<Integer> visited = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int parent = unionFind.root(i);
            if (!visited.contains(parent) && map.containsKey(parent)) {
                visited.add(parent);
                Map<Integer, Integer> pos = new HashMap<>();
                pos.put(parent, 0);
                Deque<Integer> deque = new ArrayDeque<>();
                deque.add(parent);

                while (!deque.isEmpty()) {
                    int j = deque.poll();
                    Map<Integer, Integer> dist = map.get(j);
                    for (Map.Entry<Integer, Integer> entry : dist.entrySet()) {
                        if (!pos.containsKey(entry.getKey())) {
                            pos.put(entry.getKey(), pos.get(j) + entry.getValue());
                            deque.add(entry.getKey());
                        } else if (pos.get(entry.getKey()) != pos.get(j) + entry.getValue()) {
                            System.out.println("No");
                            return;
                        }
                    }
                }
            }
        }

        System.out.println("Yes");
    }

    static class UnionFind {
        private int[] parent;
        private int[] size;

        public UnionFind(int n) {
            parent = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
            }
            size = new int[n];
            Arrays.fill(size, 1);
        }

        public int root(int n) {
            while (parent[n] != n) {
                n = parent[n] = parent[parent[n]];
            }
            return n;
        }

        public void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if (x != y) {
                if (size[x] < size[y]) {
                    size[y] += size[x];
                    parent[y] = x;
                } else {
                    size[x] += size[y];
                    parent[x] = y;
                }
            }
        }

        public boolean same(int x, int y) {
            return root(x) == root(y);
        }

        public int size(int x) {
            return size[root(x)];
        }
    }
}

Measured memory_bytes: 214848
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let f: char = *s.chars().collect::<Vec<_>>().first().unwrap();
    let l: char = *s.chars().collect::<Vec<_>>().last().unwrap();

    let n = s.split(f).filter(|s| *s != "").count();;
    if f == l {
        println!("{}", 2 * n)
    } else {
        println!("{}", 2 * n - 1)
    }
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
to = [[float("INF")] * N for i in range(N)]
aa = []

for i in range(M):
    a, b, c = map(int, input().split())
    to[a-1][b-1] = c
    to[b-1][a-1] = c
    aa.append([a-1, b-1, c])

for i in range(N):
    to[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            to[i][j] = min(to[i][j], to[i][k] + to[k][j])

#print(to)

c = 0
for i in range(M):
    for j in range(N):
        if to[j][aa[i][1]] == to[j][aa[i][0]] + aa[i][2]:
            c += 1
            break


print(M - c)

Measured memory_bytes: 74960
import std.stdio;
import std.string;
import std.conv;

void main() {
	int R = to!int(chomp(readln()));
	int G = to!int(chomp(readln()));
	
	// (R + P)/2 = G
	// R + P = 2G
	// P = 2G - R
	
	writeln(2*G - R);
}


Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#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 mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast
/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll a,b;
    cin>>a>>b;
    cout<<(a*b);
        
        












    return 0;
}

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

using namespace std;
typedef long long ll;

// #define DEBUG

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, k, x, y;
    string key, l, r;
    cin >> n;
    // map<string, int> workspace;
    multimap<string, int> workspace;

    for (int i = 0; i < n; i++)
    {
        cin >> k;
        if (k == 0)
        {
            cin >> key >> x;
            workspace.insert(make_pair(key, x));
        }
        else if (k == 1)
        {
            cin >> key;
            auto z = workspace.equal_range(key);
            for (auto itr = z.first; itr != z.second; itr++)
                cout << itr->second << "\n";
        }   
        else if (k == 2)
        {
            cin >> key;
            workspace.erase(key);
        }
        else if (k == 3)
        {
            cin >> l >> r;
            for (auto itr = workspace.lower_bound(l); itr != workspace.upper_bound(r); itr++)
            {
                auto itr2 = *itr;
                const string a = itr2.first;
                int b = itr2.second;
                cout << a << " " << b << "\n";
            }
        }
    }
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


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

void swap(int* x, int* y) {
	int tempX = *x;
	int tempY = *y;

	*x = tempY;
	*y = tempX;
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int box[3] = { a,b,c };
	if (box[0] > box[1]) {
			swap(&box[0], &box[1]);
		}
	if (box[1] > box[2]) {
		swap(&box[1], &box[2]);
	}	
        if (box[0] > box[1]) {
		swap(&box[0], &box[1]);
	}
	cout <<box[0]<<" "<<box[1]<<" "<<box[2]<<"\n";
	return 0;
}


Measured memory_bytes: 3108
def main():
    a, b, c, x, y = list(map(int, input().split(" ")))

    ans = 10**10
    for ai in range(x+1):
        ci = (x - ai)*2
        bi = y - ci//2
        if bi<0:
            bi = 0
        cost = a*ai + b*bi + c*ci
        if cost<ans:
            ans = cost

        if ai==0:
            if c*2 < b:
                bi = 0
                ci = max(x, y)*2
                cost = c*ci
                if cost<ans:
                    ans = cost

    print(ans)

if __name__=="__main__":
    main()



Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cout<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

typedef pair<pair<int,int>,int> P;

P add(P x, P y){
    int ma = x.first.first + y.first.first;
    int mb = x.first.second + y.first.second;
    int c = x.second + y.second;
    return {{ma,mb},c};
}

int main(void){
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vector<P> v(n);
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        v[i] = {{a,b},c};
    }
    map<pair<int,int>,int> cost;
    cost[{0,0}] = 0;
    rep(i,n){
        for(auto itr = cost.rbegin(); itr!=cost.rend(); ++itr){
            int a = v[i].first.first + itr->first.first;
            int b = v[i].first.second + itr->first.second;
            int c = v[i].second + itr->second;
            // printf("(%d,%d) = %d\n", a,b,c);
            // debug((cost[{a,b}]));
            if(cost.count({a,b})){
                cost[{a,b}] = min(cost[{a,b}], c);
            }else{
                cost[{a,b}] = c;
            }
        }
    }

    int mn = INF;
    for(auto itr : cost){
        if(itr.first.first == 0) continue;
        if(itr.first.first * mb == itr.first.second * ma){
            mn = min(mn, itr.second);
        }
    }
    // debug("last\n\n\n\n");
    for(auto itr : cost){
        // printf("(%d,%d) = %d\n",itr.first.first, itr.first.second, itr.second);
    }
    cout<<((mn==INF) ? -1 : mn)<<endl;
    return 0;
}


Measured memory_bytes: 1536
/*
My heart’s beating faster
I know what I’m after
 
I’ve been standing here my whole life
Everything I’ve seen twice
Now it’s time I realized
It’s spinning back around now
On this road I’m crawlin’
Save me 'cause I’m fallin’
Now I can’t seem to breathe right
'Cause I keep runnin' runnin' runnin' runnin'
Runnin' runnin' runnin' runnin'
Runnin' from my heart
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define slow_as_snail ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 
 
const ll mod = 1000000007;
#define mx 10000005
const ll mxi = 100005;

int main()
{
    slow_as_snail;
    string str;
    cin>>str;
    if(str[1]=='R')
    cout<<"ABC";
    else
    cout<<"ARC";
}

Measured memory_bytes: 3608
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;


public class Main{
	  public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	 
	    int n = sc.nextInt(); //県の数
	    int m = sc.nextInt(); //市の数
	    Map<Integer,int[]> map = new TreeMap<Integer,int[]>();
	 
	    for(int i=0; i<m; i++){
	        int[] array = new int[2];
	        array[0] = i;
	        array[1] = sc.nextInt(); //県番号
	        int b = sc.nextInt(); //誕生年
	        map.put(b,array);
	    }
	    int[] ary = new int[n]; //県の数を格納
	    String[] s = new String[m]; //IDを格納
	 
	    for(int[] num :map.values()){
	      ary[num[1]-1]++;
	      s[num[0]] = String.format("%06d%06d",num[1],ary[num[1]-1]);
	    }
	    
	/*    for(String a: s) {
	    	System.out.println(a);
	 	  }*/
	    
	    StringBuilder sb = new StringBuilder();
	    for(String ss:s) {
	    	sb.append(ss+"\n");
	    }
	    System.out.println(sb);
	    
	  }
}

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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n)cin >> p[i];

	int mem = -1;
	rep(i, n) {
		if (p[i] == i + 1) continue;
		else {
			if (mem == -1) {
				mem = p[i] - 1;
				continue;
			}
			else if (mem == i) {
				continue;
			}
			else {
				cout << "NO" << endl;
				return 0;
			}
			
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    print(max(a * b,c * d));
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
#include <valarray>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};

string str;
vector<int> in;
double dp[1<<14][14];
bool vis[1<<14][14];

double rec(int st,int la){
  if(st==(1<<la))return in[la]*2;
  if(vis[st][la])return dp[st][la];
  vis[st][la]=true;
  double& ret=dp[st][la]=1<<30;

  rep(i,SZ(in)){
    if((st&(1<<i))==0 || i==la)continue;
    double mi=rec(st^(1<<la),i);
    int l=in[la]+in[i],r=in[i]-in[la];
    double dist=sqrt(l*l-r*r);
    ret=min(ret,mi+dist-in[i]+in[la]);
  }
  return ret;
}

void solve(){
  stringstream ss(str);
  in.clear();
  int len;
  ss>>len;
  int t;
  while(ss>>t)in.pb(t);
  memset(vis,0,sizeof(vis));
  rep(i,SZ(in))
    if(len+EPS>rec((1<<SZ(in))-1,i)){
      //cout<<rec((1<<SZ(in))-1,i)<<endl;
      cout<<"OK"<<endl;
      return;
    }
  
  cout<<"NA"<<endl;
}


main(){
  while(getline(cin,str))
    solve();
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	int n;
	cin >> n;
	vector<ll> A(n), B(n), C(n);
	rep(i, n) cin >> A[i];
	rep(i, n) cin >> B[i];
	rep(i, n) cin >> C[i];
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());

	ll idx_bound_A, idx_bound_C;
	ll res = 0;
	rep(i, n) {
		ll key = B[i];
		ll numA, numC;
		auto lower = lower_bound(A.begin(), A.end(), key);
		idx_bound_A = distance(A.begin(), lower);
		if (lower==A.end()) {
			numA = n;
		}
		else numA = idx_bound_A;

		auto upper = upper_bound(C.begin(), C.end(), key);
		idx_bound_C = distance(C.begin(), upper);
		if (upper==C.end()) {
			numC = 0;
		}
		else numC = n - idx_bound_C;
		res += numA * numC;
	}
	cout << res << endl;
}

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

int main() {
    int n, m; scanf("%d%d", &n, &m);
    if      (n==1 && m==1) {printf("%d\n", 1);}
    else if (n==1        ) {printf("%d\n", m-2);}
    else if (        m==1) {printf("%d\n", n-2);}
    else                   {printf("%ld\n", abs((long long)(n-2)*(m-2)));}
    return 0;
}

Measured memory_bytes: 3788
//https://atcoder.jp/contests/agc036/tasks/agc036_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-1.in"); //input.txt
  std::cin.rdbuf(in.rdbuf());
#endif
    ll S; cin>>S;

    ll x1=ceil(sqrt(S)); //繰り上げる
    ll y2=x1;
    ll x2=1;
    ll y1=x1*y2-S;
    assert(S==x1*y2-x2*y1);
    assert(y1>=0);

    cout<<0<<" "<<0<<" ";
    cout<<x1<<" "<<y1<<" ";
    cout<<x2<<" "<<y2<<endl;
    return 0;
}

Measured memory_bytes: 256
//C - Big Array:
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, x, y, ansF;
    ll k;
    map<int, ll> ans;
    cin >> n >> k;
    loop(i, 0, n) {
        cin >> x >> y;
        ans[x] += y;
    }
    for(auto x : ans) {
        k -= x.se;
        if(k <= 0) {
            ansF = x.fi;
            break;
        }
    }
    cout << ansF << "\n";
}

Measured memory_bytes: 4224
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, N;
  cin>>H>>W>>N;
  int sr, sc;
  cin>>sr>>sc;
  sr--;
  sc--;
  string S, T;
  cin>>S>>T;
  int l=-1, r=W, u=-1, d=H;
  bool can = true;
  for(int i=N-1;i>=0;--i) {
    if(T[i]=='L') r=min(W, r+1);
    if(T[i]=='R') l=max(-1, l-1);
    if(T[i]=='U') d=min(H, d+1);
    if(T[i]=='D') u=max(-1, u-1);
    if(S[i]=='L') l++;
    if(S[i]=='R') r--;
    if(S[i]=='U') u++;
    if(S[i]=='D') d--;
    if(r-l<=1 || d-u<=1) can = false;
  }
  if(can && (l<sc && sc<r && u<sr && sr<d)) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 3868
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=2e3+10;
int N;
vector<int>L;
int main()
{
    // freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin>>N;
    L.resize(N);
    for(auto &e:L)cin>>e;
    sort(L.begin(),L.end());
    int ans=0;
    for(int u=0;u<N;u++){
        for(int v=u+1;v<N;v++){
            int l=v+1,r=N-1,lstp=-1;
            while(l<=r){
                int mid=(l+r)>>1;
                if(L[u]+L[v]>L[mid]){
                    l=mid+1;
                    lstp=mid;
                }
                else r=mid-1;
            }
            if(lstp!=-1)ans+=lstp-v;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n, x;
    cin >> n >> x;
    if(500 * n >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void solve_(){
     string a,b;
    cin >> a >> b;
    
    static int dp[1000][1000];
    fill_n((int*)dp,1000*1000,0);
    
    rep(i,0,a.size()){
        rep(j,0,b.size()){
            if(i!=0) dp[i][j]=dp[i-1][j];
            if(j!=0) dp[i][j]=max(dp[i][j],dp[i][j-1]);
            
            if(a[i]!=b[j]) continue;
            
            if(i==0&&j==0) dp[0][0]=1;
            else if(i==0) dp[0][j]=1;
            else if(j==0) dp[i][0]=1;
            else dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
        }
    }
    
    cout << dp[a.size()-1][b.size()-1] << endl;
}

void solve(){
    int n;
    cin >> n;
    rep(i,0,n) solve_();
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	solve();
	return 0;
}

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

int main(){
  char alph[26];
  int count[26];
  string s, buf;

  for(char i=0; i<26; i++){
    alph[i] = 'a'+i;
    count[i] = 0;
  }

  while(getline(cin, buf)){
    s.append(buf);
    //cout << buf << endl;
  }

  for(int i=0; i<s.length(); i++){
    for(int j=0; j<26; j++){
      if(tolower(s[i])==alph[j]) count[j]++;
    }
  }

  for(int i=0; i<26; i++){
    cout << alph[i] << " : " << count[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll N; cin>>N;
    vector<ll> A(N);
    REP(i, N) cin>>A[i];
    long double ans = 0;
    REP(i, N){
        ans += 1.0 / A[i];
    }
    cout << fixed << setprecision(9) << 1.0 / ans << endl;
    return 0;
}

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




int main(){

	int n,m;
	cin>>n>>m;
	int ans = 0;
	ans += (n*(n-1))/2 + (m*(m-1))/2;
	cout<<ans<<endl;
	
	
	
	return 0;
  
}

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

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

  int cnt = 0;

  vector<int> h(n);
  rep(i,n){
    cin >> h[i];
    if(h[i]>=k)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3692
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,K,ans,r;
LL a, b;
string s;
LL con[1001];
bool sosu[1001];
int main() {

	cin >> N;

	for (int i = 2; i <= N; i++) {
		sosu[i] = true;
		for (int j = 2; j <= N; j++) {
			if (i%j == 0 && i != j) {
				sosu[i] = false;
				break;
			}
		}
	}
	for (int i = 2; i <= N; i++) {
		if (sosu[i] == false)continue;
		for (int j = 2; j <= N;j++) {
			M = j;
			while (M % i==0) {
				con[i]++;
				M /= i;
			}
		}
	}
	ans = 1;
	for (int i = 2; i <= N; i++) {
		if (sosu[i]) {
			ans *= (con[i] + 1);
			ans=ans % 1000000007;
		}
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
#include<cstring>
#include<functional>

#define INF 111111111
using namespace std;

int n,m,l,k,a,h;
struct edge{
	int t,cost;
	edge(){}
	edge(int it,int ic){
		t=it,cost=ic;
	}
};

struct data{
	int v,cost,f;
	data(){}
	data(int iv,int iif,int icost){
		v=iv;
		f=iif;
		cost=icost;
	}
	bool operator<(const data &d1)const{
		return d1.cost<cost;
	}
};

vector<edge> G[101];
int rec[101];
int dp[101][101];

int dijk(){
	priority_queue<data> que;
	que.push(data(a,m,0));
	for(int i=0;i<n;i++){
		for(int j=0;j<=m;j++){
			dp[i][j]=INF;
		}
	}
	dp[a][m]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(dp[q.v][q.f]<q.cost)continue;
		dp[q.v][q.f]=q.cost;
		if(q.v==h)return q.cost;
		if(rec[q.v]==1){
			for(int i=1;i<=m-q.f;i++){
				if(dp[q.v][q.f+i]>q.cost+i){
					dp[q.v][q.f+i]=q.cost+i;
					que.push(data(q.v,q.f+i,q.cost+i));
				}
			}
		}
		for(int i=0;i<G[q.v].size();i++){
			edge e=G[q.v][i];
			if(q.f<e.cost)continue;
			if(dp[e.t][q.f-e.cost]>q.cost+e.cost){
				dp[e.t][q.f-e.cost]=q.cost+e.cost;
				que.push(data(e.t,q.f-e.cost,q.cost+e.cost));
			}
		}
	}
	return INF;
}

int main(void){
	while(1){
		scanf("%d %d %d %d %d %d",&n,&m,&l,&k,&a,&h);
		if(n+m+l+k+a+h==0)break;
		for(int i=0;i<n;i++)G[i].clear();
		memset(rec,0,sizeof(rec));
		for(int i=0;i<l;i++){
			int r;
			scanf("%d",&r);
			rec[r]=1;
		}
		for(int i=0;i<k;i++){
			int x,y,t;
			scanf("%d %d %d",&x,&y,&t);
			G[x].push_back(edge(y,t));
			G[y].push_back(edge(x,t));
		}
		int res=dijk();
		if(res==INF)printf("Help!\n");
		else printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  vi t(n);
  rep(i,n)cin>>t[i];
  int m;cin>>m;
  vpii p(m);
  rep(i,m){
    int a,x;cin>>a>>x;
    p[i]=mp(a,x);
  }
  
  int sum=vtotal(t);
  rep(i,m){
    cout(sum-(t[p[i].first-1]-p[i].second));
  }
  return 0;
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    int a = n - k + 1;
    int x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    
    int ans = INT_MAX;
    for(int i = 0; i < a; i++){
        int l = min((abs(x[i]) + abs(x[i+k-1] - x[i])),(abs(x[i+k-1]) + abs(x[i+k-1]-x[i])));
        ans = min(ans,l);
    }
    cout << ans;
}

Measured memory_bytes: 640
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u64,
        a: [u64; n - 1],
    }

    let mut boss_cnt = vec![0; (n + 1) as usize];
    for i in 0..n - 1 {
        boss_cnt[a[i as usize] as usize] += 1;
    }

    for i in 1..n + 1 {
        println!("{}", boss_cnt[i as usize]);
    }
}


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

//types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

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

  ll n,k;
  cin >> n >> k;

  cout << n*n-k << endl;

}



Measured memory_bytes: 256