akhauriyash/Code-Regression huggingface dataset:
def search(x, y):
    x_min = 0
    y_min = 0
    x_max = 0
    y_max = 0
    f = 0
    f1 = 1
    f2 = 0
    p = 0
    while(True):
        if ( x_min <= x and x <= x_max and
             y_min <= y and y <= y_max  ): return p%3 + 1
        f = f1 + f2
        if ( p % 4 == 0 ):  x_max += f  # east
        elif ( p % 4 == 1 ): y_max += f # north
        elif ( p % 4 == 2 ): x_min -= f # west
        else:  y_min -= f               # south
        f2 = f1
        f1 = f
        p = p + 1

x,y = map(int, input().split())
print(search(x, y))




Measured memory_bytes: 5600
n=int(input())
a=[int(input()) for _ in range(n)]
a.sort()
if n==2:
  x=a[1]-a[0]
elif n%2==0:
  x=(sum(a[n//2+1:])-sum(a[:n//2-1]))*2
  x-=a[n//2-1]
  x+=a[n//2]
elif n==3:
  x=a[2]*2-a[0]-a[1]
  y=a[2]+a[1]-a[0]*2
  x=max(x,y)
else:
  x=(sum(a[n//2+2:])-sum(a[:n//2]))*2
  x+=a[n//2]+a[n//2+1]
  y=(sum(a[n//2+1:])-sum(a[:n//2-1]))*2
  y-=a[n//2]+a[n//2-1]
  x=max(x,y)
print(x)

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

#define endl '\n'
#define dbg(a) cout << #a << " := " << (a) << endl
#define all(a) (a).begin(), (a).end()

using namespace std;


void solve();
signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    solve();
}


void solve(){
    string s; cin >> s; sort(all(s));
    cout << (s == "abc" ? "Yes" : "No");

}

Measured memory_bytes: 256
import math

a,b,c,x,y = map(int,input().split())

# cを全探索？
res = float('inf')
for i in range(max(x,y)*2+1):
    money = i * c
    if i/2<x:
        money += math.ceil(x-i/2) * a
    if i/2<y:
        money += math.ceil(y-i/2) * b
    res = min(res,money)

print(res)


Measured memory_bytes: 3060
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for i in range(m)]
ans = 'No'
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m] == b[0]:
            for k in range(i+1,i+m):
                if a[k][j:j+m] != b[k-i]:
                    break
            else:
                ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
//LIFE IS NOT A PROBLEM TO BE SOLVED
 
#define rep(i, a, b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
 
using namespace std;
 
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long int LINF = 1LL<<56;

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



int main(){
	
		
	int N, W; cin >> N >> W;
	
	ll dp[W+1]; memset(dp, 0, sizeof dp);
	rep(i, 0, N){
		int w, v; cin >> w >> v;
		for(int j=W; j>=w; j--){
			dp[j] = max(dp[j], dp[j-w]+v);
		}
	}
	
	ll ans = 0;
	rep(i, 0, W+1) ans = max(ans, dp[i]);
	
	cout << ans << "\n";
	
	
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,b,k;
  cin >> a >> b >> k;

  ll diff = min(a,k);

  a = a-diff;
  b = max(0ll,b-(k-diff));
  
  //cout << fixed << setprecision(10);
  
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A, B, C;
    int K;

    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &K);

    for(int i=0; i<K; i++){
        if(C>B && B>A)
        {
            continue;
        }else if(C<=B && B>=A){
            C*=2;
        }else if(C<=B && B<=A){
            C*=2;
        }else if(C>=B && B<=A){
            B*=2;
        }
    }

    if(C>B && B>A){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long
#define inf LLONG_MAX

void solve()
{
	ll n,i;
	ll a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5 and a[1]==5 and a[2]==7)	cout<<"YES";
	else	cout<<"NO";

}


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		solve();
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int K;
    string S;
    cin >> K >> S;

    if (S.size() <= K) {
        cout << S << endl;
    }
    else {
        string ans = "";
        for (int i = 0; i < K; i++) {
            ans.push_back(S.at(i));   
        }
        cout << ans << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

typedef vector<int> Array;
typedef vector<Array> Mat;
int mod = 1000000007;

Mat identify(int n) {
	Mat ret(n, Array(n, 0));
	int i;
	rep(i, n) ret[i][i] = 1;
	return ret;
}

Mat mul(Mat a, Mat b) {
	Mat c(a.size(), Array(b[0].size(), 0));
	int i, j, k;
	
	rep(i, a.size()) {
		rep(j, b[0].size()) {
			rep(k, a[0].size()) {
				c[i][j] += a[i][k] * b[k][j];
				c[i][j] %= mod;
			}
		}
	}
	return c;
}

Array mul(Mat a, Array b) {
	Array c(a.size(), 0);
	int i, j;
	
	rep(i, a.size()) {
		rep(j, b.size()) {
			c[i] += a[i][j] * b[j];
			c[i] %= mod;
		}
	}
	return c;
}

Mat powmod(Mat a, int n) {
	if (n == 0) return identify(a.size());
	if (n % 2 == 0) return powmod(mul(a, a), n / 2);
	return mul(a, powmod(a, n - 1));
}

int n, k;
Mat a;
Array b;

signed main() {
	int i, j;
	cin >> n >> k;
	a.resize(n, Array(n));
	rep(i, n) rep(j, n) cin >> a[j][i];
	a = powmod(a, k);
	b.resize(n);
	rep(i, n) b[i] = 1;
	Array dp = mul(a, b);
	int ans = 0;
	rep(i, n) ans += dp[i];
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <algorithm>
using namespace std;
int vis[1000010],a[200010],in[1000010];
int main(){
	int n,i,j,cnt,mn=1000010,mx=0,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),vis[a[i]]++,in[a[i]]=1,mn=min(mn,a[i]),mx=max(mx,a[i]);
	for(i=1;i<=n;i++){
		cnt=1;
		while(1){
			cnt++;
			if(a[i]*cnt>mx)break;
			vis[a[i]*cnt]++;
		}
	}
	for(i=mn;i<=mx;i++)
		if(in[i]==1&&vis[i]==1)ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10268
%:pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

const int N = 2e3 + 5;
const int M = 4e6 + 5;
const int mod = 1e9 + 7;

int n, k, dp[N][N], fac[M], ifac[M];

inline int mul(int a, int b) {
	return (long long) a * b % mod;
}
inline int add(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}
inline int Pow(int a, int b) {
	int r = 1;
	for(; b; b >>= 1, a = mul(a, a))
		if(b & 1) r = mul(r, a);
	return r;
}

void pre(int n) {
	fac[0] = 1;
	for(int i = 1; i <= n; ++i)
		fac[i] = mul(fac[i - 1], i);
	ifac[n] = Pow(fac[n], mod - 2);
	for(int i = n - 1; ~i; --i)
		ifac[i] = mul(ifac[i + 1], i + 1);
}
inline int C(int n, int m) {
	if(n < 0 || m < 0 || n < m) return 1;
	return mul(fac[n], mul(ifac[m], ifac[n - m]));
}

int main() {
	cin >> n >> k;
	if(k == 1) return 0 * putchar('1');
	pre(M - 1);
	dp[0][0] = 1;
	for(int i = 0; i <= n; ++i)
		for(int j = i +(!i); j <= n; ++j) {
			if(i) dp[i][j] = dp[i - 1][j];
			dp[i][j] = add(dp[i][j], mul(dp[i][j - 1], C(i + j * (k - 1) - 1, k - 2)));
		}
	printf("%d\n", mul(dp[n][n], fac[n]));
	return 0;
}


Measured memory_bytes: 46336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  ll k, x;
  cin >> k >> x;

  if (500 * k >= x){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#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 1000003
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;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())

map<ll,int>mem;
int n,m;
vector<int>edge[50005],redge[50005];

int rec(int l,int r){
	while(edge[l].empty() && l <= r) l += 2;
	while(redge[r].empty() && l <= r) r -= 2;
	if(l > r) return 1;
	ll ky = 50005 * l + r;
	if(mem.find(ky) != mem.end()) return mem[ky];
	//use first edge
	int ans = 0;
	//decreasing order
	for(int i=edge[l].size()-1;i>=0;i--){
		if(edge[l][i] > r) continue;
		ans += 1LL * rec(l+1,edge[l][i]-1) * rec(edge[l][i]+1,r) % mod;
		if(ans >= mod) ans -= mod;
	}
	ans += rec(l+2,r);
	if(ans >= mod) ans -= mod;
	return mem[ky] = ans;
}
int main(){
	while(1){
		scanf("%d%d",&n,&m); if(n==0 && m==0) return 0;
		for(int i=1;i<=n;i++){
			edge[i].clear();
			redge[i].clear();
		}
		mem.clear();
		edge[1].pb(n);
		redge[n].pb(1);
		for(int i=1;i<=m;i++){
			int a,b; scanf("%d%d",&a,&b);
			if(a > b) swap(a,b);
			if(a%2 == b%2) continue;
			if(b-a == 1) continue;
			edge[a].pb(b);
			redge[b].pb(a);
		}
		if(n%2 == 1) {
			puts("0");
			continue;
		}
		for(int i=1;i<=n;i++){
			SORT(edge[i]);
			ERASE(edge[i]);
			SORT(redge[i]);
			ERASE(redge[i]);
			reverse(redge[i].begin(),redge[i].end());
		}
		cout << rec(1,n) << endl;
	}
}


Measured memory_bytes: 13448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> job_rewards(M);
    for (int i = 0; i < N; i++) {
        int A, B; cin >> A >> B;
        if (M < A) continue;
        job_rewards[M - A].push_back(B);
    }

    priority_queue<int> job_queue;
    int ans = 0;

    for (int i = M - 1; i >= 0; i--) {
        for (auto job_reward:job_rewards[i]) {
            job_queue.push(job_reward);
        }
        if (!job_queue.empty()) {
            ans += job_queue.top();
            job_queue.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5504
n,m = map(int,input().split())
list_x = list(map(int,input().split()))
list_sort = sorted(list_x)
if n >= m:
  print(0)
else:
  a = m - n
  list_A = []
  for i in range(m - 1):
    t = list_sort[i+1] - list_sort[i]
    list_A.append(t)
  list_B = sorted(list_A)
  s = 0
  for j in range(a):
    s += list_B[j]
  print(s)

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int s;
  cin >> s;
  vi a{s};
  for (int i = 1; i <= 1000000; i++) {
    if (a[i - 1] % 2 == 0) {
      a.push_back(a[i - 1] / 2);
    } else {
      a.push_back(a[i - 1] * 3 + 1);
    }
    // for (auto e : a) {
    //   printf("%d ", e);
    // }
    // printf("\n");
    for (int j = 0; j < a.size() - 1; j++) {
      if (a[j] == a[i]) {
        cout << i + 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [False]*(k+1)
for i in range(1,k+1):
    for j in range(n):
        if i-a[j]<0:
            break
        if dp[i-a[j]]==False:
            dp[i] = True
            break
if dp[k]==True:
    print("First")
else:
    print("Second")


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

#define MAX 200000

int max(int a,int b) { return a>b ? a: b;}
int min(int a,int b) { return a<b ? a: b;}

int main(void) {
	int R[MAX], i, n;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&R[i]);
	
	int maxv = -2000000000;
	int minv = R[0];
	
	for(int i=1; i<n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	
	printf("%d\n",maxv);

	return 0;
}


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

int main(){

int N;
cin>>N;

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

}
cout<<counter/2<<"\n";








}

Measured memory_bytes: 640
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
const int maxn=100000+5;
const ll INF=1000000000000000LL;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
/*int n,a[2][105],dp[2][105];
int main(){
    read(n);
    for (int i=1;i<=2;i++){
        for (int j=1;j<=n;j++){
            read(a[i][j]);
        }
    }
    for (int i=1;i<=2;i++){
        for (int j=1;j<=n;j++){
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
        }
    }
    cout<<dp[2][n]<<endl;
    return 0;
}*/
int n,m,L,R,D,dis[maxn];
bool vis[maxn];
vector<pair<int,int> >G[maxn];
bool dfs(int u){
    vis[u]=true;
    for (int i=0;i<(int)G[u].size();i++){
        int v=G[u][i].F;
        if (!vis[v]){
            dis[v]=dis[u]+G[u][i].S;
            if (!dfs(v)) return false;
        }
        else if (dis[u]+G[u][i].S!=dis[v]) return false;
    }
    return true;
}
int main(){
    read(n),read(m);
    for (int i=1;i<=m;i++){
        read(L),read(R),read(D);
        G[L].pb(make_pair(R,D));
        G[R].pb(make_pair(L,-D));
    }
    for (int i=1;i<=n;i++){
        if (!vis[i]){
            if (!dfs(i)) return puts("No"),0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
    int N, K, count;
    cin >> N >> K;
    long double p=0, k;

    for(int i=1;i<N+1;i++){
        k = (long double)K / i;
        for(int c=0;;c++){
            if(powl(2.0, c) >= k){
                count = c;
                break;
            }
        }
        p += (1 - powl(0.5, count))/N;
    }

    printf("%.12Lf", 1 - p);
}

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

long long a[100005];
long long pos[100005];

int main()
{
    long long n; ///LL
    cin >> n;
    for(long long i =0; i < n; ++i){
        cin >> a[i];
    }

    long long sum = 0;
    long long mi = 987654321;
    long long us = 0;
    for(long long i = 0; i < n; ++i){
        sum += abs(a[i]);
        mi = min(mi, abs(a[i]));
        if(a[i] < 0){
            us++;
        }
    }

    sum = (us % 2 == 0 ? sum : sum - 2 * mi);

    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
Branch = [list(map(int,input().split())) for i in range(M)]
Glaph = [[0 for i in range(N)] for i in range(N)]
for b in Branch:
  Glaph[b[0]-1][b[1]-1] = 1
  Glaph[b[1]-1][b[0]-1] = 1
Visited = [0 for i in range(N)]
  
def dfs(v,N,Visited):
  flag = True
  for i in range(N):
    if Visited[i] == 0:
      flag = False
  if flag:
    return 1
  
  ret = 0
  
  for i in range(N):
    if Glaph[v][i] == False: continue
    if Visited[i]: continue    
    Visited[i] = 1    
    dfs(i,N,Visited)
  
  return Visited

ans = 0
for b in Branch:
  for i in range(N):
    Visited[i] = 0
  Visited[b[0]-1] = 1
  
  Glaph[b[0]-1][b[1]-1] = 0
  Glaph[b[1]-1][b[0]-1] = 0
  
  Visited = dfs(b[0]-1,N,Visited)
  
  Glaph[b[0]-1][b[1]-1] = 1
  Glaph[b[1]-1][b[0]-1] = 1
  
  if Visited[b[1]-1] == 0:
    ans += 1
  
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String num = new String(in.readLine());
        String[] numarray = num.split("");
        boolean flg = true;

        for(int i = 1; i < numarray.length + 1; i++){
        	if(i % 2 == 0){
        		if(numarray[i-1].equals("R")){
        			flg = false;
        			break;
        		}
        	}else{
        		if(numarray[i-1].equals("L")){
        			flg = false;
        			break;
        		}
        	}
        }
        if(flg){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

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

int main()
{

    int n,k,pos;
    cin>>n>>k;
    int arr[n];
    k--;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]==1) pos=i;
    }
    int ans=0;
    ans=(n-1+k-1)/k;
    cout<<ans<<endl;

    return 0;
}

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

#define ll long long
using namespace std;
#define maxn 100000+100
int v[100];

int main() {
    int n;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v, v + n);
    sum = 1.0 * v[0];
    for (int i = 1; i < n; ++i) {
        sum = (sum + v[i]) * 1.0 / 2.0;
    }
    printf("%.7lf\n", sum);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<map>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
typedef pair<pair<int, int>, pair<int, int> > ppp;

int w, h;
bool gone[50][50][50][50];
int rf[50][50];
int lf[50][50];

int dw[4] = {0, 1, 0, -1};
int dh[4] = {-1, 0, 1, 0};

int main(){
    map<char, int> m;
    m.insert(make_pair('.', 0));
    m.insert(make_pair('#', 1));
    m.insert(make_pair('%', 2));
    m.insert(make_pair('R', 0));
    m.insert(make_pair('L', 0));
    
    while(1){
        cin >> w >> h;
        if(w == 0) break;

        queue<ppp> que;
        ppp p;
        REP(i, h){
            string s;
            cin >> s;
            REP(j, w){
                lf[i][j] = m.at(s[j]);
                if(s[j] == 'L'){
                    p.second = make_pair(i, j);
                }
            }
            cin >> s;
            REP(j, w){
                rf[i][j] = m.at(s[j]);
                if(s[j] == 'R'){
                    p.first = make_pair(i, j);
                }
            }
        }

        que.push(p);

        REP(i, h) REP(j, w) REP(k, h) REP(l, w) gone[i][j][k][l] = false;
        gone[p.first.first][p.first.second][p.second.first][p.second.second] = true;

        bool flag = false;
        while(!que.empty()){
            ppp p = que.front();
            que.pop();

            int rh = p.first.first;
            int rw = p.first.second;
            int lh = p.second.first;
            int lw = p.second.second;

            REP(i, 4){
                int nrh = rh + dh[i];
                int nrw = rw + dw[i];
                int nlh = lh + dh[i];
                int nlw = lw - dw[i];
                if(rf[nrh][nrw]==1 || nrh<0 || nrh>=h || nrw<0 || nrw>=w){
                    nrh = rh; nrw = rw;
                }
                if(lf[nlh][nlw]==1 || nlh<0 || nlh>=h || nlw<0 || nlw>=w){
                    nlh = lh; nlw = lw;
                }
                if((rf[nrh][nrw]==2 && lf[nlh][nlw]!=2) || (rf[nrh][nrw]!=2 && lf[nlh][nlw]==2)){
                    continue;
                }
                if(rf[nrh][nrw]==2 && lf[nlh][nlw]==2){
                    flag = true;
                    queue<ppp> empty;
                    swap(que, empty);
                    break;
                }
                if(!gone[nrh][nrw][nlh][nlw]){
                    gone[nrh][nrw][nlh][nlw] = true;
                    que.push(make_pair(make_pair(nrh, nrw), make_pair(nlh, nlw)));
                }
            }
        }

        if(flag){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

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

int main(){
	int c[3][3];
	rep(i,3){
		rep(j,3) cin >> c[i][j];
	}
	bool ans=false;
	rep(i,101){
		int num=0;
		int a[3], b[3];
		a[0]=i, b[0]=c[0][0]-a[0];
		a[1]=c[1][0]-b[0], b[1]=c[0][1]-a[0];
		a[2]=c[2][0]-b[0], b[2]=c[0][2]-a[0];
		rep(j,3){
			rep(k,3){
				if(a[j]+b[k]==c[j][k]) num++;
			}
		}
		if(num==9) ans=true;
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,raw_input().strip().split(' '))
graph = [[] for i in range(n)]
for i in range(m):
    s,t = map(int,raw_input().strip().split(' '))
    graph[s].append(t)
    graph[t].append(s)

color = {}
c = 0
for i in range(n):
    if not i in color:
        que = [i]
        color[i] = c
        while len(que) > 0:
            u = que[0]
            for v in graph[u]:
                if not v in color:
                    color[v] = c
                    que.append(v)
            del que[0]
        c += 1


q = int(raw_input())
for i in range(q):
    s,t = map(int,raw_input().strip().split(' '))
    if color[s] == color[t]:
        print 'yes'
    else:
        print 'no'

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

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

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


Measured memory_bytes: 6728
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
k = int(input())
s = input()

if len(s) <= k:
    print(s)
else:
    print(s[:k] + '...')


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

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

    if(s.at(k-1) == 'A') s.at(k-1) = 'a';
    else if(s.at(k-1) == 'B') s.at(k-1) = 'b';
    else s.at(k-1) = 'c';

    cout << s << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n,m,i,j;
	scanf("%d%d",&n,&m);
	int a[n],b[n],c[m],d[m],min,check,temp;

	for(i=0;i<n;i++)
		scanf("%d%d",&a[i],&b[i]);
	for(i=0;i<m;i++)
		scanf("%d%d",&c[i],&d[i]);
	
	for(i=0;i<n;i++){
		min=500000000;
		for(j=0;j<m;j++){
			temp=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(temp<min){
				min=temp;
				check=j+1;
			}
		}
		printf("%d\n",check);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
int main () {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (abs(c-a)<=d || abs(b-a)<=d && abs(c-b)<=d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

ll a,b;
int main(){
    cin >> a >> b;
    if(b==0){
        cout << a*a << endl;
        return 0;
    }
    ll ans = 0;
    for(int x = 1; x < a+1; ++x){
        if(x-1 >= b){
            ans += a/x*(x-b);
            ans += max(0LL,(a%x) - b + 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		System.out.println(a[a.length - 1] - a[0]);
		scan.close();

	}

}


Measured memory_bytes: 20692
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
int a[100000];
int dp[100000];
int main() {
  int n, k;
  cin >> n >> k;
  int inf = 1 << 30;
  rep(i, n){
    cin >> a[i];
    dp[i] = inf;
  }
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  for(int i = 2; i < n; i++){
    reps(j, k){
      if(i >= j)
        chmin(dp[i], dp[i-j] + abs(a[i] - a[i - j])); 
      else break;
    }
  }
  cout << dp[n-1] << endl;
}


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

using namespace std;

int n, a[100005], m, b[100005];

int main(void)
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = n; i >= 1; --i)
    {
        int tmp = upper_bound(b + 1, b + 1 + m, a[i]) - b;
        if (tmp == m + 1)
            b[++m] = a[i];
        else b[tmp] = a[i];
    }
    printf("%d\n", m);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
typedef long long ll;

void ans(bool qus)
{
    if (qus == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Ans(bool qust)
{
    if (qust == true)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

////////////////---START---////////////////

int main(){
    vector<vector<char>> vec(3,vector<char>(3));
    rep(i,3){
        rep(j,3){
            cin >> vec.at(i).at(j);
        }
    }
    rep(i,3){
        cout << vec.at(i).at(i);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,i;
  cin>>N;
  long long ans=0;
 
  long long a[3*N];
  for (i=0;i<3*N;i++)cin>>a[i];
  sort(a,a+3*N);
  reverse(a,a+3*N);
  
  for (i=0;i<N;i++){
    ans += a[2*i+1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 5988
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import defaultdict

def f(x):
    return (int(str(x)[0]), int(str(x)[-1])) 
def main():
    N = int(readline())
    df = defaultdict(int)
    for i in range(1, N+1):
        df[f(i)] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans +=  df[(i, j)]*df[(j, i)]
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 40556
#include <iostream>

using namespace std;

int main()
{
    int n , t ,r ,mini ,total=0 ;
    cin>> n >> t ;
    int a[n] ;
    for(int i=0 ; i<n ; i++){
        cin >> a[i] ;
    }
    for(int i=0 ; i<=n ;i++){
           for(int f=0 ; f<n-1 ;f++){
            if (a[f]>a[f+1]){
                mini = a[f] ;
                a[f]=a[f+1];
                a[f+1]=mini ;

        }
           }
    }
    for(int i=0 ; i<t ;i++){
        total+=a[i];
    }
    cout<< total << endl;
    return 0;
}

Measured memory_bytes: 3520
#include<stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int num[n];
	int i,temp;
	for(i = 0;i < n;i++){
		scanf("%d",&num[i]);
	}
	for(i = 0;i < (n / 2);i++){
		temp = num[i];
		num[i] = num[n - i - 1];
		num[n - i -1] = temp;
	}
	for(i = 0;i < n - 1;i++){
		printf("%d ",num[i]);
	}
	printf("%d\n",num[i]);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int     H;
int     N;
int     A[1001];
int     B[1001];

int             max(int a, int b)
{
        if (a > b)
                return (a);
        else
                return (b);
}

int             culc_answer(int dp[10001])
{
        int     i;
        int     j;

        for (i = 0; i < 100000001; i++)
        {
                if (dp[i % 10000] >= H)
                        break ;
                for (j = 0; j < N; j++)
                {
                        if (i + B[j] < 100000001)
                                dp[(i + B[j]) % 10000] = max(dp[(i  + B[j]) % 10000], dp[i % 10000] + A[j]);
                }
        }
        return (i);
}

int             main(void)
{
        int     i;
        int     answer;
        int     dp[10001] = {0};

        scanf("%d%d", &H, &N);
        for (i = 0; i < N; i++)
        {
                scanf("%d%d", &A[i], &B[i]);
        }
        answer = culc_answer(dp);
        printf("%d\n", answer);
        return (0);
}

Measured memory_bytes: 1752
n=int(input())
a=list(map(int,input().split()))
d=dict()
ans=0
for i in range(n):
    if a[i]-(i+1) in d:
       # print(a[i]-(i+1))
        ans+=d[a[i]-(i+1)]
    if -(i+1+a[i]) in d:
        d[-(i+1+a[i])]+=1
    else:
        d[-(i+1+a[i])]=1
print(ans)

Measured memory_bytes: 40276
s = gets.strip
q = gets.to_i

is_reverse = false
header = []
footer = []

q.times do
  q, t, c = gets.split(' ')
  if q.to_i == 1 then
    is_reverse = !is_reverse
  elsif t.to_i == 1 then
    if is_reverse then
      footer.push(c.strip)
    else
      header.push(c.strip)
    end
  else
    if is_reverse then
      header.push(c.strip)
    else
      footer.push(c.strip)
    end
  end
end

s = header.join.reverse + s + footer.join

if is_reverse then
	puts s.reverse
else
	puts s
end


Measured memory_bytes: 17276
h, w = map(int, input().split(" "))
s = []
s.append(["."] * (w + 2))
for i in range(h):
  s.append(list("."+input()+"."))
s.append(["."] * (w + 2))

for i in range(1, h + 1):
  for j in range(1, w + 1):
    if s[i][j] != "#":
      tmp = ""
      tmp += s[i-1][j-1]+s[i-1][j]+s[i-1][j+1]
      tmp += s[i][j-1]+s[i][j+1]
      tmp += s[i+1][j-1]+s[i+1][j]+s[i+1][j+1]
      s[i][j] = str(tmp.count("#"))

for i in range(1, h + 1):
  for j in range(1, w + 1):
    print(s[i][j], end="")
  print()

Measured memory_bytes: 9220
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int d;
    cin >> d;
    string ans;
    if (d == 25) ans = "Christmas";
    if (d == 24) ans = "Christmas Eve";
    if (d == 23) ans = "Christmas Eve Eve";
    if (d == 22) ans = "Christmas Eve Eve Eve";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	int n;
	cin >> n;
	vector<int> a(n), l(n, -1);
	rep(i, 0, n){
		cin >> a[i];
		a[i]--;
		if(l[a[i]] == -1){
			if(a[i] == 0 || l[a[i] - 1] != -1){
				l[a[i]] = i;
			}
		}
	}
	int ans = -1;
	rep(i, 0, n){
		if(l[i] == -1) break;
		ans = i + 1;
	}
	if(ans == -1) cout << -1 << endl;
	else cout << n - ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <unordered_set>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
bool ok(int ans,int d[]){
    bool flag = true;
    while(ans){
        if(d[ans%10]==1) flag = false;
        ans/=10;
    }
    return flag;
}
int main(){
    int n,k;
    int d[10]={};
    int temp;
    cin >> n >> k;
    rep(i,k){
        cin >> temp;
        d[temp]=  1;
    }
    int ans = n;
    while(1){
        if(ok(ans,d)==true) break;
        else ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <string.h>

using namespace std;

typedef struct{
	int t;
	int c;
	int r;
} edge;

vector<edge> g[1002];

void add_edge(int from,int to,int cap){
	edge e1 = {to,cap,g[to].size()};
	g[from].push_back(e1);
	edge e2 = {from,0,g[from].size() - 1};
	g[to].push_back(e2);
}


int gcd(int x,int y){
	if(!y) return x;
	return gcd(y,x % y);
}

int uv[1002];

int dfs(int v,int t,int f){
	int i;
	if(v == t) return f;
	uv[v] = 0;
	for(i = 0;i < g[v].size();i++){
		if(uv[g[v][i].t] && g[v][i].c > 0){
			int d = dfs(g[v][i].t,t,min(f,g[v][i].c));
			if(d > 0){
				g[v][i].c -= d;
				g[g[v][i].t][g[v][i].r].c += d;
				return d;
			}
		}
	}
	return 0;
}


int maxflow(int s,int t){
	int f, res = 0;
	while(1){
		memset(uv,-1,sizeof(uv));
		f = 0;
		f += dfs(s,t,2);
		if(f == 0) return res;
		res += f;
	}
	return res;
}

int main(void){
	int m, n, b[500], r[500], i, j;
	while(1){
		scanf("%d%d",&m,&n);
		if(m + n == 0) break;
		for(i = 0;i < m;i++)
			scanf("%d",&b[i]);
		for(i = 0;i < n;i++)
			scanf("%d",&r[i]);
		for(i = 0;i < m;i++)
			add_edge(0,i + 1,1);
		for(i = 0;i < m;i++){
			for(j = 0;j < n;j++){
				if(gcd(b[i],r[j]) != 1){
					add_edge(i + 1,m + j + 1,1);
				}
			}
		}
		for(i = 0;i < n;i++)
			add_edge(m + i + 1,m + n + 1,1);
		printf("%d\n",maxflow(0,m + n + 1));
		for(i = 0;i < m + n + 2;i++)
			while(g[i].size()) g[i].pop_back();
	}
	return 0;
}

Measured memory_bytes: 7340
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int a, b; cin >> a >> b;
	string str; cin >> str;
	bool ok = true;
	if(str.size() != a + b + 1) ok = false;
	if(ok){
		rep(i, a) if(!isdigit(str[i])) ok = false;
		rep(i, b) if(!isdigit(str[i+a+1])) ok = false;
		if(str[a] != '-') ok = false;
	}
	if(!ok){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#define N (1000000000+7)
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;


int main(void){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k)cout<<k<<endl;
    else{
        ll ans = a;
        k-=a;
        if(b>=k)cout<<ans<<endl;
        else{
            k-=b;
            cout<<ans-k<<endl;
        }
    }
    return 0;
}

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


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

    if (A >= 13) cout << B << endl;
    else if (A >= 6) cout << B/2 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class b{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int x = int.Parse(str[0]);
    int y = int.Parse(str[1]);
    int legs;
    String ans = "No";
    for(int i=0; i<=x; i++){
      legs = 2*i+(x-i)*4;
      if(legs == y){
        ans = "Yes";
        break;
      }
    }
    Console.WriteLine(ans);
  }
}


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

using namespace std;

int main(){
    int n,m,s,c;
    cin >>n >>m;
    vector<int> ans(n+1,0);
    for(int i=0;i<m;i++){
        cin >>s >> c;
        if(ans[s]!=0&&ans[s]!=c){
            cout << -1 <<endl;
            return 0;
        }

        if(n!=1&&s==1&&c==0){
            cout << -1 <<endl;
            return 0;
        }
        
        ans[s] =c;
    }

    
    
    if(ans[1]==0 && n!=1){
        ans[1] =1;
    }

    for(int h=1;h<n+1;h++){
        cout << ans[h];
    }
}

Measured memory_bytes: 256
from sys import stdin,stdout                           #
import math                                            #
import heapq                                           #
                                                       #
t = 1                                                  #
def aint():                                            #
	return int(input().strip())                        #
def lint():                                            #
	return list(map(int,input().split()))              #
def fint():                                            #
	return list(map(int,stdin.readline().split()))     #
                                                       #	
########################################################
def f(n):
	if n==0:
		return 0
#	print(n)
	N=n
	cnt=0
	while(N):
		cnt+=N&1
		N>>=1
	return f(n%cnt)+1

def main():
	n=aint()
	x=input()
	c=x.count("1")
	if(c==0):
		for i in range(n):
			print("1")
		return
	elif(c==1):
		for i in range(n):
			if(x[i]=="1"):
				print(0)
			elif x[i]=="0":
				if x[n-1]=="1"or i==(n-1):
					print("2")
				else:
					print(1)
		return
	mod1=c+1
	mod2=c-1
	mul1=1
	mul2=1
	rem1=0
	rem2=0
	for i in range(n-1,-1,-1):
		if(x[i]=='1'):
			rem1=(rem1+mul1)%mod1
			rem2=(rem2+mul2)%mod2
		mul1=(2*mul1)%mod1
		mul2=(2*mul2)%mod2
	ans=[]
	mul1=1
	mul2=1
#	print(mod1,mod2)
#	print(rem1,rem2)
	for i in range(n-1,-1,-1):
		if(x[i]=='0'):
#			print("At index",i,"val",(rem1+mul1)%mod1)
			ans.append(f((rem1+mul1)%mod1)+1)
		else:
#			print("At index",i,"val",(rem2-mul2)%mod2)
			ans.append(f((rem2-mul2)%mod2)+1)
		mul1=(2*mul1)%mod1
		mul2=(2*mul2)%mod2
#	print("Ans:")
	for i in range(n-1,-1,-1):
		print(ans[i])
	return

#t=int(input())

########################################################
for i in range(t):                                     #
	#print("Case #"+str(i+1)+":",end=" ")		       #
	main()                                             #

Measured memory_bytes: 89268
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  ll w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<fixed<<setprecision(10)<<(long double)w*(long double)h/2;
  cout<<' ';
  if(w%2!=0 or h%2!=0) cout<<0<<endl;
  else{
    if(x==w/2 and y==h/2) cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,i;
	scanf("%d",&n);
	double A,B,ans;
	for(i=0;i<n;i++){
		scanf("%lf",&A);
		B=(double)B+(1.0/(double)A);
	}
	
	ans=(double)(1.0/B);
	printf("%lf",ans);


}


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

int main(){
    int N, D, X;
    int A[110];
    cin >> N >> D >> X;
    for (int i = 0; i < N; ++i) cin >> A[i];
    int sum = 0;
    for (int i = 0; i < N; ++i){
        int count = 0;
        for (int j = 0; j < D; ++j){
            if (j * A[i] + 1 > D) break;
            else ++count;
        }
        sum += count;
    }
    cout << sum + X << endl;
}

Measured memory_bytes: 888
from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    x,y,z=map(int,input().split())
    x,y=x-1,y-1
    G[x].append(y)
    G[y].append(x)
ans=0
t=0
k=0
reached=[0]*N
stack=deque()
while(t!=N):
    for i in range(k,N):
        if  reached[i]==0:
            reached[i]=1
            t+=1
            stack=deque(G[i])
            k=i+1
            break
    while(stack):
        g=stack.pop()
        if reached[g]==0:
            reached[g]=1
            t+=1
        for i in G[g]:
            if reached[i]:
                continue
            stack.append(i)
    #print(reached)
    #print(t)
    ans+=1
print(ans)


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e10;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

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

    int cost = INF;
    rep( i , n ){
        int c , _t;
        cin >> c >> _t;

        if(_t <= t) {
            cost = min(cost , c);
        }
    }
    if(cost == INF) {
        cout << "TLE" << endl;
        return 0;
    }

    cout << cost << endl;
}



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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

ll gcd(ll a, ll b);

ll sum(int n);

void go(){
   int a,b;cin>>a>>b;
   int ans=0;
   int cnt=1;
   while(cnt<b){
      cnt--;
      cnt+=a;
      ans++;
   }
   cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll gcd(ll a, ll b){     
   if(b == 0) return a;
   
   return gcd(b, a % b);
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


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

void bubble(struct card a[], int n){
  rep(i,n){
    for(int j=n-1; j>= i+1; j--){
      if(a[j].value < a[j-1].value){
        card t = a[j];
        a[j] = a[j-1];
        a[j-1] = t;
      }
    }
  }
}
void selection(struct card a[], int n){
  rep(i,n){
    int minj = i;
    for(int j=i; j<n; j++){
      if(a[j].value < a[minj].value) minj = j;
    }
    card t = a[i];
    a[i] = a[minj];
    a[minj] = t;
  }
}
void print(struct card a[], int n){
  rep(i,n){
    if(i>0) cout << " ";
    cout << a[i].suit << a[i].value;
  }
  cout << endl;
}

bool isStable(struct card c1[], struct card c2[], int n){
  rep(i,n) if(c1[i].suit != c2[i].suit) return false;
  return true;
}
int main(){
  card c1[100],c2[100];
  int n;
  char ch;
  cin >> n;
  rep(i,n) cin >> c1[i].suit >> c1[i].value;
  rep(i,n) c2[i] = c1[i];
  bubble(c1,n);
  selection(c2,n);
  print(c1,n);
  cout << "Stable" << endl;
  print(c2,n);
  if(isStable(c1,c2,n)) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  return 0;
}


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

signed main(){
  int A,B;
  cin>>A>>B;
  if(A==1)A=14;
  if(B==1)B=14;
  if(A>B)cout<<"Alice"<<endl;
  if(B>A)cout<<"Bob"<<endl;
  if(A==B)cout<<"Draw"<<endl;
  return 0;
}

Measured memory_bytes: 3596
n = int(input())
dat_a = list(map(int, input().split()))
dat = set()
all_color = 0

for i in range(n):
    if dat_a[i] < 400:
        dat.add("a")
    elif dat_a[i] < 800:
        dat.add("b")
    elif dat_a[i] < 1200:
        dat.add("c")
    elif dat_a[i] < 1600:
        dat.add("d")
    elif dat_a[i] < 2000:
        dat.add("e")
    elif dat_a[i] < 2400:
        dat.add("f")
    elif dat_a[i] < 2800:
        dat.add("g")
    elif dat_a[i] < 3200:
        dat.add("h")
    else:
        all_color += 1

colored = len(dat)

resmin = colored
if resmin == 0 and all_color > 0:
    resmin = 1

resmax = colored + all_color
#if resmax > 8:
#    resmax = 8

print("{0} {1}".format(str(resmin), str(resmax)))

Measured memory_bytes: 3064