akhauriyash/Code-Regression huggingface dataset:
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


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

    ll a,b,c,d,m,n,maxi=0,f=0,g=0,mini=INF,sum=0;
    cin>>a>>b>>n;
    m=a;
    c=a/n;
    a=c*n;
    if(a!=m) a+=n;
    m=b;
    d=b/n;
    b=d*n;
    if(b>m) b-=n;
    //cout<<a<<" "<<b<<endl;
    cout<<(b-a)/n+1<<endl; 
    return 0;
}


Measured memory_bytes: 3600
import numpy as np

n, m, x = map(int, input().split())

loop_number = pow(2, n)

minimum_first = pow(10, 10)

minimum = 0
minimum += minimum_first

data = np.zeros((n, m+1))

for i in range(n):
    data[i] = np.asarray(input().split(), dtype=np.uint32)

for i in range(loop_number):
    a_sum = np.zeros(m)
    c_sum = 0
    for j in range(n):
        if np.bitwise_and(i, pow(2,j)):
            a_sum += data[j][1:]
            c_sum += data[j][0]

    if np.min(a_sum) >= x and c_sum < minimum:
        minimum = c_sum

if minimum == minimum_first:
    print(-1)
else:
    print(int(minimum))



Measured memory_bytes: 27284
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    string s;
    cin >> s;
    int i;
    int cnt = 0;
    int ma = 0;
    for (i = 0; i < 3; i++)
    {
        if (s.at(i) == 'R')
            cnt++;
        else
            cnt = 0;
        ma = max(ma, cnt);
    }
    cout << ma << endl;
    
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
const int MAX = 51000;
const int MOD = 998244353;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n,int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
ll hugou(ll a){
	if(a%2==0) return 1;
	else return -1;
}
int main(){
	int K,N;
	scan(K);scan(N);
	COMinit();
	ll zentai=COM(K+N-1,N);
	ll KHj[4001];
	for(int i=N-2;i>=0;i-=2){
		KHj[i]=COM(K+i-1,i);
	}
	//printf("zentai: %lld\n",zentai);
	for(int i=2;i<=K*2;i++){
		ll toori=zentai;
		ll peanum=min(i/2,i/2-(i-K)+1);
		//printf("i:%d peanum:%lld\n",i,peanum);
		for(int nowpeanum=1;nowpeanum<=min((ll)(N-2)/2+1,peanum);nowpeanum++){
			toori+=(hugou(nowpeanum)*KHj[N-nowpeanum*2]*COM(peanum,nowpeanum))%MOD;
			toori+=MOD;
			toori%=MOD;
			//printf("%d %lld %lld\n",nowpeanum,KHj[N-nowpeanum*2],COM(i/2,nowpeanum));
		}
		prin(toori%MOD);
	}
	return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.nextLine();
		int cnt = 0;
		while (true) {
			String str = sc.next();
			if (str.equals("END_OF_TEXT"))
				break;
			if (str.equalsIgnoreCase(w))
				++cnt;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 26096
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const int MAX = 1e5 + 100;


vector<P>G[MAX];
bool used[MAX];

ll prim(){
    priority_queue<P, vector<P>, greater<P>>pq;
    memset(used, 0, sizeof(used));
    pq.push(P(0,0));
    ll ret = 0;

    while(!pq.empty()){
        ll cost = pq.top().first, v = pq.top().second;
        pq.pop();
        if(used[v])continue;
        used[v] = true;
        ret += cost;

        for(int i = 0; i < G[v].size(); i++){
            pq.emplace(G[v][i].first, G[v][i].second);
        }
    }
    return ret;
}


int main(){
    int n;
    cin >> n;
    vector<P>X, Y;

    rep(i, n){
        ll x, y;
        cin >> x >> y;
        X.emplace_back(x, i);           //(x座標,何番目の頂点)
        Y.emplace_back(y, i);           //(y座標,何番目の頂点)
    }

    sort( ALL(X) );
    sort( ALL(Y) );
    

    rep(i, n - 1){
        G[X[i + 1].second].emplace_back(X[i + 1].first - X[i].first, X[i].second);

        G[X[i].second].emplace_back(X[i + 1].first - X[i].first, X[i + 1].second);


        G[Y[i + 1].second].emplace_back(Y[i + 1].first - Y[i].first, Y[i].second);

        G[Y[i].second].emplace_back(Y[i + 1].first - Y[i].first, Y[i + 1].second);
    }

    ll res = prim();
    cout << res << endl;
}



Measured memory_bytes: 20584
#include <stdio.h>
int main(void){
    int S,s,m,h;
    
    
    scanf("%d",&S);
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
    
    }


Measured memory_bytes: 2108
#include <iostream>
#include <set>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int s;
  set<int> a;
  cin >> s;
  int p;
  for (int i = 1; i < 1000000; ++i) {
    if (i == 1) {
      a.insert(s);
      p = s;
      continue;
    }
    if (p % 2 == 0) {
      s = p / 2;
    } else {
      s = p * 3 + 1;
    }
    if (a.find(s) != a.end()) {
      cout << i << endl;
      break;
    }
    a.insert(s);
    p = s;
  }

  return 0;
}


Measured memory_bytes: 3196
/*
	*#*#*#* Author GaryMr *#*#*#*
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	匹配括号 左减右>=0
	多组数据清空？
	dp优化用g？
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define IT iterator
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,bk,ans;//n<=100
stack<mp> s;
int main(){
	scanf("%d",&n);
	if(n%2){ bk=n-1;
	}
	else bk=n;
	rb(i,1,n){
		rb(j,i+1,n){
			if(j==bk) continue;
			ans++;
			s.push({i,j});
		}
		bk--;
	}
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++){
		printf("%d %d\n",s.top().first,s.top().second);
		s.pop(); 
	} 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        explicit Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;

bool is_mid(int x, int l, int r){
    return ((l < x and x <= r )or (r < x and x <= l));
}

void sub_main(istream &is) {
    int n;
    is >> n;
    if(!is) return;
    vector<int> p(n);
    for (auto &&j : p) {
        is >> j;
    } // end j
    int cnt = 0;
    for (int i = 1; i < n-1; ++i) {
        cnt += is_mid(p[i], p[i-1], p[i+1]);
    } // end i
    cout << cnt << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_B.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

int main(void){
  int n,m;
  int i,j;

  scanf("%d%d",&n,&m);
  int a[m];
   long long int b[n];
  for(i=0;i<n;i++)
  b[i]=100;




  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    b[a[i]-1]=0;
    if(i>0&&(a[i]==a[i-1]+1)){
      printf("%d",0);
      return 0;
    }
  }


  //ここから先は二つ連続で穴が来ることはないから。

  if(b[0]==0)
  b[1]=1;
  else if(b[1]==0)
  b[0]=1;
  else{
    b[0]=1;
    b[1]=2;
  }

  for(i=2;i<n;i++){
    if(b[i]!=0)
    b[i]=b[i-1]+b[i-2];
    b[i]=b[i]%1000000007;
  }
  b[n-1]=b[n-1]%1000000007;
  //for(i=0;i<n;i++)
  //printf("%ddanme:%lld\n",i+1,b[i]);
  printf("%lld",b[n-1]);
  return 0;
}


Measured memory_bytes: 1152
import math

N,D = list(map(int, input().split()))
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
#print(X)
c = 0
for i in range(N):
    for j in range(i+1, N):
        #print(i,j)
        a = math.sqrt(sum([(X[i][k]-X[j][k])**2 for k in range(D)]))
        #print(a, float(int(a)))
        if a-float(int(a))==0:
            c+=1
            
print(c)
            

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  string s;
  cin>>s;
  int ans=inf;
  rep(i,s.size()-2){
    ans=min(ans,abs(753LL-stoi(s.substr(i,3))));
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 256
N = int(input())
S = input()

if len(set(S)) == 1:
    print(0)
    exit()

b = 0
w = 0
stones = [(0,0)]
for i in S:
    if i == "#":
        b += 1
    else:
        w += 1
    stones.append((b,w))

bb = S.count("#")
ww = S.count(".")

ans = 1e9

for b,w in stones:
    ans = min(ans,b+ww-w)

print(ans)


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

using namespace std;

int main(){
    ios_base::sync_with_stdio (false);
    int n;
    cin >> n;
    int res=0;
    int l, r;
    for(int i=0; i<n; ++i){
        cin >> l >> r;
        res+=r-l+1;
    }

    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, count; cin >> N;
	vector<int> B(N);
  
  for(int i = 0; i < N - 1; i++){
  cin >> B[i];
  }
  B[N - 1] = 100001;
  count += B[0];
    for(int i = 0; i < N - 1; i++){
  count += min(B[i], B[i + 1]);
    }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=505;

int n;
int tx[MAXN],ty[MAXN];//0:and 1:or
ull ax[MAXN],ay[MAXN];
int bx[MAXN],by[MAXN],t[MAXN][MAXN],cnt[MAXN];
ull res[MAXN][MAXN];

int main()
{
	readint(n);
	for(int i=1;i<=n;++i)cin>>tx[i];
	for(int i=1;i<=n;++i)cin>>ty[i];
	for(int i=1;i<=n;++i)cin>>ax[i];
	for(int i=1;i<=n;++i)cin>>ay[i];
	for(int k=0;k<64;++k)
	{
		int hx[4]={0,0,0,0},hy[4]={0,0,0,0};
		for(int i=1;i<=n;++i)
		{
			bx[i]=(ax[i]>>k)&1,by[i]=(ay[i]>>k)&1;
			++hx[tx[i]*2+bx[i]];
			++hy[ty[i]*2+by[i]];
		}
		if(hx[1] && hy[2])return 0*printf("-1\n");
		if(hx[2] && hy[1])return 0*printf("-1\n");
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=n;++j)t[i][j]=bx[i];
			cnt[i]=n;
		}
		for(int j=1;j<=n;++j)
			if(ty[j]!=by[j])
				for(int i=1;i<=n;++i)
					if(t[i][j]!=by[j])--cnt[i],t[i][j]=by[j];
		for(int j=1;j<=n;++j)
			if(ty[j]==by[j])
			{
				bool flag=0;
				for(int i=1;i<=n;++i)
					if(t[i][j]==by[j]){flag=1;break;}
				if(flag)continue;
				for(int i=1;i<=n;++i)
					if(bx[i]==tx[i] && cnt[i]>=2)
					{
						--cnt[i],t[i][j]=by[j];
						break;
					}
			}
		for(int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				res[i][j]|=((ull)t[i][j]<<k);
	}
	for(int i=1;i<=n;++i)
	{
		ull u=res[i][1];
		for(int j=2;j<=n;++j)
			if(tx[i]==0)u&=res[i][j];
			else u|=res[i][j];
		if(u!=ax[i])return 0*printf("-1\n");
	}
	for(int j=1;j<=n;++j)
	{
		ull u=res[1][j];
		for(int i=2;i<=n;++i)
			if(ty[j]==0)u&=res[i][j];
			else u|=res[i][j];
		if(u!=ay[j])return 0*printf("-1\n");
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
			cout<<res[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

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

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
        
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    
    for(int i=0;i<n;i++){
        cout<<a[i]<<b[i];
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int H,W,N;
  cin >> H >> W >> N;
  int count = 0;
  while(N>0)
  {
    int m = max(H,W);
    N -= m;
    count ++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  long long ans=0;
  vector<int>count(s.length());
  int t=0;
  for(int i=s.length()-1;i>=0;i--)
  {
    if(i==s.length()-1)count[i]=0;
    else if(s[i]=='B' && s[i+1]=='C')t++;
    else if(s[i]=='A' || (s[i]=='C' && s[i-1]=='B' && i>=2 ))count[i]=t;
    else t=0;
  }
  for(int i=0; i<s.length();i++)
  {
    if(s[i]=='A')ans+=count[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  
  int A, B;
  string S;
  bool ans = true;
  
  cin >> A >> B >> S;
  
  if (S.size() != A+B+1)
    ans = false;

  for (int i = 0; i < A; i++) {
    if (S.at(i) < '0' || S.at(i) > '9') {
      ans = false;
    }
    else
      ans = true;
  }
  if (S.at(A) != '-')
    ans = false;
  for (int i = A+1; i < A+B+1; i++) {
    if (S.at(i) < '0' || S.at(i) > '9')
      ans = false;
  }
  
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 256
n=gets.to_i
pt=px=py=0
r = n.times do
  t,x,y=gets.split.map(&:to_i)
  dt=t-pt
  dl=(x-px).abs+(y-py).abs
  break if dl > dt || dt.odd? != dl.odd?
  pt,px,py=[t,x,y]
end
puts r ? 'Yes' : 'No'


Measured memory_bytes: 1788
N,C,K=map(int,input().split())
A=[0]*N

for i in range(N):
    A[i]=int(input())
A=sorted(A,reverse=True)

IND=0
total=0
while(len(A)>0):
    total+=1
    IND=A[0]-K
    count=0
    i=0
    while((len(A)>0)&(count<C)) :
        if(A[0]<IND):break
        A.pop(0)
        count+=1
print(total)

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s; cin >> s;
  lint k; cin >> k;
  int p = 0;
  while (s[p] == '1') p++;
  cout << (k > p ? s[p] : '1') << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MAX 100000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll, ll> P;

ll N, M;
bool G[8][8]={0};
ll ans=0;
bool visited[8]={0};

void bfs(ll s) {
    ll i;
    ll cnt=0;
    for(i=0; i<N; i++) {
        if(visited[i]) cnt++;
    }
    
    if(cnt==N) ans++;
    
    visited[s]=1;
    for(i=0; i<N; i++) {
        if(G[s][i] && !visited[i]) {
            visited[i]=1;
            bfs(i);
            visited[i]=0;
        }
    }
    
}

int main(void) {
    cin >> N >> M;
    ll i;
    ll a, b;
    for(i=0; i<M; i++) {
        cin >> a >> b;
        a--; b--;
        G[a][b]=1;
        G[b][a]=1;
    }
    visited[0]=1;
    bfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};
using mint = Fp<MOD>;


int main() {
  string L; cin >> L;
  int n = L.size();

  mint ans = 0;
  int cnt = 0;
  rep(i, n) {
    if (L[i] == '1') {
      ans += modpow(mint(3), (n-i-1)) * modpow(mint(2), cnt);
      ++cnt;
    }
  }
  ans += modpow(mint(2), cnt);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			String s = Integer.toBinaryString(sc.nextInt());
			String out = "";
			for (int i = 0; i < s.length(); i++)
				if (s.charAt(s.length() - i - 1) == '1')
					out += (int)Math.pow(2, i) + " ";
			System.out.println(out.substring(0,out.length() - 1));
		}

	}

}

Measured memory_bytes: 15404
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
int x[200000];
map<int, int> m;
signed main() {
	int n, ans = 0;
	cin >> n;
	f(i, n) {
		cin >> x[i];
		m[x[i] - i]++;
	}
	f(i, n) {
		ans += m[0 - x[i] - i];
		m[x[i] - i]--;
	}
	cout << ans << endl;
}


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

using namespace std;

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

	string s;
	string t1,t2;

	cin >> s;

	for(int i=0;i<s.length();i++)
	{
		if(s[i]!='x')
		{
			t1 += s[i];
		}
	}

	t2 = t1;

	reverse(t2.begin(),t2.end());

	if(t2!=t1)
	{
		cout << -1 << '\n';
		return 0;
	}

	vector <int> v;
	int cnt = 0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!='x')
		{
			v.push_back(cnt);
			cnt = 0;
		}
		else
		{
			cnt++;
		}
	}
	v.push_back(cnt);
	//cout << v.size() << '\n';
	int m = v.size();
	int res = 0;
	for(int i=0;i<(m/2);i++)
	{
		res += abs(v[i] - v[m-1-i]);
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct _point {
        double x;
        double y;
} point_t;


int whichside( point_t p1, point_t p2, point_t pa, point_t pb )
{
        double tc, td;
        tc = ( p1.x - p2.x )*( pa.y - p1.y ) - ( p1.y - p2.y )*( pa.x - p1.x );
        td = ( p1.x - p2.x )*( pb.y - p1.y ) - ( p1.y - p2.y )*( pb.x - p1.x );
        if (  tc*td < 0 ) {
                return 1;
        } else {
                return 0;
        }


}


int  main()
{
        point_t p[4], vec1, vec2;
        int i = 0, j, flag = 0;
        char str[100], * tp;
        double tc, td;

        while ( fgets( str, 100, stdin ) ) {
                i = 0;
                tp = strtok( str, "," );
                while ( i < 4 ) {
                        p[i].x = atof( tp );
                        tp = strtok( NULL, "," );
                        p[i].y = atof( tp );
                        tp = strtok( NULL, "," );
                        i++;
                }
/*
                for ( i = 0 ; i < 4 ; i++ ) {
                        printf( "%lf, %lf\n", p[i].x, p[i].y );
                }
*/
                if ( !whichside( p[0], p[2], p[1], p[3] ) ) { flag = 1; }
                if ( !whichside( p[1], p[3], p[0], p[2] ) ) { flag = 1; }


                if ( flag != 1 ) {
                        printf( "YES\n" );
                } else {
                        printf( "NO\n" );
                }


        }

        return 0;
}


Measured memory_bytes: 2048
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int a,b;cin>>a>>b;
  dump(a, b);
  vi ans(4,-1);
  ans[a]=1;
  ans[b]=1;
  dump(ans);
  rep(i, 1, 4){
    if (ans[i]==-1)
      cout << i << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long int;

void inv(vector<int>& v) {
    int length = v.size();
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}
void inv(vector<int>& v, int length) {
    for (int i = 0; i < length; i++) {
        cin >> v[i];
    }
}

int main() {
    int l, r, d;
    cin >> l >> r >> d;

    int cnt = 0;
    int i = 0;
    while (i * d <= r) {
        if (l <= i * d) {
            cnt++;
        }
        i++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long

using namespace std;
const int MAXN = (int)(1e6) + 10;
const int MOD = (int)(1e9) + 7;
const ll INF = (ll)(1e18);

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

    // Type your code here
    ll n;
    double tmp, t = 0;
    cin >> n;
    while(n--) {
        cin >> tmp;
        t += 1.0 / tmp;
    }
    cout << fixed << setprecision(5) << 1.0 / t;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){
	fast;
	ll mod = (ll)1e9+7;
	ll n , k;
	cin >> n >> k;
	ll mi = 0;
	ll ma = n;
	ll cnt = 1;
	while(cnt < k){
		mi += cnt;
		cnt++;
	}
	ll back = n-1;
	cnt = 1;
	while(cnt < k){
		ma += back;
		back--;
		cnt++;
	}
	//deb(ma);
	//deb(mi);
	cnt = k;
	ll ans =0 ;
	for(ll i = k; i<=n+1;i++){
		//deb(ma - mi);
		ans = ((ans%mod)+(ma - mi+1)%mod)%mod;
		mi += cnt;
		ma += back;
		cnt++;
		back--;
	}
	cout<<ans;
	
	return 0;
}

	


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;

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


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

    int A, B;
    cin >> A >> B;

    if (A <= 9 && B <= 9) { cout << A * B << endl; }
    else { cout << "-1" << endl; }



    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int p,q,a,n;

int dfs(int np,int nq,int low,int nn){
	if(nn>n)return 0;
	if(np*q==nq*p)return 1;
	if(np*q>nq*p)return 0;
	int res=0;
	for(int i=low;i*nq<=a;i++){
		res+=dfs(i*np+nq,i*nq,i,nn+1);
	}
	return res;
}

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>p>>q>>a>>n;
		if(!p)break;
		cout<<dfs(0,1,1,0)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
  //can nlogn
	llint n,i,j,L,R;cin>>n>>L>>R;
	vector<llint>dp(n+1);
	static int pp[5001];
	for(i=0;i<n;i++){cin>>pp[i];}
	dp[0]=0;
	for(i=1;i<=n;i++){dp[i]=big;}
	for(i=0;i<n;i++){
		int p=pp[i];
		for(j=0;j<p;j++){mineq(dp[p],dp[j]);dp[j]+=L;}
		for(j=p+1;j<=n;j++){dp[j]+=R;}
		//for(j=0;j<=n;j++){cerr<<dp[j]<<" ";}cerr<<endl;
	}
  
	llint ans=big;
	for(i=0;i<=n;i++){mineq(ans,dp[i]);}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=2002;
ll n,k;
ll c[N][N];
ll C(ll n,ll m)
{
    if(c[n][m]) return c[n][m];
    if(m==0||n==m) return 1;
    if(m==1) return n;
    return c[n][m]=(C(n-1,m-1)+C(n-1,m))%mod;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=k;i++)
    {
        if(i>n-k+1)
        {
            printf("0\n");
            continue;
        }
        ll ans = 1;
        ans = C(k-1,i-1) * C(n-k+1,i) % mod;
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 29696
#include <cstdio>
#define likely(x)  __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
void reader(int *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (unlikely(k < '0' || k > '9')) break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
void reader(long long *x) {
	char k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (unlikely(k < '0' || k > '9')) break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int n, b[100009]; long long a[100009];
int main() {
	reader(&n);
	for (int i = 0; i < n; i++) {
		reader(&a[i]);
		reader(&b[i]);
	}
	long long ret = 0;
	for (int i = n - 1; i >= 0; i--) {
		long long d = (a[i] + ret) % b[i];
		if (d) ret += b[i] - d;
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 1000000007;
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool issame(int x, int y) { return root(x) == root(y); }
    bool merge(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) { return -par[root(x)]; }
};
int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    UnionFind tree(n);
    while (q--) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--, b--;
        tree.merge(a, b);
    }
    int ans = 0;
    rep(i, n) {
        if (tree.par[i] < 0) ans++;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 3800
import java.util.Scanner;

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

		int d = sc.nextInt();
		int[] c = new int[27];
		for (int i = 1; i < 27; i++) {
			c[i] = sc.nextInt();
		}
		int[][] s = new int[d + 1][27];
		for (int i = 1; i < d + 1; i++) {
			for (int j = 1; j < 27; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		int[] last = new int[27];
		int v = 0;
		for (int i = 1; i <= d; i++) {
			int maxType = 0;
			int maxV = 0;
			int[] vlist = new int[27];
			for (int j = 1; j < 27; j++) {
				int lastTmp = last[j];
				last[j] = i;
				int tmpV = v;
				tmpV += s[i][j];
				int downSatis = 0;
				for (int k = 1; k < 27; k++) {
					downSatis += (c[k] * (i - last[j]));
				}
				tmpV -= downSatis;
				vlist[j] = tmpV;
				if (j == 1) {
					maxType = j;
					maxV = tmpV;
				}
				if (maxV < tmpV) {
					maxV = tmpV;
					maxType = j;
				}
				last[j] = lastTmp;
			}
			v = vlist[maxType];
			last[maxType] = i;
			System.out.println(maxType);
		}
	}
}


Measured memory_bytes: 38220
#include <iostream>
#include <vector>
#include <map>
#include <set>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main(void) {
    int X,N;cin>>X>>N;
    vector<int> vc(N);
    for (int i = 0; i < N; i++) cin>>vc[i];
    int mi = 1e9;
    map<int, int> mp;
    for (int i = 0; i <= 101; i++) {
        if (count(all(vc), i) > 0) continue;
        int tmp = abs(i - X);
        if (tmp < mi) mi = tmp;
        mp[i] = tmp;
    }
    set<int> result;
    for (map<int,int>::iterator it = mp.begin();it!=mp.end();++it) {
        if (it->second == mi) result.insert(it->first);
    }
    set<int>::iterator bg = result.begin();
    cout << *bg << endl;
    return 0;
}

Measured memory_bytes: 3200
a,v = gets.chomp.split(" ").map(&:to_i)
b,w = gets.chomp.split(" ").map(&:to_i)
t = gets.chomp.to_i

if v <= w
  puts "NO"
  exit 0
end

k = (a - b).abs.to_f / (v - w)

if k <= t
  puts "YES"
else
  puts "NO"
end



Measured memory_bytes: 14384
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var p = ab[0] * 3 + ab[1];
        Console.WriteLine(p / 2);
    }
}


Measured memory_bytes: 13396
N,K=map(int,input().split())

clist = []
for i in range(1,N+1):
    a = i
    c = 0
    while(a<K):
        a *= 2
        c += 1
    clist.append(c)

import numpy as np
X = np.array(clist)
Y = np.array([0.5]*N)

print(sum(Y**X*(1/N)))

Measured memory_bytes: 21128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int res = 1LL << 29;

int D, G; 
int p[10], c[10]; 

int main() {
    cin >> D >> G;
    for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

    for (int bit = 0; bit < (1 << D); ++bit) {
        int cur = 0;
        int num = 0;
        for(int i = 0; i < D; ++i) {
         if (bit & (1<<i))  cur += (i+1) * 100 * p[i] + c[i], num+=p[i];
        }
        if (cur >= G) {
            res = min(res, num);
            continue;
        }
        for (int i = D-1; i >= 0; --i) {
            if (bit & (1<<i)) continue;
            for(int j = 1; j < p[i]; ++j) {
                if (cur + (i+1) * 100 * j >= G) res = min(res, num + j);
            }
            break;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 892
n = int(input())
dct = {}
for _ in range(n):
    s = input()
    if s in dct:
        dct[s] += 1
    else:
        dct[s] = 1
m = max(dct.values())
ans = []
for a, v in dct.items():
    if v == m:
        ans.append(a)
ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 92120
// ref: https://img.atcoder.jp/abc103/editorial.pdf

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N; cin >> N;
    vector<int> vA(N);
    for(uint i=0; i<N; ++i){ cin>>vA[i]; }
    
    int64 sum=0ll;
    for(uint i=0; i<N; ++i){
        sum += vA[i] - 1;
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		
		int n = 0;
		int i = 0;
		int j = 0;
		int count = 0;
		int gre[];
		int pnum[];
		
		n = Integer.parseInt(as.next());
		
		pnum = new int[n];
		gre = new int[n];
		
		for(i=0;i<n;i++){
			
			pnum[i] = Integer.parseInt(as.next());
			gre[i] = (int) Math.sqrt(pnum[i]);
			
		}
		
		for(i=0;i<n;i++){
			for(j=2;j<=gre[i]+1;j++){
				
				if(j == gre[i]+1 && pnum[i] != 1){
					
					count++;
					
				}
				if(pnum[i] % j == 0){
					
					break;
					
				}
				
			}
		
		}
		
		sb.append(count);
		System.out.println(sb.toString());

	}

}

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

enum Status {WHITE, GRAY, BLACK};

queue<int> que;
Status *status;
int *dist;
vector<vector<int> > a;
int n;

int main(){
        cin>>n;
        a = vector<vector<int> >(n, vector<int>());
        status = new Status[n];
        dist = new int[n];

        int m, k, r;
        for(int i=0;i<n;i++){
                cin>>r;
                cin>>m;
                for(int j=0;j<m;j++){
                        cin>>k;
                        a[r-1].emplace_back(k-1);
                }
        }
        for(int i=0;i<n;i++) status[i] = WHITE;
        for(int i=0;i<n;i++) dist[i] = -1;

        que.push(0);
        dist[0] = 0;
        while(!que.empty()){
                int v = que.front(); que.pop();
                if(status[v]==BLACK) continue;
                for(int i=0;i<a[v].size();i++){
                        if(status[a[v][i]]==WHITE){
                                dist[a[v][i]] = dist[v]+1;
                                status[a[v][i]] = GRAY;
                                que.push(a[v][i]);
                        }
                }
                status[v] = BLACK;
        }

        for(int i=0;i<n;i++){
                cout<<i+1<<" "<<dist[i]<<endl;
        }
        return 0;
}


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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 501
using namespace std;

void quick () {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a , b ;
    cin >> a >> b ;
    if ((a*b*1%2!=0)||(a*b*2%2!=0)||(a*b*3%2!=0)){
        cout << "Yes" ;
    }else {
        cout << "No" ;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m,x;
	int ans=INF;
	int cnt = 0;
	cin >>n>>m>>x;
	Vi a(m);
	cin >> a;
	vector<bool> dis(n+1,false);
	rep(i, m) { dis[a[i]  ]= true; }
	for (int i = x; i < n;i++){
		cnt += (dis[i]);
	}
	chmin(ans, cnt);
	cnt = 0;
	for(int i = x; i >= 0; i--) { cnt += (dis[i]); }
	cout << min(ans,cnt) << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){
	

int n;
cin>>n;


vector < ll> arr(n);

for( int i=0;i<n;i++)
cin>>arr[i];
ll ans =0;
for(int i=2;i<n;i++)
ans^=arr[i];

if(( (arr[0]^arr[1])^ans )==0 ){
	
	cout<<0<<endl;
	return 0;
}


//a+b = a^b +2*a&b   
//  (S - ans )/2 = a&b

//cout<<ans<<endl;

ll xo = arr[0]+arr[1] - ans;
if(xo&1){
cout<<-1<<endl;
return 0;
}

xo /=2;
bitset < 60 > cmp ;
cmp.reset();
cmp=ans; 
bitset< 60 > bt ;
bitset < 60 > seco(arr[1]);

bitset < 60 > fr(arr[0]);

bt.reset();
bt= xo;


ll second = xo;
ll first = xo;
ll sums = arr[0]+arr[1];

for(ll i=59; i >=0;i--){
	if(bt[i]==1 &&  cmp[i]==1){
		cout<<-1<<endl;
		return 0 ;
	}
	if(bt[i]==1)
	{
		continue;
	}
	
	if(cmp[i]==1){
		
		if( (first +(1LL<<i)) <= arr[0]  ){
			first+=(1LL<<i);
			//cout<<first<<endl;
			
		}
		else{
			
			second+=(1LL<<i);
		}
		
	}
	
	
}


if(first==0 ||(first > arr[0])){
	cout<<-1<<endl;
	return 0;
	
}

if(first+second!=arr[0]+arr[1])
{
	cout<<-1<<endl;
}
 
 cout<<arr[0]-first<<endl;
 


return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3664
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n+2];
        long ans = 0;
        for(int i=1;i<=n;i++){
            a[i]=sc.nextInt();
        }
        for(int i=1;i<=n;i++){
            if(a[i]+a[i-1]>x){
                ans += a[i]+a[i-1]-x;
                a[i]=x-a[i-1];
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50896