akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

const double PI = 3.14159265358979323846;

double yogen(double a, double b, double kaku)
{
    double tmp = pow(a,2) + pow(b,2) - 2 * a * b * cos(kaku);
    return sqrt(tmp);
}

double kaku(double h, double m)
{
    double hun = 60 * h + m;
    double rad = hun / 360 * PI;
    return rad;
}

int main(int argc, char const *argv[]) {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double hour_rad = kaku(h,m);
    double min_rad = kaku(0,m)* 12;
    double rad = abs(min_rad - hour_rad);
    double ans = yogen(a,b,rad);
    // cout << ans << endl;
    printf("%20.20lf",ans);
    printf("\n");
    return 0;
}


Measured memory_bytes: 4192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll hp; cin >> hp;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    ll ans = 0, val = a[0];
    for(int i = 0; i < n; i++)
    {
        if(b[i] <= val || hp <= 0) break;
        hp -= b[i];
        ans++;
    }
    if(hp >= 0) ans += (hp + val - 1) / val;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String s = sc.next();
        if( (int)s.charAt(0)-48 >= 0 && (int)s.charAt(0)-48 <=48 ){
          System.out.println('A');
        }else{
          System.out.println('a');
        }      
	}
}

Measured memory_bytes: 27020
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int r = 0;
    for(int i = 0;i < n;i ++){
        if(a[0] > (a[n-1]+1)/2){
            r = a[0];
            break;
        }
        if(a[i] > (a[n-1]+1)/2){
             if(a[i] - (a[n-1]+1)/2 < (a[n-1]+1)/2 - a[i-1]) r = a[i];
             else r = a[i-1];
             break;
        }
    }
    cout << a[n-1] << " " << r << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int mod = 200003;
int val[mod];

typedef long long LL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int get(int s) {
    return s > 1 ? 32 - __builtin_clz(s - 1) : 0;
}

typedef complex<double> base;

void fft(vector<base> &a, bool inv){
	int n = a.size(), j = 0;
	vector<base> roots(n/2);
	for(int i=1; i<n; i++){
		int bit = (n >> 1);
		while(j >= bit){
			j -= bit;
			bit >>= 1;
		}
		j += bit;
		if(i < j) swap(a[i], a[j]);
	}
	double ang = 2 * acos(-1) / n * (inv ? -1 : 1);
	for(int i=0; i<n/2; i++){
		roots[i] = base(cos(ang * i), sin(ang * i));
	}

	for(int i=2; i<=n; i<<=1){
		int step = n / i;
		for(int j=0; j<n; j+=i){
			for(int k=0; k<i/2; k++){
				base u = a[j+k], v = a[j+k+i/2] * roots[step * k];
				a[j+k] = u+v;
				a[j+k+i/2] = u-v;
			}
		}
	}
	if(inv) for(int i=0; i<n; i++) a[i] /= n;
}

vector<ll> DOIT(vector<ll> &v, vector<ll> &w){
	int n = 1;
	while(n < max(v.size(), w.size())) n <<= 1;
	n <<= 1;
	vector<base> v1(n), v2(n);
	vector<base> r1(n), r2(n);
	for(int i=0; i<v.size(); i++){
		v1[i] = base(v[i] >> 15, v[i] & 32767);
	}
	for(int i=0; i<w.size(); i++){
		v2[i] = base(w[i] >> 15, w[i] & 32767);
	}
	fft(v1, 0);
	fft(v2, 0);
	for(int i=0; i<n; i++){
		int j = (i ? (n - i) : i);
		base ans1 = (v1[i] + conj(v1[j])) * base(0.5, 0);
		base ans2 = (v1[i] - conj(v1[j])) * base(0, -0.5);
		base ans3 = (v2[i] + conj(v2[j])) * base(0.5, 0);
		base ans4 = (v2[i] - conj(v2[j])) * base(0, -0.5);
		r1[i] = (ans1 * ans3) + (ans1 * ans4) * base(0, 1);
		r2[i] = (ans2 * ans3) + (ans2 * ans4) * base(0, 1);
	}
	fft(r1, 1);
	fft(r2, 1);
	vector<ll> ret(n);
	for(int i=0; i<n; i++){
		ll av = (ll)round(r1[i].real());
		ll bv = (ll)round(r1[i].imag()) + (ll)round(r2[i].real());
		ll cv = (ll)round(r2[i].imag());
		ret[i] = (av << 30) + (bv << 15) + cv;
	}
	while (ret.back() == 0) ret.pop_back();
	return ret;
}

int main() {
  int cur = 1;
  memset(val, -1, sizeof val);
  for(int i = 0; i < mod - 1; i++) {
    val[cur] = i;
    cur = (cur * 2) % mod;
  }
  int n;
  scanf("%d", &n);
  long long sum = 0;
  vector <ll> cnt (mod);
  for(int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if(x != 0) {
      cnt[val[x]] += 1;
    }
    sum -= (1LL * x * x) % mod;
  }
  auto ans = DOIT(cnt, cnt);

  cur = 1;
  for(int i = 0; i < ans.size(); i++) {
    sum += 1LL * cur * ans[i];
    cur = (cur * 2) % mod;
  }
  sum /= 2;
  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 42872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;

class Main {

	final static int MAX = 200_000;
	static long[] leftArr = new long[MAX/2+2];
	static long[] rightArr = new long[MAX/2+2];



	public static void main(String[] args) {

		int n = 0;
		long[] arr = null;


		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

			n = Integer.parseInt(br.readLine());
			arr = Stream.of(br.readLine().split(" ")).mapToLong(Long::parseLong).toArray();

		} catch (IOException e) {
			e.printStackTrace();
		}

		long ans = mergeSort(arr, n, 0, n);

		System.out.println(ans);

	}

	private static long mergeSort(long[] arr, int n, int left, int right) {

		int mid;
		long v1, v2, v3;

		if ( left+1 < right ) {
			mid = (left+right)/2;
			v1 = mergeSort(arr, n, left, mid);
			v2 = mergeSort(arr, n, mid, right);
			v3 = merge(arr, n, left, mid, right);
			return v1 + v2 + v3;
		} else {
			return 0;
		}
	}

	private static long merge(long[] arr, int n, int left, int mid, int right) {

		int i, j, k;
		long cnt = 0;
		int n1 = mid - left;
		int n2 = right - mid;

		for (i = 0; i < n1; i++) {
			leftArr[i] = arr[left+i];
		}
		for (i = 0; i < n2; i++) {
			rightArr[i] = arr[mid+i];
		}
		leftArr[n1] = Long.MAX_VALUE;
		rightArr[n2] = Long.MAX_VALUE;

		i = 0; j = 0;
		for(k = left; k < right; k++) {
			if(leftArr[i] <= rightArr[j]) {
				arr[k] = leftArr[i++];
			} else {
				arr[k] = rightArr[j++];
				cnt += (n1-i);
			}
		}
		return cnt;
	}
}

Measured memory_bytes: 75644
use std::collections::vec_deque::VecDeque;

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn read_ints() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let (h, w) = {
        let t = read_ints();
        (t[0], t[1])
    };

    let bd: Vec<Vec<u8>> = (0..h).map(|_| read_line().into_bytes()).collect();
    let mut q = VecDeque::new();
    q.push_back((0i32, 0i32, 0i32));
    let mut dep = vec![vec![-1; w as usize]; h as usize];

    while !q.is_empty() {
        let (x, y, d) = q.pop_front().unwrap();
        if dep[y as usize][x as usize] >= 0 {
            continue;
        }
        dep[y as usize][x as usize] = d;

        for &(dx, dy) in &[(0, 1), (1, 0), (0, -1), (-1, 0)] {
            let cx = x + dx;
            let cy = y + dy;

            if !(cx >= 0 && cx < w && cy >= 0 && cy < h) {
                continue;
            }

            if bd[cy as usize][cx as usize] == b'#' {
                continue;
            }

            q.push_back((cx, cy, d + 1));
        }
    }

    let len = dep[h as usize - 1][w as usize - 1];
    let mut whites = 0;
    for y in 0..h {
        for x in 0..w {
            if bd[y as usize][x as usize] == b'.' {
                whites += 1;
            }
        }
    }

    // eprintln!("{} {}", len, whites);

    println!("{}", if len < 0 { -1 } else { whites - len - 1 });
}

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

template <typename T>
using lim = numeric_limits<T>;

const int MOD = 1e9+7;
const int MAXN = 1e5+1;

vector<int> prime;
bool is_composite[MAXN];
int phi[MAXN];

void sieve(int n){
	memset(is_composite, 0, sizeof is_composite);
	phi[1] = 1;
	for (int i = 2; i < n; i++){
		if (!is_composite[i]) {
			prime.push_back(i);
			phi[i] = i-1;
		}
		for (int j = 0; j < prime.size() and i*prime[j] < n; j++){
			is_composite[i*prime[j]] = true;
			if (i % prime[j] == 0){
				phi[i*prime[j]] = phi[i]*prime[j];
				break;
			}
			phi[i*prime[j]] = phi[i]*phi[prime[j]];
		}
	}
}

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

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

	sieve(MAXN);
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	for (int i = 1; i <= k; i++) ans = (ans+phi[i]*modpow(k/i,n,MOD)%MOD)%MOD;

	cout << ans << "\n";
}

Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

map<pair<int, bool>, int> mem;
ll helper(vector<ll>& arr, int z, int w, int idx, bool is_x) {
    if (idx == arr.size())
        return llabs(z-w);
    if (mem.count({idx, is_x}) > 0)
        return mem[{idx, is_x}];
    if (is_x) {
        ll res = INT_MIN;
        for(int i = idx; i < arr.size(); i++) {
            ll tmp = helper(arr, arr[i], w, i+1, false);
            res = max(res, tmp);
        }
        mem[{idx, is_x}] = res;
        // cout << "gamer: " << is_x << ", res " << res << endl;
        return res;
    } else {
        ll res = INT_MAX;
        for(int i = idx; i < arr.size(); i++) {
            ll tmp = helper(arr, z, arr[i], i+1, true);
            res = min(res, tmp);
        }
        // cout << "gamer: " << is_x << ", res " << res << endl;
        mem[{idx, is_x}] = res;
        return res;
    }
    return -1;
}

int main() {
    int n;
    ll z, w;
    cin >> n >> z >> w;
    vector<ll> arr(n, 0);
    for(auto& val: arr) {
        cin >> val;
    }
    cout << helper(arr, z, w, 0, true) << endl;
    return 0;
}




Measured memory_bytes: 768
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<vector<ll>> a(2, vector<ll>(n)), sum(2, vector<ll>(n+1));
  REP(i, 2) REP(j, n) cin >> a[i][j];
  sum[0][0] = sum[1][0] = 0;
  REP(i, n){
    sum[0][i+1] = sum[0][i] + a[0][i];
    sum[1][i+1] = sum[1][i] + a[1][i];
  }
  ll ans = 0;
  REP(i, n){
    chmax(ans, sum[0][i+1]+sum[1][n]-sum[1][i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// rust input macro: 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 mut 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 main() {
  input!{
    n: i32, m: i32,
    a: [i32; n]
  };
  let mut sum: i32 = 0;
  for i in a.iter() {
    sum += *i;
  }
  let mut cnt = 0;
  for i in a.iter() {
    if i * 4 * m >= sum {
      cnt += 1;
    }
  }
  if cnt >= m {
    println!("Yes");
  }else{
    println!("No");
  }
  
}


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

int main(){
  ll N,n,h,w,x,y;
  cin >> N;
  n=-1;
  for(ll i=1;i<=3500;i++){
    for(ll j=1;j<=3500;j++){
      x = 4*i*j - N*i -N*j;
      y = N*i*j;
      if(x >0 && y%x == 0){
        n = i;
        h = j;
        w = y/x;
        break;
      }
    }
    if(n >0) break;
  }
  
  cout << n <<" "<< h <<" "<< w;
  
  return 0;
}


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

int main() {
  string O, E;
  cin >> O >> E;
  rep (i, O.size()){
      cout << O.at(i);
    if (i<E.size()) cout << E.at(i);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;
const int mod=998244353;

int N,S,d[3010];
ll cnt[3010],cnt2[3010],ans;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>S;
    for(int i=1;i<=N;i++) cin>>d[i];
    for(int i=1;i<=N;i++){
    	cnt[0]=i;
    	for(int j=d[i];j<3010;j++) cnt2[j]=(cnt[j]+cnt[j-d[i]])%mod;
    	for(int j=0;j<3010;j++)cnt[j]=cnt2[j];
    	ans=(ans+cnt[S])%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define inf 0x6fffffff
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    int n=read(),k=read();
    printf("%d\n",n-k+1);
    return 0;
}

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

int main() {
	int N; cin >> N;
	vector<int>A(N);
	int M = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		M = max(M, A[i]);
	}

	double x = 0.5 * M;
	int m = A[0];
	for (int i = 1; i < N; i++) {
		if (abs(A[i] - x) <= abs(m - x))m = A[i];
	}

	cout << M << " " << m << endl;
	
	return 0;
}

Measured memory_bytes: 1272
#include<stdio.h>
int main(void)
{
	int a,b,c;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a+b==c) {
		printf("Yes\n");
	}
	else if(a+c==b) {
		printf("Yes\n\n");
	}
	else if(b+c==a) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}
		
	

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			int[] s = new int[n];
			if(n==0) break;
			for(int i=0;i<n;++i){
				s[i]=sc.nextInt();
			}
			Arrays.sort(s);
			double sum=0;
			for(int i=1;i<n-1;++i){
				sum+=s[i];
			}
			System.out.println((int)(sum/(n-2)));
		}
	}
}



Measured memory_bytes: 29044
import 'dart:convert';
import 'dart:io';
import 'dart:async';
import "dart:math";

Future main() async {
  List nd = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  Stream<String> xyLines =
      stdin.transform(utf8.decoder).transform(LineSplitter()); // ここ大事（複数行入力）
  List<int> xy = [];
  int count;
  count = 0;
  int lineNum;
  lineNum = 1;
  await for (String line in xyLines) {
    lineNum = lineNum + 1;

    xy = line.split(" ").map((x) => int.parse(x)).toList();
    // print(xy[0]);
    // print(xy[1]);
    double dist = sqrt((xy[0] * xy[0]) + (xy[1] * xy[1]));
    if (dist <= nd[1]) {
      count++;
    }
    if (lineNum > nd[0]) break;
  }
  print(count);
}


Measured memory_bytes: 24956
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<vector<int>> g(n);
    vector<string> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        rep(j,n){
            if (a[i][j]-'0'){
                g[i].push_back(j);
            }
        }
    }
    ll ans = -1;
    bool out = 0;
    rep(i,n){
        queue<ll> q;
        q.push(i);
        vector<ll> d(n,-1);
        d[i] = 1;
        while(!q.empty()){
            ll u = q.front();
            q.pop();
            for (ll v:g[u]){
                if (d[v] != -1){
                    if ((d[v]+d[u]+1)%2) out = 1;
                    continue;
                }
                d[v] = d[u]+1;
                q.push(v);
            }
        }
        chmax(ans,*max_element(all(d)));
    }
    if (out) PRINT(-1);
    else PRINT(ans);
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		if(b<=a) {
			System.out.println("delicious");
		}else if(b<=a+x) {
			System.out.println("safe");
		}else {
			System.out.println("dangerous");
		}
	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

vector<int> prime(int n)
{
    vector<bool> num;
    vector<int> p;

    for (int i = 0; i <= n + 10; i++)
        num.push_back(true);

    FOR(i, 2, n)
    {
        if (!num[i])
            continue;

        p.push_back(i);

        for (int j = i * 2; j <= n; j += i)
        {
            num[j] = false;
        }
    }

    return p;
}

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

    int n;
    cin >> n;

    V p = prime(100000);

    V res;
    int j = 0;
    while (res.size() < n)
    {
        if (p[j] % 10 == 1)
            res.push_back(p[j]);
        j++;
    }

    REP(i, n)
    cout << res[i] << (i < n - 1 ? " " : "\n");

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
using namespace std;

int main ()
{
  int n, k;
  int x;
  int ans = 0;
  vector<int> A(200000);

  scanf("%d", &n);
  scanf("%d", &k);

  for (int i = 0; i < n; i++) {
    A[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    A[x-1] += 1;
  }

  sort(A.begin(), A.begin() + n);

  for (int i = 0; i < n - k; i++) {
    if (A[i] == 0) {
      continue;
    }
    ans += A[i]; 
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
  int n, t;
  cin >> n >> t;
  queue<pair<int, string> > ps;
  for(int i = 0; i < n; ++i) {
    string id;
    int size;
    cin >> id >> size;
    ps.push(make_pair(size, id));
  }
  for(int time = 0; !ps.empty();) {
    auto p = ps.front();
    ps.pop();
    time += min(p.first, t);
    p.first -= t;
    if(p.first > 0) {
      ps.push(p);
    } else {
      cout << p.second << ' ' << time << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4404
n=int(input())
c={chr(ord('a') +i): 0 for i in range(26)}

for s1c in input():
    c[s1c] += 1

for i in range(1,n):
    c2={chr(ord('a') +i): 0 for i in range(26)}
    for j in input():
        c2[j] += 1
    for j in range(ord('a'),ord('z')+1):
        c[chr(j)] = min(c[chr(j)],c2[chr(j)])

for i in range(ord('a'),ord('z')+1):
    print(chr(i)*c[chr(i)],end="")
print()


Measured memory_bytes: 3064
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  C = [0] * M  # Num of City, P, Y, Num of birth in Y
  P = [0] * (N+1)
  for m in range(M):
    p, y = map(int, input().split())
    C[m] = [m, p, y, 0]
  C = sorted(C, key=lambda x: x[2])

  for c in C:
    P[c[1]] += 1
    c[3] = P[c[1]]
  C = sorted(C, key=lambda x: x[0])

  for c in C:
    print('{:06d}{:06d}'.format(c[1], c[3]))


if __name__ == '__main__':
  main()

Measured memory_bytes: 30608
#include <iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
char c[1000000];
int main()
{
  string a,b;
  cin>>a>>b;
  cout<<a[0]<<b[0];
  int j=1,k=2;
  for(int i=1;i<a.size();i++)
  {
    c[j]=a[i];
    j=j+2;
}
for(int i=1;i<b.size();i++)
{
  c[k]=b[i];
  k=k+2;
}
for(int i=1;i<=a.size()+b.size()-2;i++)
cout<<c[i];
cout<<endl;
return 0;
}


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

int ctoi(char c){
  return c - '0';
}

int main(void){
  char t[4];
  int s[4];
  for(int i = 0; i < 4; i++){
    cin >> t[i];
    s[i] = ctoi(t[i]);
  }
  int y1 = s[0]*10 + s[1],y2 = s[2] * 10 + s[3];
  if(y1 >= 1 && y1 <= 12){
    if(y2 >= 1 && y2 <= 12){
      cout << "AMBIGUOUS" << endl;
    }
    else{
      cout <<"MMYY" << endl;
    }
  }
  else{
    if(y2 >= 1 && y2 <= 12){
      cout << "YYMM" << endl;
    }
    else cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()






int main() {
	ll d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MAX_COMB = 5000;
const LL mod = 998244353;
LL fct[MAX_COMB+1];
LL invfct[MAX_COMB+1];

void build(){
	fct[0] = fct[1] = 1;
	repp(i,2,MAX_COMB+1){
		fct[i] = fct[i-1] * i % mod;
	}
	LL x = fct[MAX_COMB];
	invfct[MAX_COMB] = 1;
	for(int i = mod - 2 ; i > 0 ; i >>= 1){
		if(i % 2 == 1) (invfct[MAX_COMB] *= x) %= mod;
		(x *= x) %= mod;
	}
	repm(i,MAX_COMB,0){
		invfct[i-1] = invfct[i] * i % mod;
	}
}

LL comb(int x , int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return fct[x] * invfct[y] % mod * invfct[x-y] % mod;
}

int main(){
	build();
	int K,N; cin >> K >> N;
	vector<LL> ans(2*K+1,0);
	vector<LL> dp(N+1,0);
	dp[0] = 1;
	repp(i,2,K+2){
		if(i&1){
			vector<LL> nx(N+1,0);
			LL s = 0;
			repp(j,0,N+1){
				nx[j] = (s+dp[j])%mod;
				s = (s+2*dp[j])%mod;
			}
			swap(dp,nx);
			repp(j,0,N+1) (ans[i] += dp[j]*comb(N-j+K-i,N-j)) %= mod;
			if(i == K+1) ans[i] = dp[N];
		} else {
			repp(j,0,N) (ans[i] += dp[j]*(comb(N-j+K-i,N-j)+comb(N-j+K-i-1,N-j-1))) %= mod;
			(ans[i] += dp[N]) %= mod;
			if(i == K+1) ans[i] = (dp[N-1]+dp[N])%mod;
		}
		
		ans[2*K+2-i] = ans[i];
	}
	repp(i,2,2*K+1) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int count = 0;
		String s = sc.next();
        String sa[];
        sa = new String[s.length()];
        String c = "CODEFESTIVAL2016";
        String ca[];
        ca = new String[c.length()];
        for(int i=0; i<c.length(); i++){
            //if(i == c.length() - 1){
            //ca[i] = c.substring(i);
            //sa[i] = s.substring(i);
            ca[i] = String.valueOf(c.charAt(i));
            sa[i] = String.valueOf(s.charAt(i));
            //}
            //else{
            //ca[i] = c.substring(i, i+1);
            //sa[i] = s.substring(i, i+1);
            //}
            if(ca[i].equals(sa[i])){
            count = count;
            }
            else {
                count = count + 1;
            }
        }
		// 出力
		System.out.println(count);
	}
}

Measured memory_bytes: 8916
import collections

N, K = map(int,input().split())
A = list(map(int,input().split()))

A_cou = collections.Counter(A)
B = A_cou.most_common()
l = len(B)
count = 0

if K >= l:
    print(0)
else:
    for i in range(l - K):
        count += B[-i-1][1]
    print(count)


Measured memory_bytes: 39312
#include<cstdio>
 
int main(){
	long int lyuka[87];
    int N;
  	scanf("%d", &N);
  	for(int i=0;i!=87;i++){
    	if(i==0){
          lyuka[0]=2;
        }else if(i==1){
          lyuka[1]=1;
        }else if(i>=2){
        	lyuka[i]=lyuka[i-1]+lyuka[i-2];
        }
    }
printf("%ld\n",lyuka[N]);
return 0;
}

Measured memory_bytes: 128
A = [2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, 4870847, 7881196, 12752043, 20633239, 33385282, 54018521, 87403803, 141422324, 228826127, 370248451, 599074578, 969323029, 1568397607, 2537720636, 4106118243, 6643838879, 10749957122, 17393796001, 28143753123, 45537549124, 73681302247, 119218851371, 192900153618, 312119004989, 505019158607, 817138163596, 1322157322203, 2139295485799, 3461452808002, 5600748293801, 9062201101803, 14662949395604, 23725150497407, 38388099893011, 62113250390418, 100501350283429, 162614600673847, 263115950957276, 425730551631123, 688846502588399, 1114577054219522, 1803423556807921, 2918000611027443, 4721424167835364, 7639424778862807, 12360848946698171, 20000273725560978, 32361122672259149, 52361396397820127, 84722519070079276, 137083915467899403, 221806434537978679, 358890350005878082, 580696784543856761, 939587134549734843]
print(A[int(input())])

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

int main(){
	int n,ans=0;
	cin>>n;
	int A[n]={};
	for(int i=0;i<n;i++)cin>>A[i];
	int flag=1;
	while(flag){
		flag=0;
		for(int j=n-1;j>=1;j--){
			if(A[j]<A[j-1]){
				swap (A[j],A[j-1]);
				flag=1;
			}
		}
	}
	int i=n-1;
	while(i-1>=0){
        ans+=A[i];
		ans-=A[i-1];
		i=i-2;
    }
	if(i==0)ans+=A[0];
	cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n, d=0;
	cin >> n;
	int i=n;

	while(1) {
		d += i%10;
		if(i<10) break;
		i /= 10;
	}

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

Measured memory_bytes: 256
import heapq as hq
N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))

hq.heapify(A)

for i in range(M):
  a = -hq.heappop(A)
  hq.heappush(A, -(a//2))

print(-sum(A))

Measured memory_bytes: 14252
n, m, r = map(int, input().split())
#高速化dijkstra
import heapq
def dijkstra_heap(s,edge):
  d = [float("inf")] * n #始点sから各頂点への最短距離
  used = [False] * n
  d[s] = 0
  used[s] = True
  edgelist = []
  #edgelist : (sからの暫定(未確定)最短距離+頂点)
  #edge[s] : sから出る枝の(重み,終点)の配列
  for w,v in edge[s]:
    heapq.heappush(edgelist,w*10**6+v) #sの隣の点は枝の重さがそのまま暫定最短距離となる
  while len(edgelist):
    #まだ使われてない頂点の中から最小の距離のものを探す→確定させる
    minedge = heapq.heappop(edgelist)
    #minedge : (sからの確定最短距離+頂点)
    v = minedge%10**6
    if used[v]:
      continue
    d[v] = minedge//10**6
    used[v] = True
    for w,u in edge[v]:
      if not used[u]:
        heapq.heappush(edgelist,(d[v]+w)*10**6+u)
  return d

edge = [[] for _ in range(n)]

for i in range(m):
  u,v,w = map(int, input().split())
  edge[u].append((w,v))

d = dijkstra_heap(r,edge)
for ans in d:
    if ans==float('inf'):
        print('INF')
    else:
        print(ans)


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

int main(){
  int N,K;
  cin >>N >>K;
  vector<int> l(N);
  for(int i=0;i<N;i++)
    cin >>l.at(i);
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int s=0;
  for(int i=0;i<K;i++)
    s+=l.at(i);
  cout <<s <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 1e9 + 7;
const ll maxn = 200005;
const ll N = 500005;

void solve(){
	
}
int main(){  
	cin.tie(0); 
    ios::sync_with_stdio(false);
	double T,m,k,sum=0,a,b,n;
	/*scanf("%d",&T); 
	while(T--){
		//solve();	
		
	}*/
	int flag=0,t;
	scanf("%lf%lf",&a,&b);
	for(double i=1;i<=1500;i++){
		if(floor(i*0.08)==(int)(a)&&floor(i*0.1)==(int)(b)){
			t=i;
			flag=1;
			break;
		}
	}
	if(flag) printf("%d",t);
	else printf("-1");


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;

int n;

string s;
vector <string> ans;
void brute(int pos, int big_char)
{
    if(pos == n)
    {
        ans.pb(s);
        return;
    }

    for(int i = 0; i <= big_char; i++)
    {
        s.pb(char((int)'a' + i));
        brute(pos + 1, max(big_char, i + 1));
        s.pop_back();
    }
}

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

    cin >> n;
    brute(0, 0);

    for(auto t: ans)
        cout << t << endl;


    return 0;
}


Measured memory_bytes: 9716
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    ll a,b,k;cin >> a >> b >> k;
    if (a-k < 0){
        if (b-(k-a)>0){
            cout << 0 << " " << b-k+a << endl;
        }
        else {
            cout << 0 << " " << 0<< endl;
        }
    }
    else cout << a-k << " " << b << endl;
    return 0;
}

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

const int maxn = 1000009;
const int MOD = 1e9+7;
LL f[maxn], n, sum;

int main(){
	scanf("%lld", &n);
	f[1] = n; f[2] = n*n%MOD;
	for (int i=3; i<=n; i++){
		f[i] = (f[i-1] + (n-1)*(n-1) + sum + (n-i+2)) % MOD;
		sum = (sum + f[i-2]) % MOD;
	}
	printf("%lld\n", f[n]);
	return 0;
}

Measured memory_bytes: 8064
import itertools
import sys
input = sys.stdin.readline

X = int(input())
ans = 1

for b in range(2, X+1):
    for i in itertools.count(2):
        bp = b ** i
        # print(bp)
        if bp <= X:
            ans = max(ans, bp)
        else:
            break

print(ans)


Measured memory_bytes: 9096
#include<stdio.h>

int main()

{
    int n,k,x,y,a;
    scanf("%d%d%d%d",&n,&k,&x,&y);

    if(n<k)
    {
        a=n*x;
        printf("%d",a);
    }

    else
    {
        a=k*x+(n-k)*y;
        printf("%d",a);

    }
    return 0;
}


Measured memory_bytes: 128
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int A, B, C; cin >> A >> B >> C;
  cout << max(0ll, C-(A-B)) << endl;
}


Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	new aoj0092().doIt();
    }
    class aoj0092{
    	int dp(int n,int a[][]){
    		int result = 0;
    		for(int i = 1;i < n;i++){
				for(int j = 1;j < n;j++){
					if(a[i][j] != 0){
						a[i][j] = Math.min(a[i-1][j-1], Math.min(a[i-1][j],a[i][j-1]))+1;
						result = Math.max(result,a[i][j]);
					}
				}
			}
    		return result;
    	}
    	void doIt(){
    		while(true){
    			int n = sc.nextInt();
    			if(n == 0)break;
    			int a[][] = new int [n][n];
    			for(int i = 0;i < n;i++){
    				String str = sc.next();
    				char ctr[] = str.toCharArray();
    				for(int j = 0;j < n;j++){
    					if(ctr[j] == '.')a[i][j] = 1;
    					else a[i][j] = 0;
    				}
    			}
    			System.out.println(dp(n,a));
    		}
    	}
    }
}

Measured memory_bytes: 72912
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String [] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pr=new PrintWriter(System.out);
		ArrayList<task> ar=new ArrayList<task>();
		String[] s=br.readLine().split(" ");
		int n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);
		for (int i=0;i<n;i++){
			ar.add(new task(br.readLine()));
		}
		int totaltime=0;
		while (!ar.isEmpty()){
			int tasktime=ar.get(0).gettime();
			if (tasktime>q){
				ar.get(0).timecut(q);
				ar.add(ar.get(0));
				ar.remove(0);
				totaltime+=q;
			}else {
				totaltime+=ar.get(0).gettime();
				pr.println(ar.get(0).getname()+" "+totaltime);
				ar.remove(0);
			}
		}
		pr.close();
	}
}

class task{
	private String name;
	private int time;
	public task(String str){
		String[] stmp=str.split(" ");
		this.name=stmp[0];
		this.time=Integer.parseInt(stmp[1]);
	}
	public String getname(){
		return this.name;
	}
	public int gettime(){
		return this.time;
	}
	public void timecut(int t){
		this.time-=t;
	}
}

Measured memory_bytes: 56632
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#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 mat(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;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	ll a, b;
	cin >> a >> b;
	ll i = b - a;
	ll s =  i*(i + 1)/2;
	cout << s - b;
	return 0;
}





Measured memory_bytes: 256
inp = input()
inp = inp.split()
N = int(inp[0])
M = int(inp[1])
BigM = N+2

E = []
for m in range(M):
    abinp = input()
    abinp = abinp.split()
    a = int(abinp[0])
    b = int(abinp[1])
    E.append([a,b])

# program
Edict = [[] for n in range(N+1)]
for e in E:
    Edict[e[0]].append(e[1])
    Edict[e[1]].append(e[0])

output = [0] + [0] + [BigM]*(N-1)
prev = [0 for n in range(N+1)]
prev_cnt = 0
now = [1]

prev[1] = 1
while len(now) > 0:
    n = now.pop(0)
    prev_cnt += 1
    for next in Edict[n]:
        if prev[next] == 0:
            output[next] = n
            now.append(next)
            prev[next] = 1

if prev_cnt == N:
    print("Yes")
    for n in range(2,N+1):
        print(output[n])
else:
    print("No")

Measured memory_bytes: 52808
N=int(input())
S=input()
LIST=[]

i=0
while i<N:
    if i<=N-1 and len(LIST)>=1 and LIST[-1]=="(" and S[i]==")":
        i+=1
        LIST.pop()
    else:
        LIST.append(S[i])
        i+=1

print("("*LIST.count(")")+S+")"*LIST.count("("))

Measured memory_bytes: 3060
/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃ 　
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting　　　　　　　　　　
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃　　　　　　　　　　　
 * 　　　　　　　　　┃　　　┃  　　　　　　
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃　　　　　　　　　　　
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */ 
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 200005
#define nm 7000000
#define pi 3.1415926535897931
using namespace std;
const ll inf=1000000;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
 

ll n,m;
int main(){
	n=read();m=read();
	if(n==1&&m==1)printf("1\n");
	else if(n==1)printf("%lld\n",m-2);
	else if(m==1)printf("%lld\n",n-2);
	else printf("%lld\n",(n-2)*(m-2));
	return 0;
}


Measured memory_bytes: 256
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll A, B;
int main(){
	IOS;
	cin >> A >> B;
	ll ans = 0;
	if (A > B){
		ans += A;
		A --;
	}else{
		ans += B;
		B--;
	}
		if (A > B){
		ans += A;
		A --;
	}else{
		ans += B;
		B--;
	}
		
	cout << ans;
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
package main
 
import (
  "fmt"
  "math"
)
 
const inf = math.MaxInt32
 
func min(nums ...int) int {
    if len(nums) == 0 {
        panic("funciton min() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Min(float64(res), float64(nums[i])))
    }
    return res
}
 
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
  
func main() {
  var n,k int
  fmt.Scan(&n)
  fmt.Scan(&k)
  h := make([]int, n)
  dp := make([]int, n)
  
  for i := range h {
    fmt.Scan(&h[i])
  }
 
  for i := range dp {
    dp[i] = inf
  }
 
  dp[0] = 0
  
  for i := 1; i < n; i++ {
    if i <= k {
      for j := 0; j < i ; j++ {
        dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]))
      } 
    } else {
      for j := i-k; j < i ; j++ {
        dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]))
      }
    }
  }
	
  fmt.Println(dp[n-1])
}

Measured memory_bytes: 5504
#include <cstdio>
using namespace std;
int main(){
	#define int long long
	int x, y, z;
	int N, Y;
	
	scanf("%lld %lld", &N, &Y);
	for(x=0; x*10000<=Y; x++){
		if(Y-1000*N-9000*x<0 or (Y-1000*N-9000*x)%4000!=0)
			continue;
		y=(Y-1000*N-9000*x)/4000;
		if(N-x-y<0)
			continue;
		z=N-x-y;
		printf("%lld %lld %lld", x, y, z);
		return 0;
	}
	printf("-1 -1 -1");
	return 0;
}
/*
x=i
y=y
z=N-i-y
10000x+5000y+1000z=Y
10000i+5000y+1000(N-i-y)=Y
9000i+4000y+1000N=Y
4000y=Y-1000N-9000i
*/

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+9;
ll coast[N];
vector<pair<int,ll>>v[N];
bool visited[N];
void dfs(int x,ll sum){
    coast[x]=sum;
    visited[x]=true;
    for (int i=0;i<v[x].size();i++){
        if (!visited[v[x][i].first]){
            dfs(v[x][i].first,sum+v[x][i].second);
        }
    }
}
int main()
{
    FASTINOUT;
    int x,a,b,c;
    cin>>x;
    for (int i=0;i<x-1;i++){
      cin>>a>>b>>c;
      v[a].push_back({b,c});
      v[b].push_back({a,c});
    }
    int q,start;
    cin>>q>>start;
    dfs(start,0);
    while (q--){
        cin>>a>>b;
        cout<<coast[a]+coast[b]<<endl;
    }
    return 0;
}


Measured memory_bytes: 14464