akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long int mod=1000000007;
long long int dp[2019][2019];
long long int ans[2020][2020];
int S[2019];
int T[2019];
int main(void){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    for(int i=0;i<M;i++){
        cin>>T[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<=N;i++){
        ans[i][0]=1;
    }
    for(int j=0;j<=M;j++){
        ans[0][j]=1;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if (S[i]==T[j]){
                dp[i][j]=ans[i][j];
            }
            else{
                dp[i][j]=0;
            }
            ans[i+1][j+1]=((dp[i][j]+ans[i+1][j])%mod +(ans[i][j+1]-ans[i][j])%mod)%mod;
            ans[i+1][j+1]%=mod;
            ans[i+1][j+1]+=mod;
            ans[i+1][j+1]%=mod;
        }
    }
    cout<<ans[N][M]%mod<<endl;
}


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

const int MAX = 500;
int main() {
	int N, M, Q, L, R;
	cin >> N >> M >> Q;
	static int A[MAX][MAX], sum[MAX][MAX];
	for (int i = 0;i < N;++ i) for (int j = 0;j < N;++ j) A[i][j] = 0, sum[i][j] = 0;
	for (int i = 0;i < M;++ i) {
		cin >> L >> R;
		++ A[L - 1][R - 1];
	}
	for (int i = 0;i < N;++ i) { // 累積和O(N^2)
		for (int j = 0;j < N - i;++ j) {
			if (i == 0) sum[j][j] = A[j][j];
			else sum[j][i + j] = A[j][i + j] + sum[j + 1][i + j] + sum[j][i + j - 1] - sum[j + 1][i + j - 1];
		}
	}
	for (int i = 0;i < Q;++ i) {
		cin >> L >> R;
		cout << sum[L - 1][R - 1] << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

Nが小さいことを利用してO(N^2)で何とかならないか考えてみよう
前もって、A[l][r]は区間lから区間rまで走る電車の個数とする
その時、sum[l][r]は区間lから区間rまでの間に走る電車の個数とすると、
これはA[l][r]+sum[l][r-1]+sum[l+1][r]-sum[l+1][r-1]に等しい
よって下準備O(N^2)でsum[l][r]を求め、各クエリにはそのままsum[l][r]を返せばO(Q)なのでO(M+N^2+Q)
*/

Measured memory_bytes: 2816
package main

import (
	"fmt"
	"sort"
)

func getGcd(a, b int) (c int) {
	switch {
	case a < b:
		c = getGcd(b, a)
	case a%b == 0:
		c = b
	case a%b != 0:
		c = getGcd(b, a%b)
	}
	return
}

func main() {
	var A, B, K int
	fmt.Scan(&A, &B, &K)
	C := getGcd(A, B)
	var divs []int
	for i := 1; i <= C; i++ {
		if C%i == 0 {
			divs = append(divs, i)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(divs)))
	fmt.Println(divs[K-1])
}


Measured memory_bytes: 512
mod=2019
l,r=map(int,input().split())
if r-l >2019:
  print(0)
else:
  res = [2020]
  r=min(l+2018,r)
  for i in range(l,r):
    for j in range(i+1,r+1):
      res += [i*j%mod]
  print(min(res))

Measured memory_bytes: 75436
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

const int MAX = 10000;
int stack[MAX];
int len = 0;

void init() {
    len = 0;
}

int top() {
    return stack[len-1];
}

bool isEmpty() {
    return len == 0;
}

int pop() {
    return stack[--len];
}

void push(int x) {
    stack[len++] = x;
}

const int MAXS = 100;
char s[MAXS];

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    init();
    while (~scanf("%s", s)) {
        if (s[0] == '+') {
            int a = pop();
            int b = pop();
            int c = b + a;
            push(c);
        } else if (s[0] == '-') {
            int a = pop();
            int b = pop();
            int c = b - a;
            push(c);
        } else if (s[0] == '*') {
            int a = pop();
            int b = pop();
            int c = b * a;
            push(c);
        } else if (s[0] == '/') {
            int a = pop();
            int b = pop();
            int c = b / a;
            push(c);
        } else {
            int num = atoi(s);
            push(num);
        }
    }

    printf("%d\n", pop());
    return 0;
}

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

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

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

int main() {
  int n, m, x, y;
  cin >> n >> m;

  map<int, set<int> > p;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    p[x].insert(y);
  }

  while (!p[1].empty()) {
    int x = *begin(p[1]);
    if (p[x].count(n)) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
    p[1].erase(x);
  }
  cout << "IMPOSSIBLE" << endl;
}

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

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

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

    string S; cin >> S;

    ll ans = 0;

    if(S == "RRR") cout << 3 << endl;
    else if(S == "RRS" || S == "SRR") cout << 2 << endl;
    else if(S == "SSS") cout << 0 << endl;
    else cout << 1 << endl;

    return 0;

}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);
int make(int *a,int n,int b,char *c[4],char *buf);

int main(){
	
	char buf[100];
	int   a[4];
	char  *b[4];

	b[0]=(char *)malloc(sizeof(char)*100);
	b[1]=(char *)malloc(sizeof(char)*100);
	b[2]=(char *)malloc(sizeof(char)*100);
	b[3]=(char *)malloc(sizeof(char)*100);

	while(1){
		scanf("%d %d %d %d",a,a+1,a+2,a+3);
		if(a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0)
			break;
		sprintf(b[0],"%d",a[0]);
		sprintf(b[1],"%d",a[1]);
		sprintf(b[2],"%d",a[2]);
		sprintf(b[3],"%d",a[3]);
		if(make(a,4,10,b,buf)==0)
			printf("0\n");
		else
			printf("%s\n",buf);
	}
	return 0;
}

int make(int *a,int n,int b,char *c[4],char *buf){

	int i,j,k,d[4];
	char *e[4];
	e[0]=(char *)malloc(sizeof(char)*100);
	e[1]=(char *)malloc(sizeof(char)*100);
	e[2]=(char *)malloc(sizeof(char)*100);
	e[3]=(char *)malloc(sizeof(char)*100);

	
	if(n==1){
		if(a[0]==b){
			sprintf(buf,"%s",c[0]);
			return 1;
		}else
			return 0;
	}
	for(i=0;i<=n-2;i++)
		for(j=i+1;j<=n-1;j++){
			k=0;
			while(k<i){
				d[k]=a[k];
				e[k]=c[k];
				k++;
			}
			while(k+1<j){
				d[k]=a[k+1];
				e[k]=c[k+1];
				k++;
			}
			while(k+2<n){
				d[k]=a[k+2];
				e[k]=c[k+2];
				k++;
			}
			d[k]=a[i]+a[j];
			sprintf(e[k],"(%s+%s)",c[i],c[j]);
			if(make(d,n-1,b,e,buf)==1)
				return 1;
			d[k]=a[i]-a[j];
			sprintf(e[k],"(%s-%s)",c[i],c[j]);
			if(make(d,n-1,b,e,buf)==1)
				return 1;
			d[k]=a[j]-a[i];
			sprintf(e[k],"(%s-%s)",c[j],c[i]);
			if(make(d,n-1,b,e,buf)==1)
				return 1;
			d[k]=a[i]*a[j];
			sprintf(e[k],"(%s*%s)",c[i],c[j]);
			if(make(d,n-1,b,e,buf)==1)
				return 1;
		}
	return 0;
}

Measured memory_bytes: 7032
#include <cstdio>
#include <algorithm>

using namespace std;

typedef struct {
	int a, b, c;
} fuku_t;

int d, n;

int t[200];
fuku_t fuku[200];

int dp[200][200];

int main()
{
	scanf("%d %d", &d, &n);

	for (int i = 0; i < d; ++i) scanf("%d", &t[i]);

	for (int i = 0; i < n; ++i) scanf("%d %d %d", &fuku[i].a, &fuku[i].b, &fuku[i].c);

	for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
		if (fuku[j].a <= t[0] && t[0] <= fuku[j].b && fuku[i].a <= t[1] && t[1] <= fuku[i].b) {
			dp[1][i] = max(dp[1][i], abs(fuku[j].c - fuku[i].c));
		}
	}

	for (int i = 2; i < d; ++i) for (int j = 0; j < n; ++j) for (int k = 0; k < n; ++k) {
		if (fuku[j].a <= t[i] && t[i] <= fuku[j].b && fuku[k].a <= t[i - 1] && t[i - 1] <= fuku[k].b) {
			dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(fuku[k].c - fuku[j].c));
		}
	}

	int ans = 0;

	for (int i = 0; i < n; ++i) ans = max(ans, dp[d - 1][i]);

	printf("%d\n", ans);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  regex re(R"(^(hi)+$)");

  smatch m;

  string s;
  cin >> s;

  if (regex_search(s, m, re)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int main () {
  int N;
  cin >> N;

  bool four = false;
  rep(i,N) {
    char s;
    cin >> s;
    if(s == 'Y') four = true;
  }

  cout << (four ? "Four" : "Three") << endl;
  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>;

int main(){
    int n;
    cin >> n;
    vector<int> a(n-1);
    rep(i,n-1) cin>>a[i];
    vector<int> b(n,0);
    int cnt=0;
    rep(i,n-1){
        b[a[i]-1]++;
    }
    rep(i,n) cout << b[i] <<endl;
}

Measured memory_bytes: 4776
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[][] p = new int[n][2];
		for(int i=0;i<n;i++){
			p[i][0] = sc.nextInt();
			p[i][1] = sc.nextInt();
		}
		
		long min = Long.MAX_VALUE;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				for(int r=0;r<n;r++){
					for(int s=r+1;s<n;s++){
						int left = p[i][0], right = p[j][0];
						int top = p[r][1], button = p[s][1];
						
						if(left>right){
							int tmp = left;
							left = right;
							right = tmp;
						}
						if(top<button){
							int tmp = top;
							top = button;
							button = tmp;
						}
						
						int cnt = 0;
						for(int t=0;t<n;t++){
							if(left<=p[t][0] && p[t][0]<=right && button<=p[t][1] && p[t][1]<=top)
								cnt++;
						}
						
						if(cnt>=k){
							long area = (long)(right-left)*(top-button);
							if(area<min)
								min = area;
						}
					}
				}
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 24532
/*
[abc132] D - Blue and Red Balls
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2000;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int extgcd(int a, int b, int& x, int& y) {
        int d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    static int mod_inv(int a, int m) {
        int x, y;
        extgcd(a, m, x, y);
        return (m + x) % m;
    }
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator-(const gf x) const { return gf((n - x.n + MOD) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf operator/(const gf x) const { return *this * x.inv(); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
    gf& operator-=(const gf x) { return *this = (*this - x); }
    gf& operator*=(const gf x) { return *this = (*this * x); }
    gf& operator/=(const gf x) { return *this = (*this / x); }
    gf inv() const { return gf(mod_inv(n, MOD)); }
    gf pow(ll e) const {
        gf a = *this;
        gf x = 1;
        for (; e > 0; e >>= 1) {
            if (e & 1) {
                x = x * a;
            }
            a = a * a;
        }
        return x;
    }
};

int N, K;
gf fact[MAX_N + 1];

gf c(int n, int k) {
    return (n < 0 || k < 0 || n - k < 0) ? 0
                                         : fact[n] / (fact[k] * fact[n - k]);
}

void solve() {
    if (N == K) {
        cout << 1 << endl;
        for (int i = 2; i <= K; i++) {
            cout << 0 << endl;
        }
        return;
    }

    fact[0] = 1;
    for (int i = 1; i <= N; i++) {
        fact[i] = fact[i - 1] * i;
    }

    for (int i = 1; i <= K; i++) {
        cout << (c(K - 1, i - 1) * c(N - K + 1, i)).n << endl;
    }
}

int main() {
    cin >> N >> K;

    solve();

    return 0;
}


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

using namespace std;
typedef long long ll;
ll n,m;
//ll a[200005],s[200005],b[200005];

int main(){
	
	scanf("%lld%lld",&n,&m);
	if(n>m)swap(n,m);
	if(m-n<=1)printf("Brown\n");
	else printf("Alice\n");
	
	return 0;
	
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
void pa(int a[],int n){
    for(int i=0;i<n;i++){
        if(i>0){
            printf(" ");
        }
        printf("%d",a[i]);
    }
    printf("\n");
}
void pe(int a[],int n){
    for(int i=1;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        pa(a,n);
    }
}
int main(){
    int n;
    int a[110];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);  
    }
    pa(a,n);
    pe(a,n);
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  int count = 0;
  for(int i = 0; i < 3; i++){
    if (S.at(i) == 'o'){
      count += 100;
    }
  }
  cout << 700 + count << endl;
}

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
void SieveOfEratosthenes(ll n);
ll fastpowMOD(ll a, ll p,ll MOD);
ll lcm(ll a, ll b);
const int LIM = 1e5+5, MOD =  1e9+7;
ll mod = 998244353;
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; a %= MOD; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
bool seive[LIM];
 
void SieveOfEratosthenes(ll n)
{ memset(seive, true, sizeof(seive));
seive[0] = false;
seive[1] = false;
 for (ll p=2; p*p<=n; p++) if (seive[p] == true) for (ll i=p*p; i<=n; i += p) seive[i] = false; }
 
 
 ll combo(ll n, ll k){
 	if(k==0) return 1;
 	ll N=1,D=1;
 	for(ll i = 1;i<=k;i++){
 		N = (((n-i+1)%MOD)*N)%MOD;
 		D = (D*i)%MOD;
	 }
	 
	 return (N*fastpowMOD(D,MOD-2,MOD))%MOD;
 }
 
 
ll lcm(ll a, ll b)  
 {  
    return (a*b)/__gcd(a, b);  
 } 
/*********************************************/

int main(){
	fastio;
	ll h,w;
	cin>>h>>w;
	vector< vector<char> > maze(h,vector<char>(w,0));
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>maze[i][j];
		}
	}
	
	ll ans = 0;
	
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(maze[i][j]=='.'){
				vector< vector<bool> > vis(h,vector<bool>(w,false));
				queue< pair< pair<ll,ll> , ll> > q;
				q.push(make_pair(make_pair(i,j),0));
				vis[i][j] = true;
				ll dx[] = {-1,0,0,1};
				ll dy[] = {0,1,-1,0};
				
				ll lp = 0;
				while(!q.empty()){
					pair< pair<ll,ll> ,ll> pt;
					pt = q.front();
					ll x = pt.first.first, y = pt.first.second;
					if(lp<pt.second){
						lp = pt.second;
					}
					q.pop();
					for(ll k=0;k<4;k++){
						if((x+dx[k])<h && (y+dy[k])<w && (x+dx[k])>=0 && (y+dy[k])>=0){
							ll tx = x+dx[k], ty = y+dy[k];
							if(!vis[tx][ty] && maze[tx][ty]=='.'){
								q.push(make_pair(make_pair(tx,ty),pt.second+1));
								vis[tx][ty] = true;
							}
						}
					}	
				}
				
				ans = max(ans,lp);
			}
			
				
			
		}
	}
	
	cout<<ans<<"\n";
	
	
}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma warning( disable : 4996 )
#define ll long long
#define pb push_back
#define endl '\n'
#define fastIO cin.tie( 0 );ios_base::sync_with_stdio( false )
#define pii pair<int, int>
#define eps 1e-13
#define M 2000
#define N 1005

using namespace std;

int H, W, n, x, y;
string S, T;

inline void init()
{
    cin >> H >> W >> n >> x >> y >> S >> T;
}

inline void solve()
{
    int X = x, Y = y;
    for ( int j = 0; j < S.size(); ++j ) {
        if ( S[j] == 'L' )
            --Y;
        if ( Y < 1 ) {
            cout << "NO";
            return;
        }
        if ( T[j] == 'R' && Y < W )
            ++Y;
    }
    X = x, Y = y;
    for ( int j = 0; j < S.size(); ++j ) {
        if ( S[j] == 'R' )
            ++Y;
        if ( Y > W ) {
            cout << "NO";
            return;
        }
        if ( T[j] == 'L' && Y > 1 )
            --Y;
    }
    X = x, Y = y;
    for ( int j = 0; j < S.size(); ++j ) {
        if ( S[j] == 'D' )
            ++X;
        if ( X > H ) {
            cout << "NO";
            return;
        }
        if ( T[j] == 'U' && X > 1 )
            --X;
    }
    X = x, Y = y;
    for ( int j = 0; j < S.size(); ++j ) {
        if ( S[j] == 'U' )
            --X;
        if ( X < 1 ) {
            cout << "NO";
            return;
        }
        if ( T[j] == 'D' && X < H )
            ++X;
    }
    cout << "YES";
}

int main()
{
    fastIO;
    init();
    solve();
    cout << endl;
    return 0;
}


Measured memory_bytes: 920
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string s,t; cin>>s>>t;
  if (s.size() < t.size())
    swap(s,t);
  map<char, vector<int>> table;
  for (int i = 0; i < s.size(); i++)
    table[s[i]].push_back(i);

  vector<pair<int, string>> dp;
  dp.emplace_back(-1, "");
  for (auto c : t) {
    for (int i = dp.size()-1; i >= 0; i--) {
      auto jit = upper_bound(table[c].begin(), table[c].end(), dp[i].first);
      if (jit == table[c].end())
        continue;
      if (i == dp.size()-1)
        dp.emplace_back(*jit, dp[i].second+c);
      else {
        if (dp[i+1].first > *jit)
          dp[i+1] = {*jit, dp[i].second+c};
      }
    }
  }
  cout << dp.back().second << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> S(n);
  for (int i = 0; i < n; i++) {
    cin >> S.at(i);
  }
  int X=S.size();
  set<int> L(S.begin(), S.end());
  int Y=L.size();
  if(X==Y){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 10368
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int L, R, d;
    cin >> L >> R >> d;

    int count = 0;

    reple(i, L, R)
    {
        if (i % d == 0) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
signed main(){
  string c;
  cin>>c;
  for(int i=0;i<4;i++)
    cout<<c[i];
  cout<<' ';
  for(int i=4;i<12;i++)
    cout<<c[i];

  cout<<endl;
  return(0);
}
  

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;


// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}


vi dh = {0, 1,  0, -1};
vi dw = {1, 0, -1,  0};

int h, w;
vvi dist;
vector<vector<char> > s;

void dfs(int ch, int cw) {
  rep (i, 4) {
    int nh = ch + dh[i];
    int nw = cw + dw[i];
    if (s[nh][nw] == '#') {
      continue;
    }
    if (dist[nh][nw] > dist[ch][cw] + 1) {
      dist[nh][nw] = dist[ch][cw] + 1;
      dfs(nh, nw);
    }
  }
  return;
}

int main() {
  scanf("%d %d", &h, &w);
  s.assign(h+2, vector<char>(w+2, '#'));
  int whites = 0;
  FOR (i, 1, h+1) {
    FOR (j, 1, w+1) {
      scanf(" %c", &s[i][j]);
      if (s[i][j] == '.') {
        whites += 1;
      }
    }
  }
  dist.assign(h+2, vi(w+2, INT_MAX / 2));
  dist[1][1] = 1;
  dfs(1, 1);

  int ans;
  if (dist[h][w] == INT_MAX / 2) {
    ans = -1;
  } else {
    ans = whites - dist[h][w];
  }
  printf("%d\n", ans);

  return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    int l, r, d, c = 0;
    cin >> l >> r >> d;
    while (l <= r)
    {
        if (l % d == 0)
        {
            c++;
        }
        l++;
    }
    cout << c << endl;
}

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

int main() {
    string str, q, p;
    int a, b, n;
    cin >> str >> n;
    for (int i = 0; i < n; i++) {
        a = 0, b = 0, q = " ";
        cin >> q >> a >> b;
        if (q == "print") {
            cout << str.substr(a, b - a + 1) << endl;
        }
        if (q == "reverse") {
            for (int j = a, m = b; j < m; j++, m--) {
                swap(str[j], str[m]);
            }
        }
        if (q == "replace") {
            cin >> p;
            str = str.substr(0, a) + p + str.substr(b + 1);
        }
    }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll H,W,cnt=0;
    char c[55][55];
    cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> c[i][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') cnt++;
		}
	}
	if (cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e18
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;


//template< typename T1, typename T2 > struct pair {
  //T1 first;
  //T2 second;
//};
               
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

   string s; cin >> s;
   long x = 0;
   long y = 0;
   forn(i , 0 , s.size()){
     if(s[i] == 'W') x += y;
     else y++;
   }
   cout << x << endl; 
 
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<cstring>

using namespace std;
#define W 8
#define H 8
#define W_C 12
#define H_C 12

char tile[W_C][H_C];

char check(int w,int h)
{

    if(tile[w][h+1]=='1'&&tile[w-1][h+1]=='1'&&tile[w-1][h+2]=='1') return 'D';
    if(tile[w+1][h]=='1'&&tile[w][h+1]=='1'&&tile[w+1][h+1]=='1') return 'A';
    if(tile[w][h+1]=='1'&&tile[w][h+2]=='1'&&tile[w][h+3]=='1') return 'B';
    if(tile[w+1][h]=='1'&&tile[w+2][h]=='1'&&tile[w+3][h]=='1') return 'C';
    if(tile[w+1][h]=='1'&&tile[w+1][h+1]=='1'&&tile[w+2][h+1]=='1') return 'E';
    if(tile[w][h+1]=='1'&&tile[w+1][h+1]=='1'&&tile[w+1][h+2]=='1') return 'F';
    if(tile[w+1][h]=='1'&&tile[w-1][h+1]=='1'&&tile[w][h+1]=='1') return 'G';

    return 'Y';
}


int main()
{
    while(1)
    {
        memset(tile,'0',sizeof(tile));
        char ans = 'Z';

        for(int j=1;j<=H;j++)
        {
            for(int i=1;i<=W;i++)
            {
                cin >> tile[i][j];

            }
        }
        for(int j=1;j<=H;j++)
        {
            for(int i=1;i<=W;i++)
            {
                if(tile[i][j]=='1')
                {
                    ans = check(i,j);
                    break;
                }
            }
            if(ans != 'Z') break;
        }



        if(cin.eof()) break;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    read2(a,b);
    cout << (b>=a ? "unsafe":"safe");
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
const int N=2e5+10;
using namespace std;
char s[N];
int n,ans;
string lst,nw;
int main() {
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		nw+=s[i];
		if(nw!=lst){
			lst=nw;nw="";ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        int waza;
        boolean hantei = false;
        for(int i = 0; i < N; i++) {
            waza = sc.nextInt();
            H -= waza;
            if(H <= 0) {
                hantei = true;
            }
        }
        
        if(hantei) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
        
        

    }
}


Measured memory_bytes: 46592
N, M = map(int, input().split())
dp = [0] + [1<<100] * ((1<<N)-1)
for _ in range(M):
    dppre = dp
    a, b = map(int, input().split())
    C = [int(a)-1 for a in input().split()]
    mask = sum([1<<C[i] for i in range(b)])
    for maskpre in range(1<<N):
        new = mask | maskpre
        dp[new] = min(dp[new], dppre[maskpre] + a)
        maskpre -= 1
print(dp[-1] if dp[-1] < (1<<100) else -1)

Measured memory_bytes: 49884
import java.util.*;
import java.util.Arrays;
import java.util.Comparator;
class Data{
    private int a;
    private int b;
    public Data(int a, int b) {
        this.a = a;
        this.b = b;
    }
    public int getA() {
        return a;
    }
    public int getB() {
        return b;
    }
}
public class Main {    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();        
		int a = sc.nextInt();
        int [] s = new int [n];
        for(int i=0;i<n;i++){s[i]=sc.nextInt();}
        Arrays.sort(s);
		int [] in = new int [a];
        int [] in2 = new int [a];
        long ans = 0;
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                             in2[i] = sc.nextInt();
                            }
        Data [] d = new Data [a];
         for(int i=0;i<a;i++){d[i] = new Data(in[i],in2[i]);                            
                             }
        Arrays.sort(d, new Comparator<Data>() {
            public int compare(Data d1, Data d2) {
                return d1.getB() - d2.getB();
            }
        }); 
        int b = a-1;
        int count = 0;
        for(int i=0;i<n;i++){if(b>=0 && d[b].getB()>s[i]){s[i]=d[b].getB();
                                                          count++;                                                 
                                                          if(count==d[b].getA())
                                                          {b--;count=0;}
                                                         }else{break;}
                  }        
		for(int i=0;i<n;i++){ans+=s[i];}
        System.out.println(ans);
	}
}

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

int main(void) {
    int h,w; cin >> h >> w;
    const int INF = 1e9;
    vector<vector<int>> dist(h,vector<int>(w,INF));
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    queue<P> pp;

    int ans = 0;

    //上下左右の移動用の配列
    int di[4] = {-1,1,0,0};
    int dj[4] = {0,0,-1,1};

    rep(l,h) {
        rep(k,w) {
        //bfs
        //スタート地点が'.'かどうか
        if(s[l][k]=='#') continue;
        //dist中身初期化
        rep(i,h) rep(j,w) dist[i][j] = INF;
        dist[l][k] = 0; //スタート地点
        pp.push(make_pair(l,k));
        while(!pp.empty()) {
            P v = pp.front();
            pp.pop();
            //上下左右の移動ができるか
            rep(i,4) {
                P vxy = make_pair(v.first+di[i],v.second+dj[i]);
                if(vxy.first<0 || vxy.second<0) continue;
                if(vxy.first>h-1 || vxy.second>w-1) continue;
                if(s[vxy.first][vxy.second] == '#') continue;
                if(dist[vxy.first][vxy.second]<=dist[v.first][v.second]+1) continue;
                if(dist[vxy.first][vxy.second]!=INF) continue;
                dist[vxy.first][vxy.second] = dist[v.first][v.second]+1;
                pp.push(make_pair(vxy.first,vxy.second));
                }
            }
            //最大値か確認
            rep(i,h){ 
                rep(j,w) {
                    if(dist[i][j]==INF) continue;
                    if(ans<dist[i][j])  ans = dist[i][j];
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
# import fractions
# import sys
from sys import stdin

n = int(stdin.readline().rstrip())

ab = [list(map(int, stdin.readline().rstrip().split())) for i in range(n)]
ab.reverse()
ans = 0
for abi in ab:
    abi[0] += ans
    if abi[0] % abi[1] == 0:
        pass
    else:
        ans += abi[1] - (abi[0] % abi[1])
print(ans)

Measured memory_bytes: 31476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
 
public class Main {
 
    static int len;
    static int[] arr;
     
    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
         
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
         
        int len = Integer.parseInt(reader.readLine());
        int[] arr = new int[len];
         
        String arrStr = reader.readLine();
        StringTokenizer tokenizer = new StringTokenizer(arrStr, " ");
         
        int i = 0;
        while (tokenizer.hasMoreElements()) {
           arr[i++] = Integer.parseInt((String) tokenizer.nextElement());
        }
         
//        System.out.println("len" + len);
//        System.out.println("arr" + Arrays.toString(arr));
         
        reader.close();
         
         
        sort(arr);
    }
     
    public static void sort(int[] arr){
         
        printArr(arr);
         
        for (int i = 1; i < arr.length; i++) {
             
            for (int j = i; j >= 1; j--) {
                 
                int current = arr[j];
                int prev = arr[j - 1];
                 
                if(current < prev){
                    swap(arr, j - 1, j);                
                }
                else{
                    break;
                }
            }
             
            printArr(arr);
        }
    }
     
    public static void swap(int[] arr, int from, int to){
        int temp = arr[from];
        arr[from] =  arr[to];
        arr[to] = temp;
     }
     
     
    static void printArr(int[] arr){
        String msg = "";
        for (int i = 0; i < arr.length; i++) {
            msg += arr[i];
            if(i == arr.length -1){
                break;
            }
            msg += " ";
        }
         
        System.out.println(msg);
    }
     
     
}

Measured memory_bytes: 58312
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll l, r;int main()
{
	FAST
	cin>>l>>r;
	if(r-l>5000) cout<<0<<'\n';
	else {
		ll ans=2018;
		FOR(i,l,r+1){
			FOR(j,i+1,r+1){
				ans=min(ans,i*j%2019);
			}
		}
		cout<<ans<<'\n';
	}
}


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

int main()
{
    int a1[] = {1,3,5,7,8,10,12};
    int a2[] = {4,6,9,11};
    int a, b, c1 = 0, c2 = 0;
    cin >> a >> b;

    for(int i = 0; i < 7; i++)
    {
        if(a1[i] == a || a1[i] == b) c1++;
    }
    for(int i = 0; i < 4; i++)
    {
        if(a2[i] == a || a2[i] == b) c2++;
    }

    if(a == 2 && b == 2) cout << "Yes" << endl;
    else if(c1 == 2 || c2 == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
num = [1]

5.times do |i|
    num << 9**(i + 1)
end
6.times do |i|
    num << 6**(i + 1)
end

num = num.sort
dp = Array.new(N + 1, 10**9)
dp[0] = 0

1.upto(N) do |i|
    num.each do |x|
    next if i < x
    dp[i] = dp[i] < dp[i - x] + 1 ? dp[i] : dp[i - x] + 1
    end
end

puts dp[-1]

Measured memory_bytes: 2556
#import sys
#input = sys.stdin.readline
from itertools import product
def main():
    N, K = map( int, input().split())
    D = list( map( int, input().split()))
    NN = list( map( int, str(N)))
    A = [ i for i in range(10) if i not in D]
    ANS = []
    for i in range(1,6):
        for p in product(A, repeat = i):
            now = 0
            for j in range(i):
                now = now*10+p[j]
            if now >= N:
                ANS.append(now)
    print( min(ANS))
if __name__ == '__main__':
    main()


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double
int main(){
  string s;
  cin >> s;
  vector<int> a;
  vector<bool> b(26,true); 
  int n=s.length(); //nは文字数 
  rep(i,n){
    int k = s[i]-'a';
    a.push_back(k);
    b[k]=false;
  }
  
  if(n==26){
    int x=-1;
    rep(i,n-1){
      if(a[i]<a[i+1]) x=i;
    }

    if(x==-1){
      cout << -1 << endl;
      return 0;
    }
    sort(a.begin()+x+1,a.end());
    int tmp=26;
    FOR(i,x+1,n){
      if(a[i]>a[x]&&tmp>a[i]) tmp = a[i];
    }
    a[x]=tmp;
    n=x+1;

  }else{
    int y=-1;
    rep(i,26){
      if(b[i]){
        y=i;
        break;
      }
    }
    a.push_back(y);
    n++;
  }
  rep(i,n){
    char z='a'+a[i];
    cout<<z;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,x = LI()
    if x == 1 or x == 2*N-1:
        print('No')
        return

    ans = [0] * (2*N-1)
    ans[N-2] = x-1
    ans[N-1] = x
    ans[N] = x+1

    j = N+1
    for i in range(1,2*N):
        if i < x-1 or i > x+1:
            ans[j] = i
            j += 1
            if j >= 2 * N - 1:
                j = 0
    print('Yes')
    print(*ans,sep='\n')


if __name__ == '__main__':
    main()

Measured memory_bytes: 51120
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  long long n;
  scanf("%lld", &n);
  char s[n][1001];
  for (long long i=0; i<n; i++) {
    scanf("%s", s[i]);
  }

  bool flag = true;
  for (long long i=0; i<n; i++) {
    for (long long j=i+1; j<n; j++) {
      long long len1;
      for(len1=0; s[i][len1]!='\0'; ++len1);
      long long len2;
      for(len2=0; s[j][len2]!='\0'; ++len2);
      if (len1 != len2) continue;
      bool same = true;
      for (long long k=0; k<len1; k++) {
        if (s[i][k] != s[j][k]) {
          same = false;
          break;
        }
      }
      if (same) {
        flag = false;
        break;
      }
    }
  }
  for (long long i=0; i<n-1; i++) {
    long long len;
    for(len=0; s[i][len]!='\0'; ++len);
    if (s[i][len-1] != s[i+1][0]) {
      flag = false;
      break;
    }
  }

  if (flag) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 256
<?php
$len = trim(fgets(STDIN));
$str = trim(fgets(STDIN));
$ans = 0;
$offset = 0;
while(true){
  if(strpos($str, "ABC", $offset) === FALSE){
    break;
  } else {
    $offset = strpos($str, "ABC", $offset) + 1;
    $ans++;
  }
}
echo $ans;
?>

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

ll n,x;

ll f(ll a,ll b){
    if(a<=b) {
        if(b%a==0) return 2*a*(b/a) - a; 
        else return 2 * a *(b/a) + f(a,b%a);
    }else {
        if(b==0) return 0;
        else return f(b,a);
    }  
}

int main() {
    ios::sync_with_stdio(0);
    cin>>n>>x;
    cout<<n + f(x,n-x)<<endl;
    return 0;
}




Measured memory_bytes: 256
lines = readlines
n, k = lines[0].chomp.split(' ')

hasOkashi = Array.new(n.to_i, 0)

i = 0
while(i < k.to_i * 2) do
  lines[i+2].chomp.split(' ').each do |a|
    hasOkashi[a.to_i - 1] = 1
  end
  i = i + 2
end

puts hasOkashi.count { |a| a == 0 }


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int r;
    cin >> r;
    out(r * r);
}


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

void input(int n,string &str)
{
  for(int i=0;i<n;i++)
    cin>>str.at(i);
}

int main(){
  int n;
  string str;
  int p=1;
  int w;
  
  vector<int> f(200000);
  vector<int> t(200000);
  vector<char>c(200000);
  string a={};
  string b={};
  int q;
  
  getline(cin,str);
  n=str.size();
  cin>>q;
  
  for(int i=0;i<q;i++)
  {
    cin>>t.at(i);
    if(t.at(i)==1)
      p*=-1;
    else
    {
      cin>>f.at(i)>>c.at(i);
      w=f.at(i)*p;
      if(w==1||w==-2)
        a=c.at(i)+a;
      else
        b=b+c.at(i);
    }
    
  }
  str=a+str+b;
  if(p==-1)
      reverse(str.begin(), str.end());
  cout<<str<<endl;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
 
int main() {
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	int i=0,j=0;
	while(i<n){
		cout<<s[i]<<t[i];
		i++;
	}
	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>;

const ll INF = ll(1e18) + 1;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (l + 1 < r) {
    ll x = (l + r) / 2;
    bool ok = [&] {
      ll tot = 0;
      rep(i, n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l + 1 < r) {
            int c = (l + r) / 2;
            if (a[c] * a[i] < x)
              r = c;
            else
              l = c;
          }
          tot += n - r;
        } else {
          int l = -1;
          int r = n;
          while (l + 1 < r) {
            int c = (l + r) / 2;
            if (a[c] * a[i] < x)
              l = c;
            else
              r = c;
          }
          tot += r;
        }
        if (a[i] * a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok)
      l = x;
    else
      r = x;
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,sum(0),mm;
  string ans("Yes");
  cin >> n >> m;
  vector<int>a(n);
  for(int i = 0;i<n;i++){
    cin >> a.at(i);
    sum += a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  for(int i = 0;i<m;i++){
    if(a.at(i) < (double)sum/(m*4)){
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

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

//data types
typedef long long ll;
typedef long li;
typedef int ii;
typedef float ff;
typedef double dd;
typedef long double pp;
typedef vector<int> vi;
typedef pair<int,int> pi;

//vector and pair components
#define f first
#define s second
#define push_back pb
#define make_pair mp

//loops
#define for1(i,v,m) for(i=v;i<=m;i++)
//#define rev(v,x,z) for(v=x;v>=z;v--)
//#define inf(m,j,k) for(m=j;m>=k;m++)

ii main()
{

    ii n,k,i,x,y,z,f; set<int> s;
    
    cin>>n>>k;
    
    for1(i,1,n)
    {
    
        s.insert(i);
    
    
    }
    
    
    for1(z,1,k)
    {
    
        cin>>x;
         
        for1(f,1,x)
        {
        
            cin>>y;
            
            s.erase(y);
            
        
        }
    
    }
 
    
    
    cout<<s.size()<<"\n";
    
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> b(n);
    for(int i=0;i<n;i++) cin >> b[i];
    map<int, int> m;
    for(int i=0;i<n;i++){
        m[b[i]]++;
    }
    int ans = 0;
    for(auto kv : m){
        int x = kv.first;
        int nx = kv.second;
        if(x > nx){
            ans += nx;
        }
        if(x < nx){
            ans += nx-x;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5120