akhauriyash/Code-Regression huggingface dataset:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    T = input().strip()
    res = ""
    for t in T:
        if t == "?":
            t = "D"
        res += t

    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 10000
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<li, li> pt;

#define fi first
#define se second
#define lson ((p<<1))
#define rson ((p<<1)+1)
#define mid ((L+R)>>1)
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll const INF = 1e12;

ll n, m, p, dist[2507];
ll a[5007], b[5007], c[5007];

int main() {
    fastIO;
    cin >> n >> m >> p;
    for(li i = 0; i < m; i ++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        c[i] = - c[i] + p;
    }

    for(li i = 0; i < n; i ++) dist[i] = INF;
    dist[0] = 0;

    for(li h = 0; h < 2; h ++)
    for(li i = 0; i < n; i ++) {
        for(li j = 0; j < m; j ++) {
            if(dist[a[j]] == INF) continue;
            if(h > 0 && dist[b[j]] > dist[a[j]] + c[j]) { dist[b[j]] = -INF; }
            if(!h) dist[b[j]] = min(dist[b[j]], dist[a[j]] + c[j]);
        }
    }

    if(dist[n - 1] == -INF) cout << -1;
    else if( - dist[n - 1] < 0) cout << 0;
    else cout << - dist[n - 1];

}


Measured memory_bytes: 512
import numpy as np
n = int(input())

shigoto = np.zeros((n, 2), dtype=int)

for i in range(n):
    shigoto[i] = list(map(int,input().split()))

sorted_shigoto = shigoto[np.argsort(shigoto[:, 1])]

mount = 0
ans = True
for now_shigoto in sorted_shigoto:
    mount += now_shigoto[0]
    if mount > now_shigoto[1]:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 20640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

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

int main(){
    long long N;
    long long a,b;

    bool ok=true;
    cin>>N;
    vector <pair<long long,long long>> P;
    rep(i,0,N){
        cin>>a>>b;
        P.PB(MP(b,a));
    }

    sort(P.begin(),P.end());

    long long sum=0;
    rep(i,0,N){
        sum+=P[i].second;
        if(P[i].first<sum)ok=false;
    }

    if(ok)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 6384
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let input: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = input[0];
    let a = input[1];
    let b = input[2];

    let m = n - a - 1;
    let mut ans = cmp::max(1 + n, 1 + (n%(a+1)) + (b-1) * (n/(a+1)));
    if a < b-2  && m >= 0 {
        let m = n - a - 1;
        ans = cmp::max(ans, b + m/2 * (b-a) + m%2);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;

    vector< pair<ll, ll> > dt(n);
    for(int i=0; i<n; ++i) cin >> dt[i].second >> dt[i].first;
    sort(dt.begin(), dt.end(), greater< pair<ll, ll> >());
    
    map<ll, ll> mp;
    ll sum_D = 0;

    for(int i=0; i<k; ++i){
        sum_D += dt[i].first;
        ++mp[dt[i].second];
    }

    ll type_num = mp.size();
    ll ans = sum_D + type_num*type_num;

    // next phaze
    int nxt = k, del = k-1;
    while(1){
        while(nxt<n && mp[dt[nxt].second]!=0) ++nxt;
        if(nxt == n) break;
        ++type_num;
        sum_D += dt[nxt].first;
        ++mp[dt[nxt].second];
        ++nxt;
        
        while(del>=0 && mp[dt[del].second]<2) --del;
        if(del < 0) break;
        sum_D -= dt[del].first;
        --mp[dt[del].second];
        --del;

        chmax(ans, sum_D + type_num*type_num);
    }

    cout << ans << endl;
    
	return 0;
}

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

using namespace std;

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

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

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    // cerr << "i:" << i << " a[i]:" << a[a[i] - 1] << '\n';
    if (i + 1 == a[a[i] - 1]) {
      ++cnt;
    }
  }

  cout << cnt / 2 << '\n';

  return 0;
}


Measured memory_bytes: 640
main = do
  getLine
  s <- getLine::IO[Char]
  let cumulative = scanl (\(w,e) v -> if v == 'W' then (w+1,e) else (w,e+1)) (0,0) s
  let vectorAll = last cumulative
  print $ minimum $ zipWith (\v (w,e) -> let result = w + (snd vectorAll - e) in if v == 'W' then result else  result - 1) s cumulative

Measured memory_bytes: 77180
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        cin>>n; 
        ans=3*n*n;
        cout<<ans<<endl;

    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d||(abs(a-b)<=d&&abs(c-b)<=d))cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

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

int main(int argc, char *argv[]) {

  int L, N;
  int x[50], w[50];
  int moment = 0;

  std::cin >> L >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> x[i] >> w[i];
    moment += x[i] * w[i];
  }

  if( moment < 0 ) {
    std::cout << 1 << std::endl;
    std::cout << 1 << ' ' << std::abs(moment) << std::endl;
  }
  else if( moment > 0 ) {
    std::cout << 1 << std::endl;
    std::cout << -1 << ' ' << std::abs(moment) << std::endl;
  }
  else {
    std::cout << 0 << std::endl;
  }
  
  
  return 0;
}

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

const ll limit = 1e18;

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    a *= int(b * 100 + 0.05);
    cout << a / 100 << endl;
    return 0;
}

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

int main(){

    string str1, str2;
    cin >> str1;
    cin >> str2;
    if(str1[0]==str2[2] && str1[2]==str2[0] && str1[1]==str2[1]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    double s;
    cin >> s;
    cout <<setprecision(10) <<s*s*s/27;



    return 0;
}

Measured memory_bytes: 3748
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            for (int i=1; i <= n; i++) {
                StringTokenizer st = new StringTokenizer(br.readLine());
                String e = st.nextToken();
                Long p = Long.parseLong(st.nextToken());
                Long q = Long.parseLong(st.nextToken());
                data.put(e, data.getOrDefault(e, 0L) + p * q);
            }
            
            int cnt = 0;
            for(Map.Entry<String, Long> e : data.entrySet()){
                if(e.getValue() >= 1_000_000){
                    System.out.println(e.getKey());
                    cnt++;
                }
            }
            if (cnt == 0) {
                System.out.println("NA");
            }
        }
    }
}

Measured memory_bytes: 25804
#include<bits/stdc++.h>
using namespace std;
#define re register
const int mod=998244353;
int R[13][13],R1[13],tt[1100];
char ss[1001000];
int main()
{
	tt['R']=1;tt['B']=2;tt['G']=3;
	re int n,num=1;
	scanf("%d",&n);n*=3;
	scanf("%s",ss+1);
	for(re int i=1;i<=n;i++)
	{
		re int x=tt[ss[i]],y=(x==1?2:1),z=(x==3?2:3);
		if(R[y][z])num=(long long)num*R[y][z]%mod,R[y][z]--;
		else if(R1[y])
		{
			num=(long long)num*R1[y]%mod;
			R1[y]--;
			if(x==1)R[x][y]++;
			else R[y][x]++;
		}else if(R1[z])
		{
			num=(long long)num*R1[z]%mod;
			R1[z]--;
			if(x==3)R[z][x]++;
			else R[x][z]++;
		}else
		{
			R1[x]++;
		}
	}
	for(re int i=1;i<=n/3;i++)num=(long long)i*num%mod;
	printf("%d\n",num);
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
  ll n; cin >> n;
  if(n%2==0) cout << n/2-1 << endl;
  else cout << n/2 << endl;
}

Measured memory_bytes: 256
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i=int(input())-1
print(l[i])

Measured memory_bytes: 9124
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 

using namespace std;

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,i,j,k;
    cin>>n;
    vi v(n+1);
    for(i=1;i<=n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    int ans=0;
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(v[j]<=v[i]) continue;
            for(k=j+1;k<=n;k++)
            {
                if(v[k]<=v[j]) continue;
                if(v[i]+v[j]>v[k]) ans++;
                // cout<<v[i]<<" "<<v[j]<<" "<<v[k]<<endl;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200000],b[200000];
int main(void)
{
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++){
		if(a[i]==b[n-1]){
			printf("%d\n",b[n-2]);
		}
		else{
			printf("%d\n",b[n-1]);
		}
	}
	return 0;
}

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

using namespace std;
 
int main()
{
    int n;
    while (cin >> n, n) {
	int cnt = 0;
	while (n != 1) {
	    cnt++;
	    if (n % 2 == 0) {
		n /= 2;
	    } else {
		n *= 3;
		n++;
	    }
	}
	cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3040
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  map<string,int> count;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(count.find(s)==count.end()){
      count[s]=1;
    }else{
      count[s]++;
    }
  }

  int max=0;
  for(auto& p:count){
    UpdateMax(max,p.second);
  }
  vector<string> result;
  for(auto& p:count){
    if(p.second==max){
      result.push_back(p.first);
    }
  }
  std::sort(result.begin(), result.end());
  for(auto& s:result){
    cout<<s<<endl;
  }

  return 0;
}




Measured memory_bytes: 25584
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    c=[]
    s=0
    for i in range(3):
        li=list(map(int,readline().split()))
        s+=sum(li)
        c.append(li)

    if s%3!=0:
        print("No")
    else:
        if c[0][0]+c[1][1]+c[2][2]==s//3:
            print("Yes")
        else:
            print("No")

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		out.println(a-2*b>0?a-2*b:0);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	string s, t; cin >> s >> t;
	int S; S = s.size();
	string T;T= t.erase(S);
	if (s == T) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

bool is_small(int h1, int w1, int h2, int w2) {
    int d1 = h1*h1 + w1*w1;
    int d2 = h2*h2 + w2*w2;
    if(d1 < d2) return true;
    else if(d1 > d2) return false;
    else if(h1<h2) return true;
    else return false;
}

int main()
{
    int h, w;
    while(cin>>h>>w, h) {
        int mh = 151;
        int mw = 151;
        for(int i=1; i<=150; ++i) {
            for(int j=i+1; j<=150; ++j) {
                if(i==h&&j==w) continue;
                if(is_small(i,j,h,w)) continue;
                if(is_small(i,j,mh,mw)) {
                    mh = i;
                    mw = j;
                }
            }
        }
        cout << mh << " " << mw << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let w: i64 = read(&mut stdin_lock, &mut buf, b'\n');
    let w_max = 10_000_000_000i64;
    let v_max = 1_000 * n;
    let mut ans = vec![vec![w_max; v_max + 1]; n + 1];
    ans[0][0] = 0;
    for i in 0..n {
        let wi: i64 = read(&mut stdin_lock, &mut buf, b' ');
        let vi: usize = read(&mut stdin_lock, &mut buf, b'\n');
        for j in 0..v_max + 1 {
            ans[i + 1][j] = min(ans[i][j], if j < vi { wi } else { ans[i][j - vi] + wi });
        }
    }
    let mut ans_v = 0;
    for j in 0..v_max + 1 {
        if ans[n][j] <= w {
            ans_v = j;
        }
    }
    println!("{}", ans_v);
}


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

int main() {
  int R,a,b,c;

  // 変数aで入力を受け取る
  cin >> R;
  a = R/100; //100の位の判別
  b = (R - 100*a)/10 ; //10の位の判別
  c = ((R-100*a)-(10*b))/1; //1の位の判別
  
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int INF = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    int a[m]; for(int i=0;i<m;++i){
        cin >> a[i];
        a[i]--;
    }
    int dp[n]; memset(dp,0,sizeof(dp));
    for(int i = 0;i < m; ++i) dp[a[i]] = -1;
    if(dp[0] != -1) dp[0]++;
    if(dp[1] != -1) dp[1]++;
    if(dp[1] != -1 && dp[0] != -1) dp[1]++;
    for(int i = 2; i < n; ++i){
        if(dp[i] == -1) continue;
        if(dp[i-1] != -1) dp[i] += dp[i-1]; dp[i] %= INF;        
        if(dp[i-2] != -1) dp[i] += dp[i-2]; dp[i] %= INF;
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4300
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>
using namespace std;

int main(void){
    // Your code here!
    int a, b, c;
    
    cin >> a >> b >> c;
    
    for(int i = 1; i < b; i++){
        if(a * i % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
    
    return 0;
}

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

int main() {
  string S; cin >> S;
  int L = S.size();
  int cnt = 15 - L;
  for (int i = 0; i < L; i++) {
    if (S.at(i) == 'o') cnt++;
  }
  if (cnt >= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var x, y string; fmt.Scan(&x, &y)
  var ans string
  if x < y {
    ans = "<"
  } else if x == y {
    ans = "="
  } else {
    ans = ">"
  }
  fmt.Println(ans)
}

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

int main() {
    int x;
    cin >> x;
    if (x == 1) cout << 0 << endl;
    else cout << 1 << endl;


	return 0;
}


Measured memory_bytes: 3592
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)
 
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
 
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
 
func main() {
	var n, k int
	fmt.Scan(&n, &k)
	v := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range v {
		sc.Scan()
		v[i], _ = strconv.Atoi(sc.Text())
	}
 
	ans := 0
	for i := 0; i <= min(k, n); i++ {
		for j := 0; j <= min(k, n); j++ {
			if i+j > min(k, n) {
				continue
			}
			rem := k - i - j
			a := make([]int, 0, i+j)
			for i2 := 0; i2 < i; i2++ {
				a = append(a, v[i2])
			}
			for j2 := 0; j2 < j; j2++ {
				a = append(a, v[n-1-j2])
			}
			sort.Ints(a)
			s := 0
			for _, e := range a {
				if e >= 0 {
					s += e
				} else {
					if rem > 0 {
						rem--
					} else {
						s += e
					}
				}
			}
			ans = max(ans, s)
		}
	}
	fmt.Println(ans)
}

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

class Edge
{
	public:
	int to,cost;
	Edge(int t,int c)
	{
		to=t;
		cost=c;
	}
};

vector<Edge> g[8];

int saiki(int now,int past,int n)
{
	int ret=0;
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if((past&(1<<e.to))==0)
			ret+=saiki(e.to,past|(1<<e.to),n);
	}
	if(past==(1<<n)-1)
		ret++;
	return ret;
}

int main()
{
	int n,m;
	int ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(Edge(b,1));
		g[b].push_back(Edge(a,1));
	}
	cout<<saiki(0,1,n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    vector<int>x(n,1);
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            x[i]+=x[i-1];
        }
    }
    int a=*max_element(x.begin(),x.end());
    for(int i=0;i<n;i++){
        if(x[i]==a){
            cout<<s[i]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 15104
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
ll n, a, b;
int main()
{
	scanf("%lld%lld%lld", &n, &a, &b);
	if (a > b)swap(a, b);
	if ((b - a) & 1)
	{
		ll s = min(a - 1, n - b);
		printf("%lld\n", s + (b - a + 1) / 2);
	}
	else
		printf("%lld\n", (b - a) / 2);
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

double solve(int x, int y, int z, int n, vector<vector<vector<double>>> &dp)
{
    if(x == 0 && y == 0 && z == 0)
    {
        return 0;
    }
    
    if(dp[x][y][z] != -1)
    {
        return dp[x][y][z];
    }
    
    dp[x][y][z] = (double)n/(x+y+z);
    if(x > 0)
    {
        dp[x][y][z] += (solve(x-1,y,z,n,dp)*x)/(x+y+z);
    }
    if(y > 0)
    {
        dp[x][y][z] += (solve(x+1,y-1,z,n,dp)*y)/(x+y+z);
    }
    if(z > 0)
    {
        dp[x][y][z] += (solve(x,y+1,z-1,n,dp)*z)/(x+y+z);
    }
    
    return dp[x][y][z];
}

int main()
{
    int n;
    cin >> n;
    
    int x = 0;
    int y = 0;
    int z = 0;
    for(int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        if(t == 1)
        {
            x++;
        }
        if(t == 2)
        {
            y++;
        }
        if(t == 3)
        {
            z++;
        }
    }
    
    vector<vector<vector<double>>> dp(n+1,vector<vector<double>>(n+1,vector<double>(n+1,-1)));
    
    // cout << x << " " << y << " " << z << '\n';
    cout << fixed << setprecision(12) << solve(x,y,z,n,dp) << '\n';
    
    return 0;
}


Measured memory_bytes: 216960
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) loopi(i,a)
#define loopi(i,a) for(int i=0; i<a; i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
 
using namespace std;
 
const int mod=1e9+7;
 
int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	ll t1,t2,a1,a2,b1,b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	ll diff=a1*t1+a2*t2-b1*t1-b2*t2;
	if(diff==0){
		cout << "infinity\n";
		return 0;
	}
	if(diff<0){
		swap(a1,b1);
		swap(a2,b2);
		diff*=-1;
	}
	if(a1>b1){
		cout << "0\n";
		return 0;
	}
	ll x=b1*t1-a1*t1;
	ll ans=1+2*((x-1)/diff);
	if(x%diff==0) ans++;
	cout << ans << "\n";
	return 0;
}


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

int main() {

  int A,B,C,tmp;
  cin >> A>>B>>C;
  if(A>=B){
    if(B<=C){
    	tmp = C;
      	C = B;
     	B = tmp;
	}
  }
  else{
   	 tmp = B;
     B = A;
     A = tmp;
   		if(B<=C){
        	tmp = C;
          	C = B;
          	B = tmp;

        }
   	}
   	if(A<=B){
	     tmp = B;
    	 B = A;
    	 A = tmp;
   	}
      cout << A*10 + B + C<< endl;
       

  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

s64 gcd(s64 x, s64 y)
{
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}

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

    int n;
    cin >> n;
    vs64 t(n);
    rep (i, n) cin >> t[i];

    s64 ans = 1;
    rep (i, n)
    {
        s64 g = gcd(t[i], ans);
        ans = g * (t[i] / g) * (ans / g);
    }

    cout << ans << "\n";
    return 0;
}



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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a + b == c || a + c == b || b + c == a)printf("Yes\n");
  else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int D;
  cin >> D;
  vector<int> down(27);
  for( int i = 1; i <= 26; i++ ) cin >> down[i];

  //各コンテストの満足度
  vector<vector<int>> contest(D+1, vector<int>(27));
  for( int i = 1; i <= D; i++ ){
    for( int j = 1; j <= 26; j++ ) cin >> contest[i][j];
  }

  vector<int> T(D+1);
  for( int i = 1; i <= D; i++ ) cin >> T[i];

  int M;
  cin >> M;
  for( int m = 0; m < M; m++ ){
    int day, q;
    cin >> day >> q;
    T[day] = q;
    vector<int> last(27);
    int now = 0;
    for( int d = 1; d <= D; d++ ){
      last[T[d]] = d;
      now += contest[d][T[d]];
      //満足度を下げる
      for( int i = 1; i <= 26; i++ ){
        now -= down[i]*(d-last[i]);
      }
    }
    cout << now << endl;
  }

  /*
  //各コンテストを最後に実施した日
  vector<int> last(27);

  int now = 0;
  for( int d = 1; d <= D; d++ ){
    last[T[d]] = d;
    now += contest[d][T[d]];
    //満足度を下げる
    for( int i = 1; i <= 26; i++ ){
      now -= down[i]*(d-last[i]);
    }
    cout << now << endl;
  }
  */

}


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

int main(){
    string s;
    cin >> s;
    int ans;
    if(s=="RRR") ans = 3;
    else if (s=="RRS") ans = 2;
    else if (s=="RSR") ans = 1;
    else if (s=="RSS") ans = 1;
    else if (s=="SRR") ans = 2;
    else if (s=="SRS") ans = 1;
    else if (s=="SSR") ans = 1;
    else ans = 0;

    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int numOfDigits(int n){
    int ans = 0;
    while(n){
        ans++;
        n /= 10;
    }
    return ans & 1;
}

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        ans += numOfDigits(i);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf=1e9+7;
int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='+') ans++;
		else ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
n = len(s)

case1 = []
case2 = []
now = 0
for i in range(n):
    c = '0' if now else '1'
    case1.append(c)
    c = '1' if c == '0' else '0'
    case2.append(c)
    now = 1 - now

case1 = "".join(case1)
case2 = "".join(case2)

res1, res2 = 0, 0
for i in range(n):
    res1 += 1 if case1[i] != s[i] else 0
    res2 += 1 if case2[i] != s[i] else 0

print(min(res1, res2))


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B, C, K; cin >> A >> B >> C >> K;
    if (A >= K){
        cout << K << endl;
    } else if ((A + B) >= K){
        cout << A << endl;
    } else {
        cout << A - (K - A - B) << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <ctype.h>
int main(){
  int i;
  while((i=getchar())!=EOF){
    if(isupper(i))i=tolower(i);
    else i=toupper(i);
    putchar(i);
    if(i=='\n')break;
  }
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<tuple<string, int, int>> G;
    string S;
    int P;
    for(int i = 0;i < N;i++) {
        cin >> S >> P;
        G.push_back(make_tuple(S, -P, i));
    }
    sort(G.begin(), G.end());
    for(int i = 0;i < N;i++) {
        cout << get<2>(G.at(i)) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <climits>
#include <vector>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	//return n; }
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

#define v vector
struct graph {
	struct node {int n, w;};
	v<v<node>> nodes;

	void read(int n) {
		nodes.resize(n);
		for (auto &x: nodes) {
			in();
			for (int k = in(); k--;) {
				int c = in();
				x.push_back({c, in()});
			}
		}
	}

	v<node> dks() {
		v<node> w(nodes.size(), {0, INT_MAX});
		w[0].w = 0;
		priority_queue<node> q;
		q.push({0, 0});
		while (!q.empty()) {
			node n = q.top();
			q.pop();
			if (w[n.n].n)
				continue;
			w[n.n].n = 1;
			for (node &x: nodes[n.n]) {
				w[x.n].w = min(w[x.n].w, n.w + x.w);
				q.push({x.n, w[x.n].w});
			}
		}
		return move(w);
	}
};

bool operator < (const graph::node &a, const graph::node &b) {
	return a.w > b.w;
}

int main() {
	graph g;
	g.read(in());
	int i = 0;
	for (auto &x: g.dks())
		out(i++, ' ', x.w, '\n');
}



Measured memory_bytes: 2600
#include <stdio.h>
#include <iostream>
#include <vector>
 
using namespace std;
 
long long MAX = 1000000000000000000;
 
int main(){
 
    int n;
 
    cin >> n;
 
    vector<long long> list;
 
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        list.push_back(a);
    }
 
    long long mult = 1;
    int count = 0;
    long long current = list[count];

    // cout << mult << "  " << MAX << endl;
 
    while(count < n && MAX >= 1){
        if(current == 0){
            cout << 0 << endl;
            return 0;
        }
        MAX /= current;
        mult *= current;
        count++;
        if(count < n)
            current = list[count];
        // cout << current << " " << MAX <<  endl;
    }

    while(count < n){
        if(list[count] == 0){
            cout << 0 << endl;
            return 0;
        }
        count++;
    }

    if(MAX < 1){
        cout << -1 << endl;
    }
    else{
        cout << mult << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 4256
import copy
H,W = map(int,input().split())
A = [list(input().strip()) for _ in range(H)]
while True:
    flag = 0
    for i in range(len(A)-1,-1,-1):
        fr = 0
        for j in range(len(A[0])):
            if A[i][j]=="#":
                fr = 1
                break
        if fr==0:
            B = [[0 for _ in range(len(A[0]))] for _ in range(len(A)-1)]
            for i1 in range(len(A)):
                if i1<i:
                    for j1 in range(len(A[0])):
                        B[i1][j1] = A[i1][j1]
                elif i1>i:
                    for j1 in range(len(A[0])):
                        B[i1-1][j1] = A[i1][j1]
            A = copy.deepcopy(B)
            flag = 1
    for j in range(len(A[0])-1,-1,-1):
        fc = 0
        for i in range(len(A)):
            if A[i][j]=="#":
                fc=1
                break
        if fc==0:
            B = [[0 for _ in range(len(A[0])-1)] for _ in range(len(A))]
            for j1 in range(len(A[0])):
                if j1<j:
                    for i1 in range(len(A)):
                        B[i1][j1] = A[i1][j1]
                elif j1>j:
                    for i1 in range(len(A)):
                        B[i1][j1-1] = A[i1][j1]
            A = copy.deepcopy(B)
            flag = 1
    if flag==0:break
for i in range(len(A)):
    print("".join(A[i]))

Measured memory_bytes: 73944
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll f[200000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    f[0] = 1;
    rep(i, 1, 200000){
        f[i] = f[i - 1] * i % mod;
    }
    
    ll N, M;
    cin >> N >> M;
    
    if(N == M){
        output((f[N] * f[M] % mod) * 2 % mod);
    }
    else if(abs(N - M) == 1){
        output(f[N] * f[M] % mod);
    }
    else{
        output(0);
    }
    
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=n1;i<(int)(n2);i++)
using namespace std;

signed main()
{
  int N;
  cin >> N;
  std::vector<long double> H(N);
  Rep(i, N) cin >> H[i];

  long double S;
  S = 0;
  Rep(i, N) S += 1/H[i];

  cout << 1/S;
  return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef long long Int;
typedef struct Value {
    Int v;
    bool b;
} Value;

int desc(const void *v1, const void *v2) {
    return ((Value *)v2)->v - ((Value *)v1)->v;
}
int main() {
    Int n, h;
    scanf("%lld %lld", &n, &h);
    Value *values = (Value *)malloc(2 * n * sizeof(Value));
    for (int i = 0; i < n; i++) {
        Int a, b;
        scanf("%lld %lld", &a, &b);
        Value v1 = {.v = a, .b = false};
        Value v2 = {.v = b, .b = true};
        values[2 * i] = v1;
        values[2 * i + 1] = v2;
    }
    qsort(values, 2 * n, sizeof(Value), desc);
    Int ans = 0;
    Int i = 0;
    while (h > 0) {
        Value value = values[i];
        if (value.b) {
            h -= value.v;
            ans++;
            i++;
        } else {
            Int q = h / value.v;
            Int r = h % value.v;
            if (r > 0) q++;
            ans += q;
            break;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 8304
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	int slen = s.length();
	int ans = 1000;
	for(int i = 0; i<slen; i++) {
	    char mark = s.charAt(i);
	    int curlen = slen;
	    char[] curr = s.toCharArray();
	    int locnt = 0;
	    while(curlen > 0 && !isSame(curlen, curr)) {
		for(int j = 0; j<curlen-1; j++) {
		    if(curr[j] == mark || curr[j+1] == mark) curr[j] = mark;
		}
		locnt++;
                curlen--;
	    }
	    ans = Math.min(locnt, ans);
	}
	System.out.println(ans);
    }

    public static boolean isSame(int curlen, char[] curr) {
	char mark = curr[0];
	for(int i = 1; i<curlen; i++) if(curr[i]!=mark) return false;
	return true;
    }
}



Measured memory_bytes: 23892
from collections import deque
N = int(input())
H = deque(map(int, input().split()))
ans = 0
n = 0
tmp = H.popleft()
while H:
  nxt = H.popleft()
  if tmp >= nxt:
    n += 1
    ans = max(ans, n)
  else:
    n = 0
  tmp = nxt
print(ans)

Measured memory_bytes: 14636
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        int N;
            cin >> N;
        vector<int> A(N);
        int flag = 0;
            for(int i = 0; i < N; i++){
                cin >> A.at(i);
            }
                for(int j = 0; j < N; j++){
                    if(A.at(j) % 2 == 0){
                        if(A.at(j) % 3 == 0 || A.at(j) % 5 == 0){
                            
                        }else{
                            cout << "DENIED" << endl;
                                return 0;
                        }
                    }
                }
                    cout << "APPROVED" << endl;
    return 0;}


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

// 1桁: 1         2         3         ... 9      10
// 2桁: 10 11 12  21 22 23  32 33 34  ... 98 99  100 101

void print_queue(std::queue<long> q) {
  while (!q.empty()) {
    std::cout << q.front() << " ";
    q.pop();
  }
  std::cout << std::endl;
}

int solve1() {
  int k;
  std::cin >> k;
  std::vector<long long> a;
  for (int i = 1; i <= 9; ++i)
    a.push_back(i);

  while (true) {
    if (k <= a.size()) {
      std::cout << a[k - 1] << std::endl;
      return 0;
    }
    k -= a.size();

    std::vector<long long> old;
    std::swap(old, a);
    for (auto x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
          continue;
        a.push_back(x * 10 + d);
      }
    }
  }
}

int solve2() {
  int k;
  std::cin >> k;
  std::queue<long> a;
  for (int i = 1; i <= 9; ++i)
    a.push(i);

  while (true) {
    long d = a.front();
    if (k <= 1) {
      std::cout << d << std::endl;
      return 0;
    }
    a.pop();
    for (int i = -1; i <= 1; ++i) {
      int m = d % 10 + i;
      if (m < 0 || m > 9)
        continue;
      a.push(d * 10 + m);
    }
    k--;
  }
}

int main(int argc, char *argv[]) { solve2(); }


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
  int data[10];
  int i,m,temp;
  for(i=0;i<=9;i++){
    scanf("%d",&data[i]);
  }
  
  for(i=0;i<=10-1;i++){
    for(m=10-1;m>i;m--){
      if(data[m-1]<data[m]){
	temp=data[m-1];
	data[m-1]=data[m];
	data[m]=temp;
      }
    }
  }
  
  for(i=0;i<=2;i++){
    printf("%d\n",data[i]);
  }
  return 0;
}

Measured memory_bytes: 0
n,k,c = list(map(int, input().split(' ')))
s = input().strip()

froml = list(s)
fromr = list(s)

count = 0
pre = - (c + 1)
for i in range(n):
    if count == k:
        break
    if s[i] == 'o' and i - pre > c:
        froml[i] = str(count)
        pre = i
        count += 1

count = k - 1
pre = n + c
for i in range(n - 1, -1, -1):
    if count < 0:
        break
    if s[i] == 'o' and pre - i > c:
        fromr[i] = str(count)
        pre = i
        count -= 1

for i in range(n):
    if froml[i].isdigit() and froml[i] == fromr[i]:
        print('{} '.format(i + 1))




Measured memory_bytes: 85464
import sys
from heapq import heappop, heappush


class SegTreeMin:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_min: 区間[l, r)の最小値を得る
    """

    def __init__(self, n, INF):
        """
        :param n: 要素数
        :param INF: 初期値（入りうる要素より十分に大きな数）
        """
        n2 = 1 << (n - 1).bit_length()
        self.offset = n2
        self.tree = [INF] * (n2 << 1)
        self.INF = INF

    @classmethod
    def from_array(cls, arr, INF):
        ins = cls(len(arr), INF)
        ins.tree[ins.offset:ins.offset + len(arr)] = arr
        for i in range(ins.offset - 1, 0, -1):
            l = i << 1
            r = l + 1
            ins.tree[i] = min(ins.tree[l], ins.tree[r])
        return ins

    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.offset
        self.tree[i] = x
        while i > 1:
            y = self.tree[i ^ 1]
            if y <= x:
                break
            i >>= 1
            self.tree[i] = x

    def get_min(self, a, b):
        """
        [a, b)の最小値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        result = self.INF

        l = a + self.offset
        r = b + self.offset
        while l < r:
            if r & 1:
                result = min(result, self.tree[r - 1])
            if l & 1:
                result = min(result, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1

        return result


n, *ppp = map(int, sys.stdin.buffer.read().split())
INF = 10 ** 18
indices = [0] * (n + 1)
even_p = [INF] * n
odd_p = [INF] * n
for i, p in enumerate(ppp):
    indices[p] = i
    if i % 2 == 0:
        even_p[i] = p
    else:
        odd_p[i] = p

sgt0 = SegTreeMin.from_array(even_p, INF)
sgt1 = SegTreeMin.from_array(odd_p, INF)
sgt = [sgt0, sgt1]
ans = []
heap = []
data = {}
first_p = sgt0.get_min(0, n)
i = indices[first_p]
first_q = sgt1.get_min(i, n)
j = indices[first_q]
heap.append(first_p)
data[first_p] = (first_q, 0, n, i, j)
while heap:
    p = heappop(heap)
    q, l, r, i, j = data.pop(p)
    ans.append(p)
    ans.append(q)
    if l < i:
        k = l % 2
        np = sgt[k].get_min(l, i)
        ni = indices[np]
        nq = sgt[k ^ 1].get_min(ni, i)
        nj = indices[nq]
        heappush(heap, np)
        data[np] = (nq, l, i, ni, nj)
    if i + 1 < j:
        k = (i + 1) % 2
        np = sgt[k].get_min(i + 1, j)
        ni = indices[np]
        nq = sgt[k ^ 1].get_min(ni, j)
        nj = indices[nq]
        heappush(heap, np)
        data[np] = (nq, i + 1, j, ni, nj)
    if j + 1 < r:
        k = (j + 1) % 2
        np = sgt[k].get_min(j + 1, r)
        ni = indices[np]
        nq = sgt[k ^ 1].get_min(ni, r)
        nj = indices[nq]
        heappush(heap, np)
        data[np] = (nq, j + 1, r, ni, nj)

print(*ans)


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

int main ()
{
	int N;
	scanf ("%d", &N);
	int ans=0;
	for (int i=N; i>0; i--){
		if (N/100000 < 1 && N/10000 > 0 && N > 0) ans++;
		if (N/1000 < 1 && N/100 > 0 && N > 0) ans++;
		if (N/10 < 1 && N > 0) ans++;
		N--;
	}
	printf ("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	String a = sc.next();
        String b = "";
        String data[] = a.split("");
        	for(int i = 0;data.length > i;i++){
              if(i == 3){
                data[i] = "8";
                b=b+data[i];
                
              }else{
                b=b+data[i];
              }
            }
        System.out.println(b);
    }
}


Measured memory_bytes: 23764
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
char s[201];
signed main(void)
{
	reg int ans=0;
	scanf("%s",s+1);
	reg int len=strlen(s+1);
	for(int i=1;i<=len/2;++i)
		if(s[i]!=s[len-i+1])
			++ans;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256