akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
int n, A, B, C;
vector<int> len;

int dfs(int a, int b, int c, int depth)
{
    if (depth == n)
    {
        if (a == 0 || b == 0 || c == 0)
        {
            return INF;
        }
        return abs(a - A) + abs(b - B) + abs(c - C);
    }
    int res = dfs(a, b, c, depth + 1);
    chmin(res, dfs(a + len[depth], b, c, depth + 1) + (a == 0 ? 0 : 10));
    chmin(res, dfs(a, b + len[depth], c, depth + 1) + (b == 0 ? 0 : 10));
    chmin(res, dfs(a, b, c + len[depth], depth + 1) + (c == 0 ? 0 : 10));
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> A >> B >> C;
    len.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> len[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
}

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

int main(){
    string s; cin >> s;
    bool flag=true;
    int n=s.length();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]) flag=false;
    }
    int m=(n-1)/2;
    for(int i=0;i<m/2;i++){
        if(s[i]!=s[m-i-1]) flag=false;
    }
    for(int i=0;i<m/2;i++){
        if(s[m+1+i]!=s[n-1-i]) flag=false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }
  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  string S;
  cin >> N >> S;
  llvec a(26, 0);
  rep(i, N){
    a[S[i]-'a']++;
  }

  ll ans = 1;
  rep(i, 26){
    ans = mod(ans*(a[i]+1), MOD);
  }
  cout << ans - 1;
  
  return 0;
}


Measured memory_bytes: 512
fn main() {
  proconio::input!{n:usize,mut m:usize,k:usize,mut a:[usize;n],mut b:[usize;m]};
  a.insert(0,0);
  let mut t=b.iter().sum::<usize>();
  let mut x=0;
  for i in 0..a.len(){
    t+=a[i];
    while t>k&&m>0{
      m-=1;
      t-=b[m]
    }
    if t>k{break}
    x=x.max(m+i)
  }
  println!("{}",x)
}

Measured memory_bytes: 9492
n=int(input());s=input()
for p in range(4):
  l=[p//2,p%2]+[0]*(n-2)
  for i in range(1,n):l[(i+1)%n]=[l[i-1],1-l[i-1]][::(-1)**(s[i]=="o")][l[i]]
  for i in range(n):
    if s[i]!="ox"[int(l[(i-1)%n]==l[(i+1)%n])-l[i]]:break
  else:print("".join("WS"[x]for x in l));exit()
print(-1)

Measured memory_bytes: 11216
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let K = readInt()!
let x = readIntSplit(by: " ")
print(x.reduce(0){$0+($1>K/2 ?abs(K-$1):$1)}*2)


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

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String st;
            while((st= br.readLine())!=null){
                String[] s = st.split(" ",0);
                int a = Integer.parseInt(s[0]);
                int b = Integer.parseInt(s[1]);
                int c = a;
                int d = b;
                while(b!=0){
                    int k = b;
                    b = a%b;
                    a = k;
                }
                System.out.println(a+" "+(c/a)*d);
                
            }
        }catch(Exception ex){
            System.exit(0);
        }
    }
}

Measured memory_bytes: 24096
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

X = int(input())
v = 100

cnt = 0
while v<X:
    v = v*101//100
    cnt += 1

print(cnt)




Measured memory_bytes: 9472
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            var NKM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var A = NKM[0];
            var B = NKM[1];

            var ans = -1;
            for (int i = 0; i < 100000; i++)
            {
                if (Floor(i*0.08) == A && Floor(i * 0.1) == B)
                {
                    ans = i;
                    break;
                }
            }


            Console.WriteLine(ans);
        }


    }

}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<P> v;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        v.pb(P(a, b));
    }
    sort(all(v));
    ll sum = 0, idx = -1;
    while(sum < k) {
        idx++;
        sum += v[idx].se;
    }
    cout << v[idx].fi << endl;
    return 0;
}

Measured memory_bytes: 2420
def main():
    S = str(input())
    T = str(input())
    counter = 0
    max_match = 0

    if T in S:
        print(0)
    else:
        for i in range(len(T), len(S)+1):
            counter = 0
            for j in range(len(T)):
                if S[i-len(T)+j] == T[j]:
                    counter += 1
            if max_match < counter:
                max_match = counter
        print(len(T)-max_match)
main()


Measured memory_bytes: 9108
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll d;
    cin >> d;
    d *= d;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = 0;
		int minCount = 0;
		for (int i = 0; i < n; i++) {
			int count = 0;
			a = sc.nextInt();
			while(true) {
				if (count != 0) {
					a /= 2;
				}
				if (a % 2 != 0) {
					break;
				}
				count++;
			}
			if (i == 0) {
				minCount = count;
			} else if (count < minCount) {
				minCount = count;
			}
		}
		System.out.println(minCount);
	}

}


Measured memory_bytes: 21844
n=int(input())
nl=[input() for i in range(n)]
m=int(input())
ml=[input() for i in range(m)]
nsl=list(set(nl))
mx=0
for x in range(len(nsl)):
	d=nl.count(nsl[x])-ml.count(nsl[x])
	if d>mx:mx=d
print(max(0,mx))

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int cnt = 0;

	if (a <= b) {
		cnt += a;
	}
	else if (a > b) {
		cnt += b;
	}
	if (c <= d) {
		cnt += c;
	}
	else if (c > d) {
		cnt += d;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    K, S = map(int, input().split())
    ret = 0
    for z in range(K+1):
        ret += max(min(S-z, K)-max(S-z-K, 0) + 1, 0)
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (b-a==c-b) YES;
  else NO;
  return 0;
}


Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

ll n;
void dfs(ll num,int a,int b,int c);
int ans=0;
int a=0,b=0,c=0;

int main(void) {
	cin>>n;
	dfs(0,a,b,c);
	cout<<ans<<endl;
	
}

void dfs(ll num,int a,int b,int c){
	if(a>0 && b>0 && c>0 && num<=n){
		ans++;
	}else if(num>n){
		return ;
	}
	//cout<<a<<b<<c<<endl;
	
	dfs(num*10+3,a+1,b,c);
	dfs(num*10+5,a,b+1,c);
	dfs(num*10+7,a,b,c+1);
	return ;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int n, r;
	char s;
	char c[4] = { 'S', 'H', 'C', 'D' };
	bool S[14], H[14], C[14], D[14];
	map<char, bool*> mp;

	mp['S'] = S;
	mp['H'] = H;
	mp['C'] = C;
	mp['D'] = D;

	rep(i, 4) repc(j, 1, 13) mp[c[i]][j] = false;

	cin >> n;
	rep(i, n) {
		cin >> s >> r;
		mp[s][r] = true;
	}

	rep(i, 4) repc(j, 1, 13) {
		if (!mp[c[i]][j]) cout << c[i] << ' ' << j << endl;
	}


	return 0;
}



Measured memory_bytes: 3088
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let o = read_as_string().chars().collect::<Vec<char>>();
    let e = read_as_string().chars().collect::<Vec<char>>();

    for i in 0..e.len(){
        print!("{}", o[i]);
        print!("{}", e[i]);
    }

    if o.len() > e.len(){
        println!("{}", *o.last().unwrap());
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;


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

int cost[2];

struct aa{
	vector<int> field;
	int aaa;
	int cost;
};
aa mo(aa a,const int way) {
	const int ncost(a.cost + cost[way % 2]);
	int aaaa;
	if (way == 0) {
		aaaa = ((a.aaa) + 8) % 9;
	}else if(way == 1) {
		aaaa = ((a.aaa) + 3) % 9;
	}
	else if(way == 2) {
		aaaa = ((a.aaa) + 1) % 9;
	}
	else {
		aaaa = ((a.aaa) + 6) % 9;
	}
	
	swap(a.field[a.aaa], a.field[aaaa]);
	a.aaa = aaaa;
	a.cost = ncost;
	return a;
}
class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.cost> r.cost;
	}
};
class HashVI {  // ハッシュ関数オブジェクト
public:
	size_t operator()(const vector<int> &x) const {
		const int C = 997;      // 素数
		size_t t = 0;
		for (int i = 0; i != x.size(); ++i) {
			t = t * C + x[i];
		}
		return t;
	}
	size_t operator()(const vector<vector<int>> &x) const {
		const int C = 997;      // 素数
		size_t t = 0;
		for (int i = 0; i != x.size(); ++i) {
			for (int j = 0; j < x[i].size(); ++j) {
				t = t * C + x[i][j];
			}
		}
		return t;
	}
	size_t operator()(const vector<vector<short>> &x) const {
		const int C = 9;      // 素数
		size_t t = 0;
		for (int i = 0; i != x.size(); ++i) {
			for (int j = 0; j < x[i].size(); ++j) {
				t = t * C + x[i][j];
			}
		}
		return t;
	}
};

unordered_map<vector<int>, int,HashVI>mp;

int main() {
	while (1) {
		mp.clear();
		cin >> cost[0] >> cost[1];
		if (!cost[0]&&!cost[1])break;
		short vx, vy;
		vector<int>field(9);
		for (int y = 0; y < 9; ++y) {
			int a; cin >> a;
			if (!a) {
				vx = y;
			}
			field[y] = a;
		
		}
		vector<int>ans(9);
		for (int y = 0; y < 9; ++y) {
			int a; cin >> a;
			
			ans[y] = a;
		}
		priority_queue<aa, vector<aa>, Compare>que;
		que.push(aa{ field, vx, 0 });

		int anscost = 0;

		anscost = 999999;
		while (!que.empty()) {
			aa atop(que.top());
			if (atop.field == ans) {
				anscost = atop.cost;
				break;
			}
			if (anscost <= atop.cost)break;
			que.pop();

			for (int i = 0; i < 4; ++i) {
				aa na(mo(atop, i));
				if (!mp.count(na.field) || mp[na.field]>na.cost) {
					mp[na.field]=na.cost;

					que.emplace(na);
				}
			}
		}
		cout << anscost << endl;
	}	
	return 0;
}

Measured memory_bytes: 54904
#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.at(i);
  }
  int ans=-1;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      ans=max(ans,abs(A.at(i)-A.at(j)));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ABC051 B 14:29 - 
'''
問題
整数X,Y,Zがいずれも0以上K以下であって,かつX+Y+Z=Sであるような(X,Y,Z)の組はいくつあるか？

考察
X,Yの2つがいずれも0以上K以下であって,かつX+Y=Tであるような(X,Y)の組の数をまず考える
TがK以下であればそのような組の数はmax(0,T+1)通り
TがK+1以上であればそのような組の数はmax(0,(T+1)-2*(T-K))通り

次にTのとりうる値の範囲を考える
Z=S-TであってZは0以上K以下でなければならないからTのとりうる値の範囲は0<=S-T<=K -S<=-T<=-S+K S-K<=T<=S

したがってS-K<=T<=Sについて上記の値を足し合わせればよい
'''

K,S=map(int,input().split(' '))
ans=0
for T in range(S-K,S+1):
	if T<=K:
		ans += max(0,T+1)
	else:
		ans += max(0,(T+1)-2*(T-K))
print(ans)

Measured memory_bytes: 3060
open Batteries
open Printf

let ($) g f x = g (f x)

module MyList = struct
  include List
  let foldl = fold_left
  let foldli = fold_lefti
  let foldr = fold_right
  let foldri = fold_righti
  
  let flatmap = concat_map

  let zipf = map2
  let zipfi = map2i
end

module L = MyList

let atoi = int_of_string
let itoa = string_of_int
let atof = float_of_string
let ftoa = string_of_float
let ctoi = int_of_char
let itoc = char_of_int

let stocl = String.to_list
let cltos = String.of_list
let spsp s = String.split_on_char ' ' s

module MyString = struct
  include String

  let map' f s = L.map f (stocl s)
  let mapi' f s = L.map f (stocl s)

  let zipf f a b = L.zipf f (stocl a) (stocl b)
  let zipfi f a b = L.zipfi f (stocl a) (stocl b)

  let mkstr f sep ls =
    L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)
end

module S = MyString

let rds () = read_line ()

let rdi () = atoi @@ rds ()

let rdhs () = spsp @@ rds ()
let rdhi () = rdhs () |> L.map atoi

let rdi2 () = match rdhi () with
  | a::b::_ -> (a, b)
  | _ -> (0, 0)

let rdi3 () = match rdhi () with
| a::b::c::_ -> (a, b, c)
| _ -> (0, 0, 0)

let rdi4 () = match rdhi () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0, 0, 0, 0)

let rdv n rdf =
  let rec rdv' n =
    if n <= 0 then []
    else (
      let s = rdf () in
      s::(rdv' (n - 1))
    )
  in rdv' n

let rdvi n = rdv n rdi
let rdvi2 n = rdv n rdi2
let rdvi3 n = rdv n rdi3
let rdvi4 n = rdv n rdi4

let puts s = print_endline s
let putyn b = puts (if b then "Yes" else "No")
let puti i = puts @@ itoa i

let set_power ls =
  let rec set_power' ls pls =
    match ls with
    | [] -> pls
    | hd::tl -> set_power' tl (L.flatmap (fun p -> [p; hd::p]) pls)
  in set_power' ls [[]]

let _ =
  let n = rdi () in
  let hpb = match n mod 10 with
  | 3 -> "bon"
  | 0 | 1 | 6 | 8 -> "pon"
  | _ -> "hon"
  in puts hpb;;



Measured memory_bytes: 5172
mod = 1000000007

facto = [1]*200001
tmp = 1
for i in range(1,200001):
    tmp = (tmp*i)%mod
    facto[i] = tmp

def ncr(n,r):
    return (facto[n] * pow(facto[r],mod-2,mod) % mod) * pow(facto[n-r],mod-2,mod) % mod

h,w,a,b = map(int,input().split())

ret = 0
for i in range(h-a):
    ret += ncr(b-1+i,i)*ncr(h-i-1+w-b-1,h-i-1)%mod
print(ret%mod)


Measured memory_bytes: 10868
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args>
void dbg(Args&&... args) {
  using expander = int[];
  (void)expander {0,(static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {exit(0);}

int n;
const int N = 2e5;
int a[N];

void input() {
  scanf("%d", &n);
  forn(i, 0, n) {
    scanf(" %d", &a[i]);
  }
}

ll calc(int b) {
  ll res = 0;
  forn(i, 0, n) {
    res += abs(a[i] - (b + i + 1));
  }
  return res;
}

void solve() {
  vector<int> v(n);
  forn(i, 0, n) {
    v[i] = a[i] - (i + 1);
  }
  sort(all(v));
  ll ans = calc(v[n / 2]);
  printf("%lld\n", ans);
}

int main() {
#ifdef DEBUG
//  freopen("input", "r", stdin);
//  freopen("output", "w", stdout);
//  gen();
#endif
  input();
  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

void swap(int A1[], int A2[]) {
	int tmp;
	tmp = *A1;
	*A1 = *A2;
	*A2 = tmp;
}

int bubbleSort(int A[], int N) {
	int i, j;
	int sw = 0;
	int flag = 1;
	for ( i = 0; flag; i++ ) {
		flag = 0;
	
		for ( j = N - 1; j >= i + 1; j-- ) {
			if ( A[j] < A[j - 1] ) {
				swap(&A[j], &A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void) {
	int N;
	int A[100];
	int sw;
	int i;
	
	scanf("%d", &N);
	
	for ( i = 0; i < N; i++ ) {
		scanf("%d", &A[i]);
	}
	
	sw = bubbleSort(A, N);
	
	for ( i = 0; i < N; i++ ) {
		if (i) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	
	printf("\n");
	printf("%d\n", sw);
	

	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;
using intk = int64_t;

int main() {
intk a,b,c;
  cin >>a>>b>>c;
  intk ans = 0;
  if(a%2==0&&b%2==0&&c%2==0&&a ==b && b==c){
   printf("-1\n"); 
  return 0;
  }
  else if(a ==b && b==c){
 printf("0\n"); 
  return 0;
  }
  
  while(a%2==0&&b%2==0&&c%2==0){
   intk p = a;
    intk q = b;
    intk r =c;
    a = (q+r)/2;
    b = (p+r)/2;
    c=(p+q)/2;
    ans++;
  }
  printf("%d\n",ans);
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int y, x;
    int counter = 1;
    cin >> y >> x;
    char enter[y][x + 1];
    int ans[y][x];
    for(int i = 0; i < y; i++) {
        for(int j = 0; j < x; j++) {
            ans[i][j] = -2;
        }
    }
    for(int i = 0; i < y; i++) {
        for(int j = 0; j < x; j++) {
            cin >> enter[i][j];
        }
        enter[i][x] = 'c';
    }

    for(int i = 0; i < y; i++) {
        for(int j = 0; j < x + 1;) {
            if(enter[i][j] == '.') {
                ans[i][j] = -1;
                j++;
            } else {
                ans[i][j] = 0;
                while(1) {
                    if(enter[i][j + counter] == '.') {
                        ans[i][j + counter] = counter;
                        counter++;
                    } else {
                        j = j + counter;
                        counter = 1;
                        break;
                    }
                }
            }
        }
    }
    for(int i = 0; i < y; i++) {
        for(int j = 0; j < x; j++) {
            cout << ans[i][j];
            if(j != x - 1)
                cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3128
import numpy as np
ans = 100000000000000000000000

n= int(input())
k = int(input())

for i in range(2**n):
    con = format(i,"b").zfill(n)
    temp = 1
    for c in con:
        if c == "1":
            temp += k
        else:
            temp *= 2
    if temp < ans:
        ans = temp

print(ans)


Measured memory_bytes: 20756
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "to", int, "idx");

void main() {
    int N;
    scan(N);

    auto adj = new Edge[][](N, 0);

    foreach (i ; 0 .. N - 1) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= Edge(bi, i);
        adj[bi] ~= Edge(ai, i);
    }

    auto ans = new int[](N - 1);
    ans[] = -1;
    int K;

    void dfs(int v, int p, int c) {
        int col = 1;

        foreach (e ; adj[v]) if (e.to != p) {
            if (col == c) col++;
            ans[e.idx] = col;
            K = max(K, col);
            dfs(e.to, v, col);
            col++;
        }
    }

    dfs(0, -1, -1);

    writeln(K);
    foreach (i ; 0 .. N - 1) {
        writeln(ans[i]);
    }
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 11644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int sub = b-a;
  vector<int> H(1000);
  H[0] = 0;
  for(int i=1;i<=999;i++){
    H[i] = H[i-1]+i;
  }
  cout << H[sub-1] - a << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($r,$d,$x) =  explode(" ",trim(fgets(STDIN)));

$x2[]=array();
for($i=0;$i<10;$i++) {
  $x = $r*$x - $d;
  printf("%d\n",$x);
}


Measured memory_bytes: 4604
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)


class UF {
	public:
	static const int ufmax=100052;
	int ufpar[ufmax],ufrank[ufmax],ufcnt[ufmax];
	UF() { init();}
	void init(){int i; rep(i,ufmax) { ufpar[i]=i; ufrank[i]=0; ufcnt[i]=1; } }
	int find(int x) {	return (ufpar[x]==x)?(x):(ufpar[x] = find(ufpar[x]));}
	int operator[](int x) {return find(x);}
	int count(int x) {return ufcnt[find(x)];}
	void unite(int x,int y) {
		x = find(x); y = find(y);
		if(x==y) return;
		if(ufrank[x]<ufrank[y]) ufpar[x]=y, ufcnt[y]+=ufcnt[x];
		else {ufpar[y]=x; ufcnt[x]+=ufcnt[y]; if(ufrank[x]==ufrank[y]) ufrank[x]++;}
	}
};

void mainmain(){
	int n;
	cin>>n;
	int m;
	cin>>m;
	vvint vv(m);
	UF uf;
	rep(i,n){
		int t;
		cin>>t;
		rep(j,t){
			int a;
			cin>>a;
			vv[a-1].PB(i);
		}
	}
	rep(i,m){
		rep(j,vv[i].size()){
			if(j+1<vv[i].size()){
				uf.unite(vv[i][j],vv[i][j+1]);
			}
		}
	}
	if(uf.count(0)==n){
		cout << "YES" <<endl;
	}
	else{
		cout << "NO" << endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 5760
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

string s, t;

bool check(int n){
  int len = s.length();
  for(int i = 0; i < len; i++){
    // cout << s[i] << " : " << t[(i + n) % len] << endl;
    if(s[i] != t[(i + n) % len]) return false;
  }
  return true;
}

int main(){
  cin >> s >> t;
  int len = s.length();
  if(len != t.length()){
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0; i < len; i++){
    if(s[0] == t[i]){
      if(check(i)){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define m(a) min(X,max(0,a))
using namespace std;

int r[200000],X,K,Q,T,A,s,l,k,t,x,d,f=-1;
int main()
{
  cin>>X>>K;
  for(;l<K;)cin>>r[l++];

  l = X;
  
  for(cin >> Q; Q--;cout << m(min(l, max(s, A + x)) + f * (T-t)) << endl) 
    for(cin >> T >> A; k<K&T>=r[k]; f *= -1)
      x += d=f*(r[k]-t),
      s=m(s+d),
      l=m(l+d),
      t = r[k++];
  

  return 0;
}

Measured memory_bytes: 1664
# frozen_string_literal: true

a,b = gets.split.map(&:to_i)
if 10 <= b && b < 100
    a *= 100
end
if b == 100
    a *= 1000
end
if b <= 9
    a *= 10
end
c = a + b
d = 0
i = 1
320.times do
  if c / i == i && c % i == 0
  d = 1
  break
  end
  i += 1
end
if d == 0
puts 'No'
end
if d != 0
puts 'Yes'
end


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

struct Card{ char suit, value; };

void bubble(struct Card A[], int N) {
  for(int i = 0; i<N; i++) {
    for(int j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for(int i=0;i<N;i++) {
    int minj = i;
    for(int j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for(int i=0; i<N; i++) {
    if(i>0) cout << " ";
      cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for(int i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main(void) {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for(int i=0;i<N; i++) {
    cin >> C1[i].suit >> C1[i].value;
  }
  for(int i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  vector<ll> v;
  ll i;
  ll p = A[0];
  ll f = N-1;
  set<ll> s;
  for (i = 0; i < N; i++) {
    v.push_back(p);
    if (s.count(p)) {
      auto itr = find_if(v.begin(), v.end(), [&](ll x) { return (x == p); });
        f = ll(distance(v.begin(), itr));
        break;
    }
    s.insert(p);
    if (i < N) p = A[p];
  }
  
  if (K <= i) cout << v[K-1]+1 << endl;
  else {
    ll rp = i-f;
    cout << v[(K-1-i)%rp+f]+1 << endl;
  }
}

Measured memory_bytes: 15512
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

long long xor_from_0(const long long x) {
    int keta = 0;
    long long ret = 0;
    while (x >= (long long)1 << keta) {
        keta++;
    }
    //std::cout << "check1:" << x << " " << keta << std::endl;
    long long tmp = 0;
    for (int k = keta; k >= 1; k--) {
        if (x >> k & 1) {
            tmp += ((long long)1 << k);
            if ((x - tmp) % 2 == 0) {
                ret += (long long)1 << k;
            }
        }
    }
    long long mod4 = x % 4;
    if (mod4 == 1 || mod4 == 2) {
        ret += 1;
    }
    return ret;
}

void test() {
    for (long long l = 0; l <= 16; l++) {
        std::cout << l << " " << xor_from_0(l) << std::endl;
    }
}


int main(int argc, char **argv) {
    long long A, B;
    std::cin >> A >> B;
    std::cout << (xor_from_0(A - 1) ^ xor_from_0(B)) << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,c[13]={1};
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a;cin>>a;
		c[a]++;
	}
	int ans=0;
	for(int i=1;i<12;i++)if(c[0]>1||c[12]>1||c[i]>2){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<1<<11;i++)
	{
		int d[30]={};
		for(int j=0;j<=12;j++)
		{
			if(c[j]==2)d[j]=d[24-j]=1;
			else if(c[j]==1)
			{
				if(0<j&&j<12)d[i&(1<<(j-1))?j:24-j]=1;
				else d[j]=1;
			}
		}
		int now=99,cnt=1;
		for(int j=1;j<24;j++)
		{
			if(d[j])now=min(now,cnt),cnt=1;
			else cnt++;
		}
		ans=max(ans,min(now,cnt));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef struct Maze{
  int y;
  int x;
  int t;
} MAZE;
int dy[]={0,0,1,-1};
int dx[]={1,-1,0,0};
int main() {
  int h,w; cin >> h >> w;
  vector<vector<char>> grid(h, vector<char>(w));
  vector<vector<int>> turn(h, vector<int>(w,-1));
  rep(i,h)rep(j,w) cin >> grid[i][j];
  queue<MAZE> q;
  rep(i,h)rep(j,w){
    if(grid[i][j]=='#'){
      q.push(MAZE{i,j,0});
    }
  }
  while(!q.empty()){
    int sy=q.front().y;
    int sx=q.front().x;
    int time=q.front().t;
    q.pop();
    if(turn[sy][sx]!=-1) continue;
    turn[sy][sx]=time;
    rep(dir,4){
      int ny=sy+dy[dir],nx=sx+dx[dir];
      if(ny>=h||ny<0||nx>=w||nx<0) continue;
      q.push(MAZE{ny,nx,time+1});
    }
  }
  int ans=-1;
  rep(i,h)rep(j,w) ans=max(ans,turn[i][j]);
  cout << ans << endl;
}

Measured memory_bytes: 53576
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e6+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, mx;
ll dp[MAXN][30];
bool a[30][30];
bool s[30][MAXN];
ll d(int in, int msk){
    if(in > n){
        if(msk == mx - 1) return 1;
        return 0;
    }
    if(s[in][msk]) return dp[msk][in];
    s[in][msk] = 1;
    for(int k = 1; k <= n; k++){
        if(a[in][k] && (msk & (1<<(k - 1))) == 0){
            dp[msk][in] += d(in + 1, msk | (1<<(k - 1)));
            dp[msk][in] %= mod;
        }
    }
    return dp[msk][in];
}

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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin>>a[i][j];
        }
    }
    mx = (1<<n);
    cout<<d(1, 0)<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 557312
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5+100;
typedef long long ll;
#define fr(i,low,up,st) for(register int i = (int)low;i <= (int)up;i += st)
#define nfr(i,low,up,st) for(register int i = (int)low;i >= (int)up;i -= st)
#define clr(a) memset(a,0,sizeof a)

int n,m,h,w;

struct edge{
   int r,c,a;
   bool operator < (const edge &b) const {
      return a > b.a;
   }
}e[N];

int f[N];
int cntp[N],cnte[N];

void init(){
   fr(i,1,h+w,1)f[i] = i,cntp[i] = 1;
   clr(cnte);
}

int find(int x){
   return (x == f[x])?x:f[x] = find(f[x]);
}

int main(){
   scanf("%d%d%d",&n,&h,&w);
   fr(i,1,n,1){
      scanf("%d%d%d",&e[i].r,&e[i].c,&e[i].a);
      e[i].c += h;
   }
   sort(e+1,e+n+1);
   ll ans = 0;
   init();
   fr(i,1,n,1){
      int h1 = find(e[i].r),h2 = find(e[i].c);
      if(h1 == h2){
         if(cntp[h1] == cnte[h1])continue ;
         cnte[h1]++;
         ans += e[i].a;
      }
      else {
         if(cntp[h1]+cntp[h2] < cnte[h1]+cnte[h2]+1)continue ;
         else {
            f[h1] = h2;
            cntp[h2] += cntp[h1]; cntp[h1] = 0;
            cnte[h2] += cnte[h1]+1; cnte[h1] = 0;
            ans += e[i].a;
         }
      }
   }
   printf("%lld\n",ans);
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
  double x[200000]={},m[200000]={},av=0;
  int min,n,idx,a,b;
  cin>>n;
  for(int i=0;i<n;i++){cin>>x[i];av+=x[i];}
  av/=n;
  for(int i=0;i<n;i++)m[i]=x[i];
  sort(m,m+n);
  a=m[n/2];
  b=m[n/2-1];
  av=(a+b)/2;
  for(int i=0;i<n;i++)
    if(av>=x[i])cout<<a<<endl;
    else cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 5376
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}
func combinations(n int) int {
	return (n * (n - 1)) / 2
}

func main() {
	n, m := scanInt(), scanInt()

	fmt.Println(combinations(n) + combinations(m))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int cg = 0;
  rep(i, s.size()){
    if(s.at(i) == 'g') cg++;
  }
  int h = (s.size()+1)/2;
  int ans = cg-h;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			int min = Integer.MAX_VALUE;
			int minj = 0;
			for (int j = i+1; j < n; j++) {
				if (min > a[j]) {
					min = a[j];
					minj = j;
				}
			}
			if (a[i] > min) {
				int tmp = a[i];
				a[i] = min;
				a[minj] = tmp;
				count++;
			}
		}
		print(a);
		System.out.println(count);
	}
	static void print(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i]);
			if (i != a.length-1) {
				System.out.print(" ");
			}
		}
		System.out.print("\n");
	}

}



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;




int main() {

	int m, k;
	cin >> m >> k;

	m = pow(2, m);

	if (m - 1 < k) {
		cout << -1 << endl;
		return 0;
	}
	if (m == 1) {
		cout << "0 0" << endl;
		return 0;
	}
	if (m == 2 && k == 1) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 0) {
		REP(i, m)cout << i << ' ' << i << ' ';
		return 0;
	}

	VI v;
	for (int i = m - 1; i > k; i--) {
		v.push_back(i);
	}
	v.push_back(0);
	v.push_back(k);
	v.push_back(0);
	FOR(i, k+1, m)v.push_back(i);

	FOR(i, 1, k) {
		v.push_back(i);
	}

	for (int i = k; i > 0; i--) {
		v.push_back(i);
	}

	REP(i, 2 * m)cout << v[i] << ' ';

	
}

Measured memory_bytes: 2932
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] cl = sc.next().toCharArray();
        char[] chk = {'A','T','C','G'};
        int ans = 0;
        int now = 0;
        for(int i = 0; i < cl.length; i++){
            boolean bool = false;
            for(char c: chk){
                if(cl[i] == c){
                    bool = true;
                    break;
                }
            }
            if(bool){
                now++;
            }else{
                ans = Math.max(ans,now);
                now = 0;
            }
        }
        System.out.println(Math.max(ans,now));
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;
ll scol(ll a[],int i,int j){
  ll s=0;
  for(int k=i;k<=j;k++)
    s=s+a[k];
  return s;
}
ll solve(ll a[],int s,int e,ll dp[][400]){
	if(s>=e)
	return 0;
	if(dp[s][e]!=-1)
	return dp[s][e];
	ll ans=LLONG_MAX;
	for(int i=s;i<e;i++){
		ll so1=solve(a,s,i,dp);
		ll so2=solve(a,i+1,e,dp);
		ans=min(ans,so1+so2+scol(a,s,i)+scol(a,i+1,e));
	}
	dp[s][e]=ans;
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	ll dp[n][400];
	memset(dp,-1,sizeof(dp));
	
	cout<<solve(a,0,n-1,dp)<<endl;
	// your code goes here
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<long long int> vec (87);
	vec.at(0) = 2;
	vec.at(1) = 1;
	for(int i = 2;i < 87;i++){
		vec.at(i) = vec.at(i-2) + vec.at(i-1);
	}
	cout << vec.at(N) << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for A - Meal Delivery
	var x, a, b int
	fmt.Scanf("%d %d %d", &x, &a, &b)

	if math.Abs(float64(x-a)) > math.Abs(float64(x-b)) {
		fmt.Printf("B")
	} else {
		fmt.Printf("A")
	}
}


Measured memory_bytes: 1836
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Integer n = scanner.nextInt();
        Integer a = scanner.nextInt();
        Integer b = scanner.nextInt();
        
        Integer kingaku = n*a;
        if(kingaku <= b) {
          System.out.println(kingaku);
          return;
        } else {
          System.out.println(b);
          return;
        }
        
        
    }
}

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

int alp[26];
int main()
{
    string s;
    cin >> s;
    int ssize = s.size();
    for (int i = 0; i < ssize; i++)
    {
        int c = s[i] - 'a';
        alp[c]++;
    }
    for (auto x : alp)
    {
        if (x > 1)
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int n;
int w;
long long a[110];//w
long long b[110]; //v
long long f[110][330];
const int INF=(0x7fffffff)/2;
long long ans;
 
int main() 
{
    cin>>n>>w;
    for (int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for (int i=0;i<110;i++) 
        for (int o=0;o<330;o++) f[i][o]=-INF;
    f[0][0]=0;
    for (int i=1;i<=n;i++)
        for (int o=i-1;o>=0;o--) 
            for (int j=0;j<=3*o;j++) 
                if (f[o][j]!=INF) f[o+1][j+(a[i]-a[1])]=max(f[o+1][j+(a[i]-a[1])],f[o][j]+b[i]);
    
    for (int i=1;i<=n;i++) 
        for (int o=0;o<330;o++) if (i*a[1]+o<=w && f[i][o]!=INF) ans=max(ans,f[i][o]);
        
    cout<<ans<<endl;
}

Measured memory_bytes: 512
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!(s: chars);
    match s[1] {
        'B' => println!("ARC",),
        'R' => println!("ABC",),
        _ => (),
    }
}


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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        long long n;
        cin>>n;
        string ans="";
        while(n){
            ll k=n/26;
            ll z=n%26;
            if(z==0){
                k--;
                ans=(char)('z')+ans;
            }
            else
                ans=(char)(('a'+z-1))+ans;
            n=k;
        }
        cout<<ans;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3608