akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

signed main(){
	int A, B, C, K, ans = 0;
	scanf("%d%d%d%d", &A, &B, &C, &K);
	ans += min(A, K);
	K -= min(A, K);
	K -= min(B, K);
	ans -= min(C, K);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3820
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

vector<pii> G[10000];
int d1[10000], d2[10000];
pii farestNode;


void visit(int n, int p, int w, int opt)
{
	switch (opt)
	{
	case 1:
		d1[n] = w;
		break;
	case 2:
		d2[n] = w;
		break;
	}
	if (G[n].size() == 1 && G[n][0].first == p)
	{
		if (w > farestNode.second)
		{
			farestNode = pii(n, w);
		}
		return;
	}
	for (auto& m : G[n])
	{
		if (m.first != p)
		{
			visit(m.first, n, w + m.second, opt);
		}
	}
}

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

	farestNode = pii(-1, 0);

	int V;
	scanf("%d", &V);

	for (int i = 0; i < V - 1; i++)
	{
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);

		G[u].push_back(pii(v, w));
		G[v].push_back(pii(u, w));
	}

	visit(0, -1, 0, 0);
	int t = farestNode.first;
	farestNode = pii(-1, 0);
	visit(t, -1, 0, 1);
	t = farestNode.first;
	farestNode = pii(-1, 0);
	visit(t, -1, 0, 2);

	for (int i = 0; i < V; i++)
	{
		printf("%d\n", max(d1[i], d2[i]));
	}

	return 0;
}


Measured memory_bytes: 4460
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> d(n);
  for(LL &x:d) cin >> x;
  sort(d.begin(),d.end());
  cout << d[n/2] - d[n/2-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        exit()
    
    for i in range(h):
        for j in range(w):
            if j == 0 or j == w-1 or i == 0 or i == h-1 : 
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7008
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;

//解説ac

int main()
{
	ll x;cin >> x;
	ll y = 100;
	ll i = 0;
	while (y < x) {
		y += y / 100;
		i++;

	}cout << i;

}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

ll get_root(ll n) {
    assert(n >= 0);
    ll x = sqrt(n);
    while (x * x < n)
        x++;
    while (x * x > n)
        x--;
    if (x * x != n)
        return -1;
    return x;
}

vector<pii> get_pairs(ll n) {
    vector<pii> ans;
    for (ll a = 0; a * a <= n; a++) {
        ll b = get_root(n - a * a);
        if (b != -1) {
            assert(a * a + b * b == n);
            ans.emplace_back(a, b);
         }
    }
    return ans;
}

const int N = 666;

bool was[N][N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

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

    /*
    int ans = 0;
    for (int i = 4; i <= 200 * 1000; i += 4) {
        int c = get_pairs(i).size();
        if ( c > ans ) {
            cerr << i << " " << c << endl;
            ans = c;
        }
    }
    */

    auto ps = get_pairs(a);
    for (auto p : get_pairs(b))
        ps.push_back(p);
    

    for (int rep = 2;; rep++) {
        vector<pii> cands;
        for (int i = 0; i < 2 * n; i++) {
            for (int j = 0; j < 2 * n; j++) {
                cands.emplace_back(i, j);
                was[i][j] = false;
            }
        }
        if (rep <= 7)
            stable_sort(cands.begin(), cands.end(), [rep](auto a, auto b) { return (a.first + a.second) % rep < (b.first + b.second) % rep; });
        else
            stable_sort(cands.begin(), cands.end(), [rep](auto a, auto b) { return abs(a.first - a.second) % (rep - 6) <abs(b.first - b.second) % (rep - 6); });
        vector<pii> ans;
        for (auto p : cands) {
            int i = p.first;
            int j = p.second;
            if (was[i][j] || ans.size() == n * n)
                continue;
            ans.emplace_back(i, j);
            for (int dx = -1; dx <= 1; dx += 2) {
                for (int dy = -1; dy <= 1; dy += 2) {
                    for (auto d : ps) {
                        int x = i + d.first * dx;
                        int y = j + d.second * dy;
                        if (x >= 0 && x < 2 * n && y >= 0 && y < 2 * n)
                            was[x][y] = true;
                    }
                }
            }
        }
        if (ans.size() < n * n) {
            continue;
        }
        for (auto p : ans)
            cout << p.first << " " << p.second << "\n";
        return 0;
    }
}

Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <map>
#include <algorithm>

using namespace std;

#define N 100
static const long long FAR = (1L << 31);

static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, m;
long long d[N][N];


void floyd(){
	for (int k = 0; k < n; ++k){
		for (int u = 0; u < n; ++u){
			if (FAR == d[u][k]) continue;
			for (int v = 0; v < n; ++v){
				if (FAR == d[k][v]) continue;
				d[u][v] = std::min(d[u][v], d[u][k] + d[k][v]);
			}
		}
	}
}


int main(){
	cin >> n >> m;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j)
			d[i][j] = ((i == j) ? 0 : FAR);
	}

	for (int i = 0; i < m; ++i) {
		int u, v, e; cin >> u >> v >> e;
		d[u][v] = e;
	}

 
	floyd();

	bool negitive = false;
	for (int i = 0; i < n; ++i) if (d[i][i] < 0) negitive = true;

	if (negitive) cout << "NEGATIVE CYCLE" << endl;
	else{
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < n; ++j)
			{
				if (d[i][j] == FAR)	cout << "INF";
				else cout << d[i][j];
				if (j == n - 1) cout << endl;
				else cout << " ";

			}
		}
	}
	return 0;
}

Measured memory_bytes: 3160
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-


def main():
    N = int(input())
    s = input()
    t = input()

    for i in range(N, 0, -1):
        if s[-i:] == t[:i]:
            print(N*2-i)
            break
    else:
        print(N*2)


if __name__ == '__main__':
    main()


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

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

int N;
int A[100010];

signed main()
{
    cin >> N;
    rep(i, N)cin >> A[i];

    sort(A, A + N);

    int l = 0, r = N - 1;
    int ans = A[N - 1] - A[0];
    for(int i = 0;;i++)
    {
        l++;
        r--;
        if(l > r)break;
        if(l == r)
        {
            ans += max(abs(A[l] - A[l - 1]), abs(A[r] - A[r + 1]));
            break;
        }
        ans += abs(A[l] - A[r + 1]) + abs(A[r] - A[l - 1]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4412
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main() {
    int N;
    vector<double>a;
    vector<double>b;
    cin >> N;
    for (int i = 0; i < N; i++) {
        double s; cin >> s;
        a.push_back(s);
        b.push_back(s);
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < N; i++) {
        //int big = N - (int)(upper_bound(b.begin(), b.end(), a[i]) - b.begin());
        int same = (upper_bound(b.begin(), b.end(), a[i]) - b.begin()) - (lower_bound(b.begin(), b.end(), a[i]) - b.begin())-1;
        int small = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
        cout << same + 3 * small << endl;;
       // cout <<same << " "<<small << endl;
    }
    return 0;
}

Measured memory_bytes: 4604
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    double ans = 0.0;
    for (ll i = 0; i < N; i++) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000;
        }
    }

    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back
int ans[100005];
vector<pair<lli,lli>> arr[100005];

void dfs(int src, lli amt, int par){
    if(amt%2 == 0){
        ans[src] = 0;
    }
    for(auto i : arr[src]){
        if(i.first != par){
            dfs(i.first,amt+i.second,src);
        }
    }
    return;
}
int main() {
    int n;
    cin>>n;
    for(int i=0;i<(n-1);i++){
        lli u,v,w;
        cin>>u>>v>>w;
        u--;
        v--;
        arr[u].push_back(make_pair(v,w));
        arr[v].push_back(make_pair(u,w));
    }
    for(int i=0;i<n;i++)ans[i] = -1;
    for(int i=0;i<n;i++){
        if(ans[i] == -1){
            ans[i] = 1;
        }
    }
    dfs(0,0,-1);
    for(int i=0;i<n;i++){
        cout<<ans[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 9856
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	lli a, b, c; cin >> a >> b >> c;
	
	if(a%2 == 0 || b%2 == 0 || c%2 == 0) cout << 0 << endl;
	else cout << min(min(a*b, b*c), c*a) << endl;
		
	return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
l=a+b
for i in input():
    
    if i=="a" and l>0:
        l-=1
        print ("Yes")
    elif i=="b" and l>0 and b>0:
        print ("Yes")
        l-=1
        b-=1
    else:
        print ("No")
        

Measured memory_bytes: 4016
w,h,n=gets.chomp.split.map(&:to_i)
l = 0
r = w
b = 0
t = h
n.times{
  x, y , a = gets.chomp.split.map(&:to_i)
  case a
    when 1
      l = [l,x].max
    when 2
      r = [r,x].min
    when 3
      b = [b,y].max
    when 4
      t = [t,y].min
  end
}
puts  [(r - l),0].max * [(t- b), 0].max



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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  ll N;cin >> N;
  vector<ll> A(N);
  multiset<ll> mst;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    mst.insert(A[i]);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  ll ans = 0;
  for(int i = 0;i < N;i++){
    ll num = 1;
    while(num <= A[i]){
      num *= 2;
    }
    //cout << A[i] << ' ' << num << endl;
    if(num == A[i] * 2){
      if(mst.find(A[i]) != mst.end()){
        mst.erase(mst.find(A[i]));
        if(mst.find(A[i]) != mst.end()){
          ans++;
          mst.erase(mst.find(A[i]));
        }
      }else{
        mst.erase(A[i]);
      }
    }else{
      if(mst.find(A[i]) != mst.end() && mst.find(num-A[i]) != mst.end()){
        ans++;
        mst.erase(mst.find(A[i]));
        mst.erase(mst.find(num-A[i]));
      }else{
        mst.erase(A[i]);
      }
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 11392
#include<iostream>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int tmp=b;
  while(tmp!=0){
    tmp/=10;
    a*=10;
  }
  bool ans=true;
  for(int i=1;i*i<=a+b;i++){
    if(i*i==a+b){
      ans=false;
      cout << "Yes" << endl;
      break;
    }
  }
  if(ans){
    cout << "No" << endl;
  }
}

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


# 約数を列挙 (ex. 6 => [1,2,3,6])
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def main():
    N = int(input())
    D = make_divisors(N)
    ans = 0
    for a in D:
        m = N//a - 1
        if m > a:
            ans += m
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
vector<vector<int>> e;

int dp[100010];

int dfs(int p){
    if(dp[p] != -1) return dp[p];
    int res = 0;
    for(auto&& i : e[p]){
        res = max(res, dfs(i) + 1);
    }
    return dp[p] = res;
}

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    e = vector<vector<int>>(n + 1);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        e[x].emplace_back(y);
    }
    for(int i = 1; i <= n; i++){
        dp[i] = -1;
    }
    for(int i = 1; i <= n; i++){
        ans = max(ans, dfs(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

int main() {
	int n, t, a;
	std::cin >> n >> t >> a;

	std::vector<double> v;
	v.resize(n);
	for (auto&e : v) {
		double d{};
		std::cin >> d ;
		e = std::abs(
			t - d * 0.006 - a
		);
	}

	auto beg = std::begin(v);
	auto it = std::min_element(beg, std::end(v));

	std::cout << std::distance(beg, it)+1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

	int n,k;
	cin >> n >> k;

	if(n%k==0)cout << 0 << endl;
	else cout << 1 << endl;
	

    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

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

    if(c > a+b && (c-a-b)*(c-a-b) > 4*a*b)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
#include<iomanip>
#include <math.h>

using namespace std;
typedef long long ll;

bool isInteger(double input)
{
    if(ceil(input) != floor(input))
    {
        return false;
    }
    return true;
}

bool isIntegerA_B(vector<double> A, vector<double> B)
{
    double distance = 0;
    for(int i = 0; i < A.size(); i++)
    {
        double _C = A[i] - B[i];
        distance += _C*_C;
    }

    distance = sqrt(distance);

    return isInteger(distance);
}

int main(void)
{
    int N, D;
    cin >> N >> D;

    vector<vector<double>> X;
    for(int i = 0; i < N; i++)
    {
        vector<double> _X(D);
        for(int j = 0; j < D; j++)
        {
            cin >> _X[j];
        }

        X.push_back(_X);
    }

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            if(isIntegerA_B(X[i], X[j]))
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

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

using namespace std;

#define rep(x,y) for(int x=0;x<(y);x++)

typedef long long ll;

int M,N;
int P[10005], C[512], E[512];
ll dp[10005][512];

ll dfs(int m, int n){
  if(m>M || n>=N) return 0;
  ll &res = dp[m][n];
  if(res >= 0) return res;
  res = 0;
  if(m<=M) res = max(res, dfs(min(M, m+C[n]), n+1) + P[min(M,m+C[n])]-P[m] - E[n]);
  res = max(res, dfs(m, n+1));
  return res;
}

int main(){
  scanf("%d%d",&M,&N);
  P[0] = 0;
  rep(i,M) scanf("%d",P+i+1);
  sort(P+1, P+M+1, greater<int>());
  rep(i,M) P[i+1] += P[i];
  rep(i,N) scanf("%d%d", C+i,E+i);
  memset(dp, -1, sizeof(dp));
  printf("%lld\n", dfs(0, 0));
}

Measured memory_bytes: 41292
($X,$Y)=glob<>;
for(<>){
	/ .* /;
	$x+=$-=$`-$x if$'==1;
	$X-=$-=$X-$`if$'==2;
	$y+=$-=$&-$y if$'==3;
	$Y-=$-=$Y-$&if$'==4;
}
print+($-=$X-$x)*1*($-=$Y-$y)

Measured memory_bytes: 768
import math
a=[float(i)for i in input().split()]
k=a[2]*math.pi/180
if a[2]>90.0:
    h=math.sin(k)*a[1]
    s=math.cos(k)*a[1]
    L=math.sqrt((a[0]-s)*(a[0]-s)+h*h)+a[0]+a[1]
elif a[2]<90.0:
    h=math.sin(k)*a[1]
    n=math.sqrt(a[1]*a[1]-h*h)
    L=a[0]+a[1]+math.sqrt(h*h+(a[0]-n)*(a[0]-n))
else:
    h=a[1]
    L=math.sqrt(a[0]*a[0]+a[1]*a[1])+a[0]+a[1]
S=a[0]*h/2
print("%.5f"%(S))
print("%.5f"%(L))
print("%.5f"%(h))

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

int main() {
    int x, y;
    cin >> x >> y;
    while (x != 0 || y != 0) {
        if (x < y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
        cin >> x >> y;
    }
}


Measured memory_bytes: 2988
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def solve(n, arr):
    sum = 0
    bitcount = [0]*100
    for num in arr:
        b = reversed(bin(num)[2:])
        for i, s in enumerate(b):
            if i != "0":
                bitcount[i] += int(s)
    for i, b in enumerate(bitcount):
        sum += b * (n-b) * 2**i
    return sum % (10**9 + 7)


def main():
    N = int(input())
    A_l = [int(i) for i in input().split()]
    print(solve(N, A_l))


if __name__ == "__main__":
    main()

Measured memory_bytes: 69484
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')
import sys
import itertools
import copy


def main():
    D, T, S = MI()
    # L = LLIN(N)
    if D / T <= S:
        print('Yes')
    else:
        print('No') 
    cnt = 0
    # for l in L:
    #     num = l[0] ** 2 + l[1] ** 2 
    #     if num <= D ** 2:
    #         cnt+=1
    # print(cnt)
    # print(row)
    # total = sum(row)
    # target = total - K
    # if K == total:
    #     print(1)
    #     sys.exit()
    # col = []
    # for w in range(W):
    #     cnt = 0
    #     for h in range(H):    
    #         print(A[h][w])
    #         if A[h][w] == '#':
    #             cnt += 1
    #     col.append(cnt)
    # print(col)
    # ans = 0
    # for w in range(W):
    #     for h in range(H):
    #         if A[h][w] == '#':
    #             if col[w] + row[h] - 1 == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    #         else:
    #             if col[w] + row[h] == target:
    #                 print(str(h) + str(w))
    #                 ans +=1
    # print(ans)
    #     for  in x:


    # print('AC x ' + str(cnt['AC']))
    # print('WA x ' + str(cnt['WA']))
    # print('TLE x ' + str(cnt['TLE']))
    # print('RE x ' + str(cnt['RE']))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 10916
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll a,b;
	cin >> a >> b;
	ll c = __gcd(a,b);
	cout << a*b/c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 5;
//head
int a, b, c, d, e, k;
int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    vector<int> v;
    for(int i = 0, x; i < 5; ++i) {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    cin >> k;
    puts(v[4]-v[0] > k ? ":(" : "Yay!");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int i,n,a,b,s=0;
	cin>>n>>a>>b;
	for(i=1;i<=n;i++)
	{
		int p=i,k=0,q;
		while(p!=0)
		{
			q=p%10;
			p/=10;
			k+=q;
		}
		if(k>=a&&k<=b)s+=i;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define rep(i,a,b)  for (int i = a; i < b; ++i)
#define rrep(i,z,a) for (int i = z; i >= a; --i)
#define rep0(n)     for(int i = 0 ; i < n; ++i )
#define rep1(n)     for(int i = 1 ; i <= n; ++i )
#define pb          push_back
#define sd(x)       scanf("%d",&x)
#define tc          int test;cin>>test; while(test--)
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define mp          make_pair
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl        "\n"
#define spc         " "
#define mem0(a)     memset(a,0,sizeof(a))
#define extime      cout << endl << endl << "____"<<(float)clock() / CLOCKS_PER_SEC << "s____";
#define maxn        998244353
#define mod         1000000007
//#define ll          long long int
//typedef vector<ll>  vll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
void OJ()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int solve()
{
	string s;
	cin >> s;
	if (s == "RSS" || s == "SRS" || s == "SSR")cout << 1;
	else if (s == "SSS")cout << 0;
	else if (s == "RRR")cout << 3;
	else if(s=="RSR")cout<<1;
	else cout << 2;
	return 0;
}
signed main()
{
	OJ();
	IOS
	//tc
	solve();
	//extime
	return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
char f[2005][2005];
int v[2005][2005],rui[2005][2005];
int nxt[2005][2005];
int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++) scanf("%s",f[i]);
	for(int i=0;i<n;i++){
		for(int j=1;j<m;j++){
			if(f[i][j-1] == f[i][j]) v[i][j-1] = 1;
			else v[i][j-1] = 0;
		}
	}
	for(int j=0;j<m-1;j++){
		nxt[n-1][j] = n;
		for(int i=n-2;i>=0;i--){
			if(v[i][j] != v[i+1][j]) nxt[i][j] = i+1;
			else nxt[i][j] = nxt[i+1][j];
		}
	}
	for(int i=0;i<n;i++) for(int j=0;j<m-1;j++){
		if(i) rui[i][j] += rui[i-1][j];
		if(j) rui[i][j] += rui[i][j-1];
		if(i&&j) rui[i][j] -= rui[i-1][j-1];
		rui[i][j] += v[i][j];
	}
	int ans = max(n,m);
	for(int i=0;i<n;i++){
		if( (m)*(n-i) <= ans) break;
		vector<P>vi;
		for(int j=0;j<m-1;j++){
			vi.pb(mp(nxt[i][j]-1,j));
			//if(i==3) cout << nxt[i][j]-1 << " " << j << endl;
		}
		sort(vi.begin(),vi.end());
		multiset<P>S; multiset<int>T;
		S.insert(mp(0,m-2)); T.insert(m-1);
		int prev = 0;
		for(int j=0;j<vi.size();j++){
			multiset<int>::iterator it = T.end(); it--;
			ans = max(ans,(vi[j].fi-i+1)*((*it)+1));
			if(j != vi.size()-1 && vi[j].fi != vi[j+1].fi){
			    for(int jj=prev;jj<=j;jj++){
			        //cout << jj << endl;
    				multiset<P>::iterator it = S.lower_bound(mp(vi[jj].sc,INF));
    				it--;
    				P q = *it; S.erase(it);
    				multiset<int>::iterator it2 = T.lower_bound(q.sc-q.fi+1);
    				T.erase(it2);
    				if(q.fi <= vi[jj].sc-1){
    					S.insert(mp(q.fi,vi[jj].sc-1)); T.insert(vi[jj].sc-q.fi);
    				}
    				if(vi[jj].sc+1 <= q.sc){
    					S.insert(mp(vi[jj].sc+1,q.sc)); T.insert(q.sc-vi[jj].sc);
    				}
			    }
			    prev = j+1;
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int k;

int main() {
    cin >> k;

    Vi v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << v[k-1] << '\n';

    return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n=int(input())
v=tuple(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(n-1))
c=list(map(int,input().split()))
c.sort(reverse=True)
node=[[] for _ in range(n)]
d=deque()
d.append(0)
seen=[0]*n
seen[0]=1
ans=[0]*n
for pair in v:
    node[pair[0]].append(pair[1])
    node[pair[1]].append(pair[0])

s=0
while d:
    i=d.pop()
    ans[i]=c[s]
    s+=1
    for j in node[i]:
        if seen[j]==0:
            d.appendleft(j)
            seen[j]=1
print(sum(ans)-c[0])
print(*ans)

Measured memory_bytes: 82896
fun main(args: Array<String>) {
    agc002b()
}

private data class Move(val from: Int, val to: Int)
private data class Box(var balls: Int, var redProb: Boolean)

fun agc002b() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val moves = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Move(it[0] - 1, it[1] - 1) }

    val boxes = listOf(Box(1, true)) + (2..n).map { Box(1, false) }
    for (move in moves) {
        boxes[move.from].balls--
        boxes[move.to].balls++

        if (boxes[move.from].redProb) boxes[move.to].redProb = true
        if (boxes[move.from].balls <= 0) boxes[move.from].redProb = false
    }

    val answer = boxes.count { it.redProb }

    println(answer)
}


Measured memory_bytes: 65952
n,k = map(int,input().split())
d = input().split()
price = n
ans = n
while True:
    flg = True
    for let in d:
        if str(n).count(let) > 0:
            flg = False
            break
    if flg != False:
        ans = n
        break
    n += 1
print(ans)

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

#define ll long long

int main() {
	ll n, x; cin >> n >> x; ll a[n], ans = 0;
	for(ll i = 0; i < n; i++) {
		cin >> a[i];
		ans = __gcd(ans, abs(x - a[i]));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

constexpr lint INF=1e18;

struct edge
{
	lint A,B,C;
};

int main()
{
	lint N,M,P;
	
	cin >> N >> M >> P;
	
	vector<edge> edges;
	for(int i=0;i<M;i++)
	{
		lint A,B,C;
		cin >> A >> B >> C;
		edges.push_back({A-1,B-1,-(C-P)});
	}

	lint dist[2510]{};
	for(int i=1;i<2510;i++)
		dist[i]=INF;
	
	lint ntime,n2time;
	for(lint i=0;i<2*N+10;i++)
	{
		for(auto&& e:edges)
		{
			if(dist[e.A]>=INF)continue;
			if((e.A==e.B && e.C<0)|| dist[e.A]==-INF)dist[e.B]=-INF;
			else if(dist[e.A]+e.C<dist[e.B])
				dist[e.B]=dist[e.A]+e.C;
		}

		if(i==N-1)ntime=dist[N-1];
		if(i==2*N-1)n2time=dist[N-1];
	}

	if(ntime!=n2time || dist[N-1]==-INF) cout << -1;
	else cout << max(-dist[N-1],(lint)0);
	cout << endl;

	return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t;

// <------------- Implement Functions Here ----------> //

bool comp(pll &a , pll &b) {
	if(a.s == b.s) return a.f > b.f;
	return a.s > b.s;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	vll a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(all(a));
	cout<<a[0]+a[1];
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3620
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

int N, M;


int main() {

    int N, K;
    cin >> N >> K;

    vi A(N);
    REP(i, N) {
        cin >> A[i];
    }

    vector<bool> dp(K + 1, true);
    dp[0] = false;
    
    FOR(i, 1, K + 1) {
        bool flag = false;
        for (int a : A) {
            if (i - a < 0) continue;
            if (!dp[i - a]) {
                flag = true;
                dp[i] = true;
                break;
            }
        }
        if (!flag) dp[i] = false;
    }


    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;

#ifdef _MSC_VER
    system("PAUSE");
#endif

    return 0;
}

Measured memory_bytes: 384
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	int L, R, d;cin >> L >> R >> d;
	int cnt = 0;
	for(int n = L; n <= R;n++){
		if(n%d == 0)cnt++;
	}

	cout << cnt << endl;
}	

Measured memory_bytes: 10948
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> ans(N);
    REP(m, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        ++ans[a]; ++ans[b];
    }
    REP(n, N) {
        cout << ans[n] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
taro, hanako = 0, 0
for _ in range(n): 
    strlist = input().split()
    if strlist[0] == strlist[1]:
        taro += 1
        hanako += 1
    else:
        sortedlist = sorted(strlist)
        if strlist == sortedlist:
            hanako += 3
        else:
            taro += 3
print(taro, hanako)


Measured memory_bytes: 5604
X, Y, Z = map(int, input().split())
 
num_5 = 0
num_7 = 0
 
if X == 5:
  num_5 += 1
if Y == 5:
  num_5 += 1
if Z == 5:
  num_5 += 1
  
if X == 7:
  num_7 += 1
if Y == 7:
  num_7 += 1
if Z == 7:
  num_7 += 1
  
if num_5 == 2 and num_7 == 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int x, y;
	cin >> x >> y;
	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 100; j++){
			if (i + j == x && i * 2 + j * 4 == y){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main() {
	int N, count = 0;
	char S[100], S1[50], S2[50];

	cin >> N >> S;

	if (N % 2 == 0) {
		for (int i=0; i < N / 2; i++) {
			S1[i] = S[i];
			S2[i] = S[i + N / 2];
		}
		for (int i=0; i < N / 2; i++) {
			if (S1[i] == S2[i]) {
				count++;
			}
		}
	}
	if (count == (N+1) / 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  string S,T;
  cin >> S >> T;
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  vector<int> s(26), t(26);
  int p=0;
  s.at(0)=1;
  for(int i=1;i<S.size();i++){
    if(S.at(i)!=S.at(i-1)){
	  p++;
	}
	s.at(p)++;
  }
  p=0;
  t.at(0)=1;
  for(int i=1;i<T.size();i++){
	if(T.at(i)!=T.at(i-1)){
	  p++;
	}
	t.at(p)++;
  }
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
	
  if(s==t){
	cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
typedef pair<int, int> P;
template <typename T>
T sq(T x){
  return x * x;
}
const int MAX_N = 1e5;
signed main (){
  int N;
  cin >> N;
  vector<ll> X(N),L(N);
  rep(i,N){
cin >> X.at(i) >> L.at(i);
  }
  
P range[MAX_N];
  rep(i,N){
  int min = X.at(i) - L.at(i);
int max = X.at(i) + L.at(i);
range[i] = P(max,min); 
  
  }

sort(range,range + N);
ll cur = -1000000000;
ll ans = 0;
rep(i,N){
if (cur <= range[i].second) {
  ans ++;
  cur = range[i].first;
}

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


Measured memory_bytes: 2560
/*input
1 1
-1000
*/

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int t; cin >> t; while(t--)
#define MP make_pair
#define PI acos(-1)
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL);

#define MOD(x) ((x)%(1000000007))

int main() {
	godspeed;
	int n, k;
	cin >> n >> k;
	int64 a[n];
	int64 mx = LLONG_MIN;
	rep(i, n) {cin >> a[i]; mx = max(mx, a[i]);}
	sort(a, a+n);
	int64 prod = 1;
	if (k % 2 == 0) {
		int p1 = 0, p2 = n-1;
		rep(i, k/2) {
			if (a[p1] * a[p1+1] < a[p2] * a[p2-1]) {
				prod *= MOD(a[p2] * a[p2-1]);
				p2 -= 2;
			} else {
				prod *= MOD(a[p1] * a[p1+1]);
				p1 += 2;
			}
			prod = MOD(prod);
		}
	} else {
		if (mx == 0) {
			prod = 0;
		} else if (mx < 0) {
			rep(i, k) {
				prod *= a[n-i-1];
				prod = MOD(prod);
			}
		} else {
			prod = a[n-1];
			k--;
			int p1 = 0, p2 = n-2;
			rep(i, k/2) {
				if (a[p1] * a[p1+1] < a[p2] * a[p2-1]) {
					prod *= MOD(a[p2] * a[p2-1]);
					p2-=2;
				} else {
					prod *= MOD(a[p1] * a[p1+1]);
					p1+=2;
				}
				prod = MOD(prod);
			}
		}
	}
	prod = MOD(MOD(prod) + 1000000007);
	cout << prod << endl;
}


/*
3 5 1 4 2 6 --
1st + 2nd + 2nd + 3rd + 3rd
*/

Measured memory_bytes: 5140
import itertools

n = int(input())
ps = tuple(map(int, input().split()))
qs = tuple(map(int, input().split()))

perm = []
for i in range(1, n + 1):
    perm.append(i)

for i, x in enumerate(itertools.permutations(perm)):
    if x == ps:
        a = i
    if x == qs:
        b = i

print(abs(a - b))


Measured memory_bytes: 3060
import kotlin.math.min

fun main() {
    println(solve())
}

val solve: () -> Any = {
    val (N, M, X) = readIntList()
    val list = List(N) { readIntList() }
    val knowledge = MutableList(M) { 0 }

    fun f(cost: Int, knowledge: List<Int>, count: Int): Int {
        if (count == N) {
            return if (knowledge.all { it >= X }) cost else Int.MAX_VALUE
        }
        return min(
            f(cost, knowledge, count + 1),
            f(cost + list[count][0], knowledge.withIndex().map { (i, v) -> v + list[count][i + 1] }, count + 1)
        )
    }

    val ans = f(0, List(M) { 0 }, 0)

    if (ans == Int.MAX_VALUE) -1 else ans
}

val mod: Int = 1_000_000_007


fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

fun <E> List<E>.toPair() = this[0] to this[1]

fun <T> readPair(t: (String) -> T) = readPair(t, t)
fun <S, T> readPair(s: (String) -> S, t: (String) -> T) =
    readLine()!!.split(" ").let { Pair(s(it[0]), t(it[1])) }

fun Int.pow(n: Int) = Math.pow(this.toDouble(), n.toDouble())
fun Int.powInt(n: Int) = pow(n).toInt()

fun minAndMax(a: Int, b: Int) = if (a < b) a to b else b to a


Measured memory_bytes: 41904
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n; cin >> n;
	cout << (n > 29 ? "Yes" : "No") << "\n";
	
	
	
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define vi vector<int>
using namespace std;

const int mod=998244353;
int ksm(int x,int t){
	int tot=1;
	while(t){
		if(t&1) tot=1ll*tot*x%mod;
		x=1ll*x*x%mod;
		t/=2;
	}
	return tot;
}
const int N=2000010;//1<<17
int where[N],limit;
int poor[N<<2],inv[N],n,m,fac[N],finv[N],h[N];
int*w[2][18],*now=poor;
void pre(){
	inv[1]=1;for(int i=2;i<=2*n;i++) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	fac[0]=1;for(int i=1;i<=2*n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	finv[2*n]=ksm(fac[2*n],mod-2);for(int i=2*n-1;i>=0;i--) finv[i]=1ll*finv[i+1]*(i+1)%mod;
	for(int u=0,l=2;u<18;u++,l<<=1){
		w[1][u]=now;now+=l+1;
		w[0][u]=now;now+=l+1;
		w[1][u][0]=1;w[1][u][1]=ksm(3,(mod-1)/l);
		for(int i=2;i<=l;i++) w[1][u][i]=1ll*w[1][u][i-1]*w[1][u][1]%mod;
		for(int i=0;i<=l;i++) w[0][u][i]=w[1][u][l-i];
	}
}
void prepare(int n){
	int l=0;limit=1;
	while(limit<=n) limit<<=1,l++;
	for(int i=0;i<limit;i++) where[i]=(where[i>>1]>>1)|((i&1)<<(l-1));
}
void DFT(vi&now,int op){
	int**w1=w[op];
	for(int i=0;i<limit;i++) if(i<where[i]) swap(now[i],now[where[i]]);
	for(int l=1,u=0,r=2;r<=limit;l=r,r<<=1,u++){
		int*w2=w1[u];
		for(int i=0;i<limit;i+=r){
			for(int v=0;v<l;v++){
				int&x=now[i+v],&y=now[i+l+v],b=1ll*y*w2[v]%mod;
				y=(x>=b)?(x-b):(x+mod-b);
				x=(x+b>=mod)?(x+b-mod):(x+b);
			}
		}
	}
	if(!op){
		int tmp=ksm(limit,mod-2);
		for(int i=0;i<limit;i++) now[i]=1ll*now[i]*tmp%mod;
	}
}
vi operator*(vi f,vi g){
	int tot=f.size()+g.size()-2;
	prepare(tot);f.resize(limit);g.resize(limit);
	DFT(f,1);DFT(g,1);
	for(int i=0;i<limit;i++) f[i]=1ll*f[i]*g[i]%mod;
	DFT(f,0);f.resize(tot+1);
	return f;
}
int a[N];
vi A,B,C,D,E;

vi gas(int l,int r){
	if(l==r){
		vi f;f.resize(h[l]/2+1);f[0]=1;
		int t=inv[2];
		for(int i=1;i<=h[l]/2;i++) 
			f[i]=1ll*fac[h[l]]*t%mod*finv[h[l]-2*i]%mod*finv[i]%mod,t=1ll*t*inv[2]%mod;
		return f;
	}
	int mid=(l+r)/2;
	return gas(l,(l+r)/2)*gas((l+r)/2+1,r);
}

int main(){
	scanf("%d",&n);pre();
	int x;
	for(int i=1;i<=2*n;i++) scanf("%d",&x),h[x]++;
	vi f=gas(1,100000);
	int tot=0,op=1;
	for(int i=0;i<f.size();i++) 
		tot+=1ll*op*f[i]%mod*fac[2*(n-i)]%mod*ksm(inv[2],n-i)%mod*finv[n-i]%mod,op=(op==1)?(mod-1):1,tot%=mod;
	printf("%d",tot%mod);
}

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

int main(void){
  string s1, s2;
  cin >> s1 >> s2;
  if(s1.size() > s2.size()){
    cout << "GREATER" << endl;
    return 0;
  }else if(s1.size() < s2.size()){
    cout << "LESS" << endl;
    return 0;
  }
  for(int i=0;i<s1.size();++i){
    if(s1[i] > s2[i]){
      cout << "GREATER" << endl;
      return 0;
    }else if(s1[i] < s2[i]){
      cout << "LESS" << endl;
      return 0;
    }
  }
  cout << "EQUAL" << endl;
}

Measured memory_bytes: 256