akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
namespace remoon {
    #define re register
    #define de double
    #define le long double
    #define ri register int
    #define ll long long
    #define sh short
    #define ui unsiged int
    #define ull unsigned long long
    #define pii pair<int, int>
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define tpr template <typename ra>
    #define rep(iu, st, ed) for(ri iu = st; iu <= ed; iu ++)
    #define drep(iu, ed, st) for(ri iu = ed; iu >= st; iu --)	
    #define gc getchar
    inline int read() {
        int p = 0, w = 1; char c = gc();
        while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
        while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
        return p * w;
    }
    int wr[50], rw;
    #define pc(iw) putchar(iw)
    tpr inline void write(ra o, char c = '\n') {
        if(!o) pc('0');
        if(o < 0) o = -o, pc('-');
        while(o) wr[++ rw] = o % 10, o /= 10;
        while(rw) pc(wr[rw --] + '0');
        pc(c);
    }
    tpr inline void cmin(ra &a, ra b) { if(a > b) a = b; }
    tpr inline void cmax(ra &a, ra b) { if(a < b) a = b; } 
    tpr inline bool ckmin(ra &a, ra b) { return (a > b) ? a = b, 1 : 0; }
    tpr inline bool ckmax(ra &a, ra b) { return (a < b) ? a = b, 1 : 0; }
}
using namespace std;
using namespace remoon;

namespace mod_zone {
    int mod = 0;
    inline void inc(int &a, int b) { a += b; if(a >= mod) a -= mod; }
    inline void dec(int &a, int b) { a -= b; if(a < 0) a += mod; }
    inline int Inc(int a, int b) { return (a + b >= mod) ? a + b - mod : a + b; }
    inline int Dec(int a, int b) { return (a - b < 0) ? a - b + mod : a - b; }
    inline int mul(int a, int b) { return 1ll * a * b % mod; }
    inline int fp(int a, int k) {
        int ret = 1;
        for( ; k; k >>= 1, a = mul(a, a))
        if(k & 1) ret = mul(ret, a);
        return ret;
    }
}
using namespace mod_zone;

char s[200005];
int num[256];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	ll ans = 1ll * n * (n - 1) / 2 + 1;
	rep(i, 1, n) {
		ans -= num[s[i]];
		num[s[i]] ++;
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll a[5], n, b[6], m = infll, ind;

int main()
{
    cin >> n;
    for (int i = 0; i < 5; i++)
        cin >> a[i];
    sort(a, a + 5);
    m = a[0];
    cout << (n + m - 1) / m + 4 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  cout<<(n)*(n-1)/2+m*(m-1)/2<<'\n';
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main() {
	int n;
	long a[200010];
	cin >> n;
	long sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	long ans = 111111111111111;
	long cnt = 0;
	for (int i = 0;i < n - 1;i++) {
		cnt += a[i];
		ans = min(abs((sum - cnt) - cnt), ans);
	}
	cout << ans << endl;

	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1792
/* Author : bhavye9499 - Bhavye Anand Gupta */
 
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define endl "\n"
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define showArr(A,a,n) {for(int i=a; i<a+n; i++) cout << A[i] << " "; cout << endl;}
#define showPair(A,a,n) {for(int i=a; i<a+n; i++) cout << A[i].fi << " " << A[i].se << endl;}
 
const ll MOD = 1e9 + 7;
 
ll n;
double A[3030], dp[3030][3030];
 
double fun(ll i, ll j);
 
int main() {
    ios::sync_with_stdio(false);
    for(int i = 0; i < 3030; i++) {
        for(int j = 0; j < 3030; j++) {
            dp[i][j] = -1;
        }
    }
 
    cin >> n;
    for(int i = 0; i < n; i++) {
    	cin >> A[i];
    }
    
    double ans = fun(0, 0);
 
    cout << fixed << setprecision(10);
    cout << ans << endl;
}
 
double fun(ll i, ll j) {
	if(dp[i][j] != -1)
		return dp[i][j];
	if(i + j == n && i > n / 2)
		return dp[i][j] = 1;
	if(i + j == n && j > n / 2)
		return dp[i][j] = 0;
	return dp[i][j] = (A[i + j] * fun(i + 1, j)) + ((1 - A[i + j]) * fun(i, j + 1));
}

Measured memory_bytes: 72192
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

const ll MAX = 1000000, INF = 1LL << 50;

vector<ll> solve(vector<pll> &data) {
  ll n = data.size();
  vector<ll> cost(n), damage(n);
  REP(i, 0, n) cost[i] = data[i].first;
  REP(i, 0, n) damage[i] = data[i].second;

  vector<ll> dp(MAX + 1, INF);
  dp[0] = 0;
  REP(k, 0, n) REP(i, 0, MAX) {
    if(i + damage[k] <= MAX) {
      dp[i + damage[k]] = min(dp[i + damage[k]], dp[i] + cost[k]);
    }
  }
  return dp;
}

int main(void) {
  ll N, M;
  while(cin >> N, N != 0) {
    vector<ll> H(N);
    REP(i, 0, N) cin >> H[i];
    cin >> M;
    vector<pll> S, A;
    REP(i, 0, M) {
      string name, target;
      ll cost, damage;
      cin >> name >> cost >> target >> damage;
      if(target == "Single") S.push_back(pll(cost, damage));
      if(target == "All") A.push_back(pll(cost, damage));
    }

    vector<ll> acost = solve(A);

    vector<ll> scost = solve(S);
    for(ll i = MAX - 1; i >= 0; i--) scost[i] = min(scost[i], scost[i + 1]);

    ll ans = INF;
    REP(i, 0, MAX + 1) {
      ll d = acost[i];
      REP(j, 0, N) d += scost[max(H[j] - i, 0LL)];
      ans = min(ans, d);
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 18604
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	int k;
	cin >> input;
	cin >> k;
	set<string> data;
	int len = input.size();

	for (int i = 0; i < len; i++)
	{
		for (int j = 1; j <= min(5, len - i); j++)
		{
			data.insert(input.substr(i, j));
		}
	}
	int count = 0;
	for (auto out : data)
	{
		count++;

		if (count < k)
			continue;
		else
		{
			cout << out << endl;
			return;
		}
	}

	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

//vector<ll> a;

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

 // a.reserve(n);
  vector<int> a;
  a.reserve(300000);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    a[i] -= i+1;
  }

  sort(a.begin(), a.begin()+n);
  long long  b;
  if(n%2 == 0) {
    b = a[n/2 -1];
  } else {
    b = a[(n-1)/2];
  }

  long long  r = 0;

  for(int i=0;i<n;i++) {
    r += abs(a[i] - b);
  }

  cout << r << endl;
return 0;
}


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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    set<int> s;
    s.insert(1);
    s.insert(2);
    s.insert(3);

    int a, b;
    cin >> a >> b;

    s.erase(a);
    s.erase(b);

    cout << *s.begin() << '\n';

    return 0;
}

Measured memory_bytes: 256
s = list(input())
ans = 0
length = 1
Si = s[0]
loop = [0]
for i in loop:
	Si_1 = ""
	for j in range(0,length):
		Si_1 += s[i+1+j]
	if Si == Si_1:
		length += 1
		i -= 1
		loop.append(i+1)
	else:
		ans += 1
		i += length - 1
		length = 1
		Si = Si_1
		loop.append(i+1)
	if i + length + 1 == len(s):
		ans += 1
		break
print(ans)

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

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

    long t, a;
    cin >> t >> a;

    vector<long> h(n);
    rep(i,n) {
        cin >> h.at(i);
    }

    vector<long> tempDif(n);
    rep(i,n) {
        tempDif.at(i) = abs(a*1000-(t*1000-h.at(i)*6));
    }

    int index = min_element(tempDif.begin(), tempDif.end()) - tempDif.begin();

    cout << index+1 << endl;
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> r(m), l(m);
    rep(i, m)
    {
        cin >> l[i] >> r[i];
    }
    sort(all(l));
    sort(all(r));
    int ans = 0;
    if (r.front() - l.back() + 1 >= 0)
    {
        ans = r.front() - l.back() + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, k;

ll solve() {
    if (k == 0) return n * n;
    ll res = 0;
    for (ll b = k+1; b <= n; b++) {
        res += (b - k) * ((n+1) / b) + ((n+1)%b==0 ? 0 : max(0LL, n % b - k + 1));
    }
    return res;
}

void input() {
    cin >> n >> k;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
                )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get!($t)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_| get!($($t),*)).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.sprit_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;).collect::<Vec<_>>())
    };
}

fn main() {
    let n = get!(u64);
    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", n * 2);
    }
}


Measured memory_bytes: 4352
N = int(input())
a = list(map(int, input().split()))
ans = 10**10

for i in range(1, N):
    if i == 1:
        x = sum(a[:i])
        y = sum(a[i:])
    else:
        x += a[i-1]
        y -= a[i-1]
    check = abs(x - y)
    if ans > check:
        ans = check

print(ans)

Measured memory_bytes: 23792
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	double d,n;
	long long ans;
	cin>>d>>n;
	if(n==100)n++;
	ans=pow(100,d)*n;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
max_1 = 0
max_2 = 0
nums = []
for _ in range(N):
    n = int(input())
    if n >= max_1:
        max_2 = max_1
        max_1 = n
    if n < max_1:
        if n >= max_2:
            max_2 = n
    nums.append(n)

for n in nums:
    if n == max_1:
        print(max_2)
    else:
        print(max_1)

Measured memory_bytes: 69080
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long int;

template< typename T >
T extgcd(T a, T b, T &x, T &y) {
  T d = a;
  if(b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll x, y;
    ll gcd = extgcd(a, b, x, y);
    ll ans = 1;
    for(ll i = 2; i * i <= gcd; i++){
        if (gcd % i != 0)continue;
        ans++;
        while(gcd % i == 0){
            gcd /= i;
        }
    }
    if (gcd > 1LL)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3156
N, M = map(int, input().split(' '))
if M == 0:
    if N == 1:
        print(0)
    else:
        print('1', '0' * (N - 1), sep='')
else:
    is_end = False
    rst = [''] * N
    for i in range(M):
        s, c = input().split(' ')
        idx = int(s) - 1
        if idx == 0 and N != 1 and c == '0':
            print(-1)
            is_end = True
            break
        elif rst[idx] == '':
            rst[idx] = c
        elif rst[idx] != c:
            print(-1)
            is_end = True
            break
    if not is_end:
        for i, j in enumerate(rst):
            if i == 0 and j == '':
                print('1', end='')
            elif j == '':
                print('0', end='')
            else:
                print(j, end='')

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

int main(){
	int a;
	cin >> a;
    int a1, a2, a3;
    a1 = a / 100;
    a2 = (a - a1 * 100) / 10;
    a3 = a- a1 * 100 - a2 * 10; 
	cout << a1+a2+a3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;

using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	string s, t;
	bool res = false;
	cin >> s >> t;
	fi(s.size()) {
		string temp = { s[s.size() - 1] };
		s.insert(0, temp);
		s.erase(s.size() - 1);
		int j = s.compare(t);
		if (j == 0) {
			res = true;
		}
	}
	if (res == true) {
		ce("Yes");
	}
	else {
		ce("No");
	}
	
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define fi first
#define se second
#define PB push_back
#define uint unsigned
#define ull unsigned ll 
using namespace std;
const int N=105;
vector<int> vec[N][N];
int cnt[N][N],n,m;
int e[N][N],a[N][N];
int mat[N],vis[N];
bool find(int x){
	For(i,1,n)
		if (e[x][i]&&!vis[i]){
			vis[i]=1;
			if (!mat[i]||find(mat[i])){
				mat[i]=x;
				return 1;
			}
		}
	return 0;
} 
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,n) For(j,1,m){
		int x;
		scanf("%d",&x);
		int bel=(x-1)/m+1;
		++cnt[i][bel];
		vec[i][bel].PB(x);
	}
	For(i,1,m){
		For(j,1,n) For(k,1,n){
			e[j][k]=(cnt[j][k]!=0);
		}
		memset(mat,0,sizeof(mat));
		For(j,1,n){
			memset(vis,0,sizeof(vis));
			assert(find(j));
		}
		For(j,1,n){
			int to=mat[j];
			a[to][i]=vec[to][j].back();
			vec[to][j].pop_back();
			--cnt[to][j];
		}
	}
	For(i,1,n){
		For(j,1,m) printf("%d ",a[i][j]);
		puts("");
	}
	For(i,1,m){
		For(j,1,n) For(k,j+1,n)
			if (a[j][i]>a[k][i])
				swap(a[j][i],a[k][i]);
	}
	For(i,1,n){
		For(j,1,m) printf("%d ",a[i][j]);
		puts("");
	}
}

Measured memory_bytes: 1024
N = int(input())
IN = [list(map(int, input().split())) for x in range(N)]

flag = True
for t in IN:
    if t[0] < t[1] + t[2]:
        flag = False
        break
    if t[0] % 2:
        if (t[1]+t[2]) % 2 == 0:
            flag = False
            break
    else:
        if (t[1]+t[2]) % 2:
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27300
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int count=0;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]){
			count++;
		}
	}
	cout<<count<<"\n";
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define maxn 1000233
#define mod 1000000007
using namespace std;
typedef long long ll;
ll Pow(ll x, ll p) {
	ll ret = 1;
	for(; p; p >>= 1, x = x * x % mod) if(p & 1) ret = ret * x % mod;
	return ret;
}
int a[maxn];
int main() {
	ll n, ans;
	cin >> n;
	ans = Pow(10, n) + mod - Pow(9, n) + mod - Pow(9, n) + Pow(8, n);
	ans = (ans % mod + mod) % mod;
	cout << ans;
	return 0;
}

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

class Main {

    public static long solve(int[] weights, int[] val, int W, int n, long[][] memo){
        if(n <= 0 || W <= 0)
            return 0;
        if(memo[n][W] > -1){
            return memo[n][W];
        }
        long ans = Long.MIN_VALUE;
        if(W - weights[n-1] >= 0)
            ans = Math.max(ans,val[n-1] + solve( weights,val,W-weights[n-1],n-1,memo));
        
        ans = Math.max(ans, solve( weights,val,W,n-1,memo));
        
        return memo[n][W] = ans;


    }

    public static void main(String[] args) throws Exception {
        BufferedReader br  =  new BufferedReader(new InputStreamReader(System.in));
        String[] nw = br.readLine().trim().split(" ");
        int n = Integer.parseInt(nw[0]);
        int W = Integer.parseInt(nw[1]);
        int weights[] = new int[n];
        int val[] = new int[n];

        for(int i  = 0; i < n; i++){
            String[] input = br.readLine().trim().split(" ");

            weights[i] = Integer.parseInt(input[0]);
            val[i] = Integer.parseInt(input[1]);
        }

        long[][] memo = new long[n+1][W+1];
        for(int i = 0; i < memo.length; i++)
            Arrays.fill(memo[i],-1);
        System.out.println(solve(weights,val,W,n,memo));

    }
}

Measured memory_bytes: 133460
import java.util.Scanner;

public class Main {

    static String[] strs = { "eraser", "erase", "dreamer", "dream" };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();
        int idx = S.length();

        while (true) {
            boolean endsWithStr = false;
            for (String str : strs) {
                if (idx - str.length() >= 0 && S.indexOf(str, idx - str.length()) == idx - str.length()) {
                    idx -= str.length();
                    endsWithStr = true;
                    break;
                }
            }
            if (!endsWithStr) {
                System.out.println("NO");
                break;
            }
            if (idx == 0) {
                System.out.println("YES");
                break;
            }
        }
    }
}


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

int main(){
   bool card[11];
   int c[3];
   while(cin >> c[0] >> c[1] >> c[2]){
      for(int i=1;i<11;i++) card[i] = true;
      for(int i=0;i<3;i++)  card[c[i]] = false;
      int cnt = 0;
      for(int i=1;i<11;i++){
	 if(card[i] && i <= 20-c[0]-c[1]) cnt++;
      }
      cout << ((cnt >= 4)? "YES":"NO") << endl;
   }
   return 0;
}

Measured memory_bytes: 1152
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    ranges = []
    for i in range(n):
        x, l = LI()
        ranges.append([x - l, x + l])
    ranges.sort(key=lambda x: x[1])
    ans = n
    for i in range(1, n):
        if ranges[i - 1][1] > ranges[i][0]:
            ans -= 1
            ranges[i][1] = ranges[i - 1][1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 90804
<?php
    $N = trim(fgets(STDIN));
    $LN = explode(" ",trim(fgets(STDIN)));
    
    $max = max($LN);
    $long = array_sum($LN) - $max;
    
    if ($max < $long) {
        echo "Yes";
    } else {
        echo "No";
    }
?>


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	int ans=0;
	string s;

	cin>> s;

	for (int i = 0;i < s.size() / 2;i++) {
		if (s[i] != s[s.size() - 1 - i]) ans++;
	}

	cout << ans << endl;


}


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

int main(){
  long N, C, K;
  cin >> N >> C >> K;
  vector<long> T(N);
  for(int i=0; i<N; i++){
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  int t=T[0];
  int ans=1;
  int num=1;
  for(int i=1; i<N; i++){
    if(num<C && T[i]<=t+K){
      num++; continue;
    }
    t=T[i];
    ans++;
    num=1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
//Cleaning
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long lint;
int const N=1e5+10;
int n,a[N];
int cnt,h[N],deg[N];
struct edge{
	int u,v,nxt;
	edge(int u1=0,int v1=0)
	{
		u=u1,v=v1;
		nxt=h[u];
		h[u]=cnt;
	}
}ed[N<<1];
int root,fa[N],dpt[N];
struct rec{int dpt,id;} r[N];
bool cmpDpt(rec x,rec y) {return x.dpt>y.dpt;}
void dfs(int u)
{
	for(int i=h[u];i!=0;i=ed[i].nxt)
	{
		int v=ed[i].v;
		if(v==fa[u]) continue;
		fa[v]=u,dpt[v]=dpt[u]+1;
		dfs(v);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(n==2)
	{
		if(a[1]!=a[2]) printf("NO");
		else printf("YES");
		return 0;
	}
	cnt=0; memset(h,0,sizeof h);
	for(int i=1;i<=n-1;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		ed[++cnt]=edge(u,v); deg[v]++;
		ed[++cnt]=edge(v,u); deg[u]++;
	}
	for(int i=1;i<=n;i++)
		if(deg[i]>1)
		{
			fa[i]=0,dpt[i]=1;
			dfs(root=i);
			break;
		}
	for(int i=1;i<=n;i++) r[i].dpt=dpt[i],r[i].id=i;
	sort(r+1,r+n+1,cmpDpt);
	for(int i=1;i<=n;i++)
	{
		int u=r[i].id;
		if(deg[u]==1) continue;
		int maxx=0; lint sum=0;
		for(int j=h[u];j!=0;j=ed[j].nxt)
		{
			int v=ed[j].v;
			if(fa[v]!=u) continue;
			maxx=max(maxx,a[v]); sum+=a[v];
		}
		lint in=min(sum/2,sum-maxx);
		if(a[u]>sum) {printf("NO"); return 0;}
		else
		{
			if(sum-a[u]>in) {printf("NO"); return 0;}
			else a[u]-=sum-a[u];
		}
	}
	if(a[root]==0) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 7936
#include <cstdio>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==5&&b==5&&c==7||a==5&&c==5&&b==7||b==5&&c==5&&a==7)
		printf("YES");
		else
			printf("NO");
			return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

double dist(int x[], int y[], int n, int p) {
  if (p <= 3) {
    double sum = 0;
    for (int i = 0; i < n; i++)
      sum = sum + pow(abs(x[i] - y[i]), p);
    double res = pow(sum, 1.0/p);
    return res;
  } else {
    double max = 0;
    for (int i = 0; i < n; i++) {
      int d = abs(x[i] - y[i]);
      if (d > max)
        max = d;
    }
    return max;
  }
}

int main() {
  int n, x[100], y[100];

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

  printf("%.6lf\n", dist(x, y, n, 1));
  printf("%.6lf\n", dist(x, y, n, 2));
  printf("%.6lf\n", dist(x, y, n, 3));
  printf("%.6lf\n", dist(x, y, n, 4));
  
  return 0;
}


Measured memory_bytes: 2096
a, b, h, m = map(int, input().split())
import math

tanshin = h*(360/12)+(m/60)*(360/12)
tyoushin = m*(360/60)
kakudo = min(abs(tanshin-tyoushin), abs(tyoushin-tanshin))

print((a**2 + b**2 -2*a*b*math.cos(math.radians(kakudo)))**(1/2))


Measured memory_bytes: 9504
n = int(input())
lst = [None for i in range(n-1)]
for i in range(n-1):
    c,s,f = list(map(int, input().split()))
    lst[i] = (c,s,f)

# 時刻tに駅iにいる時、駅i+1に到着する時刻を返す
def next(i,t):
    if t<=lst[i][1]:
        return lst[i][0]+lst[i][1]
    elif t%lst[i][2]==0:
        return t+lst[i][0]
    else:
        return t+lst[i][0]+lst[i][2]-(t%lst[i][2])

for i in range(n-1):
    time = 0
    for j in range(i,n-1):
        time = next(j,time)
    print(time)
print(0)


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-

if __name__ == '__main__':
    A = input()
    B = input()
    C = input()
    flag='a'
    while True:
        if flag == 'a':
            if len(A)==0:
                print('A')
                exit()
            flag = A[0]
            A=A[1:]
        elif flag == 'b':
            if len(B)==0:
                print('B')
                exit()
            flag = B[0]
            B=B[1:]
        elif flag == 'c':
            if len(C)==0:
                print('C')
                exit()
            flag = C[0]
            C=C[1:]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, K;
  cin >> N >> K;
  
  int T = 1;
  
  for(int i = 0; i < N; i++)
  {
    if(T * 2 <= T + K){T *= 2;}
    else{T += K;}
  }
  
  cout << T << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double tmp = 0.0;
    
    for (int i = 0; i< N;i++) {
     tmp += (1.0 / sc.nextDouble());
    }
    
    System.out.println(1.0 / tmp);
  }
}

Measured memory_bytes: 23252
## まず反時計回りの四角形を描くように最短で一周する
## その後一周り大きい四角形を描くように一周する

sx, sy, tx, ty = map(int,input().split())

solver = []
solver.append('U'*(ty-sy))
solver.append('R'*(tx-sx))
solver.append('D'*(ty-sy))
solver.append('L'*(tx-sx))
solver.append('L')
solver.append('U'*(ty-sy+1))
solver.append('R'*(tx-sx+1))
solver.append('D')
solver.append('R')
solver.append('D'*(ty-sy+1))
solver.append('L'*(tx-sx+1))
solver.append('U')

ans = ''.join(solver)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;

    string res = "";
    rep(i, n) {
        res += s[i];
        res += t[i];
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    r = s.count("R")
    g = s.count("G")
    b = s.count("B")
    cnt = r * g * b
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = j + j - i
            if k < n:
                if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
                    cnt -= 1
    print(cnt)


if __name__ == '__main__':
    solve()


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

int main()
{
    int X; cin>>X;
    vector<bool> dp(X+1);
    dp[0]=true;
    for(int i=0;i<X;i++) if(dp[i]){
        for(int a=100;a<=105;a++) if(i+a<=X) dp[i+a]=true;
    }
    cout<<dp[X]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string.h>
using namespace std;
int main()
{
	int x,n=0;
	long long sum=2;
	cin>>x;
	do
	{
		sum=sum+1+(sum+1);
		n=n+1;
	}
	while(n<x);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=1000005;
const int mo=998244353;
int fac[N],inv[N],n,k,ans;
void init(){
	inv[0]=inv[1]=fac[0]=1;
	For(i,2,N-1) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;
	For(i,1,N-1) inv[i]=1ll*inv[i-1]*inv[i]%mo;
	For(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mo;
}
int C(int x,int y){
	if (x<0||y<0||y>x) return 0;
	return 1ll*fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int walk(int x,int y,int D){
	if (D<=0) return 0;
	return (C(x+y,x)+mo-C(x+y,y-D))%mo;
}
int main(){
	init();
	scanf("%d%d",&n,&k);
	if (k%2==0) ans=(ans+walk(k/2,k/2-1,k/2-n+1))%mo;
	For(R,k/2+1,k) ans=(ans+walk(R,k-R,R-n+1))%mo;
	printf("%d\n",ans);
}

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

/*bool kaibun(string s){
  bool judge = true;
  ll n = s.length();
  ll i = 0;
 for(i = 0; i < n; i++){
    if(s[i] != s[n-1-i]) judge = false;break;
   // i++;
  }
  return judge;
}*/

bool kaibun(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}
  
int main(){
    string s;
    cin >> s;
  string s1,s2;
  ll n = s.length();
  s1 = s.substr(0,(n-1)/2);
  s2 = s.substr((n-1)/2+1,(n-1)/2);
   /* ll n = s.length();
    bool judge = true;
    ll count = 0;
    for(ll i = 0; i < (n-1)/4; i++){
    if(s[i] == s[(n-1)/2-1-i] && s[i] == s[(n-1)/2 + 1+i] && s[i] == s[n-1-i]){
        count++;
    }
    }
    if(count == (n-1)/4){
      judge = true;
        //cout << "Yes" << endl;
      //cout << count << endl;
    }
    else{
      judge = false;
        //cout << "No" << endl;
      //cout << count << endl;
    }
  if(n == 3){
    if(s[0] == s[2]) judge = true;
    else judge = false;
  }
  if(judge) cout << "Yes" << endl;
  else cout << "No" << endl;*/
  if(kaibun(s1) && kaibun(s2) && kaibun(s)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

int main() {
	long int S,a,b,c;
	b=0;
	c=0;
	cin >> S;
	a=sqrt(S);
	if(S==1000000000000000000){
		cout << 0 << " "<< 0 <<" " <<1000000000<<" "<<0<<" "<<0<<" "<<1000000000<<endl;
	}
	else{
		if((a+1)*(a+1)-S<1000000000){
			cout << 0 << " "<< 0 <<" " <<a+1<<" "<<(a+1)*(a+1)-S<<" "<<1<<" "<<a+1<<endl;
		}
		else{
			for(int i=2;i<(a+1)*(a+1)-S;i++){
				b=i;
				if(((a+1)*(a+1)-S)%i==0){
					c=((a+1)*(a+1)-S)/i;
					break;
				}
			}
			cout << 0 << " "<< 0 <<" " <<a+1<<" "<<b<<" "<<c<<" "<<a+1<<endl;
		}
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T> void chmax(T&x, T y){if(x < y) x = y;} 
int N, K;
vector<int> G[100010];
int ans;

int dfs(int v, int p){
    int mx = 1;
    for(auto u : G[v]){
        chmax(mx, dfs(u, v) + 1);
    }
    if(mx == K && p > 1) mx = 0, ans++;
    return mx;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        int p;
        cin >> p;
        if(i == 1) ans += (p == 1 ? 0 : 1);
        else G[p].push_back(i);
    }
    dfs(1, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>

int main(){
    int n, ctr=0;
    scanf("%d", &n);
    char str[n];
    scanf("%s", str);

    for(int i=0;i<(n/2);i++){
        if (str[i] == str[i+(n/2)]){
             ++ctr;
        }
    }
    if(n%2 == 1){
        puts("No");
    } else if (ctr == (n/2)){
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

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

using namespace std;

char a[6];
int main()
{
    for(int i=1;i<=4;i++)
    {
        scanf("%c",&a[i]);
    }
    int flag=0;
    for(int i=2;i<=4;i++)
    {
        if(a[i]==a[i-1])
            flag=1;
    }
    if(flag)
        printf("Bad\n");
    else
        printf("Good\n");
    return 0;
}


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

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

  int count=0;
  for (int i=0;i<=A;++i){
    for (int j=0;j<=B;++j){
      for (int l=0;l<=C;++l){
        if (X==500*i+100*j+50*l){
          ++count;
        }
      }
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,cot=0;
    
    cin>>a>>b>>c;
    
    if(a!=b) cot++; 
    if(b!=c) cot++;
    if(a!=c) cot++;
    
    if(cot!=0) cout<<cot<<endl;
    else cout<<1<<endl;
    
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m;
    cin >> n >> m;
    int32 l = 1, r = n;
    REP(i,m){
        int32 li,ri;
        cin >> li >> ri;
        l = max(l, li);
        r = min(r, ri);
    }
    ANS(max<int32>(r - l + 1 , 0));
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			int D = sc.nextInt();
			int N = sc.nextInt();
			if(D==0&&N<100)System.out.println(N);
			if(D==0&&N==100)System.out.println(101);
			if(D==1&&N<100)System.out.println(100*N);
			if(D==1&&N==100)System.out.println(100*101);
			if(D==2&&N<100)System.out.println(10000*N);
			if(D==2&&N==100)System.out.println(10000*101);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (b) - 1;i >=a;--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}


using ll = long long;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int clamp(int n, int a, int b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

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

    int L, R;
    cin >> L >> R;

    if (L / 2019 != R / 2019) {
        cout << 0 << endl;
        return 0;
    }
    int min = INF;
    L %= 2019;
    R %= 2019;
    FOR(i, L, R + 1) {
        FOR(j, i + 1, R + 1) {
            min = std::min(min, (i * j) % 2019);
        }
    }
    cout << min << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		int list[] = {a, b};
		int sum = 0;

		for(int i=0; i<2; i++){
			if(list[0] > list[1]){
				sum += list[0];
				list[0]--;
			}else{
				sum += list[1];
				list[1]--;
			}
		}

		System.out.println(sum);
    }
}

Measured memory_bytes: 21844
incline :: Double -> Double -> Double -> Double
incline a b x = let c = x * 2 / a / b in
                if c < a
                then b / c
                else let h = (b - x / a / a) * 2 in h / a

main = do
  a:b:x:_ <- map read . words <$> getLine :: IO [Integer]
  putStrLn $ show $ (\x -> atan x * 180 / pi) $ incline (fromIntegral a) (fromIntegral b) (fromIntegral x)


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	ll H, N;
	cin >> H >> N;
	vl A(N);
	ll Asum = 0;
	rep(i, N) {
		cin >> A[i];
		Asum += A[i];
	}
	string ans = "Yes";
	if (Asum < H)
		ans = "No";
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
l = input().rstrip().split() 
a=int(l[0])
b=int(l[1])
c=int(l[2])
d=int(l[3])
if abs(c-a)<=d:
    print('Yes')
elif 0<=b-a and b-a<=d and 0<=c-b and c-b<=d:
    print('Yes')
elif 0<=b-c and b-c<=d and 0<=a-b and a-b<=d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a;//(m+1, 0);
  int tmp = m;
  int r = 0;
  for(int i = 1; i <= sqrt(m); i++) {
    if(tmp % i == 0) {
      a.push_back(i);
      a.push_back(m/i);
      //a.push_back(i);
    }
  }
  sort(a.begin(), a.end());

  //cout << m/r << endl;

  //std::sort(a.begin(), a.end());
  //a.erase(std::unique(a.begin(), a.end()), a.end());

  int ans = 0;
  //sort(a.begin(), a.end());
  for(int i = 0; i < a.size(); i++) {
    //cout << a[i] << " ";
  }
  for(int i = 0; i < a.size(); i++) {
    if(a[i] >= n) {
      //ans = max(ans, a[a.size()-1-i]);
      ans = m/a[i];
      break;
    }
  }

  cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b, c;
	cin >> a >> b >> c;

	if (a - b > c) {
		cout << 0 << endl;
	} else {
		cout << c - (a - b) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  long long n,z,w;
  cin >> n >> z >> w;
  long long a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  if(n == 1){
    cout << abs(a[0]-w) << endl;;
    return 0;
  }

  cout << max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])) << endl;


  return 0;
}


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

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

  int n, g;
  cin >> n >> g;
  vector<P> v(n);
  rep(i, 0, n) {
    int p, c;
    cin >> p >> c;
    v[i] = make_pair(p, c);
  }
  ll a = 0;
  int t = g;
  vector<pair<ll, int>> memo;
  // 大きいほうから貪欲に使うパターンをメモする
  repr(i, 0, n) {
    rep(j, 0, v[i].first) { memo.emplace_back((i + 1) * 100, i); }
    memo[memo.size() - 1].first += v[i].second;
  }

  ll ans = 1e18;
  rep(i, 0, 1 << n) {
    ll cost = 0, count = 0;
    vector<bool> is_use(n, true);
    rep(j, 0, n) {
      // iのjビット目が1なら
      if (i >> j & 1) {
        cost += 100 * (j + 1) * v[j].first + v[j].second;
        count += v[j].first;
        is_use[j] = false;
      }
    }
    if (cost < g) {
      int c = 0, cc = 0;
      while (true) {
        if (!is_use[memo[cc].second]) {
          cc++;
          continue;
        }
        if (cost + memo[cc].first >= g)
          break;
        cost += memo[cc].first;
        c++;
        cc++;
      }
      count += c + 1;
    }
    chmin(ans, count);
  }

  cout << ans << endl;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int n,k;
    cin >> n >> k;
    if(k + k-1 <= n){

        cout << "YES" << endl;
    }else{
        cout << "NO" << endl; 
    }






    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		out.println(a+b>=10?"error":a+b);
	}
}


Measured memory_bytes: 21972
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
ll num[100010] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[100010], B[100010];
    rep(i,0,N-1){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        tree[A[i]].push_back(B[i]);
        tree[B[i]].push_back(A[i]);
    }
    rep(i,0,N) num[i] = -1;
    ll K;
    cin >> K;
    ll V[100010], P[100010];
    rep(i,0,K){
        cin >> V[i] >> P[i];
        V[i]--;
        num[V[i]] = P[i];
    }
    priority_queue<lpair, vector<lpair>, greater<lpair> > pq;
    rep(i,0,N){
        if(num[i] != -1) pq.push({num[i], i});
    }
    bool ok = true;
    while(not pq.empty()){
        lpair l1 = pq.top();
        pq.pop();
        ll idx = l1.second;
        for(auto &e: tree[idx]){
            if(num[e] == -1){
                num[e] = num[idx] + 1;
                pq.push({num[e], e});
            }else{
                if(abs(num[e] - num[idx]) != 1) ok = false;
            }
        }
    }
    if(ok){
        print("Yes");
        rep(i,0,N) print(num[i]);
    }else{
        print("No");
    }
    
    

}

Measured memory_bytes: 12532
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        // ##### 初期読み込み #######################################################################

        // 1行 文字 複数 ----------------------------------------------------------------------------
        String[] stringArray = scanner.nextLine().split(" ");

        int k = Integer.parseInt(stringArray[0]);
        int n = Integer.parseInt(stringArray[1]);

        // 1行 数字 複数 ----------------------------------------------------------------------------
        String[] sArr = scanner.nextLine().split(" ");
        long[] a = new long[sArr.length];
        for (int i = 0; i < sArr.length; i++) {
            a[i] = Long.parseLong(sArr[i]);
        }

        // ##### メイン処理 #######################################################################

        long maxDistance = k - a[n-1] + a[0];
        long distance = 0;
        for (int i = 0; i < n-1; i++) {
            distance = a[i+1] - a[i];
            if (maxDistance < distance) {
                maxDistance = distance;
            }
        }
        System.out.println(k - maxDistance);
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	ll dis=(v-w)*t;
	if(v<w)
	{
		cout<<"NO\n";
		return 0;
	}
	if(dis>=abs(a-b)) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
A_leaf = list(map(int, input().split()))
if N == 0:
    print(1 if A_leaf[0] == 1 else -1)
    exit()
s = [0]*(N+2)
for i in range(1, N+2):
    s[i] = s[i-1] + A_leaf[i-1]
node = [1]*(N+1)
for i in range(1, N+1):
    node[i] = min((node[i-1] - A_leaf[i-1])*2, s[N+1]-s[i])
    if node[i] < A_leaf[i]:
        print(-1)
        exit()
else:
    print(sum(node))

Measured memory_bytes: 22312