akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
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 mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  ll l,cnt[4]={0};
  rep(i,n){
    cin>>l;
    cnt[l%4]++;
  }
  ll sum = cnt[1] + cnt[2] + cnt[3];
  // if(((cnt[0]-cnt[1]-cnt[3]-cnt[2]) == cnt[0]||sum <= cnt[0] * 2 )|| ((cnt[2]-cnt[1]-cnt[3]-cnt[0]) == cnt[2] || cnt[2]-cnt[1]-cnt[3] + cnt[0] == cnt[2] + cnt[0] ) ) cout<<"Yes"<<endl;
  if(cnt[2] >0){
    if(cnt[1] + cnt[3]<= cnt[0]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  } else {
    if(cnt[1] + cnt[3]<= cnt[0] + 1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

int main()
{
    int A, P;
    cin >> A >> P;
    int sum;
    P += A * 3;
    sum = P / 2;
    cout << sum << endl;
}


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

int main() {
  int N, ans = 0, judge = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    vec.at(i) = a - 1;
  }
  
  for (int j = 0; true; ans++) {
    
    if (vec.at(j) == 1) {
      ans++;
      break;
    }
    
    else if (vec.at(j) == -1) {
      cout << -1 << endl;
      judge = 1;
      break;
    }
    
    else {
      int x = 0;
      x = j;
      j = vec.at(x);
      vec.at(x) = -1;
    } 
    
  }
  
  if (judge == 0)
    cout << ans << endl;
    
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    return right;
}

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    vector<P<P<string, int>, int>> v(n);
    P<string, int> p;
    for (int i = 0; i < n; i++)
    {
        cin >> p.X >> p.Y;
        p.Y *= -1;
        v[i].X = p;
        v[i].Y = i + 1;
    }
    vsort(v);
    for (int i = 0; i < n; i++)
    {
        cout << v[i].Y << endl;
    }
}

Measured memory_bytes: 256
n =  int(input())
r = [0]*n

for i in range(n):
  s,v = map(str, input().split())
  v = int(v)
  r[i] = [s,v,i+1]
r.sort(reverse=True,key=lambda x:x[1])
r.sort(key=lambda x:x[0])
for i in range(n):
  print(r[i][2])

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

bool isPrime(int x){
  /* if(x<=1){
    return false;}
    for(int i=2;i<x;i++){
      if(x%i==0){
	return false;}
    }
        return true;
	}*/
  int i=3;
  if(x==2){
    return true;}
  if(x<2 || x%2==0){
    return false;}
  while( i<=sqrt(x)){
    if(x%i==0){
      return false;}
    i=i+2;}

  return true;
}


  

    int main(){
      int N,x,count=0;
      cin >> N;
      for(int i=0;i<N;i++){
	cin >> x; 
	if(isPrime(x)){
	  count++;}
      }
      cout << count << endl;

	return 0;
    }

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>

using namespace std;
int main()
{
	int x,v;
	cin >> x;
	float q,m;
	for (int i = x; i > 0; i--){
		for (int j = 2; j <= 10; j++){
			 m = 1.0 / j;
			q = pow(i,m);
			v = q;
			q *= 10000;
			q=static_cast<int>(q);
			v *= 10000;
			if (v == q){
				cout << i;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static long solve(long N, long P) {
        if (N == 1) return P;

        long M = (long) Math.round(Math.pow(P, 1.0 / N));
        while (M > 1) {
            long a = (long) Math.pow(M, N);
            if (P % a == 0) {
                break;
            }
            M -= 1;
        }
        return M;
    }

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

        long N = sc.nextLong();
        long P = sc.nextLong();

        System.out.println(solve(N, P));
    }
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int n;
string s[2];
char res;
int main()
{
	cin >> n;
	bool app=true;
	s[0]="";
	s[1]="";
	while (s[0].size()<n)
		if (app)
		{
			s[0]+='.';
			s[1]+='.';
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(s[0].size()-1,1);
			s[1].erase(s[1].size()-1,1);
			s[0]+='.';
			s[1]+='#';
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(s[0].size()-1,1);
			s[1].erase(s[1].size()-1,1);
			s[0]+='#';
			s[1]+='.';
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(s[0].size()-1,1);
			s[1].erase(s[1].size()-1,1);
			s[0]+='#';
			s[1]+='#';
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(s[0].size()-1,1);
			s[1].erase(s[1].size()-1,1);
			app=false;
		}
		else
		{
			s[0]='.'+s[0];
			s[1]='.'+s[1];
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(0,1);
			s[1].erase(0,1);
			s[0]='.'+s[0];
			s[1]='#'+s[1];
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(0,1);
			s[1].erase(0,1);
			s[0]='#'+s[0];
			s[1]='.'+s[1];
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(0,1);
			s[1].erase(0,1);
			s[0]='#'+s[0];
			s[1]='#'+s[1];
			cout << s[0] << '\n';
			cout << s[1] << endl;
			cin >> res;
			if (res=='T')
				continue;
			if (res=='e')
				return 0;
			s[0].erase(0,1);
			s[1].erase(0,1);
			app=true;
		}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int arr[6] = {500,100,50,10,5,1};
int main()
{
    int x;
    cin>>x;
    int ans = 0;
    while(x)
    {
        //cout<<x<<endl;
        if(x>=500)
        {
            ans+=(x/500)*1000;
            x-=(x/500)*500;
            continue;
        }
        else if(x>=5)
        {
            ans+=(x/5)*5;
            x-=(x/5)*5;
            continue;
        }
        else x--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n;
long long tot=1,d[99001],e[99001],s=0;
int main()
{
	cin>>n;
	d[0]=e[0]=1;
	for(int i=1,x;i<=n;i++)
	{
		cin>>x;
		s+=x;
		tot=tot*3%mod;
		for(int j=s;j>=0;j--)
		{
			d[j]=(d[j]*2+(j>=x?d[j-x]:0))%mod;
			e[j]=(e[j]+(j>=x?e[j-x]:0))%mod;
		}
	}
	long long sum=0;
	for(int i=(s+1)/2;i<=s;i++)sum=(sum+d[i])%mod;
	cout<<((tot-3*sum+3*(s%2==0?e[s/2]:0))%mod+mod)%mod<<'\n';
}


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

vector<int>v;
double EPS=1e-9;
//ll pre[500010],a[500010],res[1000001];
const ll mod=1e9+7;
ll fastpow(ll a, ll n)
{
    if(n == 0) return 1;
    ll x = fastpow(a, n/2);
    ll ans = x * x % mod;
    if(n % 2 == 1) ans = ans *a % mod;
    return ans%mod;
}

ll C(ll n,ll m) {
    if(n < m) return 0;
    ll res = 1;
    for(ll i=1; i<=m; i++) {
        ll a = (n+i-m)%mod;
        ll b = i%mod;
        res = res*(a*fastpow(b,mod-2)%mod)%mod;
    }
    return res;
}

ll Lucas(ll n,ll m) {
    if(m == 0) return 1;
    return C(n%mod, m%mod) * Lucas(n/mod,m/mod)%mod;
}
vector <ll> v1,v2;

int a[200010],vis[200010],suf[200010];
ll gcd(ll n,ll k)
{
    if(k==0)return n;
    else return gcd(k,n%k);
}
int main()
{
    ll n;
cin>>n;
bool p=0;
while(n>0)
{
    ll temp=n%10;
    if(temp==7){p=1;}
    n/=10;
}
if(p==1)cout<<"Yes";
else cout<<"No";
  /*  ll sum=0;
    for(int i=1;i<=n;i++)
{
    if(i%3!=0&&i%5!=0)sum+=i;
}
cout<<sum;*/
/*ll sum=0;
for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    for(int k=1;k<=n;k++)
{
    sum+=gcd(__gcd(i,j),k);
}
cout<<sum;*/
return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
long long a[300001];
long long f[300001][5];
int main()
{
	int l;
	scanf("%d",&l);
	int i;
	long long tot=0;
	for(i=1;i<=l;i++)
	{
		scanf("%lld",&a[i]);
		tot+=a[i];
	}
	int j;
	for(i=1;i<=l;i++)
	{
		if(a[i]!=0)
		{
			long long tmp=f[i-1][0];
			f[i][0]=tmp+a[i];
			tmp=min(tmp,f[i-1][1]);
			f[i][1]=tmp+a[i]%2ll;
			tmp=min(tmp,f[i-1][2]);
			f[i][2]=tmp+(1ll-a[i]%2ll);
			tmp=min(tmp,f[i-1][3]);
			f[i][3]=tmp+a[i]%2ll;
			tmp=min(tmp,f[i-1][4]);
			f[i][4]=tmp+a[i];
		}
		else
		{
			long long tmp=f[i-1][0]; 
			f[i][0]=tmp;
			tmp=min(tmp,f[i-1][1]);
			f[i][1]=tmp+2ll;
			tmp=min(tmp,f[i-1][2]);
			f[i][2]=tmp+1ll;
			tmp=min(tmp,f[i-1][3]);
			f[i][3]=tmp+2ll;
			tmp=min(tmp,f[i-1][4]);
			f[i][4]=tmp;
		}
	}
/*	for(i=1;i<=l;i++)
	{
		for(int j=0;j<=4;j++)
			printf("%lld ",f[i][j]);
		printf("\n");
	}*/
	long long ans=f[l][0];
	ans=min(ans,f[l][1]);
	ans=min(ans,f[l][2]);
	ans=min(ans,f[l][3]);
	ans=min(ans,f[l][4]);
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    ll n;
    string s;
    cin>>n>>s;
    string ans="No";
    if(n%2==1){
        cout<<ans<<endl;
        return 0;
    }
    if(s.substr(0, n/2) == s.substr(n/2, n/2)){
        ans="Yes";
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <sstream>
typedef std::pair <int, int> pii;
const int INF = (int)1e9;

int main()
{
	long long a, b, c;
	std::cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		std::cout << 0;
	else
	{
		std::cout << std::min (a * b, std::min (b * c, a * c));
	}
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i, N) cin >> p[i];

  int count = 0;
  rep(i, N) if (i + 1 != p[i]) count++;

  if (count <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

// // 後ろから埋めていく
// int main() {
//     int n, m;
//     cin >> n >> m;
//     vector<int> broken(n+1);
//     int a; 
//     for(int i=0; i<m; i++){
//         cin >> a;
//         broken[a] = 1;
//     }

//     vector<int> dp(n+2);
//     dp[n] = 1;
//     for(int i=n-1; i >= 0; i--){
//         if(broken[i]){
//             dp[i] = 0;
//             continue;
//         }
//         dp[i] = (dp[i+1]+dp[i+2]) % mod;
//     }
//     cout << dp[0] << endl;
//     return 0;
// }

// 前から埋めていく
int main(){
        int n, m;
    cin >> n >> m;
    vector<int> broken(n+1);
    int a; 
    for(int i=0; i<m; i++){
        cin >> a;
        broken[a] = 1;
    }

    vector<int> dp(n+1);
    dp[0] = 1;
    for(int i=1; i <= n; i++){
        if(broken[i]){
            dp[i] = 0;
            continue;
        }
        if(i==1){
            dp[i] = dp[i-1];
            continue;
        }
        dp[i] = (dp[i-1]+dp[i-2]) % mod;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
s=input()

how_many=[]
LR=[]
 
counter=0
for i in range(1,n):
    counter+=1
    if s[i-1]!=s[i]:
        how_many.append(counter)
        LR.append(s[i-1])
        counter=0
how_many.append(counter+1)
LR.append(s[-1])

accumulate=[0]
for i in range(len(how_many)):
    accumulate.append(accumulate[-1]+how_many[i])


ans=0
max_left=0
max_right=0
for g in range(len(LR)):
    l=g
    if LR[l]=="L":
        r=min(g+2*k,len(LR))
    else:
        r=min(g+2*k+1,len(LR))
    if ans<=accumulate[r]-accumulate[l]:
        ans=accumulate[r]-accumulate[l]
        max_left=l
        max_right=r
remain=how_many[:max_left]+how_many[max_right:]
ans1=ans-1+sum(remain)-len(remain)


ans=0
max_left=0
max_right=0
for g in range(len(LR)):
    l=g
    if LR[l]=="R":
        r=min(g+2*k,len(LR))
    else:
        r=min(g+2*k+1,len(LR))
    if ans<=accumulate[r]-accumulate[l]:
        ans=accumulate[r]-accumulate[l]
        max_left=l
        max_right=r

remain=how_many[:max_left]+how_many[max_right:]
ans2=ans-1+sum(remain)-len(remain)
print(max(ans1,ans2))

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

int main()
{
    int w,a,b;cin>>w>>a>>b;
    cout<<(b>a+w||a>b+w?min(abs(b-(a+w)),abs(a-(b+w))):0)<<endl;
    return 0;
}


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

int main() {

    int n;
    cin >> n;
    vector< vector< int > > p(3, vector< int >(n + 1, 0));
    for(int i = 0; i < 3; i++) {
        int size; cin >> size;
        for(int j = 0; j < size; j++) {
            int a; cin >> a;
            p[i][a]++;
        }
    }

    int sum = 0;
    vector< int > used(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        if((!p[0][i] && p[2][i] || p[1][i] && p[2][i]) && !used[i]) {
            sum++;
            used[i]++;
        }
    }
    cout << sum << endl;
}

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

int main()
{
    string n;
    cin >> n;
    int size = n.length();
    int multi = 0;

    for(int i=0; i<size; i++){
        multi += n[i] - '0';
    }

    if(multi%9) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;

}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> students(n), points(m);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        students[i].first = a;
        students[i].second = b;
    }
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        points[i].first = a;
        points[i].second = b;
    }

    rep(i, n){
        ll min_val = INF;
        int min_idx = -1;
        rep(j, m){
            ll dist = abs(students[i].first - points[j].first) + abs(students[i].second - points[j].second);
            if(dist < min_val){
                min_idx = j;
                min_val = dist;
            }
        }

        cout << min_idx + 1 << endl;
    }
}


Measured memory_bytes: 256
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 14464
n = gets.to_i
hs = gets.split.map(&:to_i)

(n-1).downto(1) do |i|
  if hs[i-1] - 1 == hs[i]
    hs[i-1] -= 1
  elsif hs[i-1] <= hs[i]
    # pass
  else
    puts 'No'
    exit
  end
end

puts 'Yes'

Measured memory_bytes: 8580
n = int(input())
s = str(input())

check = dict()
def get_pattern2(i, j):
    a = s[i]
    b = s[j]
    total = 0
    check_str = ""
    if a == "R" or b == "R":
        check_str += "R"
    if a == "G" or b == "G":
        check_str += "G"
    if a == "B" or b == "B":
        check_str += "B"

    for k in range(j+1, n):
        if check_str+str(k) in check:
            total += check[check_str+str(k)]
            break
        if a != s[k] and b != s[k]:
            total += 1
    check[check_str+str(j+1)] = total
    return total

def get_pattern(i):
    a = s[i]
    total = 0
    for j in range(i+1, n):
        if a+str(j) in check:
            total += check[a+str(j)]
            break
        if a != s[j]:
            total += get_pattern2(i, j)
    check[a+str(i+1)] = total

    # k-j = i-jなものをぬく
    for j in range(i+1, n):
        k = j + j - i
        if k >= n:
            break
        if a != s[k] and s[j] != s[k] and a != s[j]:
            total -= 1
    return total

total = 0
for i in range(n-1, -1, -1):
    total += get_pattern(i)
print(total)


Measured memory_bytes: 72064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	llong sum=0;
	REP(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	
	llong x=a[0];
	llong y=sum-x;
	llong ans=abs(x-y);
	for(int i=1;i<n-1;++i){
		x+=a[i];
		y-=a[i];
		ans=min(ans,abs(x-y));
	}
	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

const long mod=1000000007;

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

  
  long h,w,k;
   cin >> h >> w >> k;
  
  vector<vector<long>> dp(105,vector<long>(10,0));
  dp[0][0]=1;
  
  for(int i=0;i<h;i++){
   for(int j=0;j<w;j++){
      for(int l=0;l<(1<<(w-1));l++) { 
        bool flag=true;
       for(int m=0;m<w-2;m++) if((l&(1<<m)) && (l&(1<<(m+1)))) {
         flag=false;
         break;
       }
         if(!flag) continue;
        
      if(w>j&&j>0&&(l&(1<<(j-1)))) {
        dp[i+1][j-1]+=dp[i][j];
        dp[i+1][j-1]%=mod;
      }
        else if(-1<j&&j<w-1&&((l&(1<<j)))) {
          dp[i+1][j+1]+=dp[i][j];
          dp[i+1][j+1]%=mod;
        }
     
          else {
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=mod;
          }
          
    }
   }  
  }
  
  cout << dp[h][k-1] << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=sc.Ia;
		int[] h1=new int[100001];
		int[] h2=new int[s[1]];
		int[] h3=new int[s[1]];
		for(int i = 0;i<s[0];i++) {
			h1[a[i]]++;
		}
		for(int i = 1;i<100001;i++) {
			if(h1[i]%2==1){
				h2[i%s[1]]++;
				h1[i]--;
			}
			h3[i%s[1]]+=h1[i];
		}
		long ans=0;
		for(int i = 0;i<s[1];i++) {
			int p=Min(h2[i],h2[(s[1]-i)%s[1]]);
			ans+=p;
			h2[i]-=p;
			h2[(s[1]-i)%s[1]]-=p;
			p=Min(h2[i],h3[(s[1]-i)%s[1]]);
			ans+=p;
			h2[i]-=p;
			h3[(s[1]-i)%s[1]]-=p;
		}
		for(int i = 0;i<s[1];i++) {
			ans+=h3[i]>>1;
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 21344
import Control.Monad
import qualified Data.ByteString.Char8 as C
import qualified Data.IntMap.Strict as M
import Data.List
import Data.Maybe

main = join $ sub <$> (C.getLine *> get) <*> get

get = unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine

sub as [q] = sol s m <$> replicateM q get >>= mapM_ print
  where
  s = sum $ fmap fromIntegral as :: Integer
  m = M.fromList . fmap ((,) <$> head <*> length) . group $ sort as

sol :: Integer -> M.IntMap Int -> [[Int]] -> [Integer]
sol s m = fmap fst . tail . scanl' f (s,m) 

f (s,m) [b,c] = (s+fromIntegral ((c-b)*v),M.insertWith (+) c v $ M.delete b m)
  where
  v = M.findWithDefault 0 b m

Measured memory_bytes: 69164
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	string s1,s2,s3; cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>
#include <stdio.h>
using namespace std;

int main() {

char ch;

while(1){
    scanf("%c", &ch);
 
    if(isalpha(ch) && islower(ch)){
    ch = toupper(ch);
    cout<<ch;        
    }
    else if(isalpha(ch) && isupper(ch)){    
    ch = tolower(ch);
    cout<<ch;        
    }
    else{
        cout<<ch;
    }
 
    if ( ch == '\n' ) break;
}
	return 0;
}


Measured memory_bytes: 3136
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	int sum = r * 100 + g * 10 + b;
	if (sum % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<bitset>
#include<vector>
using namespace std;
int max(int a, int b){
  if(a>= b) return a;
  else return b;
}
int main(){
int n; cin >>n;
int a[n]; int sum=0;
for(int i=0;i<n;++i){
  cin >>a[i];
  sum += a[i];
}
if((sum%10)!=0){cout <<sum<<endl; return 0;}
sort(a,a+n);
for(int i=0;i<n;++i){
  if((a[i]%10)!=0){cout <<sum-a[i]<<endl; return 0;}
}
cout <<0<<endl;
}


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    string s; cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
pair<int, int> a[101];
ll dp[100001];
int main(){
    ll n,w;
    cin>>n>>w;
    for(int i=0;i<n;i++) cin>>a[i].first>>a[i].second;
    for(int i=1;i<=100000;i++) dp[i]=1e18;
    for(int i=0;i<n;i++){
        for(int j=100000;j>=a[i].second;j--){
            dp[j]=min(dp[j],dp[j-a[i].second]+a[i].first);
        }
    }
    int ans=0;
    for(int i=0;i<=100000;i++){
        if(dp[i]<=w) ans=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

int flag[5];
int num;
void count(int deep,long long n,long long now,bool on) {
	if (on) {



		for (int i = 1; i <= 4; i++) {
			bool temp = false;
			switch (i) {
			case 4:
				now -= 7 * (long long)pow(10, deep);
				temp = true;
				break;
			case 1:
				now += 3 * (long long)pow(10, deep);
				break;
			case 2:
				now += 2 * (long long)pow(10, deep);
				break;
			case 3:
				now += 2 * (long long)pow(10, deep);
			}
			flag[i]++;
			flag[i - 1]--;
			if (deep == 0) {
				if (now <= n && flag[1] > 0 && flag[2] > 0 && flag[3] > 0) {
					num++;
				}
			}
			else {
				count(deep - 1, n, now,temp);
			}

		}
	}
	else {

		for (int i = 1; i <= 3; i++) {
			switch (i) {
			case 4:
				now -= 7 * (long long)pow(10, deep);

				break;
			case 1:
				now += 3 * (long long)pow(10, deep);
				break;
			case 2:
				now += 2 * (long long)pow(10, deep);
				break;
			case 3:
				now += 2 * (long long)pow(10, deep);
			}
			flag[i]++;
			flag[i - 1]--;
			if (deep == 0) {
				if (now <= n && flag[1] > 0 && flag[2] > 0 && flag[3] > 0) {
					num++;
				}
			}
			else {
				count(deep - 1, n, now,false);
			}

		}
		flag[3]--;
	}

}

int main() {
	long long n;
	cin >> n;
	count(9, n, 0,true);
	cout << num;


	return 0;
}


Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m;
   l(i,0,n)
   {
       s1=s1+to_string(m);
   }
   l(i,0,m)
   {
       s2=s2+to_string(n);
   }
   s3=min(s1,s2);

   cout<<s3<<endl;
}


Measured memory_bytes: 3728
# AOJ ITP1_4_D: Min, Max and Sum
# Python3 2018.6.7 bal4u

n = int(input())
data = list(map(int, input().split()))   # 1行にある複数の値を整数にして、リストにしまう
#
vmin = min(data)  # 最小値
vmax = max(data)  # 最大値
vsum = sum(data)  # 合計
#
print(vmin, vmax, vsum)  # 結果表示


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
  return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->



int main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif


  int n, x;
  cin >> n >> x;

  vector<int>a(n);

  loop(i, n)
  {
    cin >> a[i];
  }

  ll ans = 0;

  for (int i = 0; i < n - 1; i++)
  {
    ll diff = (a[i] + a[i + 1]) - x;

    if (diff > 0) {
      ans += diff;

      a[i + 1] = max((ll)0, a[i + 1] - diff);
    }
  }


  cout << ans << endl;

}


Measured memory_bytes: 3720
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
n, m = l[0]
ans = []
for i, j in l:
    if j == m:
        ans.append(i)
for a in sorted(ans):
    print(a)
    


Measured memory_bytes: 49172
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define inf         2e9+5
#define mp          make_pair
#define ll          long long
#define pii         pair<int,int >
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define sf          scanf
#define pf          printf
/*------------------------------Graph Moves----------------------------*/
const int fx[]= {+1,-1,+0,+0};
const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
using namespace std;
//using namespace __gnu_pbds;
//
//template <typename T>  using orderedSet =
//    tree<T, null_type, less<T>,
//    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key
//

ll dp[2020][2020];
const int mod=1000000007;
void nCr()
{
    for(int i=0;i<=2008;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0 || j==i) dp[i][j]=1;
            else dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%mod;
        }
    }
}


int main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    nCr();
    for(int i=1;i<=k;i++)
    {
        ll ans=(dp[k-1][i-1]*dp[n-k+1][i])%mod;
        ans=(ans+mod)%mod;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 30464
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a=10,aa[10],b=0;
signed main()
{
	cin>>a;
	rep(i,5){
		cin>>aa[i];
	}
	sort(aa,aa+5);
	if(aa[0]==1){
		cout<<a+4;
	}else{
	    cout<<a/aa[0]+5;
	}
}

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

const int maxn=100005;
int n,m,dis[maxn]={0};
int s,t;
struct edge{
	int to;
	int weight;
};
vector<edge> GV[maxn];
struct qnode{
	int u,len;
	bool operator <(const qnode &tmp) const{
		return len>tmp.len;
	}
};
priority_queue<qnode> pq;

int main(){
	scanf("%d",&n);  
	for(int i=1;i<=n;i++)
		for(int j=0;j<=9;j++){
			edge tmp;
			tmp.to=((i-1)*10+j)%n+1,tmp.weight=j;
			GV[i].push_back(tmp);
		}
	for(int i=1;i<=9;i++){
		edge tmp;
		tmp.to=i+1,tmp.weight=i;
		GV[0].push_back(tmp);
	}
	
	s=0,t=1;
	memset(dis,0x3f,sizeof(dis));
	dis[0]=0;
	pq.push((qnode){0,dis[0]});
	
	while(!pq.empty()){
		qnode nowp=pq.top();
		pq.pop();
		if(nowp.len!=dis[nowp.u])  continue;
		for(int i=0;i<GV[nowp.u].size();i++){
			if (dis[GV[nowp.u][i].to]>dis[nowp.u]+GV[nowp.u][i].weight){
                dis[GV[nowp.u][i].to]=dis[nowp.u]+GV[nowp.u][i].weight;
				pq.push((qnode){GV[nowp.u][i].to,dis[GV[nowp.u][i].to]});
            }
		}
	}
	
	printf("%d",dis[1]);
	
	return 0;
}

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

using namespace std;

#define inf (ll)1e18
#define ll long long
#define all(x) x.begin(), x.end()
#define X first
#define Y second

const int N = 1000060;

const int mod = (int)1e9 + 7;
const int MX = 1000020;


int main(){

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

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

   	int n;
   	cin >> n;

   	int f[n][10];
   	for(int i = 0; i < n; ++i){
   		for(int j = 0; j < 10; ++j){
   			cin >> f[i][j];
   		}
   	}

   	int p[n][11];
   	for(int i = 0; i < n; ++i){
   		for(int j = 0; j <= 10; ++j){
   			cin >> p[i][j];
   		}
   	}

   	int lim = 1 << 10;

   	int res = -2e9;

   	for(int i = 1; i < lim; ++i){
   		int tmp = 0;
   		bool ok = false;
   		for(int j = 0; j < n; ++j){
   			int cnt = 0;
	   		for(int bit = 0; bit < 10; ++bit){
	   			if(f[j][bit] == 1 && ((1 << bit) & i) != 0)
	   				cnt++;
	   		}
	   		if(cnt > 0) ok = true;
	   		tmp += p[j][cnt];
   		}
   		if(ok)
   			res = max(res, tmp);
   	}

   	cout << res << endl;

    return 0;	
}

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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			boolean[] c = new boolean[11];
			Arrays.fill(c, true);
			c[0] = false;
			int C1 = sc.nextInt();
			int C2 = sc.nextInt();
			int C3 = sc.nextInt();
			c[C1] = false;
			c[C2] = false;
			c[C3] = false;
			int sum = C1 + C2;
			int cnt = 0;
			for(int i = 1; i <= 10; i++) {
				if(c[i] && sum + i <= 20) {
					cnt++;
				}
			}
			if(cnt >= 4) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 26264
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x
  
def pf(x):
    s = []
    while x % 2 == 0:
        s.append(2)
        x = x // 2
    i = 3
    while i**2 <= x:
        while x % i == 0:
            s.append(i)
            x = x // i
        i = i + 2
    if x != 1:
        s.append(x)
    return(s)
A, B = list(map(int,input().split()))
x = gcd(A, B)
ans = pf(x)
ans = set(ans)
print(len(ans)+1)  

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int main(){
const int MAX_V=10000;
int prime[MAX_V+1];
	int i,k,v,n,p1,q1;
	for(i=2;i<=MAX_V;i++){
		prime[i]=1;
	}
	for(i=2;i*i<=MAX_V;i++){
		if(prime[i]){
			for(k=2*i;k<=MAX_V;k+=i){
				prime[k]=0;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
	while(1){
		scanf("%d",&v);
		if(v==0)break;
		if(prime[v]==0){
			while(1){
				v--;
				if(prime[v]==1)break;
			}
		}
		p1=v;
		q1=v;
		for(i=v-1;i>0;i--){
			if(prime[i]==1)q1=i;
			if(p1-q1==2){
				printf("%d %d\n",q1,p1);
				break;
			}else{
				p1=q1;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

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

template<int mod>
struct ModInt{
    int x;

    ModInt() : x(0) {}
    
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    
    ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    
    ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    
    ModInt operator-() const {return ModInt(-x);}

    ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}

    ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}

    ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}

    ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

    bool operator==(const ModInt &p) const {return x == p.x;}

    bool operator!=(const ModInt &p) const {return x != p.x;}

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const{
        ModInt ret(1), mul(x);
        while(n > 0){
            if(n & 1)   ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a){
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() {return mod;}
};

using modint = ModInt<mod>;

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

    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for(int i = 0; i < N; ++i)  cin >> A[i];
    vector<vector<modint>> dp(N + 1, vector<modint>(S + 1));
    dp[0][0] = 1;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j <= S; ++j){
            if(dp[i][j] == 0)   continue;
            dp[i + 1][j] += dp[i][j] * 2;
            if(j + A[i] <= S)   dp[i + 1][j + A[i]] += dp[i][j];
        }
    }
    cout << dp[N][S] << endl;
}

Measured memory_bytes: 38480
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

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

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

	ll h = 0;

	h += x / 500 * 1000;

	x %= 500;

	h += x / 5 * 5;

	cout << h << endl;
}

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

#define ll long long
const int inf = 1e9+7;
const ll INF = 1e18+7;

using namespace std;

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

  int a ,b;
  cin>>a>>b;
  cout<<a*b<<"\n";
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans, l, r, d;
vector<ii> e[N];
int dist[N];
bool visited[N];
bool ok;

void dfs(int x) {
    for (auto &[to, d] : e[x]) {
        if (!visited[to]) {
            visited[to] = true;
            dist[to] = dist[x] + d;
            dfs(to);
        } else {
            // check
            if (dist[to] != dist[x] + d) {
                ok = false;
                return;
            }
        }
    }
}

int main() {
    ok = true;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r >> d;
        e[l].push_back({r, d});
        e[r].push_back({l, -d});
    }

    for (int i = 1; i <= n; ++i) {
        if (!visited[i]) {
            visited[i] = true;
            dist[i] = 0;
            dfs(i);
        }
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 15328