akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
//abc168

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    V<V<ll>> G(n);
    V<ll> a(m),b(m);
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        G[x].push_back(y);
        G[y].push_back(x);
        a[i]=x;b[i]=y;
    }
    // BFS のためのデータ構造
    vector<ll> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<ll> que;
    vector<ll> pr(n);//経路復元用の配列
    
    ll s,t;//sは出発点、tは目的地 入力等をちゃんと行え
    s=0;
    // 初期条件 (頂点 s を初期ノードとする)
    dist[s] = 0;
    que.push(s); // s を橙色頂点にする
    V<ll> ans(n,-1);
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        ll v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        // v から辿れる頂点をすべて調べる
        for (ll nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            ans[nv]=v;
            pr[nv]=v;
            que.push(nv);
        }
    }
    //経路復元
    vector<ll> path;
    path.push_back(t);
    
    
    /*各頂点が0-indexedになっているので出力の際は要注意
    結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) cout << v << ':' << dist[v] << endl;*/
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++) cout<<ans[i]+1<<"\n";
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 17708
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int answer = (a + b + c) / 2;
        if(((a + b + c) % 2) == 1){
            System.out.println("No");
        }
        else if(a == answer){
            System.out.println("Yes");
        }
        else if(b == answer){
            System.out.println("Yes");
        }
        else if(c == answer){
            System.out.println("Yes");
        }
        else if((a + b) == answer){
            System.out.println("Yes");
        }
        else if((a + c) == answer){
            System.out.println("Yes");
        }
        else if((b + c) == answer){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23636
using System;
using System.Collections.Generic;

namespace ABC045_D_SnukesColoring
{
    class ABC045_D_Review
    {
        static void Main(string[] args)
        {
            Reader.Debugging = false;

            string[] first = Reader.ReadLine().Split(' ');
            int H = int.Parse(first[0]);
            int W = int.Parse(first[1]);
            int N = int.Parse(first[2]);

            // y -> (x -> count)
            var yToXAndCount = new Dictionary<int, Dictionary<int, int>>();

            for (int i = 0; i < N; i++)
            {
                string[] split = Reader.ReadLine().Split(' ');
                int y = int.Parse(split[0]) - 1;
                int x = int.Parse(split[1]) - 1;

                for (int n = -2; n <= 0; n++)
                {
                    int Y = y + n;

                    if (Y < 0 || H - 2 < Y)
                    {
                        continue;
                    }

                    if (!yToXAndCount.ContainsKey(Y))
                    {
                        yToXAndCount[Y] = new Dictionary<int, int>();
                    }

                    for (int m = -2; m <= 0; m++)
                    {
                        int X = x + m;

                        if (X < 0 || W - 2 < X)
                        {
                            continue;
                        }

                        if (!yToXAndCount[Y].ContainsKey(X))
                        {
                            yToXAndCount[Y].Add(X, 0);
                        }

                        yToXAndCount[Y][X]++;
                    }

                }
            }

            ulong[] counts = new ulong[10];
            foreach (var yxc in yToXAndCount)
            {
                foreach (var xc in yxc.Value)
                {
                    if (yxc.Key < H - 2 && xc.Key < W - 2)
                    {
                        counts[xc.Value]++;
                    }
                }
            }

            // 0のマスは(H - 2) * (W - 2) - （1以上のマスの数）
            counts[0] = ((ulong)H - 2) * ((ulong)W - 2);
            for (int i = 1; i < counts.Length; i++)
            {
                counts[0] -= counts[i];
            }

            for (int i = 0; i < counts.Length; i++)
            {
                Console.WriteLine(counts[i]);
            }

            Console.ReadKey();
        }
    }

    public static class Reader
    {
        public static bool Debugging = true;
        private static System.IO.StringReader _sr = null;

        public static string ReadLine()
        {
            if (Debugging)
            {
                if (_sr == null)
                {
                    _sr = new System.IO.StringReader(_input.Trim());
                }

                return _sr.ReadLine();
            }

            return Console.ReadLine();
        }

        /// <summary>
        /// デバッグ用入力文字列
        /// </summary>
        private static string _input = @"
10 10 20
1 1
1 4
1 9
2 5
3 10
4 2
4 7
5 9
6 4
6 6
6 7
7 1
7 3
7 7
8 1
8 5
8 10
9 2
10 4
10 9";

    }
}


Measured memory_bytes: 76600
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define pb emplace_back
#define F first
#define S second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)
#define mp(a, b) make_pair(a, b)
#define eps 1e-9
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

bool ispal(string s, int st, int ed)
{
	for(int i=0; i<=(ed-st); i++)
	{
		if(s[i+st] != s[ed - i]) return 0;
	}
	return 1;
}

void solve()
{
	string s;
	cin>>s;
	int l = s.length() /2;
	if(ispal(s, 0, s.length()-1) && ispal(s, 0, l-1) && ispal(s, l+1, s.length()-1))
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


int main()
{
    FAST
    ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#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() {
	string S, T;
  	cin >> S >> T;
  
  	int mincnt=1000;
  	rep(i,S.size()-(T.size()-1)) {
	 	int ans=0;
      rep(j,T.size()) {
        if (S[i+j] != T[j]) ans++;
      }
      mincnt = min(mincnt, ans);
    }
  
  	cout << mincnt << endl;
    return 0;
}

Measured memory_bytes: 3576
def Easy_Linear_Programming():
    cards_reguration = input()
    cards = cards_reguration.split()
    A = int(cards[0])
    B = int(cards[1])
    C = int(cards[2])
    K = int(cards[3])
    
    point = 0
    
    if A > 0:
        if A >= K:
            point = K
            print(point)
            return
        else:
            point = A
            K -= A
            if K <= 0:
                print(point)
                return
        
    if B > 0 and K > 0:
        K -= B
        if K <= 0:
            print(point)
            return
        
    if C >= 0 and K > 0:
        point -= K
        print(point)
        return
            
    
Easy_Linear_Programming()

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

int main() {
    int R;
    cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    }
    else if (R < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int N = sc.nextInt();
    int a = 0;
    for(int i = 0;i < N;i++) {
      a += sc.nextInt();
    }
    if(H <= a) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 48996
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        mut a: [usize;n],
    }

    a.sort();
    a.reverse();

    let mut sum1 = 0;
    let mut sum2 = 0;
    for i in 0..n {
        if i%2==0 {
            sum1 += a[i];
        } else {
            sum2 += a[i];
        }
    }

    println!("{}", sum1-sum2);

}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) lower_bound(all(v),k)-v.begin()
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=100100100100;
const int mod=1000000007;
//abc137e
   bool from1[2500],ton[2500];
   void fromdfs(int i,vector<vector<P>> v){
      for(auto x: v[i]){
         if(from1[x.first])continue;
         from1[x.first]=true;
         fromdfs(x.first,v);
      }
   }
   void todfs(int i,vector<vector<P>> v){
      for(auto x: v[i]){
         if(ton[x.first])continue;
         ton[x.first]=true;
         todfs(x.first,v);
      }
   }
int main(){
   int n,m,p;cin>>n>>m>>p;
   rep(i,n){
      from1[i]=false;
      ton[i]=false;
   }
   vector<vector<P>> x(n);
   vector<vector<P>> y(n);
   vector<vector<P>> v(n);
   vi dis(n,inf);
   dis[0]=0;
   rep(i,m){
      int a,b,c;cin>>a>>b>>c;
      a--;b--;c*=-1;
      x[a].pb(P(b,c+p));
      y[b].pb(P(a,c+p));
   }
   from1[0]=true;
   ton[n-1]=true;
   fromdfs(0,x);
   todfs(n-1,y);
   if(from1[n-1]==false){
      cout<<-1<<endl;
      return 0;
   }
   rep(i,n){
      if(from1[i]==false||ton[i]==false)continue;
      for(auto d:x[i]){
         if(from1[d.first]&&ton[d.first]){
            v[i].eb(d.first,d.second);
         }
      }
   }
   bool dif=true;
   int step=0;
   while(dif){
      dif=false;
      rep(i,n){
         if(dis[i]==inf)continue;
         for(auto d: v[i]){
            if(dis[d.first]>dis[i]+d.second){
               dis[d.first]=dis[i]+d.second;
               dif=true;
            }
         }
      }
      step++;
      if(step>n){
         //閉路が存在する
         cout<<-1<<endl;
         return 0;
      }
   }
   cout<<max(-dis[n-1],(ll)0);
}


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

int main(){

  int a, b, n;
  bool sosu[1000000] = {};
  sosu[0] = true;
  sosu[1] = true;
  for(int i = 2; i < 1000000; i++){
    if(!sosu[i]){
      for(int j = i+i; j < 1000000; j+=i){
	sosu[j] = true;
      }
    }
  }

  while(cin >> a >> b >> n && (a || b || n)){

    int cnt = 0, judge = 0; 

    for(int i = a; i < 1000000; i+=b){
      if(!sosu[i]) cnt++;
      if(cnt == n){
	cout << i << endl;
	break;
      }
    }


    }



  

  return 0;
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef double db;
const db pi=acos(-1.);
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    db r;cin>>r;
    cout<<2*r*pi<<endl;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
	using namespace std;
	#define fo(i,n) for(int i=0;i<n;i++)
	#define pb push_back
	#define mp map<int,int>
	#define ump unordered_map<int,int>
	#define vi vector<int>
	#define M INT_MAX
	#define MI INT_MIN
	#define ll long long int
	#define pii pair<int,int>
	#define F first
	#define S second
	#define fall(i,a,b) for(int i=a;i<b;i++)
	#define pi 3.1415926535
	ll MOD=1e9+7;
	void solve()
	{
			ll n,k,ans=0;
			cin>>n>>k;
                  
			ll arr[n+10];
			arr[0]=0;
			for(int i=1;i<=(n+1);i++)
			arr[i]=arr[i-1]+i;

			for(int i=k;i<=(n+1);i++)
			{
				ll mini=arr[i];
				ll maxi=arr[n+1]-arr[n-i+1];
				ans+=(maxi-mini+1);
				ans%=MOD;
			}
			cout<<ans<<endl;
	}
	int main()
	{
		ios_base::sync_with_stdio(false);
	      cin.tie(NULL);
		solve();
	}

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

int main(){
  int X,Y;
  cin >> X >> Y;
  int ans=0;
  if(X == 3) ans += 100000;
  if(Y == 3) ans += 100000;

  if(X == 2) ans += 200000;
  if(Y == 2) ans += 200000;

  if(X==1 && Y==1){
    ans += 400000;
  }
  if(X == 1) ans += 300000;
  if(Y == 1) ans += 300000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:break
    a=0
    mi=1145141919
    ma=0
    for i in range(n):
        t=int(input())
        mi=min(mi,t)
        ma=max(ma,t)
        a+=t
    a-=mi+ma
    print(a//(n-2))


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll n;
ll a[mnx];
ll a1, a0;

int main(){

cin>>n;

for(int i=1; i<=n; i++){
    cin>>a[i];
    if(a[i] % 2 != 0){
        a1++;
    }
}

if(a1 % 2 != 0){ cout<<"NO\n";  return 0; }
if(a1 % 2 == 0){ cout<<"YES\n"; return 0; }

return 0;

}















Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
//    cin >> s;    int x = atoi(s[0]);
//    int a = atoi(s[1]);
    int x;
    int a;
    cin >> x >> a;
    if(x<a) {
        cout << "0";
    } else {
        cout << "10";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;

const int MAX_N = 25;
int n, W;
int w[MAX_N], v[MAX_N];

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A+B > C+D) {
		cout << "Left" << endl;
	}
	else if (A + B < C + D) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << 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 a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int count = 0;
        for (int i = 0; i <= 50; i++) {
            for (int j = 0; j <= 50; j++) {
                for(int k = 0; k <= 50; k++){
                    if (500*i + 100*j + 50*k == x && i <= a && j <= b && k <= c) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int64_t x[n], l[n]; rep(i,n) cin >> x[i] >> l[i];
	priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>, greater<pair<int64_t, int64_t>>> pq;
	rep(i,n) {
		pq.emplace(x[i] + l[i], x[i] - l[i]);
	}
	int64_t L = -LINF;
	int cnt = 0;
	while(pq.size()) {
		int64_t l, r;
		tie(r, l) = pq.top();
		pq.pop();
		if(l < L) continue;
		L = r;
		++cnt;
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 3956
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = scan!(usize, usize);
    if a == b {
        println!("Draw")
    } else if a == 1 || (b != 1 && b < a) {
        println!("Alice")
    } else {
        println!("Bob")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  int W;
  cin >> W;
  vector<int> a(W);
  for (int i = 0; i < W; i++){
    cin >> a[i];
  }
  vector<int> L(W, 0);
  int t_max = -INF;
  for (int i = 0; i < W; i++){
    t_max--;
    if (a[i] < 0){
      t_max = min(t_max, - a[i]);
    } else if (a[i] == 0){
      t_max = INF;
    } else {
      L[i] = max(min(a[i], t_max), 0);
    }
  }
  vector<int> R(W, 0);
  int t_max2 = -INF;
  for (int i = W - 1; i >= 0; i--){
    t_max2--;
    if (a[i] < 0){
      t_max2 = min(t_max2, - a[i]);
    } else if (a[i] == 0){
      t_max2 = INF;
    } else {
      R[i] = max(min(a[i], t_max2), 0);
    }
  }
  int ans = 0;
  for (int i = 0; i < W; i++){
    ans += max(L[i], R[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3904
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll L,R;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll mod = 2019;

    cin >> L;
    cin >> R;

    if(R-L>=2019) cout << 0 << endl;
    else{
        ll minmod = 2020;
        for( ll ni = L ; ni <=R ; ni++ ){
            for( ll ni2 = ni+1 ; ni2 <=R ; ni2++ ){
                ll prod = ni * ni2;
                minmod = llmin(minmod, prod % 2019  );               
            }
        }
        cout << minmod << endl;



    }
    

}

Measured memory_bytes: 3616
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int n;
    cin>>n;
    pair<pair<string,int>,int> books[n];

    string s;
    int p;
    rep(i,n){
        cin>>s>>p;
        books[i] = make_pair(make_pair(s,-p),i);
    }
    sort(books,books+n);
    rep(i,n)cout<<(books[i].second)+1<<endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	int a = count(S.begin(), S.end(), 'o');
	cout << 700 + 100 * a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <deque>

using namespace std;

long long mod = 1e5 + 7;
long long p = 31;
long long st;

pair<long long, deque<char> > next_(pair<long long, deque<char> > x) {
    long long h = x.first;
    deque<char> cur = x.second;
    long long l = (long long) cur.front();
    h -= (l * st) % mod;
    if (h < 0) {
        h += mod;
        h %= mod;
    }
    h *= p;
    h %= mod;
    h += l;
    h %= mod;
    cur.push_back(cur.front());
    cur.pop_front();
    return {h, cur};
}

long long mxd(long long x) {
    long long y = x;
    long long mx = 0;
    while (y > 0) {
        mx = max(mx, y % 10);
        y /= 10;
    }
    return mx;
}

long long mnd(long long x) {
    long long y = x;
    long long mx = 11;
    while (y > 0) {
        mx = min(mx, y % 10);
        y /= 10;
    }
    return mx;
}

long double pi = atan2(0, -1);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double t = h * 60 + m;
    long double ang = (t / 360) * pi - (m / 30) * pi;
    cout << fixed << setprecision(20) << sqrt(a * a + b * b - 2 * a * b * cos(ang)) << '\n';
    return 0;
}


Measured memory_bytes: 3628
from math import ceil

n, h = map(int, input().split())
ab = [[int(x) for x in input().split()] for y in range(n)]
ab_array = []
for a, b in ab:
    ab_array.append([a, "a"])
    ab_array.append([b, "b"])
ab_array = sorted(ab_array, key=lambda x:x[0], reverse=True)
a_max = ab_array[0][0]


cnt = 0
damage = 0

for value, katana in ab_array:
    if h <= 0:
        print(cnt)
        exit()
    if katana == "a":
        cnt += ceil(h/value)
        break
    else:
        h -= value
        cnt += 1

print(cnt)


Measured memory_bytes: 46300
N = 8
tate = [True]*N
yoko = [True]*N
rnaname = [True]*(2*N-1)
lnaname = [True]*(2*N-1)
board = [[True]*N for i in range(N)]


def update(x, y, value):
    tate[x] = value
    yoko[y] = value
    rnaname[x+y] = value
    lnaname[x-y+N-1] = value
    board[x][y] = value


def check(x, y):
    if tate[x] and yoko[y] and rnaname[x+y] and lnaname[x-y+N-1]:
        return True
    return False


def show():
    for i in range(N):
        for j in range(N):
            print('.' if board[i][j] else 'Q', sep='', end='')
        print()


# iは縦ベース
def solve(i):
    if i == N:
        show()
        exit(0)
    if tate[i] is False:
        solve(i+1)
    for j in range(N):
        if check(i, j):
            update(i, j, False)
            solve(i+1)
            update(i, j, True)


n = int(input())
for i in range(n):
    Q = list(map(int, input().split()))
    update(Q[0], Q[1], False)

for i in range(N):
    if tate[i]:
        solve(i)
        break
solve(N)




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

def cnt(i,j):
    ret=0
    si=str(i)
    for n in range(1,N+1):
        if n%10!=j:
            continue
        if str(n)[0]!=si:
            continue
        ret+=1
    return ret

ans=0
for i in range(10):
    for j in range(10):
        ans+=cnt(i,j)*cnt(j,i)
print(ans)


Measured memory_bytes: 43228
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String o = s.nextLine();
		String e = s.nextLine();
		int o1 = o.length();
		int e1 = e.length();
		int i = 0;

		String ki = "";
		String gu = "";
		String ans = "";

		for (i = 0; i < e1; i++) {

			ki = o.charAt(i) + "";

			gu = e.charAt(i) + "";

			ans = ans + ki + gu;
		}
		if (o1 - e1 == 1) {
			System.out.println(ans + o.charAt(o1 - 1));
		} else {
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
///////////////////////////////////////////
int h,w;
char a[1000][1000];
int main(){speed
    cin>>h>>w;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=w+2;i++) cout<<"#";
    cout<<endl;
    for(int i=1;i<=h;i++){
        cout<<"#";
        for(int j=1;j<=w;j++){
            cout<<a[i][j];
        }
        cout<<"#";
        cout<<endl;
    }
    for(int i=1;i<=w+2;i++) cout<<"#";
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    long long n,x;
    cin>>n>>x;
    vector<long long> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    long long res = 0;
    if(a[0]>=x){
        res+=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++){
        long long d1 = a[i]+a[i-1]-x;
        if(d1>0){
            res+=d1;
            a[i]=max(a[i]-d1,0LL);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 2e5 + 5, inf = 1e9;
const ll INF = 1e18, mod = 1e9 + 7;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[MAXN], h[MAXN], a[MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

ll Tree[2 * 1024 * 1024], Base = 1;

void chTree(int node, ll v) {
    node += Base;
    Tree[node] = v;
    while (node /= 2) {
        Tree[node] = max(Tree[2 * node], Tree[2 * node + 1]);
    }
}

ll read(int node, int lo, int hi, int l, int r) {
    if (r < lo or hi < l) {
        return 0;
    }
    if (l <= lo and hi <= r) {
        return Tree[node];
    }

    int mid = (lo + hi) / 2;
    return max(read(2 * node, lo, mid, l, r), read(2 * node + 1, mid + 1, hi, l, r));
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n;
    cin >> n;
    while (Base <= n) {
        Base *= 2;
    }

    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = 1; i <= n; i++) {
        dp[h[i]] = read(1, 0, Base - 1, 1, h[i]) + a[i];
        chTree(h[i], dp[h[i]]);
    }

    ll res = 0;
    for (int i = 1; i <= n;  i++) {
        //cout << dp[i] << " ";
        res = max(res, dp[i]);
    }
    //cout << "\n";
    cout << res << "\n";
}


Measured memory_bytes: 14080
// User: el_heffeh
// Date: 6/16/20

#include <bits/stdc++.h>

using namespace std;

int x[6];

void solve() {
	for (int i = 1; i <= 5; ++i) {
		cin >> x[i];
	}
	for (int i = 1; i <= 5; ++i) {
		if (x[i] == 0) {
			cout << i << endl;
			return;
		}
	}
}

int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);    
    //freopen("input.txt", "r", stdin);
	solve();
    return 0;
}

/* 
	When writing code, be sure to look out for:
 	* Array out of bounds access
 	* Integer overflow
 	* Variable scopes and names
 	* Be proactive and make sure to completely think a whole problem through before writing any code
 	Coding is a fun activity, and it should be treated that way. Don't get mad over some failed test cases or time limit exceeded verdicts. Keep your cool and stay calm!
*/


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

int main() {
	int x = 0;
	char S[4];
	for (int i = 0; i < 4; i++) {
		cin >> S[i];
	}

	for (int i = 0; i < 4; i++)
	{
		if (S[i] == '+')x++;
		else x--;
	}

	cout << x << endl;

	return 0;
}

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

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

	ll ans = 0;
	ans += min(a, k) - max(0, k - a - b);
	cout << ans << endl;
	return 0;
} 

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




#define rrep(i,a,b) for(int i=a;i>=b;i--)
int N;
int X[505];
//-----------------------------------------------------------------
int A[301010];
void print() {
	rep(i, 0, N * N) {
		printf("%d", A[i + 1]);
		if (i != N*N - 1) printf(" ");
	}
	cout << endl;
}

int cnt[505];
int solve() {
	vector<pair<int, int>> v;
	rep(i, 1, N + 1) v.push_back({X[i], i});
	sort(v.begin(), v.end());

	int prev = 1;
	rep(i, 0, N) {
		int xi = v[i].first;
		int idx = v[i].second;

		A[xi] = idx;

		int cnt = idx - 1;
		while (0 < cnt) {
			if (xi == prev) break;
			if (!A[prev]) {
				A[prev] = idx;
				cnt--;
			}
			prev++;
		}
		if (cnt != 0) return -1;
	}

	sort(v.begin(), v.end(), greater<pair<int,int>>());

	queue<int> que;
	rep(i, 0, N) {
		rep(j, 0, (N - v[i].second)) que.push(v[i].second);
	}

	rrep(i, N*N, 1) if(!A[i]){
		A[i] = que.front();
		que.pop();
	}

	rep(i, 1, N*N + 1) {
		int a = A[i];
		cnt[a]++;

		if (cnt[a] == a) {
			if (i != X[a]) return -1;
		}
	}

	rep(i, 1, N + 1) if (cnt[i] != N) return -1;

	return 0;
}
//-----------------------------------------------------------------
int main() {
	cin >> N;
	rep(i, 0, N) cin >> X[i + 1];

	if (solve() < 0) {
		cout << "No" << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	print();
}


Measured memory_bytes: 2292
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long LL;
LL i,j,k,n,m;
string s;
LL mod=1000000007;

int main() {
  cin >> n>>m;
  if(abs(n-m)>1) {
    cout << 0 << endl;
  } else {
    LL np=1;
    for(i=1; i<n+1;++i){
      np *= i;
      np=np%mod;
    }
    LL mp=1;
    for(i=1; i<m+1;++i){
       mp *= i;
       mp=mp%mod;
    }
    LL out = (np*mp)%mod;
    if(n==m){
      out = (2*out)%mod;
    }
    cout << out << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int i,a,c=0,d=0,e=0,f=0;
    string str;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        cin>>str;
        if(str=="AC")
        {
            c++;
        }
        else if(str=="WA")
        {
            d++;
        }
        else if(str=="TLE")
        {
            e++;
        }
        else
        {
            f++;
        }
    }
    cout<<"AC x "<<c<<endl;
    cout<<"WA x "<<d<<endl;
    cout<<"TLE x "<<e<<endl;
    cout<<"RE x "<<f<<endl;
    return 0;
}


Measured memory_bytes: 3628
long M=1e9+7,f[444][444],u;
i,j,k,a[444],b;
main(N,C){
	**f=1;
	scanf("%d%d",&N,&C);for(;j<N;)scanf("%d",a+j++);
	for(;~scanf("%d",&b);)for(j=a[i++];j<=b;j++)for(u=k=0;k<=C;k++)f[i][k]+=u=(f[i-1][k]+u*j)%M;
	printf("%ld",f[N][C]%M);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int K;
	int A;
	vector <int > like (30,0);
	for(int i=0; i<N; i++){
		cin>>K;
		for(int j=0; j<K; j++){
			cin>>A;
			like[A-1]++;
			
		}
	}
	int ans=0;
	for(int i=0; i<30; i++){
		if(like[i]==N){
			ans++;
		}
	}
	
	cout<<ans;
	
}

Measured memory_bytes: 256
while line = gets do
  a = line.chomp.split(" ").map(&:to_i)
  b = gets.chomp.split(" ").map(&:to_i)
  hit = 0
  blow = 0
  4.times do |i|
    if a.include?(b[i])
      if a[i] == b[i]
        hit += 1
      else
        blow += 1
      end
    end
  end
  puts "#{hit} #{blow}"
end

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

int main(){
   int A,B,AB,X,Y;
   cin>>A>>B>>AB>>X>>Y;

   int sum = AB*2*max(X,Y);

   int res = 0;

   if(X>=Y){
        if((A+B)*Y > AB*Y*2){
        res += AB*Y*2;
        res += A*(X-Y);
        }
        else res = A*X + B*Y;
    }

    else{
        if((A+B)*X > AB*X*2){
        res += AB*X*2;
        res += B*(Y-X);
        }
        else res = A*X + B*Y;
    } 

    res = min(res,sum);

    cout<<res<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <functional>
#include <map>
#include <set>
#include <cmath>
using namespace std;

#define INT_MAX 2147483647
#define ll long long

ll max(ll a, ll b) { return (a < b) ? b : a; }

vector<bool> visited;
vector<int> lp;
void dfs(unordered_map<int, vector<int>>& edges, int node) {
    visited[node] = true;
    for (int neighbour : edges[node]) {
        if (!visited[neighbour]) {
            dfs(edges, neighbour);
        }
        lp[node] = max(lp[node], 1 + lp[neighbour]);
    }
}

// DP !!
int main() {
    int n, m;
    cin >> n >> m;

    unordered_map<int,vector<int>> edges;
    lp.resize(n + 1, 0);
    visited.resize(n + 1, false);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        edges[x].push_back(y);
    }

    for (int i = 1; i <= n; i++) {
        if (!visited[i])
            dfs(edges, i);
    }
    
    int best = -1;
    for (int el : lp) {
        best = max(el, best);
    }

    cout << best << endl;
    
    return 0;
}

Measured memory_bytes: 12196
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


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

  int n,m;
  cin>>n>>m;
  cout<<n-m+1<<endl;


}

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

class Book {
 public:
  long cost;
  vector<long> algos;
};

// bool compare_cost(Book a, Book b) { return a.cost > b.cost; }

int main() {
  int n, m;
  long x;
  cin >> n >> m >> x;

  vector<Book> books;

  rep(i, n) {
    long c;
    cin >> c;

    Book book;
    book.cost = c;

    rep(j, m) {
      long a;
      cin >> a;
      book.algos.push_back(a);
    }
    books.push_back(book);
  }

  // sort(books.begin(), books.end(), compare_cost);

  multimap<long, int> combos;

  for (int combo = 1; combo < (1 << n); combo++) {
    long total_cost = 0;

    rep(i, n) {
      if (combo & 1 << i) {
        total_cost += books[i].cost;
      }
    }

    combos.insert({total_cost, combo});
  }

  for (auto iter : combos) {
    int combo = iter.second;
    vector<long> xp(m);

    rep(i, n) {
      if (combo & (1 << i)) {
        rep(algo_i, m) { xp[algo_i] += books[i].algos[algo_i]; }
      }
    }

    int safe_count = 0;

    rep(algo_i, m) {
      if (xp[algo_i] >= x) {
        safe_count++;
      }
    }

    if (safe_count == m) {
      cout << iter.first << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}

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

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    s = ' ' +  s; // 文字列を1オリジンで考える
    n++;
    vector<int> dp(n); // sの先頭からi文字目(1<=i<=n)までに含まれるACの数を記録する配列
    rep(i, n) {
        if (i == 0 || i == 1) dp[i] == 0;
        else if (s[i-1] == 'A' && s[i] == 'C') dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
        // cout << dp[i] << " ";
    }
    cout << endl;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        // int cnt = 0;
        // for (int i = l; i <= r - 1; i++) {
        //     if (s[i] == 'A' && s[i+1] == 'C') cnt++;
        // }
        // cout << cnt << endl;
        cout << dp[r] - dp[l] << endl;
    }
}

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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 1000000000;
  for (int i = 0; i <= max(x, y); i++) {
    int cn = 2 * i;
    int an = (x > i) ? (x - i) : 0;
    int bn = (y > i) ? (y - i) : 0;
    int val = a * an + b * bn + c * cn;
    if (val < ans) {
      ans = val;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<b)
	{
		swap(a,b);
	}
	if((a-1)>=b)
	{
		cout<<a+(a-1)<<endl;
	}
	else
	{
		cout<<a+b<<endl;
	}
	return 0;
}

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

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

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

    int mind = 100, num;
    for (int i = 0; i <= 101; i++) {
        int count = 0;
        for (int j = 0; j < kyu.size(); j++) {
            if (kyu.at(j) == i) count ++;
        }
        if (count != 0) continue;

        int d = abs(i - x);
        if (d < mind) {
            mind = d;
            num = i;
        }

    }

    cout << num << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n,ara[1002][1002],i,j;
int main()
{

int n,m,div=0;
cin>>n>>m;
if((m-1)%(n-1)!=0)div=1;
div+=(m-1)/(n-1);
cout<<div<<endl;
return  0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

/*** mod int ***/
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

/*** mod int ここまで ***/

mint dp[2005][2005];
mint sum[2005][2005];

void Main(){
    int n, m; cin >> n >> m;
    vi s(n), t(m);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
    
    //dp[0][0] = sum[0][0] = 0;
    //rep(i, n + 1) sum[i][0] = 1;
    //rep(j, m + 1) sum[0][j] = 1;
     
    rep(i, n + 1){
        rep(j, m + 1){
            dp[i+1][j+1] = (s[i] == t[j]) ? sum[i][j] + 1 : 0;
            // if(i == 0 && j == 0) cout << sum[i][j+1] << " " << sum[i+1][j] << " " << sum[i][j] << " " << dp[i+1][j+1] << endl;
            // if(i == 1 && j == 1) cout << sum[i][j+1] << " " << sum[i+1][j] << " " << sum[i][j] << " " << dp[i+1][j+1] << endl;
            sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + dp[i+1][j+1];
            
        }
    }
    
    /*
    rep(i, n+2){
        rep(j, m+2){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;

    rep(i, n+2){
        rep(j, m+2){
            cout << sum[i][j] << " ";
        }
        cout << endl;
    }
    //*/
    cout << sum[n][m] + 1 << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 66472
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,w;
int dp[103][100010];

signed main(){
    I(n); I(w);
    REPS(i,n){
        int wi,vi;
        I(wi); I(vi);
        REP(wg,w+1){
            dp[i][wg] = wg < wi ? dp[i-1][wg] : 
                max(dp[i-1][wg], dp[i-1][wg-wi] + vi);
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 79360
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) > abs(x - b)) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}
	

	return 0;
}


Measured memory_bytes: 384