akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


int n,m;
int p[1000000];


int root(int x,int a[]){
  if(a[x]==x) return x;

  return a[x] = root(a[x],a);
}


void unite(int x,int y,int a[]){
  x = root(x,a);
  y = root(y,a);
  if(x==y) return;
  a[x]=a[y];
}

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

  rep(i,n){
    cin>>p[i+1];
  }
  int a[1000000];
  rep(i,n){
    a[i+1]=i+1;
  }

  rep(i,m){
    int x,y;
    cin>>x>>y;
    unite(x,y,a);
  }
  int ans=0;
  rep(i,n){
    if(root(a[p[i+1]],a)==root(a[i+1],a))
      ans++;
  }

  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 2688
#include <iostream>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

vector<long long> a;
vector<long long> b;

bool comp(long long i, long long j) {
  if (a[i] == a[j])
    return b[i] < b[j];
  else
    return a[i] > a[j];
}

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

  a.resize(N);
  b.resize(N);
  vector<long long> indices(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i] >> b[i];
    indices[i] = i;
  }

  sort(indices.begin(), indices.end(), comp);

  int best_index = indices[0];
  vector<long long> big_b;
  for (int i = 0; i < N; ++i) {
    if (i == best_index)
      continue;
    if (b[i] > a[best_index]) {
      big_b.push_back(b[i]);
    }
  }

  sort(big_b.begin(), big_b.end(), greater<long long>());

  int i;
  for (i = 0; i < big_b.size(); ++i) {
    H -= big_b[i];
    if (H <= 0) {
      cout << i + 1 << endl;
      return 0;
    } else if (H - a[best_index] <= 0) {
      cout << i + 2 << endl;
      return 0;
    } else if (H - b[best_index] <= 0) {
      cout << i + 2 << endl;
      return 0;
    }
  }

  if (a[best_index] > b[best_index]) {
    cout << ceil((long double) H / a[best_index]) + i << endl;
  } else {
    cout << (long long)ceil((long double) (H - b[best_index]) / a[best_index]) + i + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

string s;

int main() {
	cin >> s;
	if (s == "AAA" || s == "BBB") {
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define N 100005
#define mod 1000000007
int n;
char c[N];
int dp[N][105][2];
int D;
void add(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int main(){
	scanf("%s%d",c,&D);
	n=strlen(c);
	dp[0][0][1]=1;
	for(int i=0;i<n;++i){
		for(int j=0;j<D;++j){
			for(int f=0;f<2;++f){
				for(int k=0;k<=(f?c[i]-'0':9);++k){
					add(dp[i+1][(j+k)%D][f?k==c[i]-'0':0],dp[i][j][f]);
				}
			}
		}
	}
	printf("%d\n",(dp[n][0][0]+dp[n][0][1]+mod-1)%mod);
	return 0;
}


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

int main() {
  int n,q; cin >> n >> q;
  string s; cin >> s;
  vector<int> sum(n); sum[0] = 0;
  for(int i=1; i<n; i++){
    sum[i] = sum[i-1];
    if(s[i-1]=='A' && s[i]=='C') sum[i]++;
    //cout << sum[i] << endl;
  }
  
  rep(i,q){
    int l,r; cin >> l >> r;
    cout << sum[r-1] - sum[l-1] << endl;
  }
}

Measured memory_bytes: 3812
# ABC129 C

MOD = 10**9 + 7
n, m = map(int, input().split())
a_l = [int(input()) for _ in range(m)]

dp = [0] * (n+1)
dp[0] = 1
k = 0
if m > 0 and a_l[0] == 1:
    k = min(k+1, m-1)
else:
    dp[1] = 1

for i in range(2, n+1):
    if m > 0 and i == a_l[k]:
        k = min(k+1, m-1)
        continue
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
    
print(dp[n])

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


void solve(long long N)
{
    if(N%2==1)
    {
        cout<<0<<endl;
        return;
    }
    else
    {
        long long ans=0,t=10;
        while(N/t)
        {           
            ans+=N/t;
            t*=5;
        }
        cout<<ans<<endl;
    }
}

int main()
{
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e6;
const int INF=1e9;
int main(){
	string S;cin>>S;
	rep(i,0,3){
		if(S.at(i)==S.at(i+1)){
			cout<<"Bad"<<endl;
			return 0;
		}
	}cout<<"Good"<<endl;
}

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

using namespace std;

int main()
{
    int n,i,ans=0,cnt=0;
    scanf("%d",&n);
    if(n>=400&&n<=599) printf("8");
    else if(n>=600&&n<=799) printf("7");
    else if(n>=800&&n<=999) printf("6");
    else if(n>=1000&&n<=1199) printf("5");
    else if(n>=1200&&n<=1399) printf("4");
    else if(n>=1400&&n<=1599) printf("3");
    else if(n>=1600&&n<=1799) printf("2");
    else if(n>=1800&&n<=1999) printf("1");



}


Measured memory_bytes: 3760
module module_sort
   implicit none

contains

   recursive subroutine mergesort(a, begin, end, b)
      implicit none
      integer :: a(:), b(:)
      integer, intent(in) :: begin, end ! 配列インデックスの始点、終点
      integer :: mid ! 配列中央のインデックス

      ! 再帰終了条件: begin==end のときは何もせずにreturnする
      if (begin<end) then
         mid = (begin+end)/2
         call mergesort(a,begin,mid,b)
         call mergesort(a,mid+1,end,b)
         call merge_(a,begin,mid,end,b)
      end if
      return

   contains
      subroutine merge_(array,begin,mid,end,memo)
         implicit none
         integer:: array(:), memo(:)
         integer, intent(in) :: begin, mid, end
         integer :: i, j, k, temp

         i = begin   ! 配列前半の頭のインデックス
         j = mid + 1 ! 配列後半の頭のインデックス
         do k = begin, end
            if (j > end) then
               ! 配列後半が入れ終わっている場合
               temp = array(i)
               i = i + 1
            else if (i > mid) then
               ! 配列前半が入れ終わっている場合
               temp = array(j)
               j = j + 1
            else if ( array(i) <= array(j) ) then
               temp = array(i)
               i = i + 1
            else
               temp = array(j)
               j = j + 1
            end if
            memo(k) = temp
         end do

         do i = begin, end
            array(i) = memo(i)
         end do
      end subroutine merge_
   end subroutine mergesort

end module module_sort

program abc134c2
   use module_sort
   implicit none
   integer :: n, i
   integer, allocatable :: a1(:), b1(:), org(:)

   read(*,*) n
   allocate(a1(n), b1(n), org(n))

   do i = 1, n
      read(*,*) a1(i)
   enddo
   org = a1

   b1 = 0

   call mergesort(a1, 1, n, b1)

   do i = 1, n
      if (org(i) == a1(n)) then
         write(*,*) a1(n-1)
      else
         write(*,*) a1(n)
      endif
   enddo

end


Measured memory_bytes: 5120
while 0 == 0:
    a,b = map(int,input().split())
    if a == b == 0:
        break
    for i in range(a):
        for j in range(b):
            if i == 0 or i == a-1 or j == 0 or j == b-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
    print()
    
    
    
        


Measured memory_bytes: 7004
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    string ABCD;
    void Solve() {
        //input
        ABCD = io.String;
        //cal
        var n = ABCD.Select(c => int.Parse(c.ToString())).ToArray();
        Func<int, int> f = (bit) => {
            var t = n[0];
            t += (1 & bit >> 0) == 1 ? n[1] : -1 * n[1];
            t += (1 & bit >> 1) == 1 ? n[2] : -1 * n[2];
            t += (1 & bit >> 2) == 1 ? n[3] : -1 * n[3];
            return t;
        };
        Func<int, string> strF = (bit) => {
            var t = n[0].ToString();
            t += ((1 & bit >> 0) == 1 ? "+" : "-") + n[1];
            t += ((1 & bit >> 1) == 1 ? "+" : "-") + n[2];
            t += ((1 & bit >> 2) == 1 ? "+" : "-") + n[3];
            return t+"=7";
        };
        for (int i = 0; i < 1 << 3; ++i) {
            if (f(i) == 7) {
                //cal
                WriteLine(strF(i));
                return;
            }
        }
        //存在しない
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


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

#define sai(j,n) for(sei j=0;j<sei(n);++j)
#define hsai(j,n) for(sei j=sei(n)-1;j>=0;--j)
#define kan(j,m,n) for(sei j=m;j<sei(n);++j)
#define hkan(j,m,n) for(sei j=sei(n)-1;j>=sei(m);--j)
#define zen(v) (v).begin(),(v).end()
#define yu(v) v.erase(unique(zen(v)), v.end());
#define syutu(v) si(a, (v).size()) {cout << v[a];if(a != v.size()-1)cout << " ";else cout << endl;}
#define mug 10000000111;
#define yo 10000000711;
#define kyo 1e-9;

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

using namespace std;
typedef long long sei;
typedef long double syo;
typedef vector<sei> vs;
typedef vector<syo> vy;
typedef vector<vs> vvs;
typedef vector<vy> vvy;
typedef pair<sei, sei> kS;
sei max(sei a, int b) {return max(a, sei(b));}
sei max(int a, sei b) {return max(sei(a), b);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    sei N;
    cin >> N;
    if(N < 1000) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

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

int main() {
    int ans = 0;
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A[i] = a - 1;
    }
    for(int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for(int i = 0; i < N - 1; i++) {
        cin >> C[i];
    }
    int prev = -1;
    for(int i = 0; i < N; i++) {
        ans += B[A[i]];
        if(i < N - 1) {
            if(A[i] + 1 == A[i + 1])
                ans += C[A[i]];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
using namespace std;
int x,y,ans=0;
inline int abs(int x) {return x<0 ? -x:x;}
int main() {
    cin>>x>>y;
    if(x==-y) ans=1;
    else if(abs(x)<abs(y)) ans=abs(y)-abs(x)+(x<0)+(y<0);
    else ans=abs(x)-abs(y)+(x>0)+(y>0);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#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>;

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, w;
    cin >> n >> w;
    vector<P> item(n);
    rep(i, n) cin >> item[i].first >> item[i].second;
    vector<vector<int>> dp(n + 1, vector<int>(w + 1));
    rep(i, n) rep(j, w)
    {
        chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        if (j + 1 - item[i].second < 0)
            continue;
        chmax(dp[i + 1][j + 1], dp[i][j + 1 - item[i].second] + item[i].first);
    }
    // rep(i, n + 1)
    // {
    //     rep(j, w + 1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 6756
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;
using ll = long long;


int n, m;
ll a[100005], c[100005];
int b[100005];
priority_queue<ll>Q;
ll ans = 0;
vector<pair<ll, int> >V;
vector<ll> S;
ll secondcnt = 0;

void input(){
  cin >> n >> m;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    Q.push(-a[i]);
    ans += a[i];
  }
  for(int i = 0; i < m; ++i){
    cin >> b[i] >> c[i];
    secondcnt += b[i];
    V.push_back(make_pair(c[i], b[i]));
  }
  sort(V.begin(), V.end());
  //cout << V[0].first << endl;
  ll tmp = V.size() - 1;
  int count = 0;
  //cout << n << endl;
  //cout << secondcnt << endl;
  while(count < n && count < secondcnt){
    //cout << count << endl;
    //count++;
    int cnt = V[tmp].second;
    //cout << cnt << endl;
    while(cnt > 0){
      S.push_back(V[tmp].first);
      count++;
      //cout << V[tmp].first << endl;
      cnt--;
    }
    tmp--;
  }
  sort(S.begin(), S.end());
  
  
}

ll solve2(){
  for(int i = S.size() - 1; i >= 0; --i){
    ll tmp = Q.top();
    //cout << tmp << endl;
    Q.pop();
    //cout << tmp << endl;
    if(-S[i] < tmp){
      Q.push(-S[i]);
      ans += S[i];
      ans -= -tmp;
    }else{
      Q.push(tmp);
      break;
    }
  }
  return ans;
}

int main(){
  input();
  cout << solve2() << endl;
  //S.clear();
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int A=N%10;
  if(A==3){
    cout << "bon" << endl;
  }
  else if(A==0 || A==1 || A==6 || A==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}
  

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
ll INF = 1000000007;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;
	ll ans = 1;
	bool flag = false;
	rep(i, n) {
		if (flag) {
			if (s1[i] == s2[i]) flag = false;
			else {
				ans *= 3;
				ans %= INF;
				i += 1;
			}
		}
		else {
			if (s1[i] != s2[i]) {
                ans*=2;
                ans%=INF;
				flag = true;
				i += 1;
			}
			else {
				ans *= 2;
				ans %= INF;
			}
		}
	}
    if(s1[0]==s2[0]){
      ans*=modpow(2,INF-2,INF);
      ans%=INF;
      ans*=3;
      ans%=INF;
    }else{
      ans*=3;
      ans%=INF;
    }
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main() {
    int s; cin >> s;
    vector<int> a; a.push_back(s);

    int result = 1;
    while(true) {
        result++;
        s = s%2 == 1 ? 3*s+1 : s/2;
        if (find(a.begin(), a.end(), s) == a.end()) { a.push_back(s); } else { break; }
    }
    cout << result << endl;
    return 0;
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc(); }
	return i*f;
}

const int N=2e5+50;
struct P {int x,y;} a[N];
int sx,sy,tx,ty,n,d[N],top;
int main() {
	sx=rd(), sy=rd(), tx=rd(), ty=rd(), n=rd();
	for(int i=1;i<=n;i++) {
		a[i].x=rd(), a[i].y=rd();
		if(a[i].x<min(sx,tx) || a[i].x>max(sx,tx) || a[i].y<min(sy,ty) || a[i].y>max(sy,ty)) --i, --n;
	}
	if(sx>tx) {
		sx=-sx; tx=-tx;
		for(int i=1;i<=n;i++) a[i].x=-a[i].x;
	}
	if(sy>ty) {
		sy=-sy; ty=-ty;
		for(int i=1;i<=n;i++) a[i].y=-a[i].y;
	}
	sort(a+1,a+n+1,[](const P &a,const P &b) {return a.x<b.x;});
	for(int i=1;i<=n;i++) {
		if((!top) || d[top]<a[i].y) d[++top]=a[i].y;
		else d[lower_bound(d+1,d+top+1,a[i].y)-d]=a[i].y;
	} 
	const double PI=acos(-1.0);
	double ans=(tx-sx+ty-sy)*100.0+top*(5.0*PI-20);
	if(top==min(tx-sx+1,ty-sy+1)) ans+=5.0*PI;
	printf("%.20f\n",ans);
}

Measured memory_bytes: 2816
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      // 取得
	  int N = sc.nextInt();
      int K = sc.nextInt();
      int count = 0;
      for(int i=0;i<N;i++){
        if(sc.nextInt()>=K){
          count++;
        }
      }
      System.out.println(count);
    }
}

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

using namespace std;

const int md = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long ans = 1;
  for (long long i = k; i <= n; i++) {
    long long left = (i - 1) * i / 2;
    long long right = (n * (n + 1) / 2) - ((n - i) * (n - i + 1) / 2);
    ans = (ans + right - left + 1) % md;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll T[1000];
ll M;
ll P[1000], X[1000];

int main() {
  cin >> N;
  ll sum = 0;
  rep(i, 0, N) {
    cin >> T[i];
    sum += T[i];
  }
  cin >> M;
  rep(i, 0, M) { cin >> P[i] >> X[i]; }

  rep(i, 0, M) { cout << sum + (X[i] - T[P[i] - 1]) << endl; }
}


Measured memory_bytes: 3468
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    s = kwargs["s"]
    w = kwargs["w"]

    if w >= s:
        res = 'unsafe'
    else:
        res = 'safe'

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["s"], kwargs["w"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["s"], kwargs["w"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 31164
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
char arr[upperlimit];
char arr2[upperlimit];
int main() {
	cin >> arr >> arr2;
	int len=0;
	while(arr[len]!='\0'){
		len++;
	}
	bool check=0;
	for(int i = 0; i < len; i++){
		check=1;
		for(int j = i; j < i+len; j++){
			if(arr[j%len]!=arr2[j-i]){
				check=0;
				break;
			}
		}
		if(check){
			break;
		}
	}
	if(check){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> A, B, C;

	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		A.push_back(a);
	}

	for (int i = 0; i < N; i++) {
		int b; cin >> b;
		B.push_back(b);
	}

	for (int i = 0; i < N - 1; i++) {
		int c; cin >> c;
		C.push_back(c);
	}

	int pre, sum = 0;
	for (int i = 0; i < N; i++){
		if (i==0) {
			sum += B[A[i] - 1];
		}
		else {
			sum += B[A[i] - 1];
			if (pre + 1 == A[i]) {
				sum += C[pre-1];
			}
		}
		pre = A[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())

n_flg = [False for _ in range(n)]
pena_tmp = [0 for _ in range(n)]

pena = 0

for _ in range(m):
    p,s = input().split()

    p = int(p) - 1


    if n_flg[p]:
        pass
    elif s == 'WA':
        pena_tmp[p] += 1
    elif s == 'AC':
        pena += pena_tmp[p]
        n_flg[p] = True

print(n_flg.count(True), pena)

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

using namespace std;

int main(){
    int H,W;

    while(cin >> H >> W){
        if(H == 0 && W == 0){
            break;
        }
        
        for(int i = 1; i <= H; i++){
            for(int j = 1; j <= W; j++){
                if((i%2) != 0){
                    if((j%2) != 0){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }else{
                    if((j%2) != 0){
                        cout << ".";
                    }else{
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int t,n,s,f;
	int R;
	while(1){
		R=0;
		cin>>t;
		if(t==0) break;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>s>>f;
			R+=f-s;

		}
		if(t>R) cout<<t-R<<endl;
		else cout<<"OK"<<endl;
	}







	return 0;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int a, b, n;
  cin >> n >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % n == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

	ll n, k;
	cin>>n>>k;
	double ui = log(n)/log(k);
	cout<<floor(ui)  +1 ;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 2000000
#define MOD 1000000007

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  vector<vector<ll>> dp(N+1,vector<ll>(K+1,0));
  dp.at(0).at(K)=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      dp.at(i+1).at(max(0,j-a.at(i)))+=dp.at(i).at(j);
      if(j<K){
        dp.at(i+1).at(j+1)-=dp.at(i).at(j);
      }
    }
    for(int j=0;j<K;j++){
      dp.at(i+1).at(j+1)+=dp.at(i+1).at(j);
    }
    for(int j=0;j<=K;j++){
      dp.at(i+1).at(j)%=MOD;
    }
  }

  cout<<dp.at(N).at(0)<<endl;
}


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

char s[1000];

const long double PI = acos(-1.0);

int main(){
    long long a, b, h, m;
    cin >> a >> b >> h >> m;
    printf("%.10f", (double)sqrt(a*a + b*b - 2*a*b*cos(2*PI * abs((long double)m/60 - (long double)(h*60+m)/720))));
    return 0;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int lli;
#define tc int t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define mx 1000000


int main() {
    fastio;
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<"\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    int k, n;
    cin >> k >> n;
    vector <int> a(n);
    cin >> a;
    int mini = k;
    for (int i = 0; i < n; ++i)
        mini = min(mini, k - (i ? a[i] - a[i - 1] : k + a[i] - a[n - 1]));
    cout << mini;
    return 0;
}



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

int n, acnt, ans=0, most=0;
int num[111111];
int cnt[111111];

int main()
{
  memset(num, 0, sizeof(num));
  memset(num, 0, sizeof(cnt));
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    cnt[num[i]]++;
    most = max(most, num[i]); 
  }

  for (int i = 0; i < most; i++) {
    acnt += cnt[i];

    if (acnt == n / 2) {
      int j = i+1;
      ans = 1;

      while (cnt[j] == 0) {
	ans++;
	j++;
      } 
      break;
    }
  }

  cout << ans << endl; 
}

Measured memory_bytes: 1024
//Author: Rafael Santos
//Site: santos-rj.github.io

#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define MAX 10
#define MAXV 1010
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define desync ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0)

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;
const double PI = acos(-1);
const double min_dist_v = 1e-4;
const double min_dist_e = 1e-6;
const double eps = 1e-6;

void solve(){
    int in = 0;

    cin >> in;

    if(in == 1){
      cout << 0;
    }else{
      cout << 1;
    }
    cout<<endl;
}

int main(){
    desync;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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



int main(){
	int N;cin >> N;
	int a[N];
	int maxsum =0;
	for(int i=0;i<N;i++){
		cin >> a[i];
		maxsum+=a[i] -1;
	}
	cout << maxsum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

int n, a, b, r = 0, res = 0;
vvi adj;
bitset<100005> vis;

//1 - Tiene hijo con antena
//2 - Necesita ancestro con antena
int dfs (int u) {
    int c = 0, n = 0, f = 0, d, e = 0, cv, ev;
    vis[u] = 1;

    for (int v : adj[u]) {
        if (vis[v])
            continue;
        n++;

        d = dfs(v);
        f |= d;
        if (d & 1) {
            c++;
            cv = v;
        }
        if (d & 2) {
            e++;
            ev = v;
        }
    }

    n--;
    if (n > c) {
        res += n - c;
        c += n - c;
    }
    if ((f & 2) && (c >= 2 || (c == 1 && (e > 1 || cv != ev))))
        f ^= 2;
    if (n < adj[u].size() - 1)
        f |= 2;
    if (n > 0)
        f |= 1;

    return f;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
 
    cin >> n;
    adj = vvi(n);

    for (int i = 1; i < n; i++) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);

        if (adj[a].size() > 1)
            r = a;
        else if (adj[b].size() > 1)
            r = b;
    }

    if (dfs(r) & 2)
        res++;
    cout << max(res, 1) << endl;

	return 0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
int i,j,n,c,k;
ll a,v,b,w,t;
string s;
int main(){
  cin>>a>>v>>b>>w>>t;
  if(a>0)b-=a;
  else b+=a;
  a=0;
  if(b<0)b*=-1;
  if(a>b)swap(a,b);
  if(t*v>=(t*w+b))cout<<"YES";
  else cout<<"NO";
}

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

int main() {
    int N;
    cin >> N;
    int a[110] = {};  //0で初期化
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    sort(a, a+N, greater<int>());

    //一回あたりの差の和
    int a_minus_b = 0;
    for (int i=0; i<=N; i += 2) {
        a_minus_b += (a[i] - a[i+1]);
    }
    cout << a_minus_b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto &x : a) cin >> x;

	int n4 = 0;
	int n2 = 0;
	int n1 = 0;
	for (auto x : a) {
		if (x % 4 == 0) {
			++n4;
		}
		else if (x % 2 == 0) {
			++n2;
		}
		else {
			++n1;
		}
	}

	if (n2 > 0) {
		if (n4 >= n1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (n4 + 1 >= n1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define pi pair<ll,ll>
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007

ll Set(ll N,ll pos){ return N=N | (1<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1<<pos)); }


ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s,s1,s2;
ll n,m;
ll arr[500000];
ll brr[500000];
vector<ll>v,v1;

map<ll,ll>mp;
ll vis[500005];
int main()
{__
        ll i,j,a,b,c,d,e,f,g,x,y,z,t,k,l;

        ll ans=0;
        cin>>s>>s1;

        cin>>n>>m;

        cin>>s2;

        if(s2==s) cout<<n-1<<" "<<m<<endl;
        else cout<<n<<" "<<m-1<<endl;
}





Measured memory_bytes: 2304
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    int v = 1;
    for (int i = 0; i < n; i++)
    {
        v = min(v + k, v * 2);
    }
    cout << v << endl;
}


Measured memory_bytes: 256
INF = 10000

def prim():
	color = ["WHITE" for _ in range(n)]
	d = [INF for _ in range(n)]
	pi = [None for _ in range(n)]
	d[0] = 0

	while True:
		mincost = INF
		for i in range(n):
			if color[i] != "BLACK" and d[i] < mincost:
				mincost = d[i]
				u = i
		if mincost == INF:
			break
		color[u] = "BLACK"
		for v in range(n):
			if color[v] != "BLACK" and M[u][v] != -1:
				if M[u][v] < d[v]:
					d[v] = M[u][v]
					pi[v] = u
					color[v] = "GRAY"
	sum = 0
	for u in range(n):
		if pi[u] != None:
			sum += M[u][pi[u]]
	return sum

if __name__ == "__main__":
	n = int(input())
	M = []
	for _ in range(n):
		M.append(list(map(int, input().split())))
	print(prim())


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

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

N += 1

# N: 処理する区間の長さ
N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [-INF]*(2*N0)
# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])
# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = -INF
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

update(0,0)

for h,a in zip(H,A):
    update(h,query(0,h) + a)

ans = query(0,N+1)
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n;
	cin >> n;
	ll o[n], c[n+1]={0};
	REP(i, 0, n){
		cin >> o[i];
		++c[o[i]];
	}
	ll pos = 0;
	REP(i, 0, n+1) pos += c[i]* (c[i] - 1)/2;
	REP(i, 0, n){
		cout <<  (pos -((c[o[i]] - 1)*(c[o[i]] - (c[o[i]]-2))/2)) << endl;
	}
		

}


Measured memory_bytes: 5760
h,w = map(int,input().split())
ans = [[0] * w for i in range(h)]
c_m = []
for i in range(h):
    c_lis = input()
    c_m.append(list(c_lis))
for j in range(h):
    for k in range(w):
        if ans[j][k] == 0 and c_m[j][k] == '.':
            ans[j][k] = -1
        elif c_m[j][k] == 'c':
            for l in range(w - k):
                ans[j][k + l] = l
for m in range(h):
    cha = str(ans[m][0])
    for n in range(w -1):
        cha = cha + " " + str(ans[m][n + 1])
    print(cha)

Measured memory_bytes: 7900
#define TEST_SNO	1
#define TEST_ENO	3
#define ll			long long

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

FILE *in, *ans;
int t;
int x, y, z, k;
ll a[1005];
ll b[1005];
ll c[1005];
ll ab[1000005];
ll abc[3000005];

int
out(const char *s)
{
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int
outll(ll l)
{
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

int
geti()
{
	int i;
	fscanf(in, "%d", &i);
	return i;
}

ll
getll()
{
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int
getstr(char *s)
{
	fscanf(in, "%s", s);
	return 0;
}

int
sortfnc(const void *v1, const void *v2)
{
	ll *i1 = (ll *)v1;
	ll *i2 = (ll *)v2;

	if (*i1 > *i2) {
		return -1;
	}
	else if (*i1 < *i2) {
		return 1;
	}

	return 0;
}

int
fnc()
{
	int i, j, i2, j2;
	x = geti();
	y = geti();
	z = geti();
	k = geti();
	for (i = 0; i < x; i++) {
		a[i] = getll();
	}
	for (i = 0; i < y; i++) {
		b[i] = getll();
	}
	for (i = 0; i < z; i++) {
		c[i] = getll();
	}

	i2 = 0;
	for (i = 0; i < x; i++) {
		for (j = 0; j < y; j++) {
			ab[i2] = a[i] + b[j];
			i2++;
		}
	}
	qsort(ab, i2, sizeof(ll), sortfnc);
	if (i2 > k) {
		i2 = k;
	}

	j2 = 0;
	for (i = 0; i < i2; i++) {
		for (j = 0; j < z; j++) {
			abc[j2] = ab[i] + c[j];
			j2++;
		}
	}
	qsort(abc, j2, sizeof(ll), sortfnc);

	for (i = 0; i < k; i++) {
		outll(abc[i]);
	}

	return 0;
}

int
main()
{
#ifdef TEST
	for (t = TEST_SNO; t <= TEST_ENO; t++) {
		char str[128];
		sprintf(str, "test%d.txt", t);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", t);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


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

using namespace std;

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

// Sorting
void insertionSort(int n,int*a,int g=1){for(int i=g;i<n;++i){int v=a[i],j=i-g;while(j>=0&&a[j]>v){a[j+g]=a[j];j-=g;}a[j+g]=v;}}
void shellSort(int n,int*a){vector<int>G;for(int h=1;;){if(h>n)break;G.push_back(h);h=3*h+1;}for(int i=G.size()-1;i>=0;--i)insertionSort(n,a,G[i]);}
int bubbleSort(int n,int*a){int s=0,j;bool f=1;for(int i=0;f;++i){f=0;for(j=n-1;j>=i+1;--j){if(a[j]<a[j-1]){swap(a[j],a[j-1]);f=1;s++;}}}return s;}
int selectionSort(int n,int*a){int s=0,j,m;for(int i=0;i<n-1;++i){m=i;for(j=i;j<n;++j)if(a[j]<a[m])m=j;swap(a[i],a[m]);if(i!=m)++s;}return s;}

// Searching
int binarySearch(int n,int*a,int k){int m,l=0,r=n;while(l<r){m=l+(r-l)/2;if(k<a[m])r=m;else if(a[m]<k)l=m+1;else return m;}return-1;}

// Mathematics
int gcd(int a,int b){!b?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}

// Visualization
void printArray(int n,int*a){for(int i=0;i<n;++i)printf(i>0?" %d":"%d",a[i]);printf("\n");}

int main(){
	int k,x; cin >> k >> x;
	cout << (k*500>=x ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N, P = list(map(int, input().split()))
S = input()
#S = map(int, list())

tot = 0

if P in [2,5]:
  for i in range(1,N+1):
    if int(S[-i]) % P == 0:
      tot += N-i+1
else:
  S_mod = [0] * P
  S_mod[0] = 1 # 0 = 0 mod P
  mod = 0
  mod10 = 10 % P
  mod_power10 = 1
  for i in range(N-1, -1, -1):
    mod = (int(S[i]) % P * mod_power10 + mod % P) % P
    #print(S[i:], mod)
    tot += S_mod[mod]
    S_mod[mod] += 1
    mod_power10 = (mod_power10 * mod10) % P
print(tot)

Measured memory_bytes: 3624
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

b = np.sort(np.abs(a))
c = np.sum(a < 0)

if c % 2 == 0:
  total = np.sum(b)
else:
  total = np.sum(b[1:]) - b[0]
  
print(total)

Measured memory_bytes: 23288
#include "bits/stdc++.h" //STL loaded
typedef long long ll;
using namespace std; //class or something but required for almost everything

main()
{
	ios::sync_with_stdio(0); 
    cin.tie(0); 
    ll D,T,S; 
    cin>>D>>T>>S; 
    if(D<=T*S) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3592
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]

from math import factorial as fac

S=0
for i in range(N):
    for j in range(N):
        S+=((X[i][0]-X[j][0])**2+(X[i][1]-X[j][1])**2)**(1/2)

total=fac(N)//fac(2)//fac(N-2)
print(((N-1)/(total))*S/2)

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

def comb(n, k):
    c = 1
    for i in range(min(k, n-k)):
        c *= (n-i)
    for i in range(min(k, n-k)):
        c = c//(i+1)
    return c

for i in range(1, K+1):
    if N-K+1 >= i:
        b = comb(K-1, i-1)
        r = comb(N-K+1, i)
        ans = (b*r)%(10**9+7)
        print(ans)
    else:
        print(0)

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

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

int main() {
    string dan;
    cin >> dan;
    bool easy_even = true;
    bool easy_odd = true;
    rep(i, dan.size()) {
        if (i % 2 != 0) {
            if (dan.at(i) != 'L' && dan.at(i) != 'U' && dan.at(i) != 'D')
                easy_even = false;
        } else {
            if (dan.at(i) != 'R' && dan.at(i) != 'U' && dan.at(i) != 'D')
                easy_odd = false;
        }
    }
    cout << ((easy_even && easy_odd) ? "Yes" : "No") << endl;
}



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

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5;
const num inf = 0x3f3f3f3f3f3f3f3f;
bool vis[nsz + 5];
int n;
num d, a[nsz + 5], w1[nsz + 5], w2[nsz + 5];

struct segment {
	int u, v;
	pair<num, int> a1, a2, b1, b2;
	num res;
	
	segment() {
		u = v = 0;
		a1 = a2 = b1 = b2 = {inf, 0};
		res = inf;
	}
	
	segment(pair<num, int> a1, pair<num, int> a2, pair<num, int> b1, pair<num, int> b2) {
		this->a1 = a1, this->a2 = a2, this->b1 = b1, this->b2 = b2;
		res = inf;
	}
};

segment inline operator & (const segment &ls, const segment &rs) {
	segment res;
	res.a1 = min(ls.a1, rs.a1);
	res.a2 = min(ls.a2, rs.a2);
	res.b1 = min(ls.b1, rs.b1);
	res.b2 = min(ls.b2, rs.b2);
	if (ls.res < rs.res) {
		res.res = ls.res;
		res.u = ls.u, res.v = ls.v;
	} else {
		res.res = rs.res;
		res.u = rs.u, res.v = rs.v;
	}
	if (ls.a2.first + rs.b1.first < res.res) {
		res.res = ls.a2.first + rs.b1.first;
		res.u = ls.a2.second, res.v = rs.b1.second;
	}
	if (ls.b2.first + rs.a1.first < res.res) {
		res.res = ls.b2.first + rs.a1.first;
		res.u = ls.b2.second, res.v = rs.a1.second;
	}
	return res;
}

struct segment_tree {
	#define ls  (u << 1)
	#define rs  (u << 1 | 1)
	
	segment tr[4 * nsz + 5];
	
	void init(num b1[], num b2[], int u = 1, int l = 1, int r = n) {
		if (l == r) {
			tr[u] = segment({inf, l}, {inf, l}, {b1[l], l}, {b2[l], l});
			tr[u].res = inf, tr[u].u = 0, tr[u].v = 0;
			return;
		}
		int md = (l + r) >> 1;
		init(b1, b2, ls, l, md);
		init(b1, b2, rs, md + 1, r);
		tr[u] = tr[ls] & tr[rs];
	}
	
	void set(int id, num a1, num a2, num b1, num b2, int u = 1, int l = 1, int r = n) {
		if (l == r) { tr[u] = segment({a1, l}, {a2, l}, {b1, l}, {b2, l}); return; }
		int md = (l + r) >> 1;
		id <= md ? set(id, a1, a2, b1, b2, ls, l, md) : set(id, a1, a2, b1, b2, rs, md + 1, r);
		tr[u] = tr[ls] & tr[rs];
	}
	
	segment inline qry_all() {
		return tr[1];
	}
};
segment_tree tr;

num inline w(int u, int v) {
	if (u < v)  swap(u, v);
	return w1[u] + w2[v];
}

num inline prim(int s = 1) {
	tr.init(w1, w2);
	num res = 0;
	tr.set(s, w1[s], w2[s], inf, inf);
	vis[s] = 1;
	for (int cnt = 1; cnt <= n - 1; ++cnt) {
		segment cur = tr.qry_all();
		int u = cur.u, v = cur.v;
		if (!vis[u])  tr.set(u, w1[u], w2[u], inf, inf);
		if (!vis[v])  tr.set(v, w1[v], w2[v], inf, inf);
		vis[u] = vis[v] = 1;
		res += cur.res;
	}
	return res;
}

int main() {
	scanf("%d%lld", &n, &d);
	cont (i, n) {
		scanf("%lld", &a[i]);
		w1[i] = a[i] + d * i;
		w2[i] = a[i] - d * i;
	}
	printf("%lld\n", prim());
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<int,ii> iii;
typedef vector<iii> viii;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int MOD = 1e9 + 7;
const ll INF = ll(1e18);
const ld eps = ld(1e-8);

bool pos[10];
int dig[10];
int power[6];
int DIG[10];

bool ok(int x)
{
	if(x == 0)
	{
		if(!pos[0]) return true;
		else return false;
	}
	while(x)
	{
		if(pos[x%10]) return false;
		x /= 10;
	}
	return true;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < k; i++)
	{
		cin>>dig[i];
		pos[dig[i]] = true;
	}
	int idx = 0;
	for(int i = 0; i < 10; i++)
	{
		if(!pos[i])
		{
			DIG[idx] = i;
			idx++;
		}
	}
	power[0] = 1;
	for(int i = 1; i <= 5; i++)
	{
		power[i] = power[i-1]*10;
	}
	
	int x = n;
	int cnt = 0;
	if(n == 0) cnt = 1;
	while(x)
	{
		x /= 10;
		cnt++;
	}
	for(int i = n; i < power[cnt]; i++)
	{
		if(ok(i))
		{
			cout << i << '\n';
			return 0;
		}
	}	
	int d = DIG[0];
	if(d == 0) d = DIG[1];
	cout << d;
	for(int i = 0; i < cnt; i++)
	{
		cout << DIG[0];
	}
	cout << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <cstdio>
#include <math.h>



using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
    
int main()
{
  	int Nmax = 2000;
    
    int i,j;
    int len;   // 文字列の長さ
    int flag=0;
   
    int A[Nmax];
    int N;
    int k;
    ll K;
    ll total;
    ll ans;
    ll tmp1,tmp2,tmp;
   
    
   
 
    
    // 数列
    scanf("%d %lld", &N,&K);
    for(i=0;i<=N-1;i++){
        scanf("%d ",&A[i]);
    }
  //    	cout << MOD  << endl;

              
    // １セット内での転倒数
    ll count1 = 0;
    for(i=0;i<=N-1;i++){
        for(j=i+1;j<= N-1;j++){
            if((i<j) && (A[i]>A[j])) count1++;
        }
    }
    
    // ２セット間での転倒数
    ll count2 = 0;
    for(i=0;i <= N-1;i++){
        for(j=0;j <= N-1;j++){
            if(A[i]>A[j]) count2++;
        }
    }
    
//    tmp1 = K*count1 % MOD;
  //  tmp2 = count2*K % MOD * (K-1) % MOD /2 ;
    tmp1 = K % MOD * count1 % MOD;
    tmp2 = (K * (K-1) / 2 ) % MOD * count2;    
    tmp = (tmp1 + tmp2) % MOD;

//    total = K*count1 + count2*K*(K-1)/2;
//  	cout << total << endl;
  
    ans = total % MOD;
	cout << tmp << endl;
  //  printf("%lld\n",ans );
    
    
    
 /*
    total = count1;
    for(k=2;k<=K;k++){
        total = total + count1 + (k-1)*count2;
    }
    
    // int型より大きいのでオーバーフローしないところまではdouble型で計算
    tmp =  total/(double)bunbo; 
 //   printf("%f\n",tmp);
  　sho = floor(tmp);    // 小数点以下切り捨て
//    printf("%f\n",tmp);
   
    
    tmp = total - sho*bunbo;    // int型に収まってきた
//  printf("%f\n",tmp);
    ans = (int)tmp; 
    printf("%d\n",ans );
*/
   
    
   
  
  return 0;
   
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sc(x) scanf("%d", &x)
#define pr(x) printf("%d\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 100010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
int a, b;
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	sc(a);
	sc(b);
	if (b * 2 >= a) puts("0");
	else printf("%d", a - b * 2); 
	return 0;
}


Measured memory_bytes: 256