akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
  long long int n,k,i;
  cin>>n>>k;
 if(n>k)
 {
     i=n%k;
     
     if(i*2>k)
     cout<<abs(i-k);
     else
     cout<<i;
     
 }
 
 else if(n==k)
 {
     cout<<0;
 }
 
 else
 {
     if(n*2>k)
     cout<<abs(n-k);
     else
     cout<<n;
 }
 
 
 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, K;
    cin >> N >> K;
    int cnt = 0;
    while(N > 0) {
        N /= K;
        cnt++;
    }
    output(cnt);
    
    return 0;
}


Measured memory_bytes: 256
h,w,a,b=map(int,input().split())
l=[[0]*w for _ in range(h)]
for i in range(h):
    if i<b:
        for j in range(a):
            l[i][j]=1
    else:
        for j in range(a,w):
            l[i][j]=1
for i in range(h):
    print("".join(str(n) for n in l[i]))

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

using namespace std;

const int N = 1e5 + 5;

long long a[N], b[N];

int main() {
  int n;
  long long k;
  scanf("%d %lld", &n, &k);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", a+i, b+i);
    if ((k & a[i]) == a[i])
      ans += b[i];
  }
  for (long long mask = 1; mask <= k; mask <<= 1) {
    if ((k & mask) == 0) continue;
    long long now = (mask ^ k) | (mask - 1);
    long long cur = 0;
    for (int i = 0; i < n; i++) {
      if ((now & a[i]) == a[i])
        cur += b[i];
    }
    ans = max(ans, cur);
  }
  printf("%lld\n", ans);
  return 0;
}

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

const int MAX_N = 1e5 + 5;
int N, p[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >> N;
    for(int i=0;i<N;i++) cin >> p[i];

    int ans = 0, idx = 0;
    while(idx<N){
        int len = 0;
        while(idx<N && p[idx] == idx + 1) {len++; idx++;}
        ans += (len+1) / 2;
        idx++;
    }

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

Measured memory_bytes: 640
#include<iostream>

int main(){
	
	int h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,k;
	
	std::cin >>h0>>h1>>h2>>h3>>h4>>h5>>h6>>h7>>h8>>h9;
	
	if (h8>h9) k=h8, h8=h9, h9=k;
	
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;
	
	if (h6>h7) k=h6, h6=h7, h7=k;
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;
	
	if (h5>h7) k=h5, h5=h7, h7=k;
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;

	if (h4>h7) k=h4, h4=h7, h7=k;
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;

	if (h3>h7) k=h3, h3=h7, h7=k;
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;	

	if (h2>h7) k=h2, h2=h7, h7=k;
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;

	if (h1>h7) k=h1, h1=h7, h7=k;
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;

	if (h0>h7) k=h0, h0=h7, h7=k;
	if (h7>h8) k=h7, h7=h8, h8=k;
	if (h8>h9) k=h8, h8=h9, h9=k;
	
	std::cout << h9 <<"\n"<< h8 <<"\n"<< h7 <<"\n";
	
	return 0;
	
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
using namespace std;
int main(){

  string a[50];
  int n,s,i,j,l,m,result=3000,blank=0;

  cin>>n>>s;

  for(i=0;i<n;i++) cin>>a[i];

  for(i=1;i<=n-2;i++){
    
    for(j=1;j<=n-i-1;j++){

      blank=0;
      for(l=0;l<i;l++) for(m=0;m<s;m++) if(a[l][m] != 'W') blank++;
      for(l=i;l<i+j;l++) for(m=0;m<s;m++) if(a[l][m] != 'B') blank++;
      for(l=i+j;l<n;l++) for(m=0;m<s;m++) if(a[l][m] != 'R') blank++;                       

      result=min(blank,result);

    }

  }

  cout<<result<<endl;

  return 0;

}
          
    

    
  

Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x1 = Integer.parseInt(scan.next());
		int y1 = Integer.parseInt(scan.next());
		int x2 = Integer.parseInt(scan.next());
		int y2 = Integer.parseInt(scan.next());
		int dx1 = x2 - x1;
		int dy1 = y2 - y1;
		int dx2 = (int) (dx1 * Math.cos(Math.toRadians(90))) - (int) (dy1 * Math.sin(Math.toRadians(90)));
		int dy2 = (int) (dx1 * Math.sin(Math.toRadians(90))) + (int) (dy1 * Math.cos(Math.toRadians(90)));
		int x3 = x2 + dx2;
		int y3 = y2 + dy2;
		int x4 = x3 + (-1) * dx1;
		int y4 = y3 + (-1) * dy1;
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if ( a * b % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else if ( a * b % 2 != 0 ) {
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
Cache sum with binary tree
 */

#include <stdio.h>
#include <stdlib.h>

#define OUT_LINE_SIZE 11

int *a;
int N;

void add(int i, int x) {
    i += N - 1;
    a[i] += x;
    while (i) {
        i = i >> 1;
        a[i] = a[i*2] + a[i*2+1];
    }
}

int _getSum(int m, int n, int i, int l, int r) {
    if (n < l || r < m)
        return 0;
    if (m <= l && r <= n)
        return a[i];
    return _getSum(m, n, i*2, l, (l+r)>>1) +
           _getSum(m, n, i*2+1, ((l+r)>>1)+1, r);
}

void getSum(int s, int t) {
    printf("%d\n", _getSum(s-1, t-1, 1, 0, N-1));
}



int main() {
    int n, q, com, x, y, i;
    void (*f[2])(int, int);
    char *outbuf;

    f[0] = add;
    f[1] = getSum;

    scanf("%d %d", &n, &q);
    for (i = 1, N = 1<<1; n > N; ++i, N = 1<<i);

    a = (int*)calloc(N * 2, sizeof(int));

    outbuf = (char*)malloc(sizeof(char) * OUT_LINE_SIZE * q);
    setvbuf(stdout, outbuf, _IOFBF, OUT_LINE_SIZE * q);
    
    for (; q--;) {
        scanf("%d %d %d", &com, &x, &y);
        f[com](x, y);
    }

    free(a);

    return 0;
}

Measured memory_bytes: 1596
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

ll choose(ll n){
  return n * (n - 1) / 2;
}

int main(){
  string A; cin >> A;

  ll N = A.length();
  vector<ll> vec(26);
  rep(i, N) vec[A[i] - 'a']++;
  ll ans = choose(N);
  rep(i, 26){
    ans -= choose(vec[i]);
  }
  cout << ans + 1 << endl;
}


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

using namespace std;

#define MAX 210
#define INF 1e9
const int diff = 105;

struct State{
  int n,x,y,t;
  bool operator < (const State &s)const{
    return n > s.n;
  }
};

int sx,sy,gx,gy,lx,ly;
bool can[MAX][MAX];
int dist[MAX][MAX][6];
const int dx[7] = {0,1,1,0,-1,-1,0};
const int dy[2][7] = {{1,0,-1,-1,-1,0,0},
                      {1,1,0,-1,0,1,0}};

inline bool inField(int x,int y){
  x -= diff; y -= diff;
  return -lx <= x && x <= lx && -ly <= y && y <= ly;
}

int dijkstra(){
  priority_queue<State> Q;
  Q.push((State){0,sx,sy,0});
  for(int i = 0 ; i < MAX ; i++){
    for(int j = 0 ; j < MAX ; j++){
      for(int k = 0 ; k < 6 ; k++){
        dist[i][j][k] = INF;
      }
    }
  }
  dist[sy][sx][0] = 0;

  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int x = s.x, y = s.y, t = s.t;
    if(dist[y][x][t] < s.n){ continue; }
    if(x == gx && y == gy){ return dist[gy][gx][t]; }
    int xx = x-diff,yy = y-diff;
    int ndir = abs(xx*yy*t)%6, nt = (t+1)%6;
    for(int i = 0 ; i < 7 ; i++){
      int nx = x + dx[i], ny = y + dy[abs(xx)%2][i];
      if(!inField(nx,ny) || !can[ny][nx]){ continue; }
      if(i == ndir){
        if(dist[y][x][t] < dist[ny][nx][nt]){
          dist[ny][nx][nt] = dist[y][x][t];
          Q.push((State){dist[ny][nx][nt],nx,ny,nt});
        }
      }else{
        if(dist[y][x][t]+1 < dist[ny][nx][nt]){
          dist[ny][nx][nt] = dist[y][x][t]+1;
          Q.push((State){dist[ny][nx][nt],nx,ny,nt});
        }
      }
    }
  }
  return -1;
}

int main(){
  int N,x,y;
  for(int i = 0 ; i < MAX ; i++){
    for(int j = 0 ; j < MAX ; j++){
      can[i][j] = true;
    }
  }
  cin >> sx >> sy >> gx >> gy >> N;
  sx += diff; sy += diff; gx += diff; gy += diff;
  for(int i = 0 ; i < N ; i++){
    cin >> x >> y;
    x += diff; y += diff;
    can[y][x] = false;
  }
  cin >> lx >> ly;
  cout << dijkstra() << endl;
  return 0;
}

Measured memory_bytes: 2420
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N = int(input())
A = [int(x) for x in input().split()]

B = sorted(A)

cnt = 0
for i in range(N):
    if A[i] != B[i]:
        cnt += 1

if cnt <= 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3956
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn bfs(r: usize, g: &[Vec<usize>]) -> (Vec<usize>, Vec<usize>) {
    let mut a = vec![];
    let mut parent = vec![r; g.len()];
    let mut q = std::collections::VecDeque::new();
    q.push_back(r);
    while let Some(v) = q.pop_front() {
        a.push(v);
        for &u in g[v].iter() {
            if u != parent[v] {
                parent[u] = v;
                q.push_back(u);
            }
        }
    }
    (a, parent)
}

fn run() {
    input! {
        n: usize,
        e: [(usize1, usize1); n - 1],
    }
    let mut g = vec![vec![]; n];
    for (a, b) in e {
        g[a].push(b);
        g[b].push(a);
    }
    let v = *bfs(0, &g).0.last().unwrap();
    let v = *bfs(v, &g).0.last().unwrap();
    let (q, p) = bfs(v, &g);
    let mut d = vec![false; n];
    d[v] = true;
    let mut u = q[n - 1];
    let mut a = vec![];
    while u != v {
        a.push(u);
        d[u] = true;
        u = p[u];
    }
    a.push(u);
    for i in 0..n {
        let mut ok = d[i];
        for &u in g[i].iter() {
            ok |= d[u];
        }
        if !ok {
            println!("-1");
            return;
        }
    }
    let len = a.len();
    let mut i = 1;
    while i < len - 1 - i && g[a[i]].len() == g[a[len - 1 - i]].len() {
        i += 1;
    }
    if i < len - 1 - i && g[a[i]].len() > g[a[len - 1 - i]].len() {
        a.reverse();
    }
    let mut out = String::new();
    out.push_str("1");
    let mut prev = 1;
    for a in a[1..].iter() {
        for k in 2..g[*a].len() {
            out.push_str(&format!(" {}", prev + k));
        }
        out.push_str(&format!(" {}", prev + 1));
        prev += g[*a].len() - 1;
    }
    println!("{}", out);
}

fn main() {
    run();
}


Measured memory_bytes: 19992
p1=[0,0]
*p2,N=map(int,input().split())
for _ in range(N):
	x,y,a=map(int,input().split())
	if a==1 and p1[0] < x:
		p1[0]=x
	elif a==2 and p2[0] > x:
		p2[0]=x
	elif a==3 and p1[1] < y:
		p1[1]=y
	elif a==4 and p2[1] > y:
		p2[1]=y
else:
	print(max(0,p2[0]-p1[0])*max(0,p2[1]-p1[1]))
	

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

int main()
{
	long double a, b, sum;
	while (cin>>a)
	{
		sum = a;
		for (int i = 0; i < 9; i++)
		{
			if (i % 2 == 0)
			{
				b = a * 2;
				sum = sum + b;
			}
			else
			{
				b = a / 3;
				sum = sum + b;
			}
			a = b;
		}
		cout << fixed << setprecision(8) << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
from sys import stdin
import math


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    dist = []
    for i in range(5):
        _ = int(_in[i+1])  # type:int
        dist.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    t = [0] * 5
    num = N
    for i in range(5):
        t[i] = math.ceil(num/dist[i])
        if i<4:
            num = num%dist[i]+max((N-num%dist[i])-dist[i+1]*(sum(t)-i-1),0)
    cnt = sum(t)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)



if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    dist = []
    for i in range(5):
        _ = int(_in[i+1])  # type:int
        dist.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = math.ceil(N/min(dist))+4
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)



int main()
{
	ios::sync_with_stdio(false);
	string s,t;
	int n,w=0;
	cin>>s>>t;
	n=s.length();
	for(int i=0;i<n;i++)
	{
		if(s[i]!=t[i])
		w++;
	}
	cout<<w;
	return 0;
}




Measured memory_bytes: 3860
import java.util.*;                                                                                  

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

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        double S = Integer.parseInt(line);

        double h = Math.floor(S / 3600);
        double H = S % 3600;
        double m = Math.floor(H / 60);
        double s = H % 60; 

        int ho = (int)h;
        int mo = (int)m;
        int so = (int)s;

        System.out.println(ho + ":" + mo + ":" + so);
    }   
}

Measured memory_bytes: 26068
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N = int(input())
    if N == 0:
        exit()
    n = int(input())
    true_Poly = [list(map(int, input().split())) for _ in range(n)]

    serach_Polys = []
    for _ in range(N):
        n = int(input())
        serach_Polys.append([list(map(int, input().split()))
                             for _ in range(n)])

    ans = []
    for i, poly in enumerate(serach_Polys):
        if is_same(true_Poly, poly):
            ans.append(i+1)
    if ans:
        print("\n".join(map(str, ans)))
    print("+"*5)


def is_same(poly1, poly2):
    if len(poly1) != len(poly2):
        return False

    poly_1_turn = calc_turn(poly1)
    poly_1_len = calc_dist(poly1)

    poly_2_turn = calc_turn(poly2)
    poly_2_len = calc_dist(poly2)
    if all(a == b for a, b in zip(poly_2_turn, poly_1_turn)) and all(a == b for a, b in zip(poly_2_len, poly_1_len)):
        return True

    poly_2_rev_turn = calc_turn(list(reversed(poly2)))
    poly_2_rev_len = calc_dist(list(reversed(poly2)))
    if all(a == b for a, b in zip(poly_2_rev_turn, poly_1_turn)) and all(a == b for a, b in zip(poly_2_rev_len, poly_1_len)):
        return True
    return False


def dist(p1, p2):
    return sum([abs(x1-x2) for x1, x2 in zip(p1, p2)])


def calc_dist(poly):
    return [dist(p1, p2) for p1, p2 in zip(poly, poly[1:])]


def turn(p1, p2, p3):
    """
    右回りが1 左が-1
    """
    if p1[0] == p2[0]:
        if p1[1] < p2[1]:
            if p3[0] > p2[0]:
                return 1
            else:
                return 0
        else:
            if p3[0] > p2[0]:
                return 0
            else:
                return 1
    else:
        if p1[0] < p2[0]:
            if p3[1] > p2[1]:
                return 0
            else:
                return 1
        else:
            if p3[1] > p2[1]:
                return 1
            else:
                return 0


def calc_turn(poly):
    return [turn(p1, p2, p3) for p1, p2, p3 in zip(poly, poly[1:], poly[2:])]


while True:
    solve()



Measured memory_bytes: 5732
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
STX = [tuple(lr()) for _ in range(N)]
event = []
append = event.append
for s, t, x in STX:
    append((s-x, 0, x))
    append((t-x, -1, x))

for i in range(Q):
    d = ir()
    append((d, 1, i))

event.sort()
answer = [-1] * Q
cur = set()
flag = False
INF = 10 ** 10
min_x = INF
add = cur.add
remove = cur.remove
for a, b, c in event:
    if b == 0:
        add(c)
        if c < min_x:
            min_x = c
            flag = True
    elif b == -1:
        remove(c)
        if min_x == c:
            flag = False
    elif b == 1:
        if cur:
            if not flag:
                min_x = min(cur)
                flag = True
            answer[c] = min_x

print('\n'.join(map(str, answer)))


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

int main() {
    int n, tmp, ret = 1, even = 1; cin >>n;
    for (int i = 0; i < n; i++) {
        cin >>tmp;
        ret *= 3;
        if (tmp%2==0) even *= 2;
    }
    cout << ret - even << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cmath>
    using namespace std;
     
    int main(){
      int long long N,M;
      cin>>N>>M;
      if(N<2&&M>=2) cout<<M-2<<endl;
      else if(M<2&&N>=2) cout<<N-2<<endl;
      else cout<<(N-2)*(M-2)<<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++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    while(true){
        int h,w;
        cin >> h >> w;
        if( h == 0 && w == 0) break;
        rep(i,h){
            rep(j,w){
                cout <<'#';
            }
            cout << endl;
        }
        cout << endl;
    }
return 0;
}


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(void)
{
        int n,a,b;
        cin >> n >> a >> b;

        int x;

        int count = 0;

        for(int i=1;i<=n;i++)
        {
                x=i/10000+i/1000-i/10000*10+i/100-i/1000*10+i/10-i/100*10+i-i/10*10;
                if(a<=x && x<=b)
                        count+=i;
        }

        cout << count << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
A = input()
B = input()

def show(num):
    if num == 0:
        print('EQUAL')
    if num > 0:
        print('GREATER')
    else:
        print('LESS')

if(len(A) != len(B)):
    show(len(A)-len(B))
    sys.exit(0)

for i in range(len(A)):
    a = int(A[i])
    b = int(B[i])
    if(a != b):
        show(a-b)
        sys.exit(0)

print('EQUAL')



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 100000000;
int n, x[10001][2], list[4], save[10001], l1 = 0, l2 = 0, ans = INF;
vector<int> v1, v2, v3;
int solve(int a){
	l1 = 0; l2 = 0;
	for (int i = 1; i < v2.size(); i++){
		if (v2[a + i] == v2[a]){
			l1++;
		}
		else
			break;
	}
	for (int i = 1; i < v2.size(); i++){
		if (v2[a - i] == v2[a]){
			l2++;
		}
		else
			break;
	}
	if (l1 + l2 >= 3){
		v2.erase(v2.begin() + a - l2, v2.begin() + a + l1 + 1);
		solve(a - l2-1);
	}
	else{
		return v2.size();
	}
}
int main(){
	while (true){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 1; i <= n; i++){
			cin >> x[i][0];
			v1.push_back(x[i][0]);
			if (i - list[x[i][0]] == 2){
				save[i - 1] = 2;
			}
			list[x[i][0]] = i;
			if (x[i][0] == x[i - 1][0] && x[i][0] == x[i - 2][0]){
				save[i + 1] = 1;
				save[i - 3] = 1;
			}
		}
		for (int i = 1; i <= n; i++){
			if (save[i] == 1){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				if (x[i + 1][0] == x[i + 2][0] && x[i + 1][0] == x[i + 3][0]){
					v2.insert(v2.begin() + i - 1, x[i + 1][0]);
				}
				else if (x[i - 1][0] == x[i - 2][0] && x[i - 1][0] == x[i - 3][0]){
					v2.insert(v2.begin() + i - 1, x[i - 1][0]);
				}
				ans = min(solve(i - 1), ans);
			}
			else if (save[i] == 2 && x[i + 1][0] == x[i + 2][0]){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				v2.insert(v2.begin() + i - 1, x[i + 1][0]);
				ans = min(solve(i - 1), ans);
			}
			else if (save[i] == 2 && x[i - 1][0] == x[i - 2][0]){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				v2.insert(v2.begin() + i - 1, x[i - 1][0]);
				ans = min(solve(i - 1), ans);
			}
			else save[i] = 0;
		}
		cout << ans << endl;
		for(int i=1;i<=n;i++){
			x[i][0]=0;
			save[i]=0;
		}
		list[0]=0;
		list[1]=0;
		list[2]=0;
		list[3]=0;
		ans=INF;
		v1=v3;
	}
	return 0;
}

Measured memory_bytes: 1444
import heapq
n,m=map(int,input().split())
al=list(map(int,input().split()))
hq=[]
for a in al:
    heapq.heappush(hq,-a)
for _ in range(m):
    t=heapq.heappop(hq)
    t=-(-t//2)
    heapq.heappush(hq,t)
print(-sum(hq))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
  
ll N,W;
ll v[40],w[40];
vector<P> x,y;
  
void func(int si,int ti,vector<P> &x){
  int size=ti-si;
  for(int bit=0;bit<(1<<size);bit++){
    P p=P(0,0);
    for(int i=0;i<size;i++){
      if(bit>>i&1){
        p.first+=w[si+i];
        p.second+=v[si+i];
      }
    }
    x.push_back(p);
  }
}
  
int main(){
  cin>>N>>W;
  for(int i=0;i<N;i++)cin>>v[i]>>w[i];
    
  func(0,N/2,x);
  sort(x.begin(),x.end());
  func(N/2,N,y);
  sort(y.begin(),y.end());
    
  ll target=0,maxm=-(1LL<<60),ans=0;
    
  for(int i=(int)x.size()-1;i>=0;i--){
    P p=x[i];
    while(target<(int)y.size() && p.first+y[target].first <=W ){
      maxm=max(maxm,y[target].second);
      target++;
    }
    ans=max(ans,maxm+p.second);
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 43748
package main

import "fmt"

func main() {
	// Code for A - Expired?
	var X, A, B int
	fmt.Scanf("%d %d %d", &X, &A, &B)

	if B <= A {
		fmt.Println("delicious")
	} else if B <= X+A {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


Measured memory_bytes: 1836
#include <iostream>

using namespace std;

#define MAX 100005
#define NIL -1
struct node {
  int parent;
  int left;
  int right;
};

node tree[MAX];
int d[MAX] = {};



void depth(int u,int s){
  d[u] = s;
  if(tree[u].right != NIL) depth(tree[u].right,s);
  if (tree[u].left != NIL) depth(tree[u].left, s + 1);
}

void pri(int u){
  int c;
  cout << "node " << u << ": parent = " << tree[u].parent << ", depth = " << d[u] << ", ";
  if(tree[u].parent == NIL) cout << "root, ";
  else if(tree[u].left == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for(int i = 0, c = tree[u].left; c != NIL;i++, c = tree[c].right){
  if(i) cout << ", ";
  cout << c;
  }
  cout << "]" << endl;
}

int main(){

  for(int i = 0;i < MAX;i++) tree[i].parent = tree[i].left = tree[i].right = NIL;

  int n;
  cin >> n;
  int v,k,c,l,p,vp;

  for(int i = 0;i < n;i++){
    cin >> v >> k;
    for(int j = 0;j < k;j++){
      cin >> c;
      if (j == 0){
        tree[v].left = c;
        tree[c].parent = v;
        l = tree[v].left;
      }
      else {
        tree[l].right = c;
        tree[c].parent = v;
        l = c;
      }
    }
  }
  for(int i = 0;i < n;i++){
    if(tree[i].parent == NIL){
      vp = i;
      break;
    }
  }
  depth(vp,0);
for(int i = 0;i < n;i++) pri(i);

}

Measured memory_bytes: 7764
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String S = keyboard.next();
		int L = (S.length()-1)/2;
		char[]s1 = new char[L];
		char[]s2 = new char[L];
		
		
		for(int i=0; i<S.length(); i++) {
			if(i < L) {
				s1[i] = S.charAt(i);
			}else if(i > L) {
				s2[i-L-1] = S.charAt(i);
			}
		}
		
		String ans = "No";
		
		for(int j=0; j<=L/2; j++) {
			if(s1[j]==s2[j]&& s1[L-1-j]==s2[L-1-j] && s1[j] == s1[L-1-j] && s2[j] == s2[L-1-j]) {
				ans = "Yes";
			}else {
				ans = "No";
				break;
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}



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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1];

            if (A > 9 || B > 9)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(A * B);
            }
        }
    }
}


Measured memory_bytes: 13396
// luogu-judger-enable-o2
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	char s[100];
	cin>>s;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<strlen(s);j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
/*
				C++
				encoding: UTF-8
				Modified: <02/Oct/2019 09:53:49 AM>

				✪ H4WK3yE乡
				Mohd. Farhan Tahir
				Indian Institute Of Information Technology (IIIT), Gwalior
*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define         ll                     long long
#define         ve                     vector
#define         pb                     push_back
#define         endl                   "\n"
#define         ff                     first
#define         ss                     second
#define         pii                    pair<int, int>
#define         len(v)                 int(v.size())
#define         all(v)                 v.begin(), v.end()
#define         reset(a, b)            memset(a, b, sizeof(a));
#define         fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define         dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on

int n, q;
const int N = 5e5 + 5;
int arr[N];
int tree[4 * N][26];

#define left 2 * node
#define right left + 1


void build (int node = 1, int start = 1, int end = n) {
	if (start == end) {
		tree[node][arr[start]]++;
		return;
	}
	int mid = (start + end) >> 1;
	build (left, start, mid);
	build (right, mid + 1, end);

	fr (i, 0, 26) {
		tree[node][i] = tree[left][i] + tree[right][i];
	}
}

void update (int idx, int val, int node = 1, int start = 1, int end = n) {
	if (start == end) {
		tree[node][arr[idx]]--;
		arr[idx] = val;
		tree[node][arr[idx]]++;
		return;
	}
	int mid = (start + end) / 2;
	if (start <= idx and idx <= mid)
		update (idx, val, left, start, mid);
	else
		update (idx, val, right, mid + 1, end);

	fr (i, 0, 26) {
		tree[node][i] = tree[left][i] + tree[right][i];
	}
}

int final[26];

void query (int l, int r, int node = 1, int start = 1, int end = n) {
	if (start > end or end < l or start > r) {
		return;
	}
	if (start >= l and end <= r) {
		fr (i, 0, 26) final[i] += tree[node][i];
		// return tree[node];
		return;
	}
	int mid = (start + end) >> 1;

	query (l, r, left, start, mid);
	query (l, r, right, mid + 1, end);
}


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	cin >> n;
	string s;
	cin >> s;
	fr (i, 1, n + 1) {
		arr[i] = s[i - 1] - 'a';
	}
	build ();
	int tc;
	cin >> tc;
	while (tc--) {
		int t;
		cin >> t;
		if (t == 1) {
			int idx;
			char c;
			cin >> idx >> c;
			int x = c - 'a';
			update (idx, x);
		} else {
			int l, r;
			cin >> l >> r;

			fill (final, final + 26, 0);
			query (l, r);
			// pr (final);
			int ans = 0;
			fr (i, 0, 26) {
				if (final[i] != 0) ans++;
			}
			pr (ans);
		}
	}
	return 0;
}


Measured memory_bytes: 111772
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

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

Measured memory_bytes: 3512
#include<cstdio>
using namespace std;
int max(int a,int b){return a>b?a:b;}
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n",max(a*b,c*d));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for (int i=n;^i;i--)
#define ALL(v) v.begin(),v.end()
// #define int ll 
#define eps 1e-9
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
typedef long long ll;

signed main(void){
	ll sum;
	int d;
	while(cin>>d){
		sum = 0;
		for(int i=0;i<600;i+=d) sum += d*(i*i);
		cout << sum << endl;
	}
}

Measured memory_bytes: 2996
import collections

n = int(input())
list = []
for x in range(n):
    s = input()
    list.append(s)
c = collections.Counter(list)
mc = c.most_common()
max = mc[0][1]
anslist = []
for val in mc:
    if max == val[1]: anslist.append(val[0])
    else: break
anslist.sort()
for x in anslist:
    print(x)


Measured memory_bytes: 47676
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(all(a));
  for (int i = 1; i < n; i++) {
    if (a[i - 1] == a[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long[][] coords = new long[n][2];
      for(int i = 0; i < n; i++) {
        coords[i][0] = sc.nextInt();
        coords[i][1] = sc.nextInt();
      }
      Arrays.sort(coords, (c1, c2) -> c1[0] == c2[0] ? (int)(c1[1] - c2[1]) : (int)(c1[0] - c2[0]));
      Map<String, Integer> freqMap = new HashMap<>();
      for(int i = 0; i < n; i++) {
          for(int j = i + 1; j < n; j++) {
            long dx = coords[i][0] - coords[j][0];
            long dy = coords[i][1] - coords[j][1];
            String key = dx + "," + dy;
            freqMap.put(key, freqMap.getOrDefault(key, 0) + 1);
          }
      }

      int max = 0;
      for(Integer freq : freqMap.values())
        max = Math.max(freq, max);
      System.out.println(n - max);
  }
}

Measured memory_bytes: 27476
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

bool prime(int n)
{
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    int counter = 0;
    for(int i = 11; ; i += 10){
        if(prime(i)){
            counter++;
            cout << i << endl;
            if(counter == n){
                break;
            }
        }
    }
        return 0;
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int count=0;
  
  for(int x=0; x<=k; x++) {
    for(int y=0; y<=k; y++) {
      int z=s-x-y;
      if(z>=0 && z<=k) {
        count++;
        }
      else continue;
      }
    }
  
  cout << count << endl;
  }


Measured memory_bytes: 256
m,d=[int(i) for i in input().split()]
k=0
for i in range(1,m+1):
  for j in range(1,d+1):
    d10=j//10
    d1=j%10
    if d1>=2 and d10>=2 and d1*d10==i:
      k+=1
print(k)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <stdio.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
int N;
int a[202020], b[202020];
int c[202020];

string to_bin(ll x, ll keta) {
  string ret = "";
  REP(i,keta) {
    if (x & 1 << i) ret = '1' + ret;
    else ret = '0' + ret;
  }
  return ret;
}

bool check(int x) {
  REP(i,N) c[i] = b[i] % (1 << (x + 1));
  // REP(i,N) cout << to_bin(b[i], 8) << endl;
  // cout << "----------------" << endl;
  // REP(i,N) cout << to_bin(c[i], 8) << endl;
  sort(c, c + N);

  int cnt = 0;
  REP(i,N) {
    int aa = a[i] % (1 << (x + 1));
    int T = 1 << x;
    cnt += lower_bound(c, c + N, 2 * T - aa) - lower_bound(c, c + N, T - aa);
    cnt += lower_bound(c, c + N, 4 * T - aa) - lower_bound(c, c + N, 3 * T - aa);
  }

  return cnt % 2;
}
 
signed main() {
  cin >> N;
  REP(i,N) cin >> a[i];
  REP(i,N) cin >> b[i];

  int ans = 0;
  REP(i,29) if (check(i)) ans |= 1 << i;
  // check(2);
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
  
  int N;
  bool info[100][100] = {{}};
  cin >> N;
  for(int i = 0; i < N; i++){
    int u, k;
    cin >> u >> k;
    while(k--){
      int v;
      cin >> v;
      info[u - 1][v - 1] = true;
    }
  }
  
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cout << info[i][j] << (j + 1 == N ? '\n' : ' ');
    }
  }
}


Measured memory_bytes: 3100
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: u64 = read();
    let A: u64 = read();
    let B: u64 = read();
    let rem = N % (A + B);
    let add = if rem > A {
        A
    } else {
        rem
    };
    println!("{}", ((N / (A + B)) * A) + add);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
bool used[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  bool fl=false;
  for(auto &a:A){cin>>a;if(a==0)fl=true;}
  sort(ALL(A));

  if(A[n-1]<=0){
    vector<pair<ll,ll>>ans;
    ans.pb(mp(A[n-1],A[n-2]));
    A[n-1]-=A[n-2];
    for(int i=0;i<n-2;i++){
      ans.pb(mp(A[n-1],A[i]));
      A[n-1]-=A[i];
    }
    cout<<A[n-1]<<endl;
    for(auto a:ans)cout<<a.F<<" "<<a.S<<endl;
  }else if(A[0]>=0){
    vector<pair<ll,ll>>ans;
    for(int i=1;i<n-1;i++){
      ans.pb(mp(A[0],A[i]));
      A[0]-=A[i];
    }
    ans.pb(mp(A[n-1],A[0]));
    A[n-1]-=A[0];
    cout<<A[n-1]<<endl;
    for(auto a:ans)cout<<a.F<<" "<<a.S<<endl;
  }else{
    vector<pair<ll,ll>>ans;
    for(int i=0;i<n-1;i++){
      if(A[i]>=0){
	ans.pb(mp(A[0],A[i]));
	used[i]=true;
	A[0]-=A[i];
      }
    }
    for(int i=0;i<n-1;i++){
      if(used[i]==false){
	ans.pb(mp(A[n-1],A[i]));
	A[n-1]-=A[i];
      }
    }
    cout<<A[n-1]<<endl;
    for(auto a:ans)cout<<a.F<<" "<<a.S<<endl;
  }
  return 0;
}


Measured memory_bytes: 4464
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void solve(){
    ll n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2;

  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<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++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;

int main(){
    double t, x;
    cin >> t >> x;
    printf("%.10lf\n", t/x);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc153
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc153A();
        }

        public static void solve_abc153B()
        {

        }

        public static void solve_abc153A()
        {
            int[] ha =  Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine((ha[0] + ha[1] - 1) / ha[1]);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int a;
    
    cin>>a;
    
    if(a<2){cout<<"1"<<endl;}
    
      else if((a<=4)&&(a<8)){cout<<"2"<<endl;}
      
        else if(a<8){cout<<"4"<<endl;}
        
         else if(a<16){cout<<"8"<<endl;}
          
            else if(a<32){cout<<"16"<<endl;}
            
              else if(a<64){cout<<"32"<<endl;}
              
                else if(a<=100){cout<<"64"<<endl;}

}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
xyz = n.times.map{gets.split.map(&:to_i)}

max = 0
2.times{|i|
  2.times{|j|
    2.times{|k|
      tmp = xyz.map{|(x,y,z)|
        x = -x if i>0
        y = -y if j>0
        z = -z if k>0
        [x,y,z,x+y+z]
      }
      tmp.sort!{|a,b| b[3]<=>a[3]}
      res = tmp[0...m].inject([0,0,0]){|sum,t|
        3.times.map{|l|sum[l]+t[l]}
      }
      ans = res.map{|t|t.abs}.inject(:+)
      max = ans if max < ans
    }
  }
}

p max

Measured memory_bytes: 2552
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
const ll MOD = 1000000007;

int main()
{
    ll n, k;

    cin >> n >> k;

    ll res = 0;
    for (ll width=k; width<=n+1; ++width)
    {
        res += width*(n*2LL-width+1LL)/2LL - (width-1)*width/2 + 1LL;
        res %= MOD;
        // debug(width*(n*2LL-width+1LL)/2LL , (width-1)*width/2);
        // debug(width, res);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3636
<?php
fscanf(STDIN, "%d %d", $n, $k);
$x = explode(' ', trim(fgets(STDIN)));
$i = 0;
$j = $k - 1;
$m = 10 ** 8 * 3;
while ($j < $n) {
	if ($x[$j] <= 0) {
		$m = abs($x[$i]);
	} else {
		$d = $x[$j] - $x[$i];
		$m = min($m, abs($x[$i]) + $d, $x[$j] + $d);
		if ($x[$i] > 0) break;
	}
	$i++; $j++;
}
echo $m;

Measured memory_bytes: 12792
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  VEC<int>a(4,0);
  REP(i,0,4)cin>>a[i];
  sort(ALL(a));
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
    cout<<"YES";
  }else cout<<"NO";

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        
        private static void SolveA(string[] args)
        {
            int[] nm = ReadAndParseIntArr();
            int n = nm[0];
            int m = nm[1];
            int[] c = ReadAndParseIntArr();
            int[] t = new int[n + 1];
            for(int i = 0; i < t.Length; ++i) { t[i] = int.MaxValue; }
            t[0] = 0;
            for(int i=0;i<m;++i)
            {
                for(int j = c[i];j < n+1;++j)
                {
                    t[j] = Math.Min(t[j], t[j - c[i]] + 1);
                }
            }
            int min = t[n];
            Console.WriteLine(min);
        }
        
    }
}



Measured memory_bytes: 17996