akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

#include <cassert>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


const int MAX = 2e6 + 500;
long long fac[MAX], finv[MAX], inv[MAX];

void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int f(int r, int c) {
  return (fac[r+c] * finv[r] % MOD) * finv[c] % MOD;
}

int main() {
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  comb_init();


  // ll ans = 0;
  // fromto(i, r1, r2) {
  //   fromto(j, c1, c2) {
  //     ans += f(i, j);
  //     ans %= MOD;
  //   }
  // }
  // cout << ans << endl;
  // debug(f(r2, c2) * 2 % MOD);
  ll ans = f(r2+1, c2+1);
  ans = MOD + ans - f(r2+1, c1);
  ans %= MOD;
  ans = MOD + ans - f(r1, c2+1);
  ans %= MOD;
  ans += f(r1, c1);
  ans %= MOD;
  cout << ans << endl;
  // f(r, c) = (r+c)! * (1/(r!)) * (1/(c!))
  return 0;
}


Measured memory_bytes: 47104
while true do
    h, w = gets.split.map(&:to_i)
    break if h == 0 && w == 0
    for i in 1..h do
        for x in 1..w do
            if i != 1 && i != h && x != 1 && x != w then
                print "."
            else
                print "#"
            end
        end
        puts ""
    end
    puts ""
end

Measured memory_bytes: 8732
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s, str="";
	cin >> s;
	for (int i = 0;i < s.size();i++) {
		if ((s[i]=='0')||(s[i]=='1')) {
			str += s[i];
		}
		else {
			str = str.substr(0, str.size() - 1);
		}
	}
		cout << str << endl;
		return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { 
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
int main(){
  int n;
  cin >> n;
  int min = 1 << 30; 
  int tmp = 0;
  for(int i = 1; i < n; i++){
    int a = findSumOfDigits(i);
    int b = findSumOfDigits(n-i);
    tmp = a + b;
    if (min > tmp){
      min = tmp;
    }
  } 
   cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    int arr[5]; REP(i,0,5) cin>>arr[i];
    REP(i,0,5) if(arr[i]==0) {
      cout<<i+1;
      break;
    }
  
    
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};
int main() {

    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if (p[i] > p[i-1] and p[i] < p[i+1])
            ans++;
        else if (p[i] < p[i-1] and p[i] > p[i+1])
            ans++;
    }

    cout << ans << '\n';

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
	int n,temp,count,num;
	cin >> n;
	vector<int> v;
	for (size_t i = 0; i < n; i++) {
		cin >> temp;
		v.push_back(temp);
	}

	vector<bool> x(n,false);

	count = 0;
	num = 1;
	while(true){
		// 2が押されたら終了
		if (num == 2) {
			break;
		}
		// ２回同じボタンが押されたらおかしい
		else if (x[num-1]) {
			count = -1;
			break;
		}
		// 全てのボタンを押して2にたどり着かなかったらおかしい
		else if (count > v.size()) {
			count = -1;
			break;
		}
		else {
			x[num-1] = true;
			num = v[num - 1];
			count++;
		}
	}
	cout << count << '\n';
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	string S;
	cin >> S;
	
	int n = S.size();
	vector<int> answer(n);
	
	int count = 0;
	
	// S[0]からRについてのカウント数の計算
	for (int i = 0; i < n; i++)
	{
		if (S[i] == 'R')
		{
			count++;
		}
		// Lが見つかった場合
		else {
			// 右側は切り捨て
			answer[i] += count / 2;
			// 左側は切り上げ
			answer[i - 1] += (count + 1) / 2;
			count = 0;
		}
	}
	
	
	// S[n - 1]からLについてのカウント数の計算
	for (int i = n - 1; i >= 0; i--)
	{
		if (S[i] == 'L')
		{
			count++;
		}
		// Rが見つかった場合
		else {
			// 左側は切り捨て
			answer[i] += count / 2;
			// 右側は切り上げ
			answer[i + 1] += (count + 1) / 2;
			count = 0;
		}
	}
	
	// 出力
	for (int i = 0; i < n; i++)
	{
		cout << answer[i] << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define Merlin 10000
#define Excalibur 500000
 
typedef struct edge 
{
    int origin;
    int destination;
    int tariff;
}Peak;

Peak edge[Excalibur];
int dangerous[Merlin];
 
void spear(int gungnir, int trident);

int main(int argc, char* argv[])
{
    int gungnir, trident, mjolnir;
    int gauntlet;
    scanf("%d", &gungnir);
 
    trident = 0;
    for(int i = 0; i < gungnir; ++i) 
    {
        scanf("%d", &gauntlet);
        scanf("%d", &mjolnir);
        for(int j = 1; j <= mjolnir; ++j)
        {
            edge[trident].origin = gauntlet;
            scanf("%d %d", &edge[trident].destination, &edge[trident].tariff);
            trident++;
        }
    }
     
    spear(gungnir, trident);
    
    for(int i = 0; i < gungnir; ++i) printf("%d %d\n", i, dangerous[i]);
    
    return 0;
}
void spear(int gungnir, int trident)
{
    int advanced = 1;
    for(int i = 1; i < gungnir; ++i) dangerous[i] = INT_MAX;
     
    while(advanced)
    {
        advanced = 0;
        for(int i = 0; i < trident; ++i) {
            if(dangerous[edge[i].origin] !=INT_MAX && dangerous[edge[i].origin]+edge[i].tariff < dangerous[edge[i].destination]) 
            {
                dangerous[edge[i].destination] = dangerous[edge[i].origin] + edge[i].tariff;
                advanced++;
            }
        }
    }
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, A, B, ans=0;

	cin >> N >> A >> B;

	if( N == 1 ){
		if( A == B ) ans = 1;
	}else if( N == 2 ){
		ans = N;
	}else{
		if( A <= B ) ans = 1 + (B-A)*(N-2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define N 100005
int t, n;
ll A[N];
int main()
{
	for (; ~scanf("%d", &n); )
	{
		for (int i = 1; i <= n; i++)
			scanf("%lld", &A[i]);
		sort(A + 1, A + n + 1);
		if (n % 3 == 0)
		{
			ll a = A[1], b = A[n / 3 + 1], c = A[n / 3 * 2 + 1];
			if (a != A[n / 3] || b != A[n / 3 * 2] || c != A[n] || (a ^ b ^ c) != 0)
				puts("No");
			else
				puts("Yes");
		}
		else
		{
			if (!A[0] && !A[n])
				puts("Yes");
			else
				puts("No");
		}
	}
}


Measured memory_bytes: 1024
int main()
{

	int a, b;
	scanf("%d %d", &a, &b);

	if(a > b){
        printf("a > b\n");
    }else if(a < b){printf("a < b\n");
    }else if(a == b){printf("a == b\n");
    }



    return 0;
}



Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long y = Long.parseLong(sc.next());
        int ans = 0;
        while (x <= y) {
            x *= 2;
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<stdlib.h>
#define MAX 100

int top=0,s[MAX];
int pop();
void push(int);


int main(){
  int a,b;
  char h[MAX];
  while(scanf("%s",h)!=EOF){
    if(h[0]=='+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(h[0]=='-'){
      a = pop();
      b = pop();
      push(b - a);
    }
    else if(h[0]=='*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else push(atoi(h));
  }
  printf("%d\n",pop());
  return 0;
}

int pop(){
  return s[top--];
}

void push(int x){
  s[++top]=x;
}



Measured memory_bytes: 2048
N = int(input()) # 数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

count = 0

for i in range(N-2):
    if List[i] < List[i+1] and List[i+1] < List[i+2]:
        count += 1
    elif List[i+2] < List[i+1] and List[i+1] < List[i]:
        count += 1
        
print(count)

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

using namespace std;

template<typename T> void mini(T &a, T b) { a = (a < b ? a : b); return; }

int main() {
  int n;
  cin >> n;
  int mn = n;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ans += x <= mn;
    mini(mn, x);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var cnt, ans int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	arr := make(SortBy, N)

	for i := 0; i < N; i++ {
		a, _ := strconv.Atoi(read())
		b, _ := strconv.Atoi(read())
		arr[i] = []int{a, b}
	}
	sort.Sort(arr)
	var j int
	pq := &PriorityQueue{}
	heap.Init(pq)
	for i := M - 1; 0 <= i; i-- {

		for j < len(arr) {
			if arr[j][0]+i <= M {
				heap.Push(pq, arr[j][1])
				j++
			} else {
				break
			}
		}
		if pq.Len() != 0 {
			ans += heap.Pop(pq).(int)
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i][0] == a[j][0] {
		return a[i][1] > a[j][1]
	}
	return a[i][0] < a[j][0]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll fac[2000005];
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
void pre(){fac[0]=1;fac[1]=1;for(int i=2;i<2000005;i++)fac[i]=(i*fac[i-1])%mod;}
signed main()
{   

      senky_bansal
      IIIT_ALLAHABAD
      
      ll t;
     // cin>>t;
      t=1;
      while(t--)
      {
          ll n;
          cin>>n;
          ll can =1;
          ll can2=2;
          for(int i=1;i<=n;i++)
          can*=i;
          for(int i=1;i<n;i++)
          can2*=i;
          ll x[n],y[n];
          for(int i=0;i<n;i++)
          {
              cin>>x[i]>>y[i];
          }
          double ans =0;
          for(int i=0;i<n;i++)
          {
              for(int j=i+1;j<n;j++)
              {
                  double ans1=0;
                  ll ans2 = abs(x[i]-x[j])*abs(x[i]-x[j]);
                  ans2+=abs(y[i]-y[j])*abs(y[i]-y[j]);
                  ans1+=sqrt((double)(ans2*1.0));
                  ans+=ans1;
              }
          }
          ans=ans*((double)(can2*1.0));
          double final = (double)ans/(double)(can*1.0);
          cout<<setprecision(10)<<fixed<<final<<endl;
          
          
          
      }
 

}


















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

int main() {
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dirx = x2 - x1;
	int diry = y2 - y1;
	int x3 = x2 - diry;
	int y3 = y2 + dirx;
	int x4 = x3 - dirx;
	int y4 = y3 - diry;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    char buf[21];
    int length=0;
    
    cin>>buf;
    for(int i=0; buf[i]!='\0'; i++) length++;
    for(int i=length-1; i>=0; i--) cout<<buf[i];
    cout<<endl;
    
    return 0;
}



Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;;
int main(){
  int N,K,L=0,G=1;
  cin >> N >> K;
  vector<int>S(N);
  for(int i=0;i<N;i++) cin >> S[i];
  for(int i=0;i<N;i++){
    L=L+S[i];
    if(L<=K)G++;
  }
  cout << G << endl;
}

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

 int main(){
  int X, A, B;

  cin >> X >> A >> B;

  if (A-B >= 0) cout << "delicious" << endl;

  else if (A-B < 0 && A-B >= -X) cout << "safe" << endl;

  else if (A-B < -X) cout << "dangerous" << endl;

 return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    vector<vector<ll>> a(n+10,vector<ll>(2,0));
    rep(j,2){
      rep(i,n){
        cin >> a[i][j];
      }
    }
    vector<vector<ll>> dp(n+10,vector<ll>(2,inf));
    dp[0][0] = dp[0][1] = 0;
    rep(i,2){
      if(a[0][i] == 1){
        ll l = 0;
        while(a[l][i] == 1 && l < n){
          ++l;
        }
        --l;
        dp[l][i] = 0;
      }
    }
    rep(x,n){
      rep(j,n){
        rep(i,2){
          if(a[j][i] == 0 || a[j][i] == 1){
            rep(k,3){
              if(a[j+k][!i] == 0){
                dp[j+k][!i] = min(dp[j+k][!i],dp[j][i]+1);
              }
              else if(a[j+k][!i] == 1){
                ll l = j+k;
                while(a[l][!i] == 1 && l < n){
                  ++l;
                }
                --l;
                dp[l][!i] = min(dp[l][!i],dp[j][i]+1);
              }
              else{
                ll l = j+k;
                while(a[l][!i] == 2){
                  --l;
                }
                ++l;
                dp[l][!i] = min(dp[l][!i],dp[j][i]+1);
              }
            }
          }
        }
      }
    }
    if(dp[n][0] == dp[n][1] && dp[n][1] == inf){
      cout << "NA" << endl;
    }
    else{
      ll ans = inf;
      REP(i,n-1,n+5){
        ans = min(ans,min(dp[i][0],dp[i][1]));
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3132
#include <iostream>

int ceil(double x)
{
    if (x == double((int)x)) {
        return (int)x;
    } else {
        return (int)x + 1;
    }
}

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

    int al = ceil(12.5 * A), ar = int(12.5 * (A + 1)) - 1;
    int bl = 10 * B, br = bl + 9;

    if (al > ar || bl > br) {
        std::cout << -1;
        return 0;
    }

    if (ar < bl || br < al) {
        std::cout << -1;
        return 0;
    }

    if (al <= bl && bl <= ar) {
        std::cout << bl;
        return 0;
    }

    if (bl <= al && al <= br) {
        std::cout << al;
        return 0;
    }

    std::cout << -1;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    ll max(ll a,ll b) {return a<b?b:a;}
    ll cmp(const ll &x,const ll &y) {return x>y;}
    ll a[4][110];
    int main()
    {
    	int n;
    	ll W,w1,w,x,ans=0;
    	scanf("%d%lld",&n,&W);
    	scanf("%lld%lld",&w1,&x);
    	a[0][1]=x;a[0][0]=1;
    	for(int i=1;i<n;i++)
    	{
    		scanf("%lld%lld",&w,&x);
    		int p=w-w1;
    		a[p][++a[p][0]]=x;
    	}
    	for(int i=0;i<4;i++) sort(a[i]+1,a[i]+a[i][0]+1,cmp);
    	for(int i=0;i<=a[0][0];i++)
    	for(int j=0;j<=a[1][0];j++)
    	for(int k=0;k<=a[2][0];k++)
    	{
    		ll res=(i+j+k)*w1+j+2*k;
    		res=W-res;if(res<0) continue;
    		res/=(w1+3);if(res>a[3][0]) res=a[3][0];
    		ll s=0;
    		for(int ii=1;ii<=i;ii++) s+=a[0][ii];
    		for(int ii=1;ii<=j;ii++) s+=a[1][ii];
    		for(int ii=1;ii<=k;ii++) s+=a[2][ii];
    		for(int ii=1;ii<=res;ii++) s+=a[3][ii];
    		ans=max(ans,s);
    	}
    	printf("%lld\n",ans);
    	return 0;
    }

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int nums[] = new int[10];
		for(byte i = 0; i < 10; i++) 
			nums[i] = in.nextInt();
		Arrays.sort(nums);	
		System.out.println(nums[9]);
		System.out.println(nums[8]);
		System.out.println(nums[7]);
		in.close();
	}
}

Measured memory_bytes: 26120
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {

        Console.WriteLine(string.Join("", Console.ReadLine().Select(x => 'x')));
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>

using namespace std;


int main() {
        int n, x, cnt = 0;
        cin >> n >> x;
        for (int i = 0; i < n; i++) {
                int y;
                cin >> y;
                if (y >= x) cnt++;
        }
        cout << cnt << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
template<typename T>bool chmin(T&a,T b){return a>b?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return a<b?(a=b,1):0;}
int read(){int a;scanf("%lld",&a);return a;}

const long double pi = acos(-1);
constexpr int inf = 3*TEN(18) + 10;

const int mod = TEN(9)+7;

int N, M;
pii rng[100010];
vector<pii> in[100010], out[100010];
int d[100010];

signed main()
{
	cin >> N >> M;
	rep(i, M) {
		int l, r, c; cin >> l >> r >> c;
		--l, --r;
		rng[i] = pii(l, r);
		in[l].emplace_back(c, i);
		out[r].emplace_back(c, i);
	}

	rep(i, N) d[i] = inf;
	d[0] = 0;

	set<pii> V;

	rep(i, N) {
		if (V.size())
			d[i] = V.begin()->first;

		for (pii p : out[i]) {
			int id = p.scd;
			int v = d[rng[id].first] + p.fst;
			V.erase(pii(v, id));
		}

		for (pii p : in[i]) {
			int c = p.fst, id = p.scd;
			int v = d[rng[id].first] + c;
			V.insert(pii(v, id));
		}
	}

	if (d[N - 1] >= inf) {
		puts("-1");
	} else {
		printf("%lld\n", d[N - 1]);
	}
}




Measured memory_bytes: 19584
#include<bits/stdc++.h>
#define ll long long
#define N 1001000
#define MN 1000000
#define M 998244353
using namespace std;

ll n,m,ans,jc[N],nj[N];

inline ll C(ll u,ll v){return jc[u]*nj[v]%M*nj[u-v]%M;}
inline ll po(ll u,ll v)
{
    ll res=1;
    for(;v;)
    {
	if(v&1) res=res*u%M;
	u=u*u%M;
	v>>=1;
    }
    return res;
}

int main()
{
    ll i,j;
    jc[0]=1;for(i=1;i<=MN;i++) jc[i]=jc[i-1]*i%M;
    nj[MN]=po(jc[MN],M-2);for(i=MN-1;i>=0;i--) nj[i]=nj[i+1]*(i+1)%M;
    cin>>m>>n;
    if(m>n) swap(m,n);
    ans=C(m+n,m)*m%M;
    for(i=1;i<=m;i++)
    {
	ans-=C(2*i-1,i)*C(m+n-2*i,n-i)%M;
	ans%=M;
    }
    ans=(ans+M)%M;
    cout<<(m+n-ans*po(C(m+n,m),M-2)%M+M)%M;
}


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

using namespace std;

#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 VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

using namespace std;




int main() {
	
	ll n, a, b;
	cin >> n >> a >> b;
	VLL h(n);
	REP(i, n)cin >> h[i];
	ll l = 1;
	ll r = 1000000000;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		ll c = m;
		VLL v = h;
		REP(i, n) {
			v[i] -= b * m;
			if (v[i] > 0) {
				c -= (v[i] + a - b - 1) / (a - b);
			}
		}
		if (c>=0)r = m;
		else l = m;
	}
	int ans = INF;
	for (int i = l; i <= r; i++) {
		ll c = i;
		VLL v = h;
		REP(j, n) {
			v[j] -= b * i;
			if (v[j] > 0) {
				c -= (v[j] + a - b - 1) / (a - b);
			}
		}
		if (c >= 0)ans = min(ans, i);
	}
	cout << ans << endl;
	return 0;
}

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

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

	string s; cin>>s;
	int n = s.length();

	long long ans = 0;
	int cur = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '>') {
			int j = i;
			while (j < n && s[j] == '>') j++;
			if (j-i < cur)
				ans += cur - (j-i);
			ans += 1LL*(j-i)*(j-i+1)/2;
			cur = 0;
			i = j-1;
		} else {
			ans += cur++;
		}
	}
	if (cur) ans += cur;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int res = 0;
    V<int> cnt(n + 1);
    for (int x = 1; x * x <= n; x++) {
        for (int y = 1; y * y <= n; y++) {
            for (int z = 1; z * z <= n; z++) {
                int s = x * x + y * y + z * z + x * y + y * z + z * x;
                if (s <= n) {
                    cnt[s]++;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << newl;
    }
}

Measured memory_bytes: 3660
#include <stdio.h>

int main(void){
    int i,cnt,K;
    char S[100];

    scanf("%d",&K);
    scanf("%s",S);
    for(cnt=0;S[cnt] != '\0';cnt++){}

    if(cnt<=K){
        printf("%s\n",S);
    }else{
        for(i=0;i<K;i++){
            printf("%c",S[i]);
        }
        printf("...\n");
    }
    return 0;
}

Measured memory_bytes: 1628
using System;

class Hello{

    public static void Main(){
    
        var N = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');
        int[] P = new int[N];
        
        for(int i = 0;i < N;i++){
            P[i] = int.Parse(input[i]);
        }
        
        int min = P[0];
        int c = 0;
        
        for(int i = 0;i < N;i++){
            if(min >= P[i]){
                c++;
                min = P[i];
            }
        }
        
        Console.WriteLine(c);
    }

}

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

int main(){

    int n;
    int cnt=0;
    int light=1;
    int flug=0;
    //vector<int> a(10000);

    cin>>n;
    vector<int> a(n);

    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }

    for(int i=0;i<n;i++){
        
        light=a.at(light-1);
        cnt++;
        if(light==2){
            flug=1;
            break;
        }

    }

    if(flug==1) cout<<cnt<<endl;
    else cout<<-1<<endl;


    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var p = 0.0;
            for (var i = 0; i < nk[0]; i++)
            {
                var score = i + 1;
                var tmpP = 1.0 / nk[0];
                while (score < nk[1])
                {
                    score *= 2;
                    tmpP /= 2;
                }
                p += tmpP;
            }
            Console.WriteLine(p);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

int F(int a,int b) {
    return max(SZ(to_string(a)),SZ(to_string(b)));
}
signed main() {
    int N;
    cin>>N;
    int ans=INF;
    for(int i=1;i*i<=N;i++) {
        if(N%i==0) {
            chmin(ans,F(i,N/i));
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

    vector<double> dp(n+1, 0);

    // dp[i] is probab that there are i heads so far

    dp[0]=1;

    for(int coins=0; coins<n; ++coins)
    {
        double p;
        cin>>p;
        for(int i=coins+1; i>=0; i--)
        {
            dp[i] = dp[i-1]*p + dp[i]*(1-p);
        }
        // dp[0] *= (1-p);
    }
    double ans=0;
    for(int i=n/2+1; i<=n; i++) ans+=dp[i];
    
    printf("%0.10lf\n", ans);

    return 0;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	vector<int>data(1000001);
	int s;
	cin >> s;
	map<int, int>mp;
	data[1] = s;
	mp[data[1]]++;
	for (int i = 2; i <= 1000000; i++) {
		if (data[i - 1] % 2 == 0) {
			data[i] = data[i - 1] / 2;
		}
		else {
			data[i] = 3 * data[i - 1] + 1;
		}
		mp[data[i]]++;
		if (mp[data[i]] == 2) {
			cout << i << endl;
			return 0;
		}
	}
}


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

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}


Measured memory_bytes: 3640
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
  //  FI(); /// skip this line for compile
    int n,x,k,p;
    string s;
    cin >> n >> x >> k;
    p = n/x;
    if(n%x!=0) p++;
    cout << p*k << endl;

    return 0;
    //code end
}
//okbye


Measured memory_bytes: 3648
#include <iostream>
#include <vector>

using namespace std;

int main(){
    
    vector<int> A(5);
    
    for(int i = 0; i < 5; i++){
        cin >> A[i];
    }
    int k;
    cin >> k;

    if (A[4] - A[0] <= k) {
        cout << "Yay!" << endl;
    }else
    {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef pair<lint, pii> plp;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 998244353;
const lint INF = mod*mod;
const int MAX = 2e6;

lint powmod(lint x, lint n){
    lint ret = 1;
    while(n > 0){
        if(n&1) ret *= x, ret %= mod, n -= 1;
        else x *= x, x %= mod, n >>= 1;
    }
    return ret;
}

vector<lint> fact;
vector<lint> revfact;

void setfact(int n){
    fact.resize(n+1); revfact.resize(n+1);
    fact[0] = 1;
    rep(i, n) fact[i+1] = fact[i] * (i+1) % mod;

    revfact[n] = powmod(fact[n], mod-2);
    for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * (i+1) % mod;
}

lint getC(int n, int r){
    if(n<r) return 0;
    return fact[n] * revfact[r] % mod * revfact[n-r] % mod;
}

lint part(int n, int K){
    return getC(n+K-1, K-1);
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    setfact(MAX);
    lint ans=0;
    rep(i, min(m+1, n+1))if((3*m-i)%2==0){
        ans+=getC(n, i)*part((3*m-i)/2, n)%mod;
        ans%=mod;
    }
    rep(i, min(m+1, n+1))if((m-i)%2==0){
        lint tmp=getC(n-1, i)*part((m-i)/2, n-1)%mod;
        tmp=(tmp-getC(n, i)*part((m-i)/2, n)%mod+mod)%mod;
        (tmp*=(lint)n)%=mod;
        (ans+=tmp)%=mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string s;
	ll k;
	cin >> s >> k;
	vector<string> a;
	REP(i, s.length()) FOR(j, 1, min(6, int(s.length()-i+1))) a.push_back(s.substr(i, j));
	sort(ALL(a));
	REP(i, a.size()) if (i == 0 || a[i] != a[i-1]) {
		--k;
		if (k == 0) {
			cout << a[i] << endl;
			break;
		}
	}
	return 0;
}
 

Measured memory_bytes: 1660
solve1 [-1,_,_] = "F"
solve1 [_,-1,_] = "F"
solve1 [m,f,r]
  | 80 <= c = "A"
  | 65 <= c = "B"
  | 50 <= c = "C"
  | 30 <= c = if 50 <= r then "C" else "D"
  | otherwise = "F"
  where
    c  = m + f


main = do
  seiseki' <- getContents
  let seiseki = map (map read . words) . init $ lines seiseki'
  mapM_ putStrLn $ map solve1 seiseki


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

int main(void){

	while (true){
		int n, count=0;
		cin>>n;
		if (cin.eof()) break;	
		for (int i1=0; i1<10; i1++){
			int n1 = n-i1;
			if (n1 < 0 || n1 > 27) continue;
			for (int i2=0; i2<10; i2++){
				int n2 = n1 - i2;
				if (n2 < 0 || n2 > 18) continue;
				for (int i3=0; i3<10; i3++){
					int n3 = n2 - i3;
					if (n3<0 || n3>9) continue;
					count++;
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
} 

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

using namespace std;

int main() {
  string S;
  
  cin >> S;
  
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<P> graph[500005];
set<P> used;
map<P, int> mp;
map<int, P> mpr;
vector<int> len;

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

  int n, m; cin >> n >> m;
  int num = n+1;
  rep(i, m) {
    int p, q, c; cin >> p >> q >> c;
    P pc = P(p,c);
    int pp, qq;
    if (used.find(pc) == used.end()) {
      used.emplace(pc);
      mp[pc] = num;
      num++;
    }
    pp = mp[pc];
    
    P qc = P(q,c);
    if (used.find(qc) == used.end()) {
      used.emplace(qc);
      mp[qc] = num;
      num++;
    }
    qq = mp[qc];
    
    //debug(p); debug(q); debug(c); debug(pp); debugln(qq);
    graph[pp].emplace_back(qq, 0);
    graph[qq].emplace_back(pp, 0);
    graph[p].emplace_back(pp, 1);
    graph[pp].emplace_back(p, 0);
    graph[q].emplace_back(qq, 1);
    graph[qq].emplace_back(q, 0);
  }

  len.resize(num+1, INT_MAX/2);

  priority_queue<P, vector<P>, greater<>> que;
  que.emplace(0, 1);
  len[1] = 0;
  while(!que.empty()) {
    P p = que.top(); que.pop();
    int u = p.second;
    int l = p.first;
    if (len[u] < l) continue;
    for(auto e: graph[u]) {
      int v = e.first;
      int newlen = l + e.second;
      if (newlen < len[v]) {
        len[v] = newlen;
        que.emplace(newlen, v);
      }
    }
  }

  if (len[n] == INT_MAX/2) {
    cout << -1 << endl;
  } else {
    cout << len[n] << endl;
  }
}

Measured memory_bytes: 98288
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int A[114];

int main() {
  scanf("%d", &N);

  int arg = 1;
  reps(i, 1, N+1) {
    scanf("%d", &A[i]);
    if (abs(A[i]) > abs(A[arg])) arg = i;
  }

  if (A[arg] == 0) {
    puts("0");
    return 0;
  }

  vector<pii> ans;
  reps(i, 1, N+1) {
    if (arg == i) continue;
    ans.eb(pii(arg, i));
    A[i] += A[arg];
  }

  bool neg = false;
  if (A[arg] < 0) {
    neg = true;
  }

  if (!neg) {
    reps(i, 2, N+1) {
      ans.eb(pii(i-1, i));
    }
  } else {
    rreps(i, 1, N) {
      ans.eb(pii(i+1, i));
    }
  }

  printf("%d\n", (int)ans.size());
  for (auto p : ans) {
    printf("%d %d\n", p.first, p.second);
  }
}


Measured memory_bytes: 256
x, n = gets.split.map(&:to_i)
if n != 0
  pp = gets.split.map(&:to_i)
end
xx = x

if n == 0
  puts x
elsif pp.include?(x) == false
  puts x
else
  while true
    xx += 1
    x -= 1
    if pp.include?(x)
      if pp.include?(xx)
      else
        puts xx
        break
      end
    else
      puts x
      break
    end
  end
end

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, Z, W, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> Z >> W;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    if(N==1) cout << abs(A.back()-W) << endl;
    else cout << max(abs(A.back()-W), abs(A.back()-A[A.size()-2])) << endl;
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int res = 1;
    while (res < k && n)
    {
        res *= 2;
        n--;
    }
    while (n--)
    {
        res += k;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256