akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
	FASTIO
	/*
	//double start_time = clock();
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int T;
	//cin >> T;
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		int n;
		cin >> n;
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			//set<int> st;
			int x = i;
			int cnt = 0;
			while (x) {
				//int p = x % 10;
				//st.insert(p);
				x /= 10;
				cnt++;
			}
			if (cnt & 1) {
				ans++;
				//dbg(i);
			}
			//st.clear();
		}
		cout << ans << endl;
	}

	//double end_time = clock();
	//printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		int K = Integer.valueOf(s.next());
		int[] P = new int[N+1];
		int[] C = new int[N+1];
		
		for(int i = 1 ; i <= N; i++) {
			P[i] = Integer.valueOf(s.next());
		}
		for(int i = 1 ; i <= N; i++) {
			C[i] = Integer.valueOf(s.next());
		}
		
		boolean[] used = new boolean[N+1];
		
		long ret = Integer.MIN_VALUE;
		long cur = 0;
		int idx = 0;
		for(int i = 1; i <= N; i++) {
			idx = P[i];
			cur = C[idx];
			ret = Long.max(ret, cur);
			used[i] = true;
			
			int cnt = 1;
			while(true) {
				if(used[idx] || cnt >= K) break;
				used[idx] = true;
				cnt++;
				idx = P[idx];
				cur += C[idx];
				ret = Long.max(ret, cur);
			}
			used = new boolean[N+1];
			
			if(cur > 0 && K >= cnt) {
				cur = cur * (K / cnt - 1);
				int idx2 = P[i];
				for(int j = 0; j < cnt + (K % cnt); j++) {
					cur += C[idx2];
					idx2 = P[idx2];
					ret = Long.max(ret, cur);
				}
			}
		}
		
		System.out.println(ret);
	}
}

Measured memory_bytes: 55748
N,K = list(map(int, input().split()))
p = list(map(int, input().split()))

maxstart = 0
maxval = 0
nowval = 0
for i in range(K):
  nowval += p[i]
maxval = nowval
  
for i in range(N-K):
  nowval -= p[i]
  nowval += p[i+K]
  if nowval > maxval:
    maxval = nowval
    maxstart = i+1

ans = 0
for i in range(K):
  ans += (p[i+maxstart] + 1)

print(ans/2)

Measured memory_bytes: 24548
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        System.out.println(attack(H));
        sc.close();
    }

    static long attack(long hp) {
        if (hp == 1) {
            return 1;
        }
        return attack(hp / 2) * 2 + 1;
    }
}

Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
	Scanner sc =new Scanner(System.in);
	ArrayList<Integer> ans=new ArrayList<>();
	int n=sc.nextInt();
	int y[]=new int[n];
	int m[]=new int[n];
	int d[]=new int[n];
	int i;
	int count=0;


		for(i=0;i<n;i++) {
			y[i]=sc.nextInt();
			m[i]=sc.nextInt();
			d[i]=sc.nextInt();

			int f=1000-y[i];
			int e=f/3;

			if(f%3==0) {
				if(m[i]%2==1)
					count+=20-d[i];
				else
					count+=19-d[i];
				count+=20*((10-m[i])/2)+19*((10-m[i])-(10-m[i])/2);

				count+=200*e+195*(f-e-1);
			}
			else if(f%3==1) {
				count+=20-d[i];
				count+=20*(10-m[i]);

				count+=200*e+195*(f-e-1);
			}

			else if(f%3==2) {
				if(m[i]%2==1)
					count+=20-d[i];
				else
					count+=19-d[i];
				count+=20*((10-m[i])/2)+19*((10-m[i])-(10-m[i])/2);

				count+=200*(e+1)+195*(f-(e+1)-1);
			}
			ans.add(count+1);
			count=0;
		}
		for(i=0;i<n;i++)
			System.out.println(ans.get(i));
	}
}



Measured memory_bytes: 27016
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  string s;
  cin >> s;
  int ans=0;
  rep(i,3){
    if(s[i]=='a'){ans++; break;}
  }
  rep(i,3){
    if(s[i]=='b'){ans++; break;}
  }
  rep(i,3){
    if(s[i]=='c'){ans++; break;}
  }

  if(ans==3){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

int n;

struct node
{
	int id, pid, k, d;
	int* cid;
	string type;
}N[100005];

void GetDepth(node& GN)
{
	GN.d = 0;
	node temp = GN;

	while (temp.pid != -1)
	{
		GN.d++;
		temp = N[temp.pid];
	}
}

void GetType(node& GN)
{
	if (GN.pid == -1)
		GN.type = "root";
	else if (GN.k == 0)
		GN.type = "leaf";
	else
		GN.type = "internal node";
}

void print()
{
	for (int i = 0; i < n; i++)
	{
		cout << "node " << N[i].id << ": " << "parent = " << N[i].pid << ", " << "depth = " << N[i].d << ", " << N[i].type << ", " << "[";

		if (N[i].k != 0)
		{
			for (int j = 0; j < N[i].k - 1; j++)
				cout << N[i].cid[j] << ", ";
			cout << N[i].cid[N[i].k - 1];
		}

		cout << "]" << endl;
	}	
}

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

	int place;
	cin >> n;
	
	for (int i = 0; i < n; i++)
		N[i].pid = -1;
	
	for (int i = 0; i < n; i++)
	{
		cin >> place;
		N[place].id = place;
		cin >> N[place].k;

		if (N[place].k > 0)
			N[place].cid = (int*)malloc(sizeof(int) * N[place].k);

		for (int j = 0; j < N[place].k; j++)
		{
			cin >> N[place].cid[j];
			N[N[place].cid[j]].pid = N[place].id;
		}			
	}

	for (int i = 0; i < n; i++)
		GetDepth(N[i]);

	for (int i = 0; i < n; i++)
		GetType(N[i]);	

	print();

	return 0;
}



Measured memory_bytes: 11376
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    string S, T, U;
    cin >> S >> T >> U;
    cout << S[0] << T[1] << U[2] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a;
    int b;
    int x;
    int y;

    scanf("%d %d\n", &a, &b);
    
    x = a * b;
    y = 2 * (a + b);

    printf("%d %d\n", x, y);
    return 0;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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(){
    ll A, B, N;
    cin >> A >> B >> N;

    if (N < B){
        cout << ll(A * N / B) << endl;
    } else{
        cout << ll(A * (B - 1) / B) << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n, a, b, c;
    static int A,B,C;
    public static void main(String[] args) {
        while(read()){

        }
    }

    static boolean read(){
        if(!sc.hasNext())return false;
        n = sc.nextInt();
        for(int i = 0; i < n; i++){
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            solve();
        }
        return true;
    }

    static void solve(){
        if(a != 0 && b != 0 && c!= 0){
            A = a * a;
            B = b * b;
            C = c * c;
            if(A == B + C){
                System.out.println("YES");
            }else if(B == A + C){
                System.out.println("YES");
            }else if(C == A + B){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }

}

Measured memory_bytes: 32960
//om nama sivaya
#include<bits/stdc++.h>
#define M 1000000007
#define ll long long
using namespace std;
void stockBuy(ll price[], ll n) 
{ 
    ll ca,ma,sh,f=0;
    ca=1000;
    if (n == 1) 
    {
        cout<<"1000";return;
    }
    int i = 0; 
    while (i < n - 1) { 
        while ((i < n - 1) && (price[i + 1] <= price[i])) 
            i++; 
        if (i == n - 1) 
            break;
        int buy = i++; 
        while ((i < n) && (price[i] >= price[i - 1])) 
            i++; 
        int sell = i - 1; 
        sh=ca/price[buy];
        ca=ca%price[buy];
        ca=(price[sell]*sh)+ca;
        
    } 
    cout<<ca;
} 
void solve(){
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    stockBuy(a,n);
    
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3652
#include<stdio.h>

int main (){
    int Tate, Yoko;
    scanf("%d",&Tate);
    scanf("%d",&Yoko);
    int Mawari = Tate*2+Yoko*2;
    int Men = Tate*Yoko;
    printf("%d %d\n",Men,Mawari);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   long long K;
   std::cin >> N >> K;
   int a, b;
   std::vector<std::pair<int,int> > v(N);
   for(int i=0; i<N; ++i){
      std::cin >> a >> b;
      v[i] = std::make_pair(a,b);
   }
   std::sort(v.begin(),v.end());

   long long count = 0;
   for(int i=0; i<N; ++i){
      count += v[i].second;
      if (count>=K){
	 std::cout << v[i].first << std::endl;
	 return 0;
      }
   }

   return -1;
}


Measured memory_bytes: 1024
fn main() {
    let mut r = acio::Reader::new();
    let w = r.read::<u64>();
    let h = r.read::<u64>();
    let s = (h * w) as f64 / 2.0;
    
    let x = r.read::<u64>();
    let y = r.read::<u64>();
    if w == x * 2 && h == y * 2 {
        println!("{} 1", s);
    } else {
        println!("{} 0", s);
    }
}

/// IO Module for AtCoder
#[allow(dead_code)]
mod acio {
    use std::fmt::Debug;
    use std::io::{stdin, Stdin};
    use std::str::FromStr;

    pub struct Reader {
        input: Stdin,
        stack: Vec<String>,
    }

    impl Reader {
        pub fn new() -> Self {
            Reader {
                input: stdin(),
                stack: vec![],
            }
        }

        pub fn read_by<F>(&mut self, count: usize) -> Vec<F>
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            let mut v = vec![];
            for _ in 0..count {
                v.push(self.read());
            }
            return v;
        }

        pub fn read<F>(&mut self) -> F
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            if self.stack.is_empty() {
                let mut line = self.read_line();
                self.stack.append(&mut line);
                self.stack.reverse();
            }
            self.stack.pop().unwrap().parse().unwrap()
        }

        fn read_line(&mut self) -> Vec<String> {
            let mut buf = String::new();
            self.input.read_line(&mut buf).unwrap();
            buf.split_whitespace().map(|s| s.to_string()).collect()
        }
    }
}


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


int main()
{
    int n, m, AC = 0, pen = 0, K;
    cin >> n >> m;
    vector<int> a[n + 1];
    int visited[n + 1];
    for (int i = 1; i <= m; i++)
    {
        string x;
        cin >> K >> x;
        if (x == "AC")
        {
            a[K].push_back(1);
            visited[K] = 1;

        }
        else
            a[K].push_back(0);
    }
    int temp[n + 1] = { 0 };
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < a[i].size(); j++)
        {
            if (a[i][j] == 1 && temp[i] == 0)
            {
                AC++;
                temp[i] = 1;
                break;
            }
            else if (a[i][j] == 0 && temp[i] == 0 && visited[i] == 1)
                pen++;

        }
    }
    cout << AC << " " << pen << endl;
    return 0;
}

Measured memory_bytes: 6528
n, m = map(int, input().split())
max_l = 0
min_r = 10**5
for i in range(m):
    l, r = map(int, input().split())
    max_l = max(max_l, l)
    min_r = min(min_r, r)
ans = min_r - max_l + 1
if ans < 0:
    ans = 0
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  cout << ceil(n / 2.0) << endl;
}

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

int main(){
	int k,s,count;
  	cin>>k>>s;
  	count=0;
  	for (int x=0;x<=k;x++){
      for (int y=0;y<=k;y++){
    	int z=s-x-y;
    		if(z>=0 && z<=k){
            	count++;
      	}
      }
    }
  cout<<count<<endl;
}    

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
int fun(int n, int k) {
	int p = 1;
	while (n / k) {
		n /= k;
		p++;
	}

	return p;
	
}

int main() {
	ll n, k;
	cin >> n >> k;
	int p = fun(n, k);
	cout << p;


	return 0;
}

Measured memory_bytes: 256
#include <vector>
#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>

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 EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#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;

int main() {
	ll N;
	cin >> N;
	ll i, num = 0;

	for(i = 1; i < N; i*=3) {
		num++;
	}
	
	cout << num << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

int main () {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  REP(i,N) {
    cout << ans[i] << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 23552
#include <stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] != key) i++;
	return i != n;
}

int main() {
	int i, n, A[10000 + 1], q, key, sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &A[i]);

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &key);
		if (search(A, n, key))sum++;
	}
	printf("%d\n", sum);

	return 0;
}


Measured memory_bytes: 2108
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

template<typename T> bool chmax(T&a,T b) { if(a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T&a,T b) { if(a > b) {a = b; return true;} return false;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

int N;
string s, t;
int main(void)
{
    cin >> N >> s >> t;

    rep(i, N) {
        bool ok = true;
        rep(j, N - i) {
            if (s[j + i] != t[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            debug(i + N);
            return 0;
        }
    }

    debug(2 * N);
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
vector<int> v;
int main(){
    cin>>N;
    REP(i,N){
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    int ans=0;
    REP(i,N-1){
        ans+=v[i+1]-v[i];
    }
    cout<<ans<<endl;
    
	return(0);
}

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

struct UnionFindTree {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        siz.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

int main(){
    int h, w;
    while(cin >> w >> h, h){
        int xs, ys, xg, yg;
        int n;
        cin >> xs >> ys >> xg >> yg >> n;
        xs--; ys--; xg--; yg--;
        vector<vector<int> > color(h, vector<int>(w,0));
        for(int i=0;i<n;i++){
            int c, d, x, y;
            cin >> c >> d >> x >> y;
            x--; y--;
            for(int dy=0;dy<(d?4:2);dy++){
                for(int dx=0;dx<(d?2:4);dx++){
                    color[y+dy][x+dx] = c;
                }
            }
        }
        UnionFindTree uf;
        uf.init(h*w);
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(color[i][j] == 0) continue;
                if(i+1<h && color[i][j] == color[i+1][j]){
                    uf.unite(i*w+j, (i+1)*w+j);
                }
                if(j+1<w && color[i][j] == color[i][j+1]){
                    uf.unite(i*w+j, i*w+j+1);
                }
            }
        }
        cout << (uf.is_same(ys*w+xs,yg*w+xg) ? "OK" : "NG") << endl;
    }

    return 0;
}


Measured memory_bytes: 3248
def Chocolate(n , d , x , al):

    ans = n + x

    for i in range(n):
        ans += (d - 1) // al[i]

    return ans

def main():
    n = int(input())
    d, x = map(int, input().split())
    al = [int(input()) for i in range(n)]
    print(Chocolate(n , d , x , al))


if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
N,K=gets.split.map(&:to_i)
steps=gets.split.map(&:to_i)
dp = []
dp << 0
dp << (steps[0] - steps[1]).abs
pos = 2
while pos < N
    k = 1
    min = nil
    while k <= K
        break if (pos - k) < 0
        tmp = dp[pos-k] + (steps[pos] - steps[pos-k]).abs
        min = tmp if min.nil?
        min = tmp if tmp < min
        k += 1
    end

    dp << min
    pos += 1
end
puts dp[N-1]


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

const int gkMod = 1000000007;
int gNColor;
std::vector<std::vector<int> > gGraph;

long long GetNPatternOfChild(int, int);

int main()
{

   int nNode;
   std::cin >> nNode >> gNColor;

   int a, b;
   gGraph.reserve(nNode);
   for (int i = 0; i < nNode - 1; i++) {
      std::cin >> a >> b;
      gGraph[a - 1].push_back(b - 1);
      gGraph[b - 1].push_back(a - 1);
   }
   std::cout <<  gNColor * GetNPatternOfChild(-1, 0) % gkMod << std::endl;
   return 0;
}

long long GetNPatternOfChild(int nodeFrom, int nodeNow)
{
   int nColorAvailable = gNColor - 1;
   int nEdge = gGraph[nodeNow].size();
   int nChild = nEdge;
   if (nodeFrom >= 0) {
      nColorAvailable--;
      nChild--;
   }
   if (nChild > nColorAvailable) {
      return 0;
   }
   long long nPattern = 1;
   for (int iChild = 0; iChild < nChild; iChild++) {
      nPattern *= (nColorAvailable - iChild);
      nPattern %= gkMod;
   }
   for (int iEdge = 0; iEdge < nEdge; iEdge++) {
      if (gGraph[nodeNow][iEdge] == nodeFrom) {
         continue;
      }
      nPattern *= GetNPatternOfChild(nodeNow, gGraph[nodeNow][iEdge]);
      nPattern %= gkMod;
   }
   return nPattern;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  string s;
  cin >> s;
  if ((s.find('a') != string::npos) && (s.find('b') != string::npos) && (s.find('c') != string::npos)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
x, y = gets.chomp.split.map(&:to_i)

color, direction = 0, -1
if [x, y] != [0, 0]
    rc, sq = {x:0, y:0, w:1, h:1}, nil
    while true
        color, direction = (color + 1) % 3, direction = (direction + 1) % 4
        case direction
        when 0
            sq = {x:rc[:x] + rc[:w], y:rc[:y], w:rc[:h], h:rc[:h]}
            rc = {x:rc[:x], y:rc[:y], w:rc[:w] + sq[:w], h:rc[:h]}
        when 1
            sq = {x:rc[:x], y:rc[:y] + rc[:h], w:rc[:w], h:rc[:w]}
            rc = {x:rc[:x], y:rc[:y], w:rc[:w], h:rc[:h] + sq[:h]}
        when 2
            sq = {x:rc[:x] - rc[:h], y:rc[:y], w:rc[:h], h:rc[:h]}
            rc = {x:sq[:x], y:sq[:y], w:sq[:w] + rc[:w], h:sq[:h]}
        when 3
            sq = {x:rc[:x], y:rc[:y] - rc[:w], w:rc[:w], h:rc[:w]}
            rc = {x:sq[:x], y:sq[:y], w:sq[:w], h:sq[:h] + rc[:h]}
        end
        break if x.between?(sq[:x], sq[:x] + sq[:w] - 1) && y.between?(sq[:y], sq[:y] + sq[:h] - 1)
    end
end
puts color + 1


Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()
 
  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)
 
 
using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;
 
template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}
 
template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}
 
template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}
 
template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}
 
int main() {
  int n;
  cin >> n;
  ll ans = 0;
  orep(i,n) {
    if(i%3 != 0 and i%5 != 0) ans +=i;
  }
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
typedef pair<double, string> P;

bool solve(){
	int n;
	string name;
	int p, a, b, c, d, e, f, s, m;	//Koko wo double ni suruto WA.
	P data[50];
	
	cin >> n;
	if( n == 0 ) return false;
	for( int i = 0; i < n; i++ ){
		char buf[25];
		name = buf;
		cin >> name >> p >> a >> b >> c >> d >> e >> f >> s >> m;
		double income = s * f * m - p;
		double timer = a + b + c + m * (d + e);
		double effect = income / timer;
		data[i].first = -effect;	//Swap Order Technic.
		data[i].second = name;
	}
	sort(data, data + n);
	
	for( int i = 0; i < n; i++ ){
		cout << data[i].second << endl;
	}
}

int main(){
	while(1){
		if( !solve() )
			break;
		else
			cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

string S, T, U;
int A, B;

int main() {
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S) {
        A--;
    } else {
        B--;
    }
    printf("%d %d\n", A, B);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(){
    int n;
    cin >> n;
    vector<int> v(n), p(n), q(n);
    for (int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    for (int i = 0; i < n; i++){
        cin >> q.at(i);
    }
    for(int i = 0; i < n; i++){
        v[i] = i + 1;
    }
    map<vector<int>, int> mp;
    do{
        mp[v] = mp.size();
    } while (next_permutation(v.begin(), v.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
}


Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}

int main(){
  ll n,k;
  cin>>n>>k;
  set_frac(500005);
  if(k>=n){
    cout<<nCr(n+n-1,n)<<endl;
    return 0;
  }
  vector<ll> P;
  P.push_back(1);
  P.push_back(nCr(n,2)*2%mod);
  P.push_back((P[0]+P[1]+nCr(n,2)*nCr(n-1,2))%mod);
  for(ll i=3;i<n;i++){
    P.push_back((P[i-1]+nCr(n,i)*nCr(n-1,i))%mod);
  }
  cout<<P[k]<<endl;
}


Measured memory_bytes: 12252
MOD = 10 ** 9 + 7


def solve(k, s):
    res = 0
    factorial = [1] * (2 * 10 ** 6)
    factorial_inv = [1] * (2 * 10 ** 6)
    for i in range(1, 2 * 10 ** 6):
        factorial[i] = factorial[i - 1] * i % MOD
    factorial_inv[-1] = pow(factorial[-1], MOD - 2, MOD)
    for i in range(2 * 10 ** 6 - 1, 0, -1):
        factorial_inv[i - 1] = factorial_inv[i] * i % MOD
    # print(factorial[:5])
    # print(factorial_inv[:5])
    for i in range(k + 1):
        left = k - i + len(s) - 1
        right = len(s) - 1
        ncr = (factorial[left] * factorial_inv[right] * factorial_inv[left - right]) % MOD
        add = (ncr * pow(25, k - i, MOD) * pow(26, i, MOD)) % MOD
        res += add
        res %= MOD
    # print(res)
    return res


def main():
    k = int(input())
    s = input()
    res = solve(k, s)
    print(res)


def test():
    assert solve(1, "abc") == 25 + 25 + 25 + 26
    assert solve(5, "oof") == 575111451
    assert solve(37564, "whydidyoudesertme") == 318008117


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 166796
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
int main() {

	int a, b, c; 
	cin >> a >> b >> c;
	if (a+b>=c) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,k;
  cin>>n;
  cin>>k;
  int x[n];
  REP(i,n){
    cin>>x[i];
  }
  int ans=0;
  REP(i,n){
    ans += 2*min(x[i],k-x[i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=2e5+5;
ll n,q;
vector<ll> g[N];
int visited[N];

ll v[N];
void solve()
{
	string s,t;
	cin>>s>>t;
	int l1=s.size();
	int l2=t.size();
	vector<ll> v[26];
	ll in[26];
	memset(in,0,sizeof(in));
	ll i,j;
	rep(i,0,l1){
		v[s[i]-'a'].pb(i);	
	}
	ll f=0;
	rep(i,0,l2){
		if(v[t[i]-'a'].size()==0){
			//cout<<t[i]-'a'<<" ";
			cout<<-1;
			return ;
		}	
	}
	ll ans=0,pre=-1;
	ll c=0;
	rep(i,0,l2){
		ll cur=t[i]-'a';
		ll tmp=upper_bound(v[cur].begin(),v[cur].end(),pre)-v[cur].begin();
		if(tmp==v[cur].size()){
			tmp=0;
			c++;
		}
		pre=v[cur][tmp];
	}
	ans=c*l1+pre+1;
	cout<<ans<<" ";
}

 
int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 6728
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=0
a=sum(t)
c=4*s[1]
a=a/c
b=0
for i in range(s[0]):
  if a<=t[i]:
    b=b+1
if b>=s[1]:
  print('Yes')
else:
  print('No')

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

public class Main {
	
	static int N;
	static int K;
	static int min = 100001;
	static int[] a;
	static boolean[][] dp;
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		N = sc.nextInt();
		K = sc.nextInt();
		a = new int[N];
		for(int i = 0; i < N; i++){
			a[i] = sc.nextInt();
			min = Math.min(min, a[i]);
		}
		
		dp = new boolean[K+1][2];
		
		for(int k = 0; k <= K; k++){
			if(k < min){
				dp[k][0] = false;
				dp[k][1] = false;
			}else{
				for(int aa : a){
					if(k-aa >= 0){
						if(!dp[k-aa][0]) dp[k][1] = true;
						if(!dp[k-aa][1]) dp[k][0] = true;
					}
				}
			}
		}
		
		System.out.println((dp[K][0]) ? "First" : "Second");
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 27092
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define llint long long
#define mod 1000000007
#define inf 1e18

using namespace std;
typedef pair<double, llint> P;
typedef pair<llint, P> E;

llint n;
llint a, b, c, d;
llint dp[1005][1005];

const int FACT_MAX = 2005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> n;
	cin >> a >> b >> c >> d;
	
	dp[a-1][0] = 1;
	for(int i = a-1; i < b; i++){
		for(int j = 0; j <= n; j++){
			dp[i+1][j] += dp[i][j],  dp[i+1][j] %= mod;
			llint mul = 1;
			for(int k = 1; k <= d && j+k*(i+1) <= n; k++){
				mul *= comb(n-j-(k-1)*(i+1), i+1), mul %= mod;
				if(k >= c){
					(dp[i+1][j+k*(i+1)] += dp[i][j] * mul % mod * fact_inv[k] % mod) %= mod;
				}
			}
		}
	}
	
	cout << dp[b][n] << endl;

	return 0;
}

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

int main(){
    int N,K,Q,i,A;
    cin>>N>>K>>Q;
    vector<int> point(N);

    for(i=0;i<Q;i++){
        cin>>A;
        point[A-1]+=1;
    }

    for(i=0;i<N;i++){
        if(K+point[i]-Q>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1152
def canMakeNumber(k, s):
    k = str(k).zfill(3)
    dic = {0: False, 1: False, 2: False}
    rep = False
    for t in s:
        if dic[0] is False:
            if t == k[0]:
                dic[0] = True
        else:
            if dic[1] is False:
                if t == k[1]:
                    dic[1] = True
            else:
                if dic[2] is False:
                    if t == k[2]:
                        dic[2] = True
                else:
                    continue
    if dic[0] == dic[1] == dic[2] == True:
        rep = True
    return rep


N = int(input())
S = input()
ans = 0
for i in range(0, 1000):
    if canMakeNumber(i, str(S)):
        ans += 1
print(ans)


Measured memory_bytes: 41308
s = int(input())
a = [0, 0]

a.append(10 ** 9)
a.append(1)

q, r = divmod(s, 10 ** 9)
if r > 0:
    q += 1
    r -= 10 ** 9
    r *= -1

a.append(r)
a.append(q)

print(*a)

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  string str;
  map<string, int> m;
  for (auto i = 0; i != N; ++i) {
    cin >> str;
    m[str] += 1;
  }

  const auto maxcnt = max_element(m.begin(), m.end(), [](auto &p1, auto &p2) {
                        return p1.second < p2.second;
                      })->second;

  for (auto &p : m) {
    if (p.second == maxcnt) {
      cout << p.first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define N 998244353
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1000000000
 
ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);
 
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
 
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;
 
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
 
        // Update y and x
        y = x - q * y;
        x = t;
    }
 
    // Make x positive
    if (x < 0)
       x += m0;
 
    return x;
}
 
void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
bool dp[1001][1001];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    int a, b;
    cin>>a>>b;
    int j=1;
    int ans=0;
    while(j < b){
        ans++;
        j += (a-1);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[6];
    char Y[5];
    rep(i,1){
        cin >> A[i];
    }
    cin >>Y;
    rep(i,1){
        cin >> A[i+1];
    }
    //sort(A,A+3);
    cout << (Y[0]=='+' ? A[0]+A[1] : A[0]-A[1]) << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,w,n;
    cin >> h >> w >> n;
    chmax(w,h);
    cout << (n+w-1)/w << '\n';
    return 0;
}

Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)
v = gets.chomp.split.map(&:to_i)

minus_i_a = []
sum_i_a = 0
max = 0
x = (k > n ? n : k) + 1
x.times do |i_a|
  sum_i_b = 0
  minus_i_b = []
  x.times do |i_b|
    break if i_a + i_b > k || i_b + i_a > n
    sum = sum_i_a + sum_i_b - (minus_i_a + minus_i_b).sort[0...(k - i_a - i_b)].inject(:+).to_i
    max = sum > max ? sum : max

    minus_i_b << v[n - 1 - i_b] if (v[n - 1 - i_b] < 0)
    sum_i_b += v[n - 1 - i_b]
  end
  minus_i_a << v[i_a] if v[i_a].to_i < 0
  sum_i_a += v[i_a].to_i
end

p max

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

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

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

	int N, Z, W; cin >> N >> Z >> W;

	int a[10000];
	for (int i = 0;i < N;i++){
		cin >> a[i];
	}

	cout << max(abs(a[N-1]-W), abs(a[N-1]-a[N-2])) << endl;

	return 0;

}


Measured memory_bytes: 256
n = gets.to_i
as = gets.split(' ').map(&:to_i)
abs_min = 1000000000
count = 0
sum = 0
as.each do |a|
    if a <= 0
        count += 1
    end
    sum += a.abs
    abs_min = a.abs if a.abs <= abs_min
end
if  count%2 == 0
    ans = sum
elsif count%2 == 1
    ans = sum - abs_min*2
end
puts ans


Measured memory_bytes: 8580
#include<iostream>
using namespace std;
int main(){
  int a[5];
  int k;
  
  cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;

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

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }


int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	string s, t;
	cin >> n >> s >> t;
	for (int i = n; i > 0; i--)
	{
		if (s.substr(n - i,i) == t.substr(0, i))
		{
			ans = i; break;
		}
	}

	cout << n*2-ans << endl;


	return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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

int main(){

	ll n, m;cin >> n >> m;

	vector<P> v(n);
	REP(i, n)cin >> v[i].FI >> v[i].SE;
	sort(ALL(v));

	ll cou = 0;
	ll ans = 0;

	REP(i, n){
		ll tmp = min(m - cou, v[i].SE);
		ans += tmp * v[i].FI;
		cou += tmp;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

def main():
    A, B = map(int, input().split())

    if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
        print("Possible")
    else:
        print("Impossible")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;
int tax(int x, double p)
{
	return p*(100.0+x)/100;
};
int main() {
	int x, y, s;
	while(cin >> x >> y >> s && x != 0)
	{
		int max_price = 0;
		for(int i = 1; i < s; i++)
		{
			for(int j = i; j < s; j++)
			{
				if(tax(x,i)+tax(x,j) == s)
				{
					int temp = tax(y, i) + tax(y, j);
					max_price = max(max_price, temp);
				}
			}
		}
		cout << max_price << endl;
	}
}


Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] inputs = line.split(" ");
        
        String s1 = inputs[0];
        String s2 = inputs[1];
        String s3 = inputs[2];
        String c1 = s1.substring(0, 1);
        String c2 = s2.substring(0, 1);
        String c3 = s3.substring(0, 1);
        String S1 = c1.toUpperCase();
        String S2 = c2.toUpperCase();
        String S3 = c3.toUpperCase();
        
        System.out.println(S1+S2+S3);
    }
}


Measured memory_bytes: 21204