akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

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

	const string key = "keyence";

	string s;
	cin >> s;
	const int n = (int) s.size();
	const int k = (int) key.size();
	int i = 0, j = 0;

	while (i < min(n, k) && s[i] == key[i])
		++i;
	while (j < min(n, k) && s[n - 1 - j] == key[k - 1 - j])
		++j;

	cout << (i + j >= (int) key.size() ? "YES" : "NO");
	return 0;
}


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

int main (){
   int n,b, soma=0;
   char string[5000][101], a[101];
   int sec[112345];
   scanf("%d", &n);

   for(int i=0; i<n; i++)
     scanf("%s %d", string[i], &sec[i]);

   scanf("%s",a);

   for(int i=0; i<n; i++)
   {
     if(strcmp(string[i],a)==0){
       b=i;
     }
   }

   for(int i=(b+1); i<=n; i++)
      soma+=sec[i];

    printf("%d\n", soma);

  return 0;
}


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

using namespace std;

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

string s;
int n;

bool check(){
	if(s[0] == '0') return false;
	if(s[n-1] == '1') return false;
	if(s[n-2] == '0') return false;

	for(int i = 1; i < n - 2 - i; i++){
		if(s[i] != s[n - 2 - i]) return false;
 	}

	return true;
}

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

	cin >> s;
	n = s.size();

	if(!check()){
		cout << -1 << endl;
		return 0;
	}

	vector<pii> ans;
	int t = 1;
	for(int i = 1; i < n - 1; i++){
		if(s[i] == '1'){
			ans.push_back({t, i + 1});
			t = i + 1;
		}
	}
	ans.push_back({t, n});

	t = n;
	for(int i = n - 2; i >= 1; i--){
		if(s[i] == '0'){
			ans.push_back({i + 1, t});
		}else{
			t = i + 1;
		}
	}

	for(pii p : ans){
		cout << p.first << " " << p.second << endl;
	}
}


Measured memory_bytes: 2500
input_lines = input().split()
N = int(input_lines[0])
min_value = 10 ** 15
for i in range(5):
    input_lines = input().split()
    value = int(input_lines[0])
    if value < min_value:
        min_value = value
if min_value != 1:
    print(int(N / min_value) + 5)
else:
    print(int(N / min_value) + 4)


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

deque<int> b;

int main()
{
    int n;
    cin>>n;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(i&1) b.push_front(a);
        else b.push_back(a);
    }
    if(n&1) reverse(b.begin(), b.end());
    for(auto iter=b.begin();iter!=b.end();iter++) cout<<*iter<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
#define inf 0x3f3f3f3f
#define pb push_back
#define vi vector<int>
#define fi first
#define se second 
#define mp make_pair
typedef unsigned long long ull;
//typedef pair<int,int> P;
#define LL long long 
#define pi acos(-1)
#define MOD 998244353
typedef long long ll;
using namespace std;
const int maxn = 19995; 
const char p[]="AGC";
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<' '<<max(0,a+b-n)<<endl;
	return 0;
}


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

typedef long long LL;

int main() {
    LL a,b,c;
    LL x, y;
    while (cin >> a >> b >> c >> x >> y) {
        LL res;
        if (a + b < 2 * c) {
            res = a * x + b * y;
        }
        else {
            int l = min(x, y);
            res = c * l * 2;
            if (x > y) res += min((x - y) * a,(x - y) * 2 *c);
            else res += min((y - x) * b,(y - x) * 2 * c);
        }
        cout << res << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    S = list(map(lambda x: ord(x) - 97, input()))
    T = list(map(lambda x: ord(x) - 97, input()))
    if not set(T) <= set(S):
        return -1

    tbl = [-1] * 26
    st = [None] * (len(S) + 1)
    for i, s in reversed(list(enumerate(S))):
        st[i + 1] = tuple(tbl)
        tbl[s] = i
    st[0] = tuple(tbl)
    r = 0
    c = 0
    for t in T:
        if st[r][t] == -1:
            c += 1
            r = 0
        r = st[r][t] + 1
    return c * len(S) + r

print(main())


Measured memory_bytes: 42452
import java.util.*;

class Main{
  public static void main(String arg[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int ans = 0;
    for(int i = 0;i < a;i++){
      ans+=i+1;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
def main():
    n,t = map(int,input().split())
    a = [int(x) for x in input().split()]
    mx,mn = 0,10**9
    profit = [0 for _ in range(n)]
    for i in range(n-1,-1,-1):
        now = a[i]
        mx = max(mx,now)
        profit[i] = mx-now
    mx = max(profit)
    print(profit.count(mx))
if __name__ == "__main__":
    main()

Measured memory_bytes: 63472
#include<stdio.h>
#define N 100
int min(int x,int y){
  if(x<y) return x;
  if(x>y) return y;
}

int main(){
  int i,j,k,l,n,x[N],y[N][N];
  int  p,q;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&x[i-1],&x[i]);
  }

  for(i=1;i<=n;i++){
    y[i][i]=0;
  }
  for(j=2;j<=n;j++){
    for(i=0;i<=n-j+1;i++){
    l=i+j-1;
    y[i][l]=10000000;
    for(k=i;k<=l;k++){
      q=y[i][k]+y[k+1][l]+x[i-1]*x[l]*x[k];
      y[i][l]=min(y[i][l],q);
    }
    }
  }
  printf("%d\n",y[1][n]);
  return 0;
}


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

int main() {
  int n,k,ub = 0,lb = 0;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,0,n){cin >> a[i];ub = max(ub,a[i]);}
  ub++;
  int mid = (lb+ub)/2; //ここで二分
  while(ub-lb != 1){
    int cnt = 0;
    rep(i,0,n){
      cnt += a[i]/mid;
      if(a[i]%mid == 0) cnt--;
    }
    //cout << cnt << " ";
    if(cnt > k){ //src以下（大事！！！！）になる最後の要素
      lb = mid; 
      mid = (lb+ub)/2;
    }
    else{
      ub = mid;
      mid = (lb+ub)/2;
    }
    //cout << mid << endl;
  }
  cout << ub << endl;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, x1, y1, t1, x2, y2, t2;
	cin >> n;
	t1 = x1 = y1 = 0;
	for(int i=0; i<n; i++){
		cin >> t2 >> x2 >> y2;
		if(abs(y2 - y1) + abs(x2 - x1) <= (t2 - t1) && (abs(y2 - y1) + abs(x2 - x1) - (t2 - t1)) % 2 == 0){
			x1 = x2, y1 = y2, t1 = t2;
		}
		else{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

struct card_t{
	int kosu;
	int num;
};

int compare_int(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int compare_card(const void *a, const void *b) {
	struct card_t *A = (struct card_t *)a;
	struct card_t *B = (struct card_t *)b;
	if(A->num - B->num >0){
		return -1;
	}else if(A->num - B->num <0){
		return 1;
	}else{
		return 0;
	}
}

int main(void)
{
	//変数の宣言
	int n,m;
	static int a[100010];
	static struct card_t card[100010];

	//よく使う変数
	int i,j,k;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}

	for(i=0;i<m;i++){
		scanf("%d %d",&card[i].kosu,&card[i].num);
//		scanf_s("%d %d",&card[i].kosu,&card[i].num);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	qsort(a, n, sizeof(int), compare_int);
	qsort(card, m, sizeof(struct card_t), compare_card);

	temp=0;
	flag=0;
	for(i=0;i<m;i++){
		for(j=0;j<card[i].kosu;j++){
			if(temp<n&&a[temp]<card[i].num){
				a[temp]=card[i].num;
				temp++;
			}else{
				flag=1;
			}
		}
		if(flag==1) break;
	}

	for(i=0;i<n;i++){
		ans=ans+a[i];
	}

	//	printf("計算部分終了\n");

	//出力

	//printf("%d %d",min,max);

	printf("%lld",ans);

	//	printf("結果の出力終了\n");

	return 0;
}



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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  if(a == 0 && b == 0){
    cout << 0 << " " << 0 << endl;
  }else if(a - k <= 0 && (k - a) <= b){
    cout << 0 << " " << (b-(k-a)>=0 ? b - (k - a):0) << endl;
  }else if(a - k <= 0 && (k - a) >= b){
    cout << 0 << " " << (b-(k-a)>=0 ? b - (k - a):0) << endl;
  }else if(a - k >= 0){
    cout << a - k << " " << b << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
    int H, W;
    int h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << (H-h)*(W-w) << endl;
}

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

typedef struct{
    int arr[6];
    //***軸は半時計周り***
    int X[4];//top front btm back
    int Y[4];//front right back left
    int Z[4];//top left btm right
}Dice;

void init_dice(Dice *d){
    //top
    d->X[0] = d->arr[0];
    d->Z[0] = d->arr[0];
    //front
    d->X[1] = d->arr[1];
    d->Y[0] = d->arr[1];
    //right
    d->Y[1] = d->arr[2];
    d->Z[3] = d->arr[2];
    //left
    d->Y[3] = d->arr[3];
    d->Z[1] = d->arr[3];
    //back
    d->X[3] = d->arr[4];
    d->Y[2] = d->arr[4];
    //bottom
    d->X[2] = d->arr[5];
    d->Z[2] = d->arr[5];
}

int rotate_X(int X[], int Y[], int Z[], int n){ //n : how many loops?
    //North : n=1
    //South : n=3
    int tmp, i, j;
    for(i = 0; i < n; i++){
        for(j = 0; j < 3; j++){
            tmp = X[j + 1];
            X[j + 1] = X[j];
            X[j] = tmp;
        }
    }
    Z[0] = X[0];
    Y[0] = X[1];
    Z[2] = X[2];
    Y[2] = X[3];
}

int rotate_Y(int X[], int Y[], int Z[], int n){ //n : how many loops?
    //Left : n=1
    //Right : n=3
    int tmp, i, j;
    for(i = 0; i < n; i++){
        for(j = 0; j < 3; j++){
            tmp = Y[j + 1];
            Y[j + 1] = Y[j];
            Y[j] = tmp;
        }
    }
    X[1] = Y[0];
    Z[3] = Y[1];
    X[3] = Y[2];
    Z[1] = Y[3];
}

int rotate_Z(int X[], int Y[], int Z[], int n){ //n : how many loops?
    //East : n=1
    //West : n=3
    int tmp, i, j;
    for(i = 0; i < n; i++){
        for(j = 0; j < 3; j++){
            tmp = Z[j + 1];
            Z[j + 1] = Z[j];
            Z[j] = tmp;
        }
    }

    //sync
    X[0] = Z[0]; //top
    Y[3] = Z[1]; //left
    X[2] = Z[2]; //btm
    Y[1] = Z[3]; //right
}

int find_top(Dice *d, int ptn){
    int i;
    if(d->X[0] == ptn)return 0;
    for(i = 0; i < 3; i++){
        rotate_X(d->X, d->Y, d->Z, 1);
        if(d->X[0] == ptn){
            return 0;
        }
    }
    for(i = 0; i < 3; i++){
        rotate_Z(d->X, d->Y, d->Z, 1);
        if(d->X[0] == ptn){
            return 0;
        }
    }
    return -1;
}

int find_front(Dice *d, int ptn){
    int i;
    if(d->Y[0] == ptn)return 0;
    for(i = 0; i < 3; i++){
        rotate_Y(d->X, d->Y, d->Z, 1);
        if(d->Y[0] == ptn){
            return 0;
        }
    }
    return -1;
}

int compare_dice(Dice *d1, Dice *d2){
    int i, j;
    for(i = 0; i < 6; i++){
        init_dice(d1);
        init_dice(d2);

        find_top(d1, d1->arr[i]);

        if(find_top(d2, d1->arr[i]) == -1)return -1;
        if(find_front(d2, d1->Y[0]) == -1)return -1;

        for(j = 0; j < 4; j++){
            if(d1->X[j] != d2->X[j])break;
        }
        if(j < 4)continue;

        for(j = 0; j < 4; j++){
            if(d1->Y[j] != d2->Y[j])break;
        }
        if(j == 4)return i;
    }
    return -1;
}

int main(){
    Dice dice[2];
    int i, j;

    for(i = 0; i < 2; i++){
        for(j = 0; j < 6; j++){
            scanf("%d", &dice[i].arr[j]);
            getchar();
        }
        init_dice(&dice[i]);
    }

    if(compare_dice(&dice[0], &dice[1]) >= 0)printf("Yes\n");
    else printf("No\n");
}



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<pair<ll, int>>> cost(N);
  for (int i = 1; i < N; i++) {
    cost[i].push_back(make_pair(0, i - 1));
  }
  for (int i = 0; i < M; i++) {
    int L, R, C;
    cin >> L >> R >> C;
    L--, R--;
    cost[L].push_back(make_pair(C, R));
  }

  vector<ll> to(N);
  for (int i = 1; i < N; i++) to[i] = 1e15;
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>>
      que;
  que.push(make_pair(0, 0));
  while (!que.empty()) {
    int c = que.top().first, now = que.top().second;
    que.pop();
    if (c > to[now]) continue;
    for (int i = 0; i < cost[now].size(); i++) {
      if (to[cost[now][i].second] > to[now] + cost[now][i].first) {
        to[cost[now][i].second] = to[now] + cost[now][i].first;
        que.push(make_pair(to[cost[now][i].second], cost[now][i].second));
      }
    }
  }
  cout << (to[N - 1] == 1e15 ? -1 : to[N - 1]) << endl;
}

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

//create arrays outside of main()
int N = 10;
int a[10] = {6,1,3,4,11,7,2,9,10,8};


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

    int b = a*a*a;

    cout << b;

    return 0;
}

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

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int l = 0, r = n - 1;
	int ans = 0;
	while (l < r) {
		if (s[r] == 'W') {
			r--;
			continue;
		}
		if (s[l] == 'R') {
			l++;
			continue;
		}
		if (s[l] == 'W' && s[r] == 'R') {
			s[r] = 'W';
			s[l] = 'R';
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int mxN = 1e6 + 1;

int main() {
    int m, k;
    cin >> m >> k;
    if (m == 0) {
        if (k == 0) {
            cout << "0 0";
            return 0;
        }
        else {
            cout << -1;
            return 0;
        }
    }
    if (m == 1) {
        if (k == 0) {
            cout << "0 0 1 1";
            return 0;
        }
        else {
            cout << -1;
            return 0;
        }
    }
    if (k >= (1 << m)) {
        cout << -1;
        return 0;
    }
    vector<int> ans;
    for (int i = 0; i < (1 << m); i++) {
        if (i == k) continue;
        ans.push_back(i);
    }
    ans.push_back(k);
    for (int i = (1 << m) - 1; i >= 0; i--) {
        if (i == k) continue;
        ans.push_back(i);
    }
    ans.push_back(k);
    for (int i = 0; i < (int)ans.size(); i++) {
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 4296
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
 
ll cnt[30];
signed main(void)
{
  string s;
  cin >> s;
  ll n = s.size();
 
  ll ret = 0;
  REP(i, n) {
    ret += cnt[s[i]-'a'];
    cnt[s[i]-'a']++;
  }
 
  cout << n*(n-1)/2-ret+1 << endl;
 
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
main(){
	int n,l;string s[100];
	int i=0;
	for(cin>>n>>l;i<n;i++)cin>>s[i];
	sort(s,s+n);
	for(int i=0;i<n;i++)cout<<s[i];
	cout<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int ans[q];

    rep(k, q) {
        string x, y;
        cin >> x >> y;

        int m = x.size();
        int n = y.size();

        int dp[m+1][n+1] = {};  // dp[i][j] : xのi文字目までとyのj文字目までのLCSの長さ(i, jは0-index)

        rep(i, m) {
            rep(j, n) {
                if(x[i] == y[j]) {
                    dp[i+1][j+1] = dp[i][j] + 1;
                }
                else {
                    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
                }
            }
        }

        ans[k] = dp[m][n];
    }

    rep(i, q) {
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 7092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int h,w;
    cin>>h>>w;

    vector<string>c(h);
    rep(i,0,h){
        cin>>c[i];
    }

    rep(i,0,h){
        cout<<c[i]<<endl<<c[i]<<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
	int sum=0;
	int n,p;
	cin>>n;
	p=n;
	while(p){
		sum+=p%10;
		p/=10;
	}
	if(n%sum==0)	cout<<"Yes";
	else	cout<<"No";
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);

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

    double ans = 0;

    for(int i = 1 ; i <= n; i++) {
        int coin = 0;
        while(i * pow(2,coin) < k) coin++;
        ans += 1.0 / n / pow(2,coin);
    }
    
    cout << fixed << setprecision(11) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int ab[26]={};  // ここでアルファベットのリストを作成
  int i;
  while(getline(cin,str)){    // getlineで、読み込みができたらwhile文内が繰り返す。
    for(i=0;i<str.size();i++){
      if(str[i]>='a'&&str[i]<='z') ab[str[i]-'a']++;  // str[i]-'a' でアルファベットにふられた番号になる
      else if(str[i]>='A'&&str[i]<='Z') ab[str[i]-'A']++;
    }
  //cout << str << endl;
  }
  for(i=0;i<26;i++){
    cout << (char)('a'+i) << " : " << ab[i] << endl;   // (char)('a'+i) で、文字に変化させている。
  }
  return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

int main(){

    int banco,pessoa,espaco,total;

    scanf("%d %d %d",&banco,&pessoa,&espaco);

    total=(banco-espaco)/(pessoa+espaco);


    printf("%d\n",total);


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int A[114514];
    int S[3]={-1,-1,-1};
    int zero=0;
    cin >> N;
    REP(i,N){
        cin >> A[i];
        if(A[i]==0)zero++;
    }
    int Ans=1,las=1;
    if(zero>3 || zero==0){
        GOODBYE;
    }
    REP(i,zero){
        las*=(i+1);
    }
    REP(i,N){
        int c=0;
        REP(j,3){
            if(A[i]-1==S[j]){
                c++;
                if(c==1){
                    S[j]++;
                }
            }
        }
        Ans=(Ans*c)%MOD;
    }
    //Ans=(Ans*las)%MOD;
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1024
//K-OS WITH THE OCDE

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007



void solve()
{
	ll n, k;
	cin >> n >> k;
	ll a[n];
	for (ll i = 0 ; i < n ; ++i) {
		cin >> a[i];
	}

	for (ll i  = k ; i < n ; ++i) {
        
        if(a[i] > a[i - k])
        	cout << "Yes" << endl;
        else
        	cout << "No" << endl;

	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	//TEST
	solve();
}



Measured memory_bytes: 5220
N = int(input())
table = list(map(int,input().split()))

swap_count = 0

for i in range(0,len(table)-1): #最小値を持ってくる場所のループ
    for k in range(len(table)-1,i,-1):
        if table[k-1] > table[k]:
            table[k-1],table[k] = table[k],table[k-1]
            swap_count += 1

print(' '.join(map(str,table)))
print("%d"%(swap_count))



Measured memory_bytes: 5600
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = [a + b for a in A for b in B]
AB.sort(reverse=True)
ABC = [ab + c for ab in AB[:K] for c in C[:K]]
ABC.sort(reverse=True)
[print(abc) for abc in ABC[:K]]

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> tacos(N);
  for (int i = 0; i < N; ++i) {
    cin >> tacos[i];
  }
  long sum = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = i + 1; j < N; ++j) {
      sum += (tacos[i] * tacos[j]);
    }
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int i;
char s[100001];
int a[5];
int main()
{
    int flag=1;
    while(scanf("%c",&s[i])!=EOF && s[i]!='\n')
    {
        if(s[i]=='a')
            a[0]++;
        else if(s[i]=='b')
            a[1]++;
        else if(s[i]=='c')
            a[2]++;
    }
    sort(a,a+3);
    if(a[2]-a[1]>1)
        flag=0;
    if(a[1]-a[0]>1)
        flag=0;
    if(a[2]-a[0]>1)
        flag=0;
    if(flag==1)
        printf("YES");
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 256
def find(x,ones):
    if ones == 0:
        return 0
    total = 0
    n = len(x)
    for i in range(n):
        total += int(x[i])*pow(2,n-i-1,ones)
        total %= ones

    return total

def solve(x,mod):
    x %= mod
    moves = 1
    while x != 0:
        x = x%(bin(x)[2:].count('1'))
        moves += 1

    return moves

def main():
    n = int(input())
    x = input()
    ones = x.count('1')
    less = find(x,ones-1)
    more = find(x,ones+1)
    for i in range(n):
        if x[i] == '0':
            print(solve(more+pow(2,n-i-1,ones+1),ones+1))
        else:
            if ones-1 == 0:
                print(0)
            else:
                print(solve(less-pow(2,n-i-1,ones-1),ones-1))


main()


Measured memory_bytes: 81544
HL=list()
WL=list()
while True:
    H,W=map(int,input().split())
    HL.append(H)
    WL.append(W)
    if H==0 and W==0:
        break
for i in range(len(HL)):
    for j in range(HL[i]):
        if j==0 or j==HL[i]-1:
            for k in range(WL[i]):
                print("#",end="")
            print("")
        else:
            print("#",end="")
            for l in range(WL[i]-2):
                print(".",end="")
            print("#")
        if j==HL[i]-1:
            print("")



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main()
{
  int N, M; cin >> N >> M;
  int time = 0, t;
  REP(i, M) {
    cin >> t;
    time += t;
  }
  int rest = N - time;
  if(rest < 0)
    cout << -1;
  else
    cout << rest;
}

Measured memory_bytes: 3596
/**
   Solution by Abil
**/
# include <bits/stdc++.h>

# define fr first
# define sc second
# define pb push_back
# define mk make_pair
# define sz(s) s.size()
# define all(s) s.begin(),s.end()
# define int long long

using namespace std;

const long long N = (1e5 + 10);
const long long mod = (1e9 + 7);
const long long inf = (1e9 + 7);

int dp[102][N],w[N],v[N];

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    for(int i = 1;i <= n; i++){
        cin >> w[i] >> v[i];
    }
    memset(dp,0x3f3f3f3f,sizeof(dp));
    for(int i = 1;i <= n; i++){
        dp[i][0] = 0;
    }
    dp[1][v[1]] = w[1];
    for(int i = 2;i <= n; i++){
        for(int j = 1;j < N; j++){
            dp[i][j] = min(dp[i][j],dp[i - 1][j - v[i]] + w[i]);
        }
        for(int j = 1;j < N; j++){
            dp[i][j] = min(dp[i][j],dp[i - 1][j]);
        }
    }
    for(int  i = N - 1;i >= 1; i--){
        if(dp[n][i] <= k){
            cout << i;
            return 0;
        }
    }

}


Measured memory_bytes: 80000
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < N; i++) {
			int Ai = sc.nextInt();
			int subAi = Ai - 1;
			int addAi = Ai + 1;
			map.put(Ai, map.get(Ai) == null ? 1 : map.get(Ai) + 1);
			map.put(subAi, map.get(subAi) == null ? 1 : map.get(subAi) + 1);
			map.put(addAi, map.get(addAi) == null ? 1 : map.get(addAi) + 1);
		}
		sc.close();
		
		Collection<Integer> c = map.values();
		Object[] array = c.toArray();
		Arrays.sort(array);
		System.out.println(array[array.length - 1]);
	}
}

Measured memory_bytes: 65924
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	map<int,int> cnt;
	rep(i, n){
		int a; cin >> a;
		++cnt[a];
	}
	vi two, four;
	for(pi p : cnt){
		if(p.second >= 4) four.pb(p.first);
		if(p.second >= 2) two.pb(p.first);
	}
	ll ans = 0;
	if(two.size() >= 2) ans = max(ans, (ll)two.back() * two[two.size() - 2]);
	if(four.size()) ans = max(ans, (ll)four.back() * four.back());
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  for (int i = 1; i < N; i++) {
    if (H[i] < H[i - 1]) {
      H[i]++;
      if (H[i] < H[i - 1]) {
        cout << "No" << '\n';
        return 0;
      }
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBiteEating solver = new BBiteEating();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBiteEating {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int l = in.nextInt();
            long min = Integer.MAX_VALUE;
            boolean pos = true;
            long ans = 0;
            for (int i = 1; i <= n; i++) {
                ans += l + i - 1;
                if (Math.abs(l + i - 1) < min) {
                    min = Math.abs(l + i - 1);
                    if (l + i - 1 > 0) pos = true;
                    else pos = false;
                }
            }
            out.println(ans - (pos ? min : -1 * min));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
  string S;
  cin >> S;
  int A=-1,Z;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A' && A==-1){
      A=i;
    }
    else if(S.at(i)=='Z'){
      Z=i;
    }
  }
  cout << Z-A+1 << endl;
}
  

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n,k;cin>>n>>k;
    set<ll>s;
    f(i,0,k){
        ll d;cin>>d;
        f(j,0,d){ll x;cin>>x;s.insert(x);}
    }
    cout<<n-s.size();
    return 0;  
} 





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

int main() {
  int n, t;
  cin >> n >> t;
  vector<P> p(n);
  rep(i,n){
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i,n){
    if(p[i].second <=t) {
      ans = p[i].first;
      break;
    }
  }
  if(ans) cout << ans << endl;
  else cout << "TLE" << endl;
}

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

int ni, si, li;
long long ds;

void read(void)
{
    if (scanf("%d %d %d", &ni, &si, &li) != 3)
        exit(EXIT_FAILURE);
}

void exec(void)
{
    long long ss, ls;
    
    ss = 1LL * si * (ni - 1) + li, ls = si + 1LL * li * (ni - 1);
    ds = ls - ss + 1, ds = (ds < 0) ? 0 : ds;
}

void write(void)
{
    printf("%lld\n", ds);
}

int main(void)
{
    read();
    exec();
    write();
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <iostream>
#define mod 998244353
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;

int main()
{
	int a;
	cin>>a;
	int flag=0;
	for(int i=1;i<10;i++)
	{
		if(a%i==0)
		{
			if(a/i<10&&a/i>0)
			{
				flag=1;
			}
		}
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

bool Is_Prime(int n){
  if(n==1) return false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

signed main(){
  int n;
  cin>>n;
  int ans=0;
  rep(i,n){
    int a;
    cin>>a;
    if(Is_Prime(a))ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3056
N = int(input())
D = dict()
D["AC"] = 0
D["WA"] = 0
D["TLE"] = 0
D["RE"] = 0
for i in range(N):
    s = input()
    D[s] += 1

print("AC x " + str(D["AC"]))
print("WA x " + str(D["WA"]))
print("TLE x " + str(D["TLE"]))
print("RE x " + str(D["RE"]))

Measured memory_bytes: 9212
#include <stdio.h>

#define MIN(A, B) (A) > (B) ? (B) : (A)
#define MAX(A, B) (A) > (B) ? (A) : (B)

int main() {
	int max_of_R;
	scanf("%d\n", &max_of_R);
	int R[max_of_R];
	for (int i = 0; i < max_of_R; i++) {
		scanf("%d\n", &R[i]);
	}

	int maxv = -0x80000000;
	int minv = R[0];
	for (int i = 1; i < max_of_R; i++) {
		maxv = MAX(maxv, R[i] - minv);
		minv = MIN(minv, R[i]);
	}

	printf("%d\n", maxv);

	return 0;
}



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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int a=0;
  while(s[a]!='A'){
    a++;
  }
  int b=n-1;
  while(s[b]!='Z'){
    b--;
  }
  cout<<b-a+1<<endl;
}

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

typedef struct{
  int a,b;
} Data;

bool ask(const Data& l, const Data& r){
  return l.a < r.a;
}

int main(){
  Data d[100010];
  long long n,k;
  cin >> n >> k;

  for(int i = 0;i < n;i++){
    cin >> d[i].a >> d[i].b;
  }

  sort(d,d+n,ask);

  for(int i = 0;i < n;i++){
    k -= d[i].b;
    if(k <= 0){
      cout << d[i].a << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
double s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		double x;
		cin>>x;
		x=1/x;
		s+=x;
    }
	cout<<1/s;
	return 0;
}

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

using namespace std;

#define int long long

const int N = (int)1e3 + 7;

int dp[(int)2e4 + 7];

int n;
pair < pair < int, int >, int > ar[N];

main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld %lld %lld", &ar[i].first.first, &ar[i].first.second, &ar[i].second);
	}
	sort(ar + 1, ar + n + 1, [&](pair < pair < int, int >, int > &A, pair < pair < int, int >, int > &B) {
		return A.first.first + A.first.second < B.first.first + B.first.second;
	});
	memset(dp, -1, sizeof dp);
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		int asd = ar[i].first.first;
		for (int j = ar[i].first.second + asd; j >= asd; j--) {
			if (dp[j - asd] != -1) {
				dp[j] = max(dp[j], dp[j - asd] + ar[i].second);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= 2e4; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans;
}



Measured memory_bytes: 384
use proconio::{fastout, input};
use std::collections::VecDeque;

const MOVE_A: [(isize, isize); 4] = [(0, 1), (0, -1), (1, 0), (-1, 0)];

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        c_pos: (usize, usize),
        d_pos: (usize, usize),
        s_str: [String; h],
    };
    let c_pos = (c_pos.0 - 1, c_pos.1 - 1);
    let d_pos = (d_pos.0 - 1, d_pos.1 - 1);
    let maze: Vec<Vec<char>> = s_str
        .iter()
        .map(|s| s.chars().collect::<Vec<char>>())
        .collect();
    let mut checked: Vec<Vec<isize>> = vec![vec![-1; w]; h];
    let mut que: VecDeque<(usize, usize)> = VecDeque::new();
    let mut cnt = 0;
    let mut temp_vec: Vec<(usize, usize)> = Vec::new();
    que.push_back(c_pos);
    while !que.is_empty() {
        // a
        while let Some(cur_pos) = que.pop_front() {
            if checked[cur_pos.0][cur_pos.1] != -1 {
                continue;
            }
            checked[cur_pos.0][cur_pos.1] = cnt;
            temp_vec.push(cur_pos);
            for next_shift in MOVE_A.iter() {
                if !in_maze(cur_pos, *next_shift, h, w) {
                    continue;
                }
                let next_pos = (
                    (cur_pos.0 as isize + next_shift.0) as usize,
                    (cur_pos.1 as isize + next_shift.1) as usize,
                );
                if is_road(next_pos, &maze) && checked[next_pos.0][next_pos.1] < 0 {
                    que.push_back(next_pos);
                }
            }
        }
        // b
        cnt += 1;
        while let Some(pos) = temp_vec.pop() {
            for i in -2..=2 {
                for j in -2..=2 {
                    if i == 0 && j == 0 {
                        continue;
                    }
                    if !in_maze(pos, (i, j), h, w) {
                        continue;
                    }
                    let next: (usize, usize) =
                        ((pos.0 as isize + i) as usize, (pos.1 as isize + j) as usize);
                    if is_road(next, &maze) && checked[next.0][next.1] == -1 {
                        que.push_back(next);
                    }
                }
            }
        }
    }
    println!("{}", checked[d_pos.0][d_pos.1]);
}

fn is_road(pos: (usize, usize), maze: &Vec<Vec<char>>) -> bool {
    maze[pos.0 as usize][pos.1 as usize] == '.'
}

fn in_maze(pos: (usize, usize), next: (isize, isize), h: usize, w: usize) -> bool {
    let next_pos = (pos.0 as isize + next.0, pos.1 as isize + next.1);
    0 <= next_pos.0 as isize
        && next_pos.0 < h as isize
        && 0 <= next_pos.1
        && next_pos.1 < w as isize
}


Measured memory_bytes: 16436
#include <cstdio>
#include <cstring>
#include <algorithm>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//string S;
//int k[1000000]= {0};
int P(int x)
{
    int i;
    for(i=2; i<x; i++)
    {
        if(x%i==0)
            return 0;

    }
     if(i>=x)
            return 1;
}
int main()
{
    int j=0;
    int n;
    cin>>n;
    for(int i=11; i<55555; i=i+10)
    {
        if(P(i))
        {
            if(j==n)
                return 0;
            if(j==n-1)
                cout<<i;
            else
                cout<<i<<" ";
            j++;
        }
    }

}



Measured memory_bytes: 256
#include <iostream>

int main(){
    int H,W = 0;
    while(std::cin >> H >> W){
        if(H==0 && W==0) break;
        for(int h=0; h<H; h++){
            for(int w=0; w<W; w++){
                std::cout << "#";
            }
            std::cout << "\n";
        }
        std::cout << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef pair<int, int> P;
 
const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 998244353;
 
int main(){
    int N;
    cin >> N;
 
    vector<int> D(N);
    rep(i, N) cin >> D[i];

    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
 
    sort(D.begin(), D.end());
 
    vector<int> cnt(N, 0);
    rep(i, N) cnt[ D[i] ]++;
 
    if (cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
 
    ll ans = 1;
    rep(i, N) {
        if (D[i] < 2) continue;
 
        int x = D[i];
        ans *= cnt[x - 1];
        ans %= MOD;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

int main(void)
{
    int n,d;
    cin >> n >> d;

    int m =0;

    if(n % (2*d+1) !=0)
    {
        m = n/(2*d+1)+1;
    }else{
        m = n/(2*d+1);
    }

    cout << m <<endl;
    return 0;
}

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

#define int long long
#define ll long long
#define pb push_back

string h;

bool is_pal(int a, int b){
    string y = "";
    string uy = "";
    for(int i = a; i <= b; i++){
        y += h[i];
    }
    for(int i = b; i >= a; i--){
        uy += h[i];
    }
    if (y == uy) return 1;
    else return 0;
}

main(){
    cin >> h;
    int n = h.size();
    if (is_pal(0, n - 1) && is_pal(0, ((n - 1) / 2) - 1) && is_pal(((n + 3) / 2) - 1, n - 1)) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
int main() {
        fast;
        int k,n;
        cin >> k >> n;
        vector<int>a(n);
        for(int i=0;i<n;i++)cin >> a[i];
        
        int d[n];
        
        for(int i=0;i<n-1;i++){
            d[i] = a[i+1] - a[i];
            
        }
        d[n-1] = k - a[n-1] + a[0];
        int dist =0,max_dist = 0;
        for(int i=0;i<n;i++){
            dist += d[i];
            max_dist = max(max_dist,d[i]);
        }
        
        cout << dist - max_dist << endl;
        
	return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans(0);
  
  for(int i = 0;i < s.length();i++){
	if(s.at(i) != t.at(i)){
      ans++;
    }
  }
  cout << ans;
  
    
}

   


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

 int H , W ;
 
 string Map[50] ;
 
 int num_visited = 0;
 int ans = 0;


 int main () {
 cin >> H >> W ;
 
 const int dx[8]={-1,0,1,-1,1,-1,0,1};
 const int dy[8]={-1,-1,-1,0,0,1,1,1};

 for ( int i =0; i < H ; i ++)cin >>  Map[i];

 
 for ( int i =0; i < H ; i ++){
     for ( int j =0; j < W ; j ++){
         if(Map[i][j] == '#') continue;
         int counter = 0;
        for(int k=0;k<8;k++){
         if(j+dx[k] < 0 || j+dx[k] == W)continue;
         if(i+dy[k] < 0 || i+dy[k] == H)continue;
         if(Map[i+dy[k]][j+dx[k]] == '#')counter++;
        }
    Map[i][j]  = counter + '0';
}
    cout<< Map[i]<<endl;
}
 
 }


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

	int n, l;
	cin >> n >> l;
	
	string ans;
	
	vector<string>s(n);
	
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	
	sort(s.begin(), s.end());
	
	for(int i = 0; i < n; i++) cout << s[i];
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
int main(){
    cin>>N;
    ll ans=0;
    for(ll i=1;i<N;i++){
        ans+=(N-1)/i;
    }
    cout<<ans<<endl;


    return 0;
}

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

const int MAXN = 11;
int N;
string S[MAXN];
string rem[MAXN][MAXN];
string mem[1<<MAXN][MAXN];

bool lt(const string &a, const string &b) {
  return a.size() < b.size() ||
    a.size() == b.size() && a < b;
}

string rec(int used, int prev) {
  string &res = mem[used][prev];
  if(res.size() != 1000) return res;
  if(used == (1<<N)-1) return res = "";
  for(int i = 0; i < N; ++i) {
    if(used >> i & 1) continue;
    string tmp = rem[prev][i] + rec(used | (1<<i), i);
    if(lt(tmp, res)) res = tmp;
  }
  return res;
}

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) cin >> S[i];
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        if(i == j) continue;
        if(S[j].find(S[i]) != string::npos) {
          swap(S[i], S[--N]);
          --i;
          break;
        }
      }
    }
    for(int i = 0; i < N; ++i) {
      rem[N][i] = S[i];
      for(int j = 0; j < N; ++j) {
        if(i == j) continue;
        for(int k = 0; k <= S[i].size(); ++k) {
          int l = S[i].size() - k;
          if(S[i].substr(k, l) == S[j].substr(0, l)) {
            rem[i][j] = "";
            while(l < S[j].size()) rem[i][j] += S[j][l++];
            break;
          }
        }
      }
    }
    fill(mem[0], mem[1<<MAXN], string(1000, '#'));
    cout << rec(0, N) << endl;
  }
  return 0;
}

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

int main(){
                                                                     

    string s;

    int i, j;

    
    cin >> s;


    for( i = 0 ; i < s.size() ; i = i + 1 ){

         if( s.at(i) == 'C' ){

             for( j = i + 1 ; j < s.size() ; j = j + 1 ){

                  if( s.at(j) == 'F' ){

                      cout << "Yes" << endl;

                      return 0;

                      }

                  }

             }

         }


    cout << "No" << endl;


    return 0;

    }

Measured memory_bytes: 256
def main():
    num_1 = input()
    lis = list(map(int,input().split()))
    s = 1
    num_2 = int (num_1)
    num = 10 ** 18
    if 0 in lis:
        print(0)
        return
    for x in range(num_2):
        s = s * int(lis[x])
        if s > num:
            print(-1)
            return
    print(s)
    return

main()

Measured memory_bytes: 21540
use strict;
use warnings;
use utf8;

use feature qw(say);
use Data::Dumper;

my $input = <STDIN>;
chomp $input;

my ($x, $k, $d) = (split / /, $input);

my $distance = abs($x);
my $steps = int($distance/$d);

# steps分進んだ結果
my $result_a = abs($distance - $steps * $d);
my $step_a_mod = $steps % 2;
# steps分+1進んだ結果
my $result_b = abs($distance - ($steps + 1) * $d);
my $step_b_mod = ($steps + 1) % 2;

my $step_mapping = +{
    $step_a_mod => $result_a,
    $step_b_mod => $result_b,
};

my $result = 0;
if ($k <= $steps) {
    $result = abs($distance - $k * $d);
} else {
    my $k_mod = $k % 2;
    $result = $step_mapping->{$k_mod};
}
say $result;

Measured memory_bytes: 6460