akhauriyash/Code-Regression huggingface dataset:
use std::collections::*;
use std::*;
// template {{{
macro_rules ! get {($ ($ t : tt ) ,*; $ n : expr ) => {{let stdin = std :: io :: stdin () ; let ret = std :: io :: BufRead :: lines (stdin . lock () ) . take ($ n ) . map (| line | {let line = line . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } ) . collect ::< Vec < _ >> () ; ret } } ; ($ ($ t : tt ) ,* ) => {{let mut line = String :: new () ; std :: io :: stdin () . read_line (& mut line ) . unwrap () ; let mut it = line . split_whitespace () ; _get ! (it ; $ ($ t ) ,* ) } } ; }
macro_rules ! _get {($ it : ident ; [char ] ) => {_get ! ($ it ; String ) . chars () . collect ::< Vec < _ >> () } ; ($ it : ident ; [u8 ] ) => {_get ! ($ it ; String ) . bytes () . collect ::< Vec < _ >> () } ; ($ it : ident ; usize1 ) => {$ it . next () . unwrap () . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 } ; ($ it : ident ; [usize1 ] ) => {$ it . map (| s | s . parse ::< usize > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) - 1 ) . collect ::< Vec < _ >> () } ; ($ it : ident ; [$ t : ty ] ) => {$ it . map (| s | s . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) ) . collect ::< Vec < _ >> () } ; ($ it : ident ; $ t : ty ) => {$ it . next () . unwrap () . parse ::<$ t > () . unwrap_or_else (| e | panic ! ("{}" , e ) ) } ; ($ it : ident ; $ ($ t : tt ) ,+ ) => {($ (_get ! ($ it ; $ t ) ) ,* ) } ; }
// }}}

fn log2(n: i64) -> (usize, i64) {
    let mut ret = 0;
    let mut now: i64 = 1;
    while now <= n {
        ret += 1;
        now *= 2;
    }
    (ret, now)
}
fn main() {
    let (n, x, m) = get!(i64, usize, usize);
    let log = log2(n).0;
    let mut next = vec![vec![0; log + 1]; m];
    let mut sum = vec![vec![0; log + 1]; m];
    for i in 0..m {
        next[i][0] = i * i % m;
    }
    for i in 1..=log {
        for j in 0..m {
            next[j][i] = next[next[j][i - 1]][i - 1];
        }
    }
    for i in 0..m {
        sum[i][0] = i;
    }
    for i in 1..=log {
        for j in 0..m {
            sum[j][i] = sum[j][i - 1] + sum[next[j][i - 1]][i - 1];
        }
    }
    let mut ans = 0;
    let mut left = n;
    let mut now = x;
    while left > 0 {
        let (lev, val) = log2(left);
        let lev = lev - 1;
        let val = val / 2;
        ans += sum[now][lev];
        now = next[now][lev];
        left -= val;
    }
    println!("{}", ans);
}


Measured memory_bytes: 62904
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>



using namespace std;

int min(int a,int b){
    if(a<=b){
        return a;
    }
    return b;
}

int main() {
    int ans=0;
    string s;
    cin>>s;
    int a;
    a=s.size();
    for(int i=0;i<a;i++){
        string b;
        b=s[i];
        int num=stoi(b);
        if(num==i%2){
            ans++;
        }
    }
    ans=min(ans,a-ans);
    cout<<ans<<endl;
    return 0;
}



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

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

  int n,q; cin >> n >> q;
  string s; cin >> s;
  vector<int> dp(n+1,0);
  for(int i = 1; i < n; i++){
    if(s[i-1] == 'A' && s[i] == 'C'){
      dp[i] = dp[i-1] + 1;
    }
    else {
      dp[i] = dp[i-1];
    }
  }

  for(int i = 0; i < q; i++){
    int l,r; cin >> l >> r;
    cout << dp[r-1] - dp[l-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 1872
N = int(input())

s = ''.join(sorted(input()))
h = {s: 1}
count = 0
for i in range(N - 1):
    # 比較がしやすいようにソートしたものを追加
    s = ''.join(sorted(input()))
    if s in h:
        count += h[s]
        h[s] += 1
    else:
        h[s] = 1

print(count)


Measured memory_bytes: 17852
s = input()
q = int(input())
hanten=False
mae=""
usiro=""
for i in range(q):
    tmp=input()
    if len(tmp)==1:
        hanten=not(hanten)
    else:
        if hanten==False:
            if tmp[2]=="1":
                mae=tmp[4]+mae
            else:
                usiro=usiro+tmp[4]
        else:
            if tmp[2]=="1":
                usiro=usiro+tmp[4]
            else:
                mae=tmp[4]+mae
                
ans=mae+s+usiro
if hanten==False:
    print(ans)
else:
    print(ans[::-1])

Measured memory_bytes: 10232
/*input
60 3
5 8
1 3
10 15
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>
#include <random>

using namespace std; 

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 998244353;

struct seg {
	int l, r;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int dp[n+1], pre[n+1];
	dp[0]=0;pre[0]=0;
	dp[1]=1;pre[1]=1;
	vector<seg> e;
	rep(i, k) {
		seg cur;
		cin >> cur.l >> cur.r;
		e.push_back(cur);
	}
	repl(i, 2, n+1) {
		dp[i]=0;
		for(seg rng: e) {
			if(0<=i-rng.l) dp[i]=(dp[i]+pre[i-rng.l])%MOD;
			if(0<=i-rng.r-1) dp[i]=(dp[i]-pre[i-rng.r-1]+MOD)%MOD;
		}
		pre[i]=(pre[i-1]+dp[i])%MOD;
	}
	cout << dp[n];
	return 0;	
}

Measured memory_bytes: 5176
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
int N,Q;
vector<pair<char,char > > v;
vector <char> t,d;
vector <char> Sir;
string s;
//bool Golems[20010];
map <char,int> Letters;
int cntGolems;
int verificare(int mijloc,int directie)
{
    int i;
    for(i=0;i<=Q-1;i++)
    {
        if(s[mijloc]==t[i])
        {
            if(d[i]=='R')
            {
                mijloc++;
            }
            else
            {
                mijloc--;
            }
        }
        if(directie==1)
        {
            if(mijloc>=N)
            {
                return false;
            }
            if(mijloc<0)
            {
                return true;
            }
        }
        else//directie==2
        {
            if(mijloc<0)
            {
                return false;
            }
            if(mijloc>=N)
            {
                return true;
            }
        }

    }
    return false;
}
int cautare(int st,int dr,int directie)//1 pentru STANGA, 2 pentru DREAPTA
{
    int mijloc,sol_st,sol_dr;
    sol_st=-1;
    sol_dr=N;
    while(st<=dr)
    {
        mijloc=st+(dr-st)/2;
        if(directie==1)//directie==1
        {
            if(verificare(mijloc,directie)==true)
            {
                sol_st=mijloc;
                st=mijloc+1;
            }
            else
            {
                dr=mijloc-1;
            }
        }
        else//directie==2
        {
            if(verificare(mijloc,directie)==true)
            {
                sol_dr=mijloc;
                dr=mijloc-1;
            }
            else
            {
                st=mijloc+1;
            }
        }
    }
    if(directie==2)
        return sol_dr;
    else//directie==1
        return sol_st;
}
int main()
{
    cin>>N>>Q;
    //Sir.push_back('#')
    cin>>s;
    //cout<<s<<"\n";
    cin.get();
    //s.push_back('#');
    int i;
//    for(i=0;i<s.size();i++)
//    {
//        Sir.push_back(s[i]);
//        Letters[s[i]]=i;
//    }
 //   Sir.push_back('#');
    cntGolems=N;
    for(i=1;i<=Q;i++)
    {
        char x,y;
        cin>>x>>y;
        cin.get();
        //cout<<x<<" "<<y<<"\n";
        t.push_back(x);
        d.push_back(y);
    }
    int rez=0,st2,dr1;
    dr1=cautare(0,N-1,1);
    st2=cautare(0,N-1,2);
    if(st2-dr1+1>rez)
    {
        rez=st2-dr1-1;
    }
    cout<<rez;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string S;
    int Q;
    cin >> S >> Q;
    deque<char> l, r;
    bool flag = true;
    int T, F;
    char C;
    for (int i = 0; i < Q; i++) {
        cin >> T;
        if (T == 1) flag = !flag;
        else {
            cin >> F >> C;
            if (F == 1) {
                if (flag) l.push_front(C);
                else r.push_back(C);
            } else {
                if (flag) r.push_back(C);
                else l.push_front(C);
            }
        }
    }
    if (flag) {
        for (char c : l) cout << c;
        cout << S;
        for (char c : r) cout << c;
        cout << "\n";
    } else {
        while (!r.empty()) {
            cout << r.back();
            r.pop_back();
        }
        reverse(S.begin(), S.end());
        cout << S;
        while (!l.empty()) {
            cout << l.back();
            l.pop_back();
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 896
<?php
$input = file_get_contents('php://stdin');
$inarr = explode("\n", $input);
 
$card = array_map(function ($e) {
  return explode(" ", $e);
}, array_splice($inarr, 0, 3));
 
$n = intval($inarr[0]);
$bList = array_splice($inarr, 1, $n);
 
foreach($bList as $b){
    #該当数字判定
    foreach($card as &$aList){
        $check = array_search($b, $aList);
        if($check!==false){
            $aList[$check]="0";
        }
      	unset($aList);
    }
    #ビンゴ判定
    #横
    foreach($card as $aList){
        if($aList[0]==$aList[1] and $aList[0]==$aList[2]){
            echo "Yes";
            exit();
        }
    }
    #縦
    for($i=0; $i<3; $i++){
        if($card[0][$i]==$card[1][$i] and $card[0][$i]==$card[2][$i]){
            echo "Yes";
            exit();
        }
    }
    #斜め
    if($card[0][0]==$card[1][1] and $card[0][0]==$card[2][2]){
        echo "Yes";
        exit();
    }
    if($card[0][2]==$card[1][1] and $card[0][2]==$card[2][0]){
        echo "Yes";
        exit();
    }
}
echo "No";
 
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 101010;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int mx = INF;
    vector<int> is_prime(mx,1);
    is_prime[0] = 0,is_prime[1] = 0;
    for(int i = 0;i < mx;i++){
        if(!is_prime[i]) continue;
        for(int j = i*2;j <mx;j+=i) is_prime[j] = 0;
    }

    vector<int> a(mx);
    rep(i,mx){
        if(i % 2 == 0) continue;
        if(is_prime[i] && is_prime[ (i+1) / 2 ] ) a[i] = 1;
    }

    vector<int> s(mx+1);
    rep(i,mx) s[i+1] = a[i] + s[i];

    int Q; cin >> Q;
    rep(i,Q){
        int l,r;
        cin >>l>>r;
        ++r;
        cout << s[r] - s[l] <<endl;
    }
    
}



Measured memory_bytes: 1792
#include <cstdio>
using namespace std;

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a == b){
		printf("%d\n", c);
	}else{
		if(a == c){
			printf("%d\n", b);
		}else{
			printf("%d\n", a);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
  while(x->left != NIL)   
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key)
    {
      if(k < u->key) u = u->left;
      else u = u->right;
    }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  
  if(y->left != NIL)
    {
      x = y->left;
    }else{
    x = y->right;
  }
  
  if(x != NIL) x->parent = y->parent;
  
  if(y->parent == NIL)
    {
      root = x;
    }else{
    if(y == y->parent->left)
      {
	y->parent->left = x;
      }else{
      y->parent->right = x;
    }
  
    if(y != z)
      {
	z->key = y->key;
      }
    free(y);
  }
}

  void insert(int k)
  {
    Node y = NIL;
    Node x = root;
    Node z;
    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL){
      y = x;
      if(z->key < x->key){
	x = x->left;
      }else{
	x = x->right;
      }
      z->parent = y;
    }
    if(y == NIL)
      {
	root = z;
      }
    else if(z->key < y->key)
      {
	y->left = z;
      }
    else
      {
	y->right = z;
      }
  }

  void inorder(Node u)
  {
    if(u == NIL)
      {
	return;
      }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
  void preorder(Node u)
  {
    if(u == NIL)
      {
	return;
      }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }


  int main()
  {
    int n, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ )
      {
	scanf("%s", com);
	if ( com[0] == 'f' )
	  {
	    scanf("%d", &x);
	    Node t = treeSearch(root, x);
	    if ( t != NIL ) printf("yes\n");
	    else printf("no\n");
	  }
	else if ( com[0] == 'i' )
	  {
	    scanf("%d", &x);
	    insert(x);
	  }
	else if ( com[0] == 'p' )
	  {
	    inorder(root);
	    printf("\n");
	    preorder(root);
	    printf("\n");
	  }
	else if ( com[0] == 'd' )
	  {
	    scanf("%d", &x);
	    treeDelete(treeSearch(root, x));
	  }
      }
    return 0;
  }
  



Measured memory_bytes: 20532
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

void display(int a[], int n) {
  rep(k, 0, n) {
    if (k > 0)
      cout << " ";
    cout << a[k];
  }
  cout << endl;
}

void insertionSort(int a[], int n) {
  rep(i, 1, n) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    display(a, n);
  }
}

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

  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) cin >> a[i];
  display(a, n);
  insertionSort(a, n);
}



Measured memory_bytes: 3168
import java.util.*;

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[] b = new int[n];
        int[] c = new int[n-1];
        for (int i=0;i<n;i++)a[i]=sc.nextInt();
        for (int i=0;i<n;i++)b[i]=sc.nextInt();
        for (int i=0;i<n-1;i++)c[i]=sc.nextInt();
        int ans = 0;
        for (int i=0;i<n;i++){
            ans+=b[a[i]-1];
            if (i!=n-1&&a[i+1]==a[i]+1)ans+=c[a[i]-1];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35752
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int X,A,B;
    cin>>X>>A>>B;
    if(B-A<=0) cout<<"delicious"<<endl;
    else if(B-A<=X) cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
const int MAX_N = 13;
const char* const LANK = "SHCD";

int main() {
  // int n, a[MAX_N];
  // char b[MAX_N];

  int n, a, inx;
  char b;

  bool cards[4][MAX_N];
  // int cards[4][MAX_N] = {0};
  for (int i = 0; i < 4; ++i)
    {
      for (int j = 0; j < MAX_N; ++j)
        {
          cards[i][j] = true;
        }
    }

  cin >> n;
  for (int i = 0; i < n; ++i)
    {
      // cin >> b[i] >>a[i];
      cin >> b >>a;
      if (b=='S') inx = 0;
      else if (b=='H') inx =1;
      else if (b=='C') inx =2;
      else if (b=='D') inx =3;
      cards[inx][a-1] = false;
      // cards[inx][a-1] = 1;
    }

  for (int i = 0; i < 4; ++i)
    {
      for (int j = 0; j < MAX_N; ++j)
        {
          if(cards[i][j]==true)
            cout << LANK[i] << " " << j+1 << endl;
        }
    }

  // cout << LANK[0]  <<endl;
}

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

int main(void){
  int N;
  cin >> N;
  vector<int> vec(N);
  int a=0,b=0;
  
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for(int i=0; i<N; i++){
    if(i%2==0){ // Alice
      a+=vec.at(i);
    }
    else{ // Bob
      b+=vec.at(i);
    }
  }
  cout << a-b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
#define ll long long
const int mod = 998244353;
const int maxn = 2e5+111;
ll N, M, K, fact[maxn], inv[maxn], ans=0;

ll qpow(ll a, ll b){
    ll res=1;
    while (b){
        if (b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}

ll C(ll a, ll b){
    return fact[a]*inv[b]%mod*inv[a-b]%mod;
}

int main(){
    cin>>N>>M>>K;
    fact[0]=1;
    for (int i=1; i<=N; i++) fact[i]=fact[i-1]*i%mod;
    inv[N]=qpow(fact[N], mod-2);
    for (int i=N-1; i>=0; i--) inv[i]=inv[i+1]*(i+1)%mod;
    ll p=qpow(M-1, N-K-1);
    for (int i=N-K; i<=N; i++){
        ans=(ans+M*p%mod*C(N-1, i-1)%mod)%mod;
        p=p*(M-1)%mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6756
N = int(input())
AB = []
for i in range(N):
  a, b = map(int, input().split())
  AB += [[a,b]]
  
AB.sort(key=lambda x: x[1])
time_used = 0
over_flag = 0
for i in range(N):
  a, b = AB[i]
  time_used += a
  if time_used > b:
    over_flag = 1
    
if over_flag:
  print("No")
else:
  print("Yes")

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

typedef long long ll;

int N, M, K;
ll mod = 1000000007;
ll F[200010] = {1}, R[200010];

ll pow_mod(ll a, ll b)
{
    if(b == 0)return 1;
    ll ret = pow_mod(a * a % mod, b / 2);
    if(b % 2)ret = ret * a % mod;
    return ret;
}

ll con(int a, int b)
{
    return F[a] * R[b] % mod * R[a - b] % mod;
}

ll unit(int n, int m, int k)
{
    ll ret = 0;
    for(int i = 1; i < n; i++)
    {
        ret += m * m % mod * (n - i) % mod * con(n * m - 2, k - 2) % mod * i % mod;
        ret %= mod;
    }

    return ret;
}

int main()
{
    cin >> N >> M >> K;

    for(int i = 1; i < 200010; i++)F[i] = F[i - 1] * i % mod;
    for(int i = 0; i < 200010; i++)R[i] = pow_mod(F[i], mod - 2);

    ll ans = (unit(N, M, K) + unit(M, N, K)) % mod;

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


Measured memory_bytes: 3328
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

void solve() {
  int A, B;
  cin >> A >> B;

  cout << ceil((B - 1) / (double)(A - 1)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
//const ll MOD=100000;
const ll MAX=500000;
const ll INF=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=finv[1]=finv[0]=inv[0]=inv[1]=1;
    rep(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=modpow(i,MOD-2);
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r]%MOD;
}
signed main(){
    ll N; cin>>N;
    vi A(N);
    rep(i,0,N) cin>>A[i];
    std::map<ll,ll> map;
    ll ans=0;
    rep(i,0,N){
        ll X=A[i]+N-i;
        ans+=map[X];
        map[N-i-A[i]]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 27384
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;
 
int prim(vector<vector<pair<int, int> > >& G) {
	int cost = 0;
	const int N = G.size();
	vector<bool> used(G.size());
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
	pq.push(make_pair(0, 0));
	while (!pq.empty()) {
		pair<int, int> p = pq.top(); pq.pop();
		int now = p.second;
		if (used[now]) continue;
		used[now] = true;
		cost += p.first;
		for (auto e : G[now])
			pq.push(make_pair(e.second, e.first));
	}
	return cost;
}

int main() {
	int n; cin >> n;
	vector<vector<pair<int, int> > > G(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int a; cin >> a;
			if (a != -1) G[i].push_back(make_pair(j, a));
		}
	}
	cout << prim(G) << endl;

	return 0;
}


Measured memory_bytes: 3112
/*
 * FileName:     bit_operation_1
 * CreatedDate:  2020-07-25 14:46:11 +0900
 * LastModified: 2020-07-25 14:52:02 +0900
 */

#include <stdio.h>

void bit_operation(long int a, long int b, int order){
    long int s;
    if(order == 0){
        s = a&b;
    }
    else if(order == 1){
        s = a|b;
    }
    else{
        s = a^b;
    }
    for(int i=31; i>=0; i--){
        if(1&s>>i){
            printf("1");
        }
        else{
            printf("0");
        }
    }
}
int main(void){
    long int a, b;scanf("%ld%ld", &a, &b);
    bit_operation(a, b, 0);
    printf("\n");
    bit_operation(a, b, 1);
    printf("\n");
    bit_operation(a, b, 2);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2072
a, b = map(int, input().split())
# = list(map(int, input().split()))
# = [list(map(int, input().split())) for i in range(N)]

if a <0 and b>0:
    print("Zero")

elif a==0 or b==0:
    print("Zero")

elif a>0:
    print("Positive")

elif a<0 and b<0:
    if (a-b)%2==0:
        print("Negative")
    else:
        print("Positive")


Measured memory_bytes: 2940
mod = 998244353

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    res = 0
else:
    dict_D = {}
    for d in D:
        if d not in dict_D:
            dict_D[d] = 0
        dict_D[d] += 1

    max_D = sorted(D)[-1]

    res = 1
    parent = 1
    for i in range(max_D+1):
        if i == 0:
            if dict_D[0] != 1:
                res = 0
                break
        else:
            if i not in dict_D:
                res = 0
                break
            else:
                if i != 1:
                    res *= (parent**dict_D[i])
                    res %= mod
                parent = dict_D[i]

print(res)



Measured memory_bytes: 99968
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

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

  int min_aji = 1000;
  int min_index;
  int sum_aji = 0;

  for (int i=1; i<=n; i++) {
    if (min_aji > abs(l+i-1)) {
      min_aji = abs(l+i-1);
      min_index = i;
    }
    sum_aji += l + i - 1;
  }

  cout << sum_aji - (l+min_index-1) << endl;


  return 0;
}


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(3000)
H, W = map(int, input().split())
s = ['.'*(W+2)] + [list('.'+input()+'.') for _ in range(H)] + ['.'*(W+2)]

def dfs(x, y):
  if s[y][x] == '.':
    return 0
  s[y][x] = '.'
  return 1+dfs(x+1,y)+dfs(x-1,y)+dfs(x,y+1)+dfs(x,y-1)

for y in range(1, H+1):
  for x in range(1, W+1):
    if dfs(x, y) == 1:
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 4724
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n , m;
  n = 9;
  int a[n + 1], b[m];
  for(int i = 1; i < 10; i++){
    cin >> a[i];
  }
  cin >> m;
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 1; i < 10; i++){
    for(int j = 0; j < m; j++){
      if(a[i] == b[j]){
        a[i] = -1;
        break;
      }
    }
  }
  if(a[5] == -1){
    if(a[1] == -1 && a[9] == -1){
      cout << "Yes\n";
      return 0;
    }
    if(a[2] == -1 && a[8] == -1){
      cout << "Yes\n";
      return 0;
    }
    if(a[3] == -1 && a[7] == -1){
      cout << "Yes\n";
      return 0;
    }
    if(a[4] == -1 && a[6] == -1){
      cout << "Yes\n";
      return 0;
    }
  }
  if(a[1] == -1 && a[2] == -1 && a[3] == -1){
      cout << "Yes\n";
      return 0;
  }
  if(a[7] == -1 && a[8] == -1 && a[9] == -1){
      cout << "Yes\n";
      return 0;
  }
  if(a[1] == -1 && a[4] == -1 && a[7] == -1){
      cout << "Yes\n";
      return 0;
  }
  if(a[3] == -1 && a[6] == -1 && a[9] == -1){
      cout << "Yes\n";
      return 0;
  }
  cout << "No\n";
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long H, long long N, std::vector<long long> A){
  long long t = 0;
  for (int i = 0; i < N; ++i) {
    t += A[i];
  }
  if (t < H) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }
}

int main(){
  long long H;
  scanf("%lld",&H);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(H, N, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++) cin>>a[i];
	map<int,int> mod;
	for(int i=1;i<=n;i++) mod[i-a[i]]++;
	int ans  = 0;
	for(int i=1;i<=n;i++){
		ans += mod[a[i]+i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 27884
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

def main():
    r = ni()
    print(r*2*3.1415926535897932384626433832795028)
    #print(ans)
    return


if __name__ == '__main__':
    main()



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

int main() {
  int N,K;
  int64_t count=0;
  cin>>N>>K;
  vector<int> hp(N);
  for(int i=0;i<N;i++){
    cin>>hp.at(i);
  }
  
  sort(hp.begin(),hp.end());
  reverse(hp.begin(), hp.end());
  
  if(N==K){
    cout<<0<<endl;
  }
  else{
    for(int i=K; i<N;i++){
      count+=hp.at(i);
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    vector<string> a={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string S;
    cin >> S;
    rep(i,7) if (S==a[i]) cout << 7-i << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int d = sc.nextInt();

        int[][] pos = new int[n][d];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < d; j++){
                pos[i][j] = sc.nextInt();
            }
        }

        int count = 0;
        for(int j = 1; j < n; j++){
            for(int i = 0; i < j; i++){
                int sum = getPow(pos[i], pos[j], d);
                //System.out.println(sum);
                if(isPow(sum)){
                    count++;
                }
            }
        }

        System.out.println(count);
    }

    public static boolean isPow(int n){
        for(int i = 0; i <= n; i++){
            if(n == i * i){
                return true;
            }
        }
        return false;
    }

    public static int getPow(int[] a, int[] b,  int d){
        int sum = 0;
        for(int i = 0; i < d; i++){
            sum += (a[i] - b[i]) * (a[i] - b[i]);
        }
        return sum;
    }
}

Measured memory_bytes: 22740
n = input()
a = [int(c) for c in n]
if(a[-1] == 3):
    print('bon')
elif(a[-1] == 0):
  print('pon')
elif(a[-1] == 1):
  print('pon')
elif(a[-1] == 6):
  print('pon')
elif(a[-1] == 8):
  print('pon')
elif(a[-1] == 2):
  print('hon')
elif(a[-1] == 4):
  print('hon')
elif(a[-1] == 5):
  print('hon')
elif(a[-1] == 7):
  print('hon')
elif(a[-1] == 9):
  print('hon')

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
    return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
    return (x*y)%MOD;
}

ll pwr(ll x,ll y){
    ll pw[32]={},w=1;
    pw[0]=x;
    fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
    fr(i,32){
        w=mlt(w,1+(y%2)*(pw[i]-1));
        y/=2;
    }
    return w;
}

ll inv(ll x){
    return pwr(x,MOD-2);
}

ll fc[200010]={1};
ll fct(ll x){
    if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
    return fc[x];
}

ll ifc[200010]={1};
ll ifct(ll x){
    if(ifc[x]==0) ifc[x]=inv(fct(x));
    return ifc[x];
}

ll comb(ll n,ll r){
    if(n<0 || r<0 || n<r) return 0;
    return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
}

int main(){
    ll n,a,b,c,d,f;
    cin>>n>>a>>b>>c>>d;
    ll dp[1010][1010]={};
    fct(1010);
    ifct(1010);
    ifr(i,1010){
        ifc[i]=mlt(i+1,ifc[i+1]);
    }
    dp[b+1][n]=1;
    for(ll i=b;i>=a;i--){
        //cout << i << endl;
        fr(j,n+1){
            dp[i][j]=ad(dp[i][j],dp[i+1][j]);
            f=1;
            Fr(k,c-1) f=mlt(f,comb(j+k*i,i));
            for(ll k=c;k<=d;k++){
                if(j+i*k>n) break;
                f=mlt(f,comb(j+k*i,i));
                dp[i][j]=ad(dp[i][j],mlt(dp[i+1][j+i*k],mlt(f,ifct(k))));
            }
        }
    }
    /*for(int i=2;i<4;i++){
        fr(j,8) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[a][0]<<endl;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] s = sc.next().split("");
        int x = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            if ("D".equals(s[i])) {
                x--;
                continue;
            }
            x++;
            if (x > max) {
                max = x;
            }
        }
        System.out.println(max);
    }

}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        
        String[] numbers = scanner.nextLine().split(" ");
        
        int x = Integer.parseInt(numbers[0]);
        int y = Integer.parseInt(numbers[1]);
        
        if (x >= y) {
            System.out.println(gcd(y, x%y) + "");
        } else {
            System.out.println(gcd(x, y) + "");
        }
    }
    
    private static int gcd(int x, int y) {
        if (y == 0) {
            return x;
        }
        int d = 0;
        for (int i = 1; i <= y / 2; i++) {
            if (x % i == 0 && y % i == 0) {
                d = i;
            }
        }
        return d;
    }
}


Measured memory_bytes: 26264
#include <stdio.h>
#include <stdlib.h>
struct Card{
  char EGARA;
  int NUM;
};
void BubbleSort(struct Card *);
void SelectionSort(struct Card *);
int isStable(struct Card *,struct Card *);
void print(struct Card *);


int n;

int main(){
  int i;
 struct Card A[1000], B[1000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c",&A[i].EGARA);
    scanf("%d",&A[i].NUM);
  }
  for(i=0;i<n;i++){
    B[i]=A[i];
  }
  BubbleSort(A);
  SelectionSort(B);
  print(A);
  printf("Stable\n");
  print(B);
  if(isStable(A,B)==1)
    printf("Stable\n");
  else
    printf("Not stable\n");
    return 0;
}

void BubbleSort(struct Card *A){
  int i,j;
  struct Card m;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j].NUM<A[j-1].NUM){
	m=A[j];
	A[j]=A[j-1];
	A[j-1]=m;
      }
    }
  }
}

void SelectionSort(struct Card *B){
  int i,minj,j;
  struct Card m;
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(B[j].NUM<B[minj].NUM){
	minj=j;
      }
    }
    m=B[i];
    B[i]=B[minj];
    B[minj]=m;
  }
}

void print(struct Card *A){
  int i;
  for(i=0;i<n;i++){
    if(i>0)
      printf(" ");
    printf("%c%d",A[i].EGARA,A[i].NUM);
  }
  printf("\n");
}

int isStable(struct Card *A,struct Card *B){
  int i;
  for(i=0;i<n;i++){
    if(A[i].EGARA!=B[i].EGARA)
      return 0;
  }
  return 1;
}
    
	
	



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


int main()
{
	int counter[256]{0};
	char ch;
	while ((ch = getchar()) != EOF)
		counter[ch]++;
	for (int i = 97; i < 123; i++)
		printf("%c : %d\n", i, counter[i]+counter[i-32]);

}



Measured memory_bytes: 3204
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
    int N,K;
    int ind=0;
    long long x[100000]={};
    long long m = 4000000001;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    for(int i=0;i<N-K+1;i++){
        m = min(x[i+K-1] - x[i] + min(abs(x[i]), abs(x[i+K-1])), m);    
    }
    cout << m << endl;
}


Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct node{
	int number;
	string letters;
	vector<node> children;
	char get_char(int index,int &pos){
		int remain=index-pos+1;
		if(letters!=""){
			if(letters.size()>=remain){
				return letters[remain-1];
			}else{
				pos+=letters.size();
				return '\0';
			}
		}else{
			REP(i,number){
				REP(j,children.size()){
					char c=children[j].get_char(index,pos);
					if(c!='\0'){
						return c;
					}
				}
			}
			return '\0';
		}
	}
};

int number(string &s,int &pos){
	int ret=0;
	while(isdigit(s[pos])){
		ret*=10;
		ret+=s[pos]-'0';
		pos++;
	}
	return ret;
}

string letters(string &s,int &pos){
	string ret;
	while(isalpha(s[pos])){
		ret+=s[pos];
		pos++;
	}
	return ret;
}

void lp(string &s,int &pos){
	assert(s[pos]=='(');
	pos++;
}
void rp(string &s,int &pos){
	assert(s[pos]==')');
	pos++;
}
string letter(string &s,int &pos){
	assert(isalpha(s[pos]));
	string ret;
	ret+=s[pos];
	pos++;
	return ret;
}

vector<node> nodes(string &s,int &pos){
	vector<node> ret;
	while(pos<s.size()){
		if(isdigit(s[pos])){
			node nod;
			nod.number=number(s,pos);
			if(s[pos]=='('){
				lp(s,pos);
				nod.children=nodes(s,pos);
				rp(s,pos);
			}else{
				node c;
				c.letters=letter(s,pos);
				nod.children.push_back(c);
			}
			ret.push_back(nod);
		}else if(isalpha(s[pos])){
			node nod;
			nod.letters=letters(s,pos);
			ret.push_back(nod);
		}else{
			break;
		}
	}
	return ret;
}

int main(){
	string s;
	int index;
	while(cin>>s>>index,s!="0"||index){
		int pos=0;
		vector<node> roots=nodes(s,pos);
		pos=0;
		REP(i,roots.size()){
			char c=roots[i].get_char(index,pos);
			if(c!='\0'){
				cout<<c<<endl;
				goto next;
			}
		}
		cout<<0<<endl;
		next:;
	}
}

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

using namespace std;

int arr[105];
int n,x;

int main()
{
	cin >> x >> n;
	for(int i=0;i<n;i++) cin >> arr[i];
	sort(arr,arr+n);
	int xid=-1;
	for(int i=0;i<n;i++)
	{
		if(arr[i]==x) xid=i;
	}
	if(xid==-1)
	{
		cout << x << endl;
		return 0;
	}
	int mn=arr[0],mx=arr[n-1];
	for(int i=xid-1;i>=0;i--)
	{
		if(arr[i]!=arr[i+1]-1)
		{
			mn=arr[i+1]; break;
		}
	}
	for(int i=xid+1;i<n;i++)
	{
		if(arr[i]!=arr[i-1]+1)
		{
			mx=arr[i-1]; break;
		}
	}
	mn--; mx++;
	if(abs(mn-x)<=abs(mx-x))
		cout << mn << endl;
	else
		cout << mx << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.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++)

const int INF = 1001001001;

/*リスト一式*/
/*NDDTPTHで置換する型を変更してリストのデータを指定*/
/*使用する前にPTHをアルファベットで置換*/
typedef struct node{
  int nx, hv;
} NDDTPTH;
typedef struct listElementPTH{
  NDDTPTH data;
  struct listElementPTH *next;
  struct listElementPTH *prev;
} LIELPTH;
typedef struct listPTH{
  int size;
  LIELPTH *front;
  LIELPTH *back;
} LISTPTH;
LIELPTH *new_listElement_PTH(NDDTPTH d){
  LIELPTH *ret = (LIELPTH *)malloc(sizeof(LIELPTH));
  ret->data = d;
  ret->next = NULL;
  ret->prev = NULL;
  return ret;
}
LISTPTH *new_list_PTH(void){
  LISTPTH *ret = (LISTPTH *)malloc(sizeof(LISTPTH));
  ret->back = NULL;
  ret->front = NULL;
  ret->size = 0;
  return ret;
}
void push_back_PTH(NDDTPTH d, LISTPTH *list){
  LIELPTH *new = new_listElement_PTH(d);
  if(list->size == 0){
    list->front = list->back = new;
  }else{
    list->back->next = new;
    new->prev = list->back;
    list->back = new;
  }
  list->size++;
}
void push_front_PTH(NDDTPTH d, LISTPTH *list){
  LIELPTH *new = new_listElement_PTH(d);
  if(list->size == 0){
    list->front = list->back = new;
  }else{
    list->front->prev = new;
    new->next = list->front;
    list->front = new;
  }
  list->size++;
}
int pop_back_PTH(LISTPTH *list){
  if(list == NULL || list->size == 0){
    return 1;
  }
  if(list->size == 1){
    free(list->back);
    list->front = list->back = NULL;
    list->size = 0;
    return 0;
  }
  LIELPTH *bk = list->back;
  LIELPTH *nbk = bk->prev;
  free(bk);
  nbk->next = NULL;
  list->back = nbk;
  list->size--;
  return 0;
}
int pop_front_PTH(LISTPTH *list){
  if(list == NULL || list->size == 0){
    return 1;
  }
  if(list->size == 1){
    free(list->back);
    list->front = list->back = NULL;
    list->size = 0;
    return 0;
  }
  LIELPTH *fr = list->front;
  LIELPTH *nfr = fr->next;
  free(fr);
  nfr->prev = NULL;
  list->front = nfr;
  list->size--;
  return 0;
}
/*ここまでリスト一式*/

#define N 100

int main(){
  int n;
  scanf("%d", &n);
  LISTPTH *gr[N];
  rep(i, n){
    gr[i] = new_list_PTH();
  }
  rep(i, n){
    int a;
    scanf("%d", &a);
    int k;
    scanf("%d", &k);
    rep(j, k){
      int v, c;
      scanf("%d%d", &v, &c);
      NDDTPTH nd;
      nd.hv = c; nd.nx = v;
      push_back_PTH(nd, gr[i]);
    }
  }
  int d[N];
  rep(i, n){
    d[i] = INF;
  }
  int chk[N];
  rep(i, n){
    chk[i] = 0;
  }
  d[0] = 0;
  chk[0] = 1;
  int now = 0;
  rep(i, n-1){
    for(LIELPTH *p = gr[now]->front; p != NULL; p = p->next){
      NDDTPTH nd = p->data;
      if(chk[nd.nx] == 1) continue;
      int a1 = d[nd.nx];
      int a2 = d[now] + nd.hv;
      if(a1 < a2) d[nd.nx] = a1;
      else d[nd.nx] = a2;
    }
    int mn = INF, nx = -1;
    rep(j, n){
      if(chk[j] == 1) continue;
      if(mn > d[j]){
        mn = d[j];
        nx = j;
      }
    }
    if(nx == -1) break;
    chk[nx] = 1;
    now = nx;
  }

  rep(i, n){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define fr         first
#define se         second
#define sc(x)      scanf("%d",&x)
#define pr(x)      printf("%d ",x)
#define scl(x)     scanf("%lld",&x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P
string a,b,c;
int main()
{
    cin>>a>>b>>c;
    reverse(all(a));
    reverse(all(b));
    reverse(all(c));
    char x = a.back();
    a.pop_back();
    while(sz(a)&&sz(b)&&sz(c))
    {
        if(x=='a')
        {
            x = a.back();
            a.pop_back();
            continue;
        }
        if(x=='b')
        {
            x = b.back();
            b.pop_back();
            continue;
        }
        if(x=='c')
        {
            x = c.back();
            c.pop_back();
            continue;
        }
    }
    if(sz(a)==0)
        cout<< 'A';
    else if(sz(b)==0)
        cout<< 'B';
    else if(sz(c)==0)
        cout<< 'C';
    r0;
}


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

using namespace std;
#define taskname ""
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e5 + 5;
//a + b - a ^ b = 2 * (a & b)
int bit[19] , a[maxn] , n;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen(taskname".INP", "r",stdin);
	//freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)
        cin >> a[i];
    int j = 0;
    ll res = 0;
    a[0] = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        for(int t = 0 ; t < 20 ; ++t)
            if(a[i - 1] & (1 << t))bit[t]--;
        while(j <= n)
        {
            int ok = 1;
            for(int t = 0 ; t < 20 ; ++t)ok = min(ok , 1 ^ (bit[t] >= 2));
            if(ok == 0)break;
            ++j;
            for(int t = 0 ; t < 20 ; ++t)
                if(a[j] & (1 << t))
                {
                    bit[t]++;
                    if(bit[t] == 2)ok = 0;
                }
            //cout << j << " " << bit[2] << endl;
            if(!ok)break;
        }
        //cout << j << " " <<  bit[2] << endl;
        res += j - i;
    }
    cout << res;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> ans(100000000);
	for (int i = 1; i <= sqrt(n); i++){
		for (int j = 1; j <= sqrt(n); j++){
			for (int k = 1; k <= sqrt(n); k++){
				ans[i*i+j*j+k*k+i*j+j*k+k*i]++; 
			}
		}
	}
	for (int i = 1; i <= n; i++) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 393884
#include<iostream>
#include<vector>
 
using namespace std;
 
int main(){
    int n, m, s, t, q, i, j;
    int id, color = 0;
    bool answer_yes = false;
 
    // enter
    cin >> n >> m;
    vector< vector<int> > Adj(n);
    vector<int> Stack;
    vector<int> Check(n, 0);
    vector<int>::iterator it, itend;
    for (i = 0; i < m; i++) {
        cin >> s >> t;
        Adj[s].push_back(t);
        Adj[t].push_back(s);
    }
    /*for (i = 0; i < n; i++) {
        cout << "\n" << i << " : " << flush;
        for (auto it2 = Adj[i].begin(); it2 != Adj[i].end(); it2++) {
            cout << *it2 << " " << flush;
        }
    }
    cout << endl;*/
 
    // calculate
    for (i = 0; i < n; i++) {
        if (Check[i] == 0) {
            color++;
            Stack.push_back(i);
            Check[i] = color;
            while (!Stack.empty()) {
                id = Stack.back();
                //cout << "\nid : " << id << " color : " << color << endl;
                itend = Adj[id].end();
                for (it = Adj[id].begin(); it != itend; it++) {
                    if (!Check[*it]) {
                        Stack.push_back(*it);
                        Check[*it] = color;
                        break;
                    }
                }
                if (it == itend) {
                    Stack.pop_back();
                }
            }
        }
    }
 
    //find
    cin >> q;
    for (i = 0; i < q; i++) {
        cin >> s >> t;      
        if (Check[s] == Check[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 9384
#include <iostream>
#include <cmath>

using namespace std;
int main()
{
    int N;
    int L;
    cin>> N >> L;
    int sum=0;
    int diff=L;
    for(int i=1;i<=N;i++)
    {
        sum+=L+i-1;
        if(abs(diff)>abs(L+i-1))
        {
            diff=L+i-1;
        }
    }
    cout<<sum-diff<<endl;
    
}

Measured memory_bytes: 256