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

#define endl '\n'

string s;
int n, m;
int dp[100010];

void debug(bool x){
    cout << (x ? "true" : "false") << endl;
}

bool can(int i, int k, int d){
    if (i + d >= n) return 1;
    int cont = 0;
    int best = -1;
    for (int j=1; j<=d; j++){
        if (s[i+j] == '0') best = j;
    }
    if (best == -1) return 0;
    return dp[i + best] <= k;
    for (; i<n; ){
        best = -1;
        for (int j=m; j>=1; j--){
            if (i + j >= n || s[i+j] == '0'){
                best = i+j;
                break;
            }
        }
        if (best == -1) return 0;
        i = best;
        cont++;
    }
    return cont <= k;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> s;
    int tam = 1;
    vector<int> optimal;
    for (int i=n; i>0;){
        int best = -1;
        for (int j=m; j>0; j--){
            if (i - j < 0 || s[i-j] == '0'){
                best = i-j;
                if (i - j < 0) best = 0;
                break;
            }
        }
        if (best == -1){
            cout << "-1\n";
            return 0;
        }
        dp[best] = tam++;
        optimal.push_back(best);
        i = best;
    }
    for (int i=0; i<n; i++){
        if (dp[i] != 0) continue;
        dp[i] = dp[i-1];
    }
    tam--;

    /*
    for (int i=1; i<=3; i++){
        debug(can(0, ))
    }
    */

    int cont = 0;
    vector<int> ans;
    for (int i=0; i<n;){
        int l = 1, r = m, best = -1;
        while(l <= r){
            int mid = (l+r)>>1;
            if (can(i, tam-cont-1, mid)){
                best = mid;
                r = mid-1;
            } else l = mid+1;
        }
        ans.push_back(best);
        i += best;
        cont++;
    }
    for (int x : ans) cout << x << " ";
    cout << endl;
}

Measured memory_bytes: 1864
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
 
int main() {
  int N, K;
  cin >> N;
  string S;
  cin >> S;
  cin >> K;
  
  char t = S[K-1];
  for (int i=0; i<S.size(); ++i){
    if (S[i] != t){
      S[i] = '*';
    }
  }
  cout << S << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  if(s[0] != s[1] && s[1] != s[2] && s[2] != s[0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

typedef long long ll;

int n;
ll a, b, in, h[100000];

bool check(ll x){
    ll needA = 0;
    for(int i = 0; i < n; i++){
        ll residual = h[i] - b*x;
        if(residual > 0)    needA += (residual+a-b-1)/(a-b);
    }
    return needA <= x;
}

int main(){
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++)  cin >> h[i];

    ll r = 0;
    for(int i = 0; i < n; i++)  r += (h[i]+a-1)/a;

    ll l = 1;
    while(l < r){
        ll mid = (l+r)/2;
        if(check(mid))  r = mid;
        else            l = mid;
        if((l+r)/2 == mid)  break;
    }

    if(check(l))    cout << l << endl;
    else            cout << r << endl;

    return 0;
}

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

char a;
int main(){
  cin>>a;
  if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int n, m, q;
int ans = 0;

void debug_vector(vector<int> &vec) {
  cout << "[ ";
  REP(i, vec.size()) {
    cout << vec[i] << ", ";
  }
  cout << " ]";
}

void dfs(int s, int prev, vector<int> &seq, vector<vector<int>> & vec) {
  if (s == n) {
    int tmp = 0;
    REP(i, q) {
      int a = vec[i][0] - 1;
      int b = vec[i][1] - 1;
      if ((seq[b] - seq[a]) == vec[i][2])  {
        tmp += vec[i][3];
      }
    }
    ans = max(ans, tmp);
    return;
  }
  for (int i = prev; i <= m; i++) {
    seq[s] = i;
    dfs(s+1, i, seq, vec);
  }
}


int main()
{
  cin >> n >> m >> q;
  vector<vector<int>> vec;
  vector<int> seq(m, 0);
  REP(i, q) {
    vector<int> r(4, 0);
    REP(j, 4) {
      cin >> r[j];
    }
    vec.push_back(r);
  }
  dfs(0, 1, seq, vec);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N; cin >> N;

  if (N == 3){
    cout << 61 << endl;
  }else{
    ll DP[N + 1][256];

    for (int i = 0; i < 256; i++){
      for (int j = 0; j < N + 1; j++){
        DP[j][i] = 0;
        DP[4][i] = 1;
      }
    }

    const int A = 0, G = 1, C = 2, T = 3;

    for (int i = 0; i < 4; i++){
      DP[4][64 * A + 16 * G + 4 * C + i] = 0;
      DP[4][64 * G + 16 * A + 4 * C + i] = 0;
      DP[4][64 * A + 16 * C + 4 * G + i] = 0;

      DP[4][64 * i + 16 * A + 4 * G + C] = 0;
      DP[4][64 * i + 16 * A + 4 * C + G] = 0;
      DP[4][64 * i + 16 * G + 4 * A + C] = 0;

      DP[4][64 * A + 16 * i + 4 * G + C] = 0;
      DP[4][64 * A + 16 * G + 4 * i + C] = 0;
    }
    
    for (int i = 5; i < N + 1; i++){
      for (int j = 0; j < 256; j++){
        int num = j;

        int num1 = num % 4; num = num / 4;
        int num2 = num % 4; num = num / 4;
        int num3 = num % 4; num = num / 4;


        DP[i][j] = 0;

        for (int k = 0; k < 4; k++){
          DP[i][j] += DP[i - 1][64 * num3 + 16 * num2 + 4 * num1 + k];
        }
        DP[i][j] = DP[i][j] % nmax;
      }

      for (int j = 0; j < 4; j++){
        DP[i][64 * A + 16 * G + 4 * C + j] = 0;
        DP[i][64 * G + 16 * A + 4 * C + j] = 0;
        DP[i][64 * A + 16 * C + 4 * G + j] = 0;

        DP[i][64 * j + 16 * A + 4 * G + C] = 0;
        DP[i][64 * j + 16 * A + 4 * C + G] = 0;
        DP[i][64 * j + 16 * G + 4 * A + C] = 0;

        DP[i][64 * A + 16 * j + 4 * G + C] = 0;
        DP[i][64 * A + 16 * G + 4 * j + C] = 0;
      }
    }
    
    ll ans = 0;
    for (int i = 0; i < 256; i++){
      ans += DP[N][i];
    }
    cout << ans % nmax << endl;
  }

  return 0;
}


Measured memory_bytes: 384
<?php
$n = fgets(STDIN);
$a1 = fgets(STDIN);
$a2 = fgets(STDIN);

//$n = 5;
//$a1 = "3 2 2 4 1";
//$a2 = "1 2 2 2 1";

$asum = 0;
$bsum = 0;
$sumtemp = 0;
$summax = 0;

$h1 = explode(" ", $a1);
$h2 = explode(" ", $a2);

for($i = 0; $i < $n; $i++){
	$asum += $h1[$i];
	$bsum = 0;
	for($h = $i; $h < $n; $h++){
		$bsum += $h2[$h];
	}
	if($asum + $bsum > $summax){
		$summax = $asum + $bsum;
	}
}
echo $summax;
?>



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

price = []
point = []

for i in range(n):
    book = list(map(int, input().split()))
    price.append(book[0])
    point.append(book[1:])

s = -1

for i in range(2**n):
    buy_price = 0
    buy_point = [0] * m
    for j in range(n):
        if i >> j & 1:
            buy_price += price[j]
            for k in range(m):
                buy_point[k] += point[j][k]

    if all([l >= x for l in buy_point]):
        if s > buy_price or s < 0:
            s = buy_price

print(s)


Measured memory_bytes: 9204
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), p = next();
  var s = next(1);
  var ans = 0;
  if(10 % p === 0){
    for(var i = 0; i < n; i++){
      if(s[i] % p === 0)ans += i+1;
    }
    return ans;
  }
  var map = xArray(0,p);
  map[0] = 1;
  var keta = 1, val = 0;
  for(var i = n; i--;){
    val += s[i] * keta;
    val %= p;
    map[val]++;
    keta *= 10;
    keta %= p;
  }
  for(var i = 0; i < p; i++)ans += map[i]*(map[i]-1)/2;
  return ans;
}

Measured memory_bytes: 7884
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    string s;cin>>s;
    ll n=SIZE(s);
    REP(i,n){
        if((i+1)%2==1){
            cout<<s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 3720
let rec insert x  = function
  [] -> [x]
  | hd :: tl -> if x < hd then x :: hd :: tl
                else hd :: (insert x tl) ;;

let print_intlist = function
    [] -> ()
  | hd :: tl -> print_int hd;
                List.iter (Printf.printf " %d") tl;
                print_newline();;

let ins_ord lst =
  let rec f res = function
      [] -> ()
    | hd::tl -> let l = insert hd res in
                print_intlist (List.append l tl);
                f l tl
  in
  f [] lst ;;
                                             
let () =
  let m = Scanf.scanf "%d\n" (fun x -> x) in
  let as_ = Array.init m (fun _ -> Scanf.scanf "%d " (fun x -> x)) in
  let lst = Array.to_list as_ in
  ins_ord lst ;;


Measured memory_bytes: 2968
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}
int n;
ll a[120000];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", a + i);
    }
    ll nowa = 0;
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        if (i % 2 == 0) {
            if (sum <= 0)
                nowa += 1 - sum, sum = 1;
        }
        else {
            if (sum >= 0)
                nowa += sum + 1, sum = -1;
        }
    }
    ll ans = nowa;
    nowa = 0;
    sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i];
        if (i % 2 == 1) {
            if (sum <= 0)
                nowa += 1 - sum, sum = 1;
        }
        else {
            if (sum >= 0)
                nowa += sum + 1, sum = -1;
        }
    }
    ans = min(ans, nowa);
    cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int a,b,rev,digit,count=0,x;
    cin>>a>>b;
    for(;a<=b ; )
    {
        x=a;
        rev=0;
        while(x!=0)
        {
            digit=x%10;
            rev=(rev*10)+digit;
            x=x/10;
        }
        if(a==rev)
            count++;

            a++;
    }
    cout<<count<<endl;
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li n,m;
    cin>>n>>m;
    cout<<(n==m?"Yes":"No")<<endl;

    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
//mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9+7, N = 2e5+5;

int a[N], n, m, k;

void solve(int test_case){
	int i, j;
	cin >> n;
	cout << (n^1);
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}



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

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL); 
   int n;cin>>n;
   if(n>=400 && n<600){
      cout<<"8"<<endl;
   }if(n>=600 && n<800){
      cout<<"7"<<endl;
   }if(n>=800 && n<1000){
      cout<<"6"<<endl;
   }if(n>=1000 && n<1200){
      cout<<"5"<<endl;
   }if(n>=1200 && n<1400){
      cout<<"4"<<endl;
   }if(n>=1400 && n<1600){
      cout<<"3"<<endl;
   }if(n>=1600 && n<1800){
      cout<<"2"<<endl;
   }if(n>=1800 && n<2000){
      cout<<"1"<<endl;
   }
   return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	static class Monster {
		int X,H;

		public Monster(int x, int h) {
			X = x;
			H = h;
		}
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int D = sc.nextInt();
		int A = sc.nextInt();
		Monster[] monster = new Monster[N];
		for(int i=0; i<N; i++) {
			monster[i] = new Monster(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(monster, new Comparator<Monster>() {
			public int compare(Monster m1, Monster m2) {
				return Integer.compare(m1.X, m2.X); 
			}
		});

		int[] XX = new int[N];
		for(int i=0; i<N; i++)
			XX[i] = monster[i].X;
		
		int[] right = new int[N];
		for(int i=0; i<N; i++) {
			int to = monster[i].X + D*2;
			int idx = Arrays.binarySearch(XX, to);
			if(idx<0)
				idx = -idx-2;
			right[i] = idx+1;
		}

		long[] diff = new long[N+1];
		long ans = 0;
		long damage = 0;
		for(int i=0; i<N; i++) {
			damage += diff[i];
			if(monster[i].H-damage > 0) {
				long bomb = (monster[i].H-damage +A-1)/A;
				ans += bomb;
				damage += bomb*A;
				diff[right[i]] -= bomb*A;
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
	
}


Measured memory_bytes: 103256
x,y = map(int,input().split())

a = [4,6,9,11]
b = [1,3,5,7,8,10,12]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == y == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        String ans = "No";
        if (A == B && A != C) ans = "Yes";
        if (A == C && A != B) ans = "Yes";
        if (B == C && A != B) ans = "Yes";
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#define LEN 100005
int min(int a, int b) {return a < b ? a : b;}

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if ( tail == LEN ) tail = 1;
  else tail++;
}

P dequeue(){
	P x;
  x = Q[head];
  if ( head == LEN ) head = 1;
  else head++;
  return x;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q) ;
  
   for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1; tail = n+1;

  while( head != tail ){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else printf("%s %d\n",u.name, elaps);
  }
  
  return 0;
}


Measured memory_bytes: 11856
import java.util.Scanner;

public class Main {
	static final int CHECK = 0;
	static final int RINGO = 1;
	static final int KAKI  = 2;
	static final int MIKAN = 3;
	
	int[][] field;
	int h, w, fruit;
	int[] dy = { 1, 0, -1,  0 };
	int[] dx = { 0, 1,  0, -1 };

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h + w == 0)
				break;
			field = new int[h][];
			for (int i = 0; i < h; i++) {
				field[i] = new int[w];
				char[] f = scan.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (f[j] == '@')
						field[i][j] = RINGO;
					else if (f[j] == '#')
						field[i][j] = KAKI;
					else
						field[i][j] = MIKAN;
				}
			}
			int ans = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (field[i][j] != CHECK) {
						ans++;
						fruit = field[i][j];
						bfs(i, j);
					}
				}
			}
			System.out.println(ans);
		}
	}

	void bfs(int y, int x) {
		if (y < 0 || x < 0 || y >= h || x >= w || field[y][x] != fruit)
			return;
		field[y][x] = CHECK;

		bfs(y + 0, x + 1);
		bfs(y + 0, x - 1);
		bfs(y + 1, x + 0);
		bfs(y - 1, x + 0);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 28876
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(void){
    string s; cin>>s;
    int K; cin>>K;
    vector<string>ss;
    
    for(int a=0;a<s.size();a++){
        int b=1;
        while(b<=5&&a+b<s.size()+1){
            ss.push_back(s.substr(a,b));
            b++;
        }
    }
    sort(ss.begin(), ss.end());
    ss.erase(unique(ss.begin(), ss.end()), ss.end());
    cout<<ss[K-1];
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,q,b,c,sum=0;
	cin>>n;
	vector<ll>v(100001);
	for(ll i=0;i<n;i++){
		cin>>a;
		v[a]++;
		sum+=a;
	}
	cin>>q;
	for(ll i=0;i<q;i++){
		cin>>b>>c;
		int w;
		w=v[b];
		v[b]=0;
		v[c]+=w;
		sum=sum-(b*w)+(c*w);
		cout<<sum<<endl;
	}
	return 0;
}


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

const long long mod=1e9+7;

using namespace std;

long long f[1000010],revf[1000010];

long long qpow(long long a,long long b){
  long long ret=1;
  while(b){
    if(b&1) ret=(ret*a)%mod;
    a=(a*a)%mod;
    b>>=1;
  }
  return ret;
}

void init(){
  f[0]=1; revf[0]=qpow(f[0],mod-2);
  for(long long i=1;i<1000010;i++){
    f[i]=i*f[i-1]%mod;
    revf[i]=qpow(f[i],mod-2);
  }
}

long long C(long long n,long long m){
  return (f[n]*revf[m])%mod*revf[n-m]%mod;
}

long long count_ways(long long a,long long b,long long c,long long d){
  long long tot=(c-a)+(d-b);
  long long down=(c-a);
  long long ret=C(tot,down);
  return ret;
}

int main()
{
    init();
    long long h,w,a,b;
    cin>> h >> w >> a >> b;
    long long tot=count_ways(1,1,h,w);
    for(long long i=1;i<=b;i++){
        long long tmp=count_ways(1,1,h-a,i)*count_ways(h-a+1,i,h,w)%mod;
        while(tot<tmp) tot+=mod;
        tot=(tot-tmp)%mod;
    }
    cout<<tot<<endl;
    return 0;
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,j;
	cin>>n>>m;
	char a[n+2][m+2];
	for(i=0;i<=n+1;i++)
		for(j=0;j<=m+1;j++)
			a[i][j]='.';
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>a[i][j];
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			if(a[i][j]=='#')
			{
				if(a[i+1][j]=='#')
					continue;
				if(a[i-1][j]=='#')
					continue;
				if(a[i][j+1]=='#')
					continue;
				if(a[i][j-1]=='#')
					continue;
				cout<<"No"<<endl;
				return 0;
			}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var a = new HashSet<int>();
            for(int i = 0; i < 3; i++)
            {
                a.Add(line[i]);
            }
            Console.WriteLine(a.Count());
        }
    }
}

Measured memory_bytes: 13396
def sum_of_dig(n):
    s = str(n)
    l = len(s)
    return sum(int(s[i]) for i in range(l))

N, A, B = (int(x) for x in input().split())
ans = 0
for i in range(1, N+1):
    j = sum_of_dig(i)
    if A <= j and j <= B:
        ans += i
else:
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int x;
    cin>>x;
    int gg=__gcd(x,360LL);
    int ans=(360)/gg;
    cout<<ans;
    
} 
    
 


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
int main(){
    int n;
    cin>>n;
    vector<int> vec;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        vec.push_back(t);
    }
    int ans=INF;
    for(int i=-100;i<=100;i++){
        int now=0;
        for(int j=0;j<vec.size();j++){
            now+=(vec[j]-i)*(vec[j]-i);
        }
        ans=min(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int w = scanner.nextInt();
        int h = scanner.nextInt();
        int n = scanner.nextInt();
        int b1 = 0;
        int b2 = w;
        int b3 = 0;
        int b4 = h;
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            int a = scanner.nextInt();
            if (a == 1) {
                b1 = Math.max(b1, x);
            } else if (a == 2) {
                b2 = Math.min(b2, x);
            } else if (a == 3) {
                b3 = Math.max(b3, y);
            } else {
                b4 = Math.min(b4, y);
            }
        }
        System.out.println(Math.max(0, b4 - b3) * Math.max(0, b2 - b1));
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);


int main(){
  often();
  int n,maximum=0;
  cin >> n;
  vi h(n);
  rep(i,n) cin >> h[i];
  rep(i,n){
    if(h[i] < maximum - 1){
      cout << "No" << endl;
      return 0;
    }
    maximum = max(maximum,h[i]);
  }
  cout << "Yes" << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
} 

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>

using namespace std;
#define mod 1000000007
#define ll long long 


ll n,w, a[100009], b[100009];
ll dp[109][100009];

// map<int, map<ll, ll> > dp;
 
ll solve(int r, int idx) {
    if(idx == n)
        return r == 0 ? 0 : INT_MAX;

    if(dp[idx][r] != -1)
    	return dp[idx][r];

    ll ans = solve(r, idx + 1);
    if(b[idx] <= r)
    	ans = min(ans, a[idx] + solve(r - b[idx], idx + 1));
     
    return dp[idx][r] = ans;
}

int s(int v_max) {

	for(int i = v_max; i >= 0; i--) {
		if(solve(i, 0) <= w)
			return i;
	}
	return 0;
}
 
int main() {
 
    // int t;
    // cin>>t;
    // while(t--) {
        cin>>n>>w;
        memset(dp, -1, sizeof(dp));

        int v_max = 0;

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

        cout<<s(v_max)<<endl;

}


Measured memory_bytes: 88780
use std::io::*;
use std::str::FromStr;
use std::cmp;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
    
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let (a, b): (i32, i32) = (read(), read());
  println!("{}", cmp::max(a - b * 2, 0));
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	string W, T;
	int count = 0;

	cin >> W;

	transform(W.begin(), W.end(), W.begin(), ::toupper);

	while (1) {
		cin >> T;
		if (T == "END_OF_TEXT") break;
		transform(T.begin(), T.end(), T.begin(), ::toupper);
		if (W == T) count++;
	}
		
	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3160
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f;
const int maxn = 1e5+500;
ll T,n,m;
int main() {
    cin>>n>>m;
    int i;
    for(i=0;i<=20;i++){
    	int t  = i*n-i+1;
    	if(t>=m)
    		break;
	}
	cout<<i<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  string s;
  cin >> n >> s;
  int mxcnt = 0;

  REP2(k,1,n-1){//切れ目の位置
    map<char,bool> mp;
    int cnt = 0;
    //前半
    REP2(i,0,k){
      mp[s[i]] = true;
    }

    //後半
    REP2(i,k,n){
      if(mp[s[i]] == true) {
        cnt++;
        mp[s[i]] = false;
      }
    }
    mxcnt = max(cnt,mxcnt);

  }

  cout << mxcnt << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <math.h>
#include <string.h>
int memo[100005], arr[100005], vis[100005];
int min(int a, int b)
{
    return a<b ? a : b;
}
int dp(int n)
{
    if(n==0)
        return 0;
    if(n==1)
        return fabs(arr[1]-arr[0]);
    if(vis[n]==1)
        return memo[n];
    vis[n]=1;
    return memo[n] = min(dp(n-1)+fabs(arr[n]-arr[n-1]), dp(n-2)+fabs(arr[n]-arr[n-2]));
}
int main()
{
    memset(arr, 0, sizeof(arr));
    memset(memo, 0, sizeof(memo));
    memset(vis, 0, sizeof(vis));
    int n;  scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &arr[i]);
    printf("%d\n", dp(n-1));
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << " "<<  a<< " " << b<< endl;;
    return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int c[531],s[531],f[531];

    Scd(n);
    n--;
    Rep(i,n){
        Scd3(c[i],s[i],f[i]);
    }

    int ans = 0;
    int n1 = n+1;
    Rep(j,n1){
        ans = 0;
        Repe(i,n,j){
            if( ans < s[i] ) ans = s[i];
            if( ans % f[i] ) ans = ans / f[i] * f[i] + f[i];
            ans += c[i];
        }
        printf ("%d\n", ans);
    }

    return 0;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/agc039/tasks/agc039_a

s = list(input())
k = int(input())


i = 0
a = 0

while i < len(s):
  if i == len(s) - 1:
    break
  if s[i] == s[i+1]:
    a += 1
    i += 2
  else:
    i += 1
else:
  print(a * k)
  exit()
  
i = -1
b = 0

while i < len(s):
  if i == len(s) - 1:
    print(a + b * (k - 1))
    exit()
  if s[i] == s[i + 1]:
    b += 1
    i += 2
  else:
    i += 1
else:
  print(a * ((k + 1) // 2) + b * ((k - 1) // 2))
  exit()

Measured memory_bytes: 61716
#include<bits/stdc++.h>
#define maxn 302

using namespace std;
typedef double db;
db dp[maxn][maxn][maxn];
int n,k,cnt[4];
int main(){
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> k; cnt[k]++;
    }
    for (int sum=1;sum<=3*n;sum++)
    for (int k=0;k*3<=sum;k++)
    for (int j=0;j*2+k*3<=sum;j++){
        int i=sum-j*2-k*3;
        if (i+j+k>n) continue;
        if (i>0) dp[i][j][k]+=(db)i/(i+j+k)*dp[i-1][j][k];
        if (j>0) dp[i][j][k]+=(db)j/(i+j+k)*dp[i+1][j-1][k];
        if (k>0) dp[i][j][k]+=(db)k/(i+j+k)*dp[i][j+1][k-1];
        dp[i][j][k]+=(db)n/(i+j+k);
    }
    printf("%.13f\n",dp[cnt[1]][cnt[2]][cnt[3]]);
}


Measured memory_bytes: 215296
s = list(input())
n = len(s)
t = 0
odd = 0
even = 0
while t < n:
  odd += int(s[t])
  t += 2
u = 1
while u < n:
  even += int(s[u])
  u += 2
if n%2 == 0:
  print(min(n//2+odd-even,n//2+even-odd))
else:
  print(min(n//2+odd-even,n//2+even+1-odd))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
  ll s,a=1000000000,d=1;cin>>s;
  cout<<0<<" "<<0<<" "<<a<<" "<<d<<" ";
  if(s%a==0)cout<<0<<" "<<s/a <<endl;
  else cout<<(((-s)%a)+a)%a<<" "<<s/a +1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define AB_BHI_NI_DEGI               \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double
#define endl "\n"

#define ordered_set tree<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>

int power(int a, int n, int m)
{
   int res = 1;
   int ans = 0;
   while (n)
   {
      if (n % 2)
         res = (res * a) % m;
      a = (a * a) % m;
      n = n / 2;
      ans += a;
   }
   return res;
}
int32_t main()
{
   AB_BHI_NI_DEGI
   //freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
   //cout.precision(20);
   //cout << fixed;
   int T = 1;
   //cin >> T;
   int cnt = 1;
   //sieve();
   while (T--)
   {
      int n, x, m;
      cin >> n >> x >> m;
      int ans = x;
      int prev = x;
      map<int, int> mp;
      mp[x] = 1;
      int s = -1;
      int i;
      for (i = 1; i < n; i++)
      {
         int x = (prev * prev) % m;
         if (mp.count(x))
         {
            s = x;
            break;
         }
         mp[x]++;
         prev = x;
         ans += x;
      }
      if (s == -1)
      {
         cout << ans << "\n";
         continue;
      }
      ans = x;
      prev = x;
      for (i = 1; i < n; i++)
      {
         int x = (prev * prev) % m;
         if (x == s)
            break;
         ans += x;
         prev = x;
      }
      int cy = 0, cyl = 0;
      mp.clear();
      while (1)
      {
         int x = (prev * prev) % m;
         if (mp.count(x))
            break;
         cy += x;
         prev = x;
         mp[x]++;
         cyl++;
      }
      int len = n - i;
      int y = len / cyl;
      ans += y * cy;
      int rem = len % cyl;
      while (rem--)
      {
         int x = (prev * prev) % m;
         ans += x;
         prev = x;
      }
      cout << ans << "\n";
   }
   return 0;
}

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

int main() {
  int N;
  int sum = 0;
  cin >> N;

  for(int i=0; i < N; i++){
    int A, B; 
    cin >> A >> B;
    int C = 0;
    if(B - A != 0){
      C = B - A + 1;
    }
    else{
      C = 1;
    
    }
    sum += C;
  }
  cout << sum << endl;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (100006)
ll n, m, ans, mod=998244353, dp[MAXN][2];
map<pi, ll> mp;
ll val(ll x,ll y){
	return mp.find(pi(x,y)) == mp.end() ? -1 : mp[pi(x,y)];
}
ll flex(ll a,ll b,ll c,ll d){
	if(val(a,b)==-1&&val(c,d)==-1)return 2;
	else return 1;
}
ll qexp(ll x,ll e){ll sum=1;for(;e;e>>=1,x*=x,x%=mod)if(e&1)sum*=x,sum%=mod;return sum;}
int main(){
	FAST
	cin>>n>>m;
	FOR(i,1,m){
		ll a,b,c;
		cin>>a>>b>>c;
		mp[pi(a,b)]=c;
		if(a==b || llabs(a-b)<=2)continue;
		if(mp.find(pi(b,a)) != mp.end()) {
			if((mp[pi(b,a)]+mp[pi(a,b)])&1){
				cout<<"0\n";return 0;
			}
		}
	}
	// decide centreline if both 2 decided then check whether can fit anot, and check 3 also
	dp[1][0]=val(1,1) != 1;
	dp[1][1]=val(1,1) != 0;
	FOR(i,2,n){
		if(val(i,i)!=1) {
			if(val(i-1,i)!=-1&&val(i,i-1)!=-1){
				dp[i][0]=dp[i-1][0]*(val(i-1,i) ^ val(i,i-1) ^ 1)
					+ dp[i-1][1]*(val(i-1,i) ^ val(i,i-1));
			}else{
				dp[i][0]=(dp[i-1][0]+dp[i-1][1]) * flex(i-1,i,i,i-1) % mod;
			}
		}
		if(val(i,i)!=0) {
			if(val(i-1,i)!=-1&&val(i,i-1)!=-1){
				dp[i][1]=dp[i-1][0]*(val(i-1,i) ^ val(i,i-1))
					+ dp[i-1][1]*(val(i-1,i) ^ val(i,i-1) ^ 1);
			}else{
				dp[i][1]=(dp[i-1][0]+dp[i-1][1]) * flex(i-1,i,i,i-1) % mod;
			}
		}
		if(i != n){
			ll v1=val(i-1,i+1), v2=val(i+1,i-1);
			if(v1 != -1 && v2 != -1){
				if((v1+v2)&1)dp[i][0]=0;
				else dp[i][1]=0;
			}else{
				dp[i][0] *= flex(i-1,i+1,i+1,i-1), dp[i][0] %= mod;
				dp[i][1] *= flex(i-1,i+1,i+1,i-1), dp[i][1] %= mod;
			}
		}
		// cerr<<dp[i][0]<<' '<<dp[i][1]<<'\n';
	}
	ll ans = (dp[n][0] + dp[n][1]) % mod;
	ll mi=0;
	for(auto i:mp){
		if(mp.find(pi(i.f.s,i.f.f))!=mp.end() && i.f.f > i.f.s) continue;
		if(llabs(i.f.f-i.f.s) <= 2) continue;
		++ mi;
	}assert(mp.size()==m);
	cerr<<"ans: "<<ans<<'\n';
	cerr<<"hmm: "<<((n-3) * (n-3+1) / 2 - mi)<<'\n';
	ans *= qexp(2, (n-3) * (n-3+1) / 2 - mi), ans %= mod;
	cout<<ans<<'\n';
}


Measured memory_bytes: 8332
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	inline void chmax(ll &x,ll y) {x=x>y?x:y;}
	inline void chmin(ll &x,ll y) {x=x<y?x:y;}

	const int MAX_N=1e5+10;
	struct PP
	{
		int m[MAX_N];PP(){memset(m,0,sizeof m);}
		int& operator [] (int i) {return m[i];}
		PP inv()
		{
			PP b;for(int i=1;i<MAX_N;i++) b[m[i]]=i;
			return b;
		}

		friend PP operator * (PP a,PP b)
		{
			PP c;for(int i=1;i<MAX_N;i++) c[i]=a[b[i]];
			return c;
		}
		friend PP operator / (PP a,PP b)
		{
			return a*b.inv();
		}
	};
	PP qpower(PP x,int e)
	{
		PP ans;for(int i=1;i<MAX_N;i++) ans[i]=i;
		while(e)
		{
			if(e&1) ans=ans*x;
			x=x*x;e>>=1;
		}
		return ans;
	}
	PP a[10],A,ans;
	void main()
	{
		int n,k;scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++) a[1][i]=qread();
		for(int i=1;i<=n;i++) a[2][i]=qread();
		a[0]=a[2].inv()*a[1];for(int i=3;i<=5;i++) a[i]=a[i-1]/a[i-2];
		A=a[2]/a[1]/a[2]*a[1];ans=qpower(A,k/6)*a[k%6]/qpower(A,k/6);
		for(int i=1;i<=n;i++) printf("%d ",ans[i]);
 	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 17536
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
string intostr(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}

char Uplowch(char ch)
{
    if(ch >= 'A' &&  ch <= 'Z')
        ch += 32;
    return ch;
}
char Lowupch(char ch)
{
    if(ch >= 'a' &&  ch <= 'z')
        ch -= 32;
    return ch;
}
bool Isalpha(char ch)
{
    if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
        return true;
    return false;
}
int Strtoint(string str)
{
    stringstream ss(str);
    int x = 0;
    ss >> x ;
    return x ;
}
string Intostr(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}

#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)

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

int dx[] = {0, 0, -1, 1} ;    // right , left , forward , backward
int dy[] = {1, -1, 0, 0} ;

//bool check(int x , int y) {
//    if(x <= n && y <= m && x >= 1 && y >= 1)
//        return 1 ;
//    return 0 ;
//}

int main()
{
    //freopen("in.txt","r",stdin);

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

  ll n;
  cin>>n;
  map<string ,ll> mp;
  ll ans=0;

  while(n--)
  {
      string s;
      cin>>s;
      if(mp[s]==0)
      {
          ans++;
          mp[s]=1;
      }


  }

  cout<<ans<<nn;


}



Measured memory_bytes: 19100
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

bool comp(pair<ll,ll> a, pair<ll,ll> b){
    return a.first+a.second < b.first+b.second;
}

int main(){
    int N; cin >> N;
    vector<ll> X(N), L(N);
    vector<pair<ll,ll>> XL(N);
    rep(i,N) cin >> XL[i].first >> XL[i].second;

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

    int ans = 0;
    ll right_end = -INF;
    rep(i,N){
        if (right_end <= XL[i].first-XL[i].second){
            right_end = XL[i].first+XL[i].second;
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 6432
piyo = (input()).split()
H = int(piyo[0])
W = int(piyo[1])
flag = True
pic = []

kuu = [0 for i in range(W+1)]

pic += kuu

for i in range(H):
  pic = pic + [0] + list(input()) + [0]

pic += kuu

for i in range(len(pic)):
  if pic[i] == "#":
    if not(pic[i-1] == "#" or pic[i+1] == "#" or pic[i-W-2] == "#" or pic[i+W+2] == "#"):
      flag = False
      break
      

if flag:
  print("Yes")
else:
  print("No")


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

#define MAX 100000 + 10

typedef struct {
    char name[20];
    int time;
} TASK;

template <class T> class Queue {
    T A[MAX];
    int head = 0;
    int tail = 0;

  public:
    bool isFull() {
        return (tail + 1) % MAX == head;
    }
    bool isEmpty() {
        return tail == head;
    }
    void enqueue(T x) {
        if (isFull()) {
            exit(1);
        }
        A[tail++] = x;
        if (tail > MAX) {
            tail = 0;
        }
    }
    T dequeue() {
        if (isEmpty()) {
            exit(1);
        }
        T val = A[head++];
        if (head > MAX) {
            head = 0;
        }
        return val;
    }
};

int main() {
    Queue<TASK> Q;
    int n, q;
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++) {
        TASK x;
        scanf("%s %d", x.name, &x.time);
        Q.enqueue(x);
    }
    int cnt = 0;
    while (!Q.isEmpty()) {
        TASK x = Q.dequeue();
        if (x.time > q) {
            x.time -= q;
            cnt += q;
            Q.enqueue(x);
        } else {
            cnt += x.time;
            printf("%s %d\n", x.name, cnt);
        }
    }
    return 0;
}



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

int main(void)
{
    int a, b;
    cin >> a >> b;
    if(a == b) cout << a + b << endl;
    else cout << 2*max(a, b) -1 << endl;
    return 0;
}

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

int main() {
    int m;
    cin >> m;
    cout << 48-m << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <string>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    if (a.size() > b.size())
    {
        cout << "GREATER";
    } else if (a.size() < b.size())
    {
        cout << "LESS";
    } else
    {
        for (int i = 0; i < a.size(); ++i)
        {
            if ((a[i] - '0') > (b[i] - '0'))
            {
                cout << "GREATER";
                return 0;
            } else if ((a[i] - '0') < (b[i] - '0'))
            {
                cout << "LESS";
                return 0;
            }
        }
        cout << "EQUAL";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  if(n%10==9||n/10==9) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100



void output(int A[], int n){

  int i;

  printf("%d",A[0]);

  for(i=1;i<n;i++)
    printf(" %d",A[i]);
  putchar('\n');
  
}

void insertionsort(int A[], int n){
  int v=0;
  int i,j;

  for(i=1; i<=n-1; i++){

    v=A[i];
    j=i-1;

    while(j >=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    output(A, n);
  }
}

int main(void){
  int A[N],n,i,j;

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

  output(A,n);

  insertionsort(A,n);
  
 
  return 0;

}



Measured memory_bytes: 2732
#include<stdio.h>
int func();
 
int main(){
    int dice[100][6];
    int n;
    int i,j;
    int flag=1;
     
    scanf("%d", &n);
    for(i=0;i<n;i++)for(j=0;j<6;j++)scanf("%d", &dice[i][j]);
 
    for(i=1;i<n;i++){
        flag = func(dice[0],dice[i]);
        if(flag){
            printf("No\n");
            return 0;
        }
    }
 
    printf("Yes\n");
    return 0;
}
 
int func(int a_dice[], int b_dice[]){
    int surface[24][3]={{1,2,3},{2,3,1},{3,1,2},
                        {1,3,5},{3,5,1},{5,1,3},
                        {1,5,4},{5,4,1},{4,1,5},
                        {1,4,2},{4,2,1},{2,1,4},
                        {6,2,4},{2,4,6},{4,6,2},
                        {6,4,5},{4,5,6},{5,6,4},
                        {6,5,3},{5,3,6},{3,6,5},
                        {6,3,2},{3,2,6},{2,6,3}};
    int i;
 
    for(i=0;i<24;i++){
        if((a_dice[surface[i][0]-1]==b_dice[0]) && (a_dice[surface[i][1]-1]==b_dice[1])  && (a_dice[surface[i][2]-1]==b_dice[2])){
            if((a_dice[6-surface[i][0]]==b_dice[5]) && (a_dice[6-surface[i][1]]==b_dice[4])  && (a_dice[6-surface[i][2]]==b_dice[3])){
                return 1;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    s < t ? cout << "Yes" << '\n' : cout << "No" << '\n'; 

}



Measured memory_bytes: 256