akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static int gcd(int x, int y){
		if(y == 0){
			return x;
		}else{
			return gcd(y, x % y);
		}
	}


	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		while (true) {
			final int p = sc.nextInt();
			final int n = sc.nextInt();
			
			if(p == 0 && n == 0){
				break;
			}
			
			final double ans = Math.sqrt(p);
			double less = Double.MIN_VALUE;
			double more = Double.MAX_VALUE;
			int less_u = 1, less_v = 1, more_x = 1, more_y = 1;
			
			//bottom
			for(int b = 1; b <= n; b++){
				
				//top
				int high_a = n + 1;
				int low_a  = 1;
				while(high_a - low_a > 1){
					
					int mid_a = (high_a + low_a) / 2;
					
					double raito = (double) (mid_a) / b;
					
					if(ans < raito){
						high_a = mid_a;
					}else if(ans > raito){
						low_a = mid_a;
					}else{
						high_a = low_a = mid_a;
						break;
					}
				}

				double low_raito = (double) (low_a) / b;
				double high_raito = (double) (high_a) / b;

				//System.out.println(b + " " + high_a + " " + low_a);
				
				if(low_raito <= ans && low_raito >= less){
					final int gcd = gcd(low_a, b);
					
					//System.out.println("updated less " + b + " : " + less + " => " + low_raito);
					
					less   = low_raito;
					less_u = low_a / gcd;
					less_v = b / gcd;
				}
				
				if(high_a <= n && high_raito >= ans && high_raito <= more){
					final int gcd = gcd(high_a, b);
					
					///System.out.println("updated more " + b +" : " + more  + " => " + high_raito);
					
					more   = high_raito;
					more_x = high_a / gcd;
					more_y = b / gcd;
				}
				//System.out.println(more + " " + less);
			}
			
			System.out.println(more_x + "/" + more_y + " " + less_u + "/" + less_v);
			
		}
	}

}

Measured memory_bytes: 21204
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a).most_common()
cnt = 0
for i, cc in enumerate(c):
    if cc[0] < cc[1]:
        cnt += cc[1] - cc[0]
    elif cc[0] > cc[1]:
        cnt += cc[1]
print(cnt)


Measured memory_bytes: 21228
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

A, B, K = LI()

nums = []
for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        nums.append(i)

print(nums[-K])


Measured memory_bytes: 66540
n=int(input())
lst=[]
for i in range(n):
  s,t=input().split()
  t=int(t)
  lst.append([s,t])
x=input()
a=0
for i in range(n):
  if lst[i][0]==x:
    idx=i
    break
for j in range(idx+1,n):
  a+=lst[j][1]
print(a)
  

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int one,k;
    for(int i=0;i<s.size();i++){
        if(s[i]!='1'){
            one=i;
            break;
        }
    }
    cin>>k;
    if(one>=k){
        cout<<"1"<<endl;
    }
    else{
        cout<<s[one]<<endl;
    }
    return(0);
}

Measured memory_bytes: 3604
#include <stdio.h>
int main(void) {
	int d, sum, i;
	while(scanf("%d",&d) != EOF ) {
		sum = 0;
		for( i = 1; i < 600 / d; i++ ) {
			sum +=( ( i * d )*( i * d ) * d ) ;
		}
		printf("%d\n",sum);
	}
	return(0);
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#if defined(_MSC_VER)||__cplusplus > 199711L
#define AUTO(r,v) auto r = (v)
#else
#define AUTO(r,v) typeof(v) r = (v)
#endif
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(AUTO(it,(c).begin());it != (c).end();)
#define LL long long
#define int LL
#define inf  (int)(1LL << 50)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lowb lower_bound
#define upb upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#define cx() real()
#define cy() imag()
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin) { T c; REP(i, n) { cin >> c; a.push_back(c); } }
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>; using psi = pair<string, int>; using vvi = vector<vi>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------



signed main()
{
	QUICK_CIN;
	//debug_input;
	string a, b;

	cin >> a >> b;

	int aa, bb;

	aa = a.size();
	bb = b.size();



	cout << (aa > bb ? "GREATER" : (aa < bb ? "LESS" : (a == b ? "EQUAL" : (a > b) ? "GREATER" : "LESS"))) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main(void){
    long long n, a[200020];
    long long sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    
    long long min = 1e18, k = sum;
    for (int i = 1; i < n; i++) {
        sum -= a[i - 1];
        if (min > abs(2 * sum - k)) min = abs(2 * sum - k);
    }
    cout << min << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  
  int i, j;
  int n, u, k, t[100];
  int v[100][100];
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      v[i][j] = 0;
    }
  }
  
  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);

    for(j = 0; j < k; j++){
      scanf("%d", &t[j]);
      t[j]--;
    }
    
    for(j = 0; j < k; j++){
      v[i][t[j]] = 1;
    }
    
  }
  
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n - 1; j++){
      printf("%d ", v[i][j]);
    }
    printf("%d\n", v[i][j]);
  }
  
  return 0;
}

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

int main() {
  char a, b; cin >>a >>b;
  bool x, y;
  if (a == 'H') x = true;
  else x = false;
  if (b == 'H') y = true;
  else y = false;
  char ans;
  
  if (x&&y) ans = 'H';
  else if (x||y) ans = 'D';
  else ans = 'H';
  
  cout <<ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	char s[4];
	int i,all=700;
	for(i=1;i<=3;i++){
		cin>>s[i];
		if(s[i]=='o'){
			all=all+100;
		}
	}
	cout<<all<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N, H = map(int, readline().rstrip().split())
    A, B = [], []
    for _ in range(N):
        a, b = map(int, readline().rstrip().split())
        A.append(a)
        B.append(b)
    
    a_max = max(A)
    B.sort(reverse=True)
    damage = 0
    cost = 0
    for b in B:
        if b < a_max:
            break
        damage += b
        cost += 1
        if damage >= H:
            break
    if damage < H:
        cost += -(-(H - damage) // a_max)
    
    print(cost)
    return

if __name__ == '__main__':
    main()

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	string big, little;
	cin >> big >> little;
	int ans = 1e9;
	int max_cnt = big.size() - little.size() + 1;
	for (int i = 0; i < max_cnt; i++)
	{
		int tmp = 0;
		for (int j = 0; j < little.size(); j++) tmp += (big[i + j] != little[j]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3552
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c; cin >> a >> b>> c;
    vi d;
    d.pb(a);d.pb(b); d.pb(c);
    sort(all(d));
    int ans = 0;
    if ((d[2]-d[1])%2 ==0 && (d[2]-d[0])%2 ==0) {
        ans = (d[2]-d[1])/2+(d[2]-d[0])/2;
    } else if (((d[2]-d[1])%2 ==0 && (d[2]-d[0])%2 ==1) || ((d[2]-d[1])%2 == 1 && (d[2]-d[0])%2 == 0)) {
         ans = (d[2]-d[1])/2+(d[2]-d[0])/2 + 2;
    } else {
        ans = (d[2]-d[1])/2+(d[2]-d[0])/2 +1;
    }
    ct(ans);
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)

// デバッグ

#ifdef DEBUG
#include <cassert>
#define my_assert(x) assert(x)
#else
#define my_assert(x)
#define assert(x)
#endif

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

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // 浮動小数の表示の精度
    cout << setprecision(15);

    string s;
    cin >> s;
    map<string, int> m = {
        {"SSS", 0},
        {"RSS", 1},
        {"SRS", 1},
        {"SSR", 1},
        {"RSR", 1},
        {"RRS", 2},
        {"SRR", 2},
        {"RRR", 3}
    };
    cout << m[s] << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
using Graph = vector<vector<ll> >;
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; }
const ll INF = 1e18;


//入力
ll n;

ll a[310][310];

//Warshall-floyd
ll dp[310][310];//dpテーブルには辺がないところにはINF、i==jには０を入れておく
void warshallfloyd(){
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }
}

ll mincost[310];
bool used[310];

ll prim(){
    rep(i,n){
        mincost[i]=INF;
        used[i]=false;
    }
    mincost[0]=0;
    ll res = 0;
    while(1){
        ll v = -1;
        //全域木からのコストが最小になる頂点を探す
        rep(i,n){
            if(!used[i]&&(v==-1||mincost[i]<mincost[v])) v=i;
        }
        if(v==-1)break;
        used[v]=true;
        res += mincost[v];
        rep(i,n){
            chmin(mincost[i],a[v][i]);
        }
    }
    return res;
}


int main(){
    cin >> n;
    rep(i,310)rep(j,310){
        dp[i][j]=INF;
    }    
    rep(i,310)dp[i][i]=0;
    rep(i,n)rep(j,n){
        cin>>a[i][j];
        dp[i][j]=a[i][j];
    }
    warshallfloyd();
    rep(i,n)rep(j,n)if(a[i][j]!=dp[i][j]){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            ll res = INF;
            rep(k,n){
                if(k==i||k==j)continue;
                chmin(res,a[j][k]+a[k][i]);
            }
            if(res>a[i][j])ans+=a[i][j];
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 5096
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

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

    int ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if (
                    l[i] + l[j] > l[k]
                    && l[j] + l[k] > l[i]
                    && l[k] + l[i] > l[j]
                ) {
                    ans += 1;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S;
  cin>>S;
  sort(ALL(S));
  if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
    int H, W, no[100][100] = {};
    char S[100][100];
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        int c = 0;
        for (int j = 0; j < W; j++)
        {
            cin >> S[i][j];
            if (S[i][j] == '.')c++;
        }
        if (c == W) {
            for (int k = 0; k < W; k++)
            {
                no[i][k] = 1;
            }
        }
    }
    for (int i = 0; i < W; i++)
    {
        int c = 0;
        for (int j = 0; j < H; j++)
        {
            if (S[j][i] == '.')c++;
        }
        if (c == H) {
            for (int k = 0; k < H; k++)
            {
                no[k][i] = 1;
            }
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (no[i][j] == 0)cout << S[i][j];
        }
        int c = 0;
        for (int j = 0; j < W; j++)
        {
            if (no[i][j] == 1)c++;
        }
        if (c != W)cout << endl;
    }
}

Measured memory_bytes: 256
use std::collections::VecDeque;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let s = sc
        .read::<String>()
        .chars()
        .map(|c| c as usize - 'A' as usize)
        .collect::<Vec<_>>();

    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut removed = vec![false; n];
    let mut count = vec![vec![0; 2]; n];
    let mut q = VecDeque::new();
    for i in 0..n {
        for &next in graph[i].iter() {
            count[i][s[next]] += 1;
        }
        if count[i][0] == 0 || count[i][1] == 0 {
            q.push_back(i);
        }
    }

    while let Some(remove) = q.pop_front() {
        removed[remove] = true;
        for &next in graph[remove].iter() {
            if removed[next] {
                continue;
            }
            count[next][s[remove]] -= 1;
            if count[next][s[remove]] == 0 {
                q.push_back(next);
            }
        }
    }

    if removed.contains(&false) {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, x, a, b, c, k;
	string s;
	//ll ans = 0;
	//float ans = 0;
	string ans;

	cin >> k >> s;

	if (s.size() <= k) {
		ans = s;
	}
	else {
		ans = s.substr(0, k);
		ans += "...";
	}
	cout << ans << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_b();

	return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

int n;

int main(){
	scanf("%d",&n); printf("%d\n",(n-2)*180);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int n, a, b; cin >> n >> a >> b;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
    }
    sort(all(p));
    int x = lower_bound(all(p), a + 1) - p.begin();
    int y = lower_bound(all(p), b + 1) - p.begin();
    cout << min({x - 0, y - x, n - y}) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,ans=0,lst=0,len=0,f=0;
char s[1000010];
int main(){
	scanf("%s",s);
	n=strlen(s);
	for(register int i=0;i<n;i++){
		len++;
		if(s[i]!=s[i+1]){
			if(len%3==2){
				f^=1;
				if(!f)ans+=(2*(lst-1)/3)+(2*(len-1)/3)+3;
				lst=len;
			}
			if(len%3==1){
				if(f)ans+=(2*(lst-1)/3)+1;
				f=0;
				ans+=(2*len/3)+1;
			}
			if(len%3==0){
				ans+=2*len/3;
			}
			len=0;
		}
	}
	if(f)ans+=(2*(lst-1)/3)+1;
	printf("%d",ans);
	return 0;
}

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

ll cnt;
void solve(ll n,ll p,ll c){
	if(!n){cnt++;return;}
	if(c>=4)return;
	for(ll i=p;i*i<=n;i++)
		solve(n-i*i,i,c+1);
}
int main() {
	ll n;
	while(scanf("%lld",&n),n){
		cnt=0;
		solve(n,1,0);
		printf("%lld\n",cnt);
	}
}

Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int N,M;
    int a[214514];
    int b[214514];
    int c[214514]={};
    bool ex=0;
    cin >> N >> M;
    REP(i,M){
        cin >> a[i] >>b[i];
        if(a[i]==1){c[b[i]]+=1;}
        if(b[i]==N){c[a[i]]+=2;}
    }
    REP(i,N){if(c[i]==3){ex=1;}}
    if(ex==1){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
    return 0;
}

Measured memory_bytes: 2816
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("a");
        list.add("e");
        list.add("i");
        list.add("o");
        list.add("u");

        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();

        if (list.contains(str)) {
            System.out.println("vowel");
        } else {
            System.out.println("consonant");
        }

        scanner.close();
    }
}

Measured memory_bytes: 23380
n,m =map(int,input().split())
l= [11]*n
for _ in range(m):
    s,c=map(int,input().split())
    if l[s-1] != str(c) and l[s-1] != 11:
        print(-1)
        exit()
    else:
        l[s-1] = str(c)
for index,i in enumerate(l):
    if i == 11:
        if n>1 and (index==0):
            l[index] = '1'
        else:
            l[index] = '0'
if n>=2:
    if l[0] == '0' or l[0]==l[1]=='0':
        print(-1)
        exit()
print(''.join(l))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll gcd(ll x,ll y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
void solve(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll lcm=c*d/gcd(c,d);
    a--;
    ll lar=b-b/c-b/d+b/lcm;
    ll sma=a-a/c-a/d+a/lcm;
    print(lar-sma);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
	public static void main(String[] args){
		
		Scanner inputTime = new Scanner(System.in);
		int input = inputTime.nextInt();
		int h = input / 3600;
		int amari = input % 3600;
		int m = amari / 60;
		int s = amari % 60;
		
		System.out.println(h + ":" + m + ":" + s);
		
	}
}

Measured memory_bytes: 17324
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct team {
	int m = 0, t, s = 0;
	vector<int> p;
	bool operator < (team a) const {
		return s == a.s ? m == a.m ? t > a.t : m < a.m : s > a.s;
	}
};

int main() {
	for (int M, T, P, R; (M = in(), T = in(), P = in(), R = in(), M);) {
		vector<team> a(T);
		{
			int i = 1;
			for (team &o: a) {
				o.t = i++;
				o.p.resize(P);
			}
		}
		while (R--) {
			int m = in(), t = in() - 1, p = in() - 1;
			team &o = a[t];
			if (in())
				o.p[p] += 20;
			else {
				o.m += o.p[p] + m;
				o.s++;
			}
		}
		sort(a.begin(), a.end());
		for (int i = 0; i < T; i++) {
			if (i)
				out(a[i].s == a[i - 1].s && a[i].m == a[i - 1].m ? '=' : ',');
			out(a[i].t);
		}
		outl();
	}
}


Measured memory_bytes: 2576
#include <iostream>
#include <cstdio>
#include <utility>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int a, b;
	cin >> a >> b;
	if(a < b) swap(a, b);
	int m = b;
	while(m) {
		int t = a / m;
		swap(a -= t * m, m);
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main() {
	long long N, a[1000000], d = 0,ans1=0,ans2=0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 2; i <= N; i++) {
		if (a[i] > a[i - 1]) {
			d++;
			if (d >= ans1) {
				ans1 = d;
			}
		}
		if (a[i] < a[i - 1]) {
			d = 0;
		}
	}
		d = 0;
		for (int i = 2; i <= N; i++) {
			if (a[i] < a[i - 1]) {
				d++;
				if (d >= ans2) {
					ans2 = d;
				}
			}
			if (a[i] > a[i - 1]) {
				d = 0;
			}
		}
		cout << max(ans1, ans2) + 1<< endl;
	return 0;
}

Measured memory_bytes: 3832
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
        int a,b,c,tot,sum,num = 0;
        cin>>a>>b>>c>>tot;
        for(int i = 0;i <= a;i++){
        	for(int j = 0;j <= b;j++){
        		for(int t = 0;t <= c;t++){ 
                   sum = 500*i + 100*j + 50*t;
        	{	if(sum == tot)
        				num++;
        			
        			}
              }
            }
		}printf("%d",num);
}

Measured memory_bytes: 256
n = int(input())
lx = 0
ly = 0
lt = 0
for _ in range(n):
    t, x, y = map(int, input().split())
    dt = t - lt
    dx = abs(x - lx)
    dy = abs(y - ly)
    dxy = dx + dy
    if dxy > dt:
        print('No')
        exit()
    elif (dt - dxy) % 2 == 1:
        print('No')
        exit()
    lx = x
    ly = y
    lt = t
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N, M, Q;
  cin >> N >> M >> Q;

  //boost::multi_array<int, 2> mat(boost::extents[N + 1][N + 1]);
  int mat[N + 1][N + 1];
  memset(mat, 0, sizeof(mat));

  FOR(i, M) {
    int L, R;
    cin >> L >> R;
    mat[L][R]++;
  }

  FOR(i, N + 1) {
    FOR(j, N) { mat[i][j + 1] += mat[i][j]; }
  }

  for (int i = N; i > 0; i--) {
    FOR(j, N + 1) { mat[i - 1][j] += mat[i][j]; }
  }

  while (Q--) {
    int p, q;
    cin >> p >> q;
    cout << mat[p][q] << "\n";
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	cout << (n * (n-1)) / 2 + (m * (m-1)) / 2 << "\n";


	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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


int main() {
	int a, b;
	cin >> a >> b;
	int ma=INT_MIN;
	ma = max(ma, a + b);
	ma = max(ma, a * b);
	ma = max(ma, a - b);
	cout << ma;
}

Measured memory_bytes: 256
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,MOD=1e9+7;

bool f(int m,int y)
{
 if(m>=1 && m<=12)
 return 1;
 else
 return 0;
}

void solve()
{
 string s;
 cin>>s;

 int mm=(s[0]-48)*10+(s[1]-48);
 int yy=(s[2]-48)*10+(s[3]-48);

 //cout<<mm<<" "<<yy<<"\n";

 int a=0,b=0;

 if(f(mm,yy))
 a=1;
 if(f(yy,mm))
 b=1;

 if(a && b)
 cout<<"AMBIGUOUS";
 else if(a)
 cout<<"MMYY";
 else if(b)
 cout<<"YYMM";
 else
 cout<<"NA";

}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque

n = int(input())
a = [deque(map(int, sys.stdin.readline().rstrip().split())) for _ in range(n)]

current = []

for i in range(n):
    target = a[i][0] -1
    if a[target][0] -1 == i and i < target:
        current.append([i, target])

day = 0
zc = 0
while True:
    popped = 0
    plist = set()
    zeros = 0
    tc = []
    for i in current:
        a[i[0]].popleft()
        a[i[1]].popleft()
        if len(a[i[0]]) > 0:
            plist.add(i[0])
        else:
            zc += 1
        if len(a[i[1]]) > 0:
            plist.add(i[1])
        else:
            zc += 1
    for i in plist:
        target = a[i][0] -1
        if a[target][0] -1 == i:
            if not target in plist or i < target:
                tc.append([i, target])
    day += 1
    if len(tc) == 0:
        break
    current = tc

if zc != n:
    day = -1

print(day)


Measured memory_bytes: 73820
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    string s[4] = { "dreamer","eraser","dream","erase"};
    string ss;
    cin >> ss;
    while(ss.length() > 0){
        if(ss.length() < 5) {
            cout << "NO"<<endl;return 0;
        }
        ll suc = false;
        rp(i,4){
            if(s[i].length() <= ss.length())
                if(s[i] == ss.substr(ss.length()-s[i].length(),s[i].length()))
                    {
                        ss = ss.substr(0,ss.length()-s[i].length());
                        suc = true;
                        break;
                    }
        }
        if(!suc) {
            cout << "NO"<<endl;return 0;
        }
    }
    cout << "YES"<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 512
#include<stdio.h>
 
#define MAX 101
#define inf 1000000000
#define NIL -1000000000
#define WHITE 0
#define BLACK 1
 
int n;
int d[MAX],pi[MAX],color[MAX],G[MAX][MAX];
 
dijkstra(){
  int v,i,u,mincost;
 
  for(v=0;v<n;v++){
    d[v]=inf;
    pi[v]=NIL;
    color[v]=WHITE;
  }
 
  d[0]=0;
 
  while(1){
    mincost=inf;
 
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
    mincost=d[i];
    u=i;
      }
    }
    if(mincost==inf) break;
 
    color[u]=BLACK;
 
    for(v=0;v<n;v++){
      if(G[u][v]!=-1){
    if(color[v]!=BLACK && d[u]+G[u][v]<d[v]){
      pi[v]=u;
      d[v]=d[u]+G[u][v];
    }
      }
    }
  }
}
 
int main(){
  int i,j,u,k,v,c;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=inf;
    }
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      G[u][v]=c;
    }
  }
 
  dijkstra();
 
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
 
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int sum_min=100;
  int sum_A=0;
  int sum_B=0;
  int A=0,B=0;
  for(int x=1; x<N; x++){
    A=x;
    B=N-x;
    sum_A=0;
    sum_B=0;
    //cout<<A<<" "<<B<<endl;
    for(int i=1; A+B>0; i++){
      sum_A+=A%10;
      A/=10;
      sum_B+=B%10;
      B/=10;
      //cout<<A<<" "<<B<<endl;
      //cout<<sum_A<<" "<<sum_B<<endl;
    }
    if(sum_A+sum_B<sum_min){
      sum_min=sum_A+sum_B;
      //cout<<sum_min<<endl;
    }
  }
  
  cout<<sum_min<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=998244353;

#define pb push_back
#define mp make_pair


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

    ll t,n,k;
    cin>>k>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end());
    ll diff=a[0]+k-a[n-1];
    for(ll i=1;i<n;i++){
        if(a[i]-a[i-1]>diff){
            diff=a[i]-a[i-1];
        }
    }
    cout<<k-diff;

    return 0;
}




Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int r, c, i, j;
    int d[101][101]={};
    
    scanf("%d %d",&r,&c);
    
    for(i=0; i<r; i++){
        for(j=0;j<c;j++){
            scanf("%d",&d[i][j]);
            d[i][c]+=d[i][j];
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c+1;j++){
            d[r][j]+= d[i][j];
        }
    }
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
            printf("%d",d[i][j]);
            if(j<c){
                printf(" ");
            }
            else{
                printf("\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    auto s=n%100;
    n/=100;
    int ym,my;
    if(s<=12 && s>=1)ym=1;
    else ym=0;
    if(n<=12 && n>=1)my=1;
    else my=0;
    if(ym && my){
        cout<<"AMBIGUOUS"<<endl;
    }else if(ym){
        cout<<"YYMM"<<endl;
    }else if(my){
        cout<<"MMYY"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a==1 && b==2)
        cout<<"3\n";
    else if(a==2 && b==1)
        cout<<"3\n";
    else if((a==1 && b==3) || (a==3 && b==1))
        cout<<"2\n";
    else
        cout<<"1\n";
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

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


def f(l, m):
    return sum([m % x for x in l])


def lcm(x, y):
    return (x * y) // gcd(x, y)


a = reduce(lcm, A)
print(f(A, a-1))

Measured memory_bytes: 67160
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int c = a;
  int d = 1;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < 100; ++i) {
    if (c < b) {
      c += a-1;
      d++;
    }
    else break;
  }
  cout << d << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
import marshal

class Graph:
    def __init__(self, n, dictated=False, decrement=True, destroy=False, edge=[]):
        self.n = n
        self.dictated = dictated
        self.decrement = decrement
        self.destroy = destroy
        self.edge = [set() for _ in range(self.n)]
        self.parent = [-1]*self.n
        self.info = [-1]*self.n
        for x, y in edge:
            self.add_edge(x,y)

    def add_edge(self, x, y):
        if self.decrement:
            x -= 1
            y -= 1
        self.edge[x].add(y)
        if self.dictated == False:
            self.edge[y].add(x)

    def add_adjacent_list(self, i, adjacent_list):
        if self.decrement:
            self.edge[i] = set(map(lambda x:x-1, adjacent_list))
        else:
            self.edge[i] = set(adjacent_list)

    def bfs(self, start, goal=-1, time=0, save=False):
        """
        :param start: スタート地点
        :param goal: ゴール地点
        :param save: True = 前回の探索結果を保持する
        :return: （ループがあっても）最短距離。存在しなければ -1
        """
        if self.decrement:
            start -= 1
            goal -= 1
        p, t = start, time
        for q in self.edge[p]:
            if H[q] >= H[p]:
                return 0
        return 1

    def connection_counter(self):
        """
        :return: 連結成分の個数。有効グラフではあまり意味がない。
        """
        cnt = 0
        for start in range(self.n):
            cnt += self.bfs(start + self.decrement, save=False)
        return cnt


N, M = map(int, input().split())
H = list(map(int, input().split()))

graph = Graph(N,dictated=False,decrement=True,destroy=False)

for _ in range(M):
    a, b = map(int, input().split())
    graph.add_edge(a,b)

print(graph.connection_counter())

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

// 1. 現在地から次の目的地までの距離を測る
// 	a. 間に合わない
// 		NO
// 	b. ピッタリ
// 		YES
// 	c. 余裕がある
// 		i. 必要な歩数 + 偶数
// 			YES
// 		ii. 必要な歩数 + 奇数
// 			NO

type Coordinate struct {
	x, y int
}

func getDistance(c0, c1 Coordinate) int {
	d := math.Abs(float64(c1.x - c0.x)) + math.Abs(float64(c1.y - c0.y))
	return int(d)
}

func canTravel(t, d int) (res bool) {
	if dif := t-d; dif < 0 {
		res = false
	} else if dif == 0 {
		res = true
	} else if dif > 0 {
		if dif % 2 == 0 {
			res = true
		} else {
			res = false
		}
	}
	return
}

func main() {
	var n, t0, t1 int
	var c0, c1 Coordinate

	fmt.Scan(&n, &t1, &c1.x, &c1.y)

	for i := 0; i < n-1; i++ {
		if canTravel(t1-t0, getDistance(c0, c1)) {
			t0 = t1
			c0 = c1
			fmt.Scan(&t1, &c1.x, &c1.y)
		} else {
			fmt.Println("No")
			return
		}
	}

	if canTravel(t1-t0, getDistance(c0, c1)) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	return
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for (int q = 0; q < w - 1; q++) {
        string a, b;
        for (int i = h - 1; i >= 0; i--) {
            a.push_back(c[i][q]);
            b.push_back(c[i][q + 1]);
        }
        vector<vector<int>> d(h + 1, vector<int>(h + 1));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < h; j++) {
                d[i + 1][j + 1] = (a[h - 1 - i] == b[h - 1 - j]) + d[i][j];
            }
        }
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= h; j++) {
                d[i][j] += min(d[i - 1][j], d[i][j - 1]);
            }
        }
        ans += d[h][h];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > F(N + 1);
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= N && i * i + j * j <= N; j++) {
      for(int k = 1; k <= N && i * i + j * j + k * k + i * j + j * k + k * i <= N; k++) {
        F[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for(int i = 1; i <= N; i++) cout << F[i] << "\n";
}

Measured memory_bytes: 3616
import math

(a, b, c, k) = [int(s) for s in input().split()]

s = [(a, 1), (b, 0), (c, -1)]

ans = 0
for (i, v) in s:
    if k - i < 0:
        i = k
    ans += i * v

    k = k - i

    if k == 0:
        break

print(ans)



Measured memory_bytes: 9124
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var S = Console.ReadLine();
        var answer = 0;
        var count = 0;
        foreach (var l in S){
            if (!(l == 'A' || l == 'C' || l == 'G' || l == 'T')){
                if (answer < count) answer = count;
                count = 0;
                continue;}
            count++;}
        if (answer < count) answer = count;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 25940