akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1005,INF=1<<30;
int par[MAX],size[MAX],ma[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
        ma[i]=0;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b,int cost){
    if(root(a)!=root(b)){
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
        ma[root(a)]=cost;
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

struct edge{
    int from;
    int to;
    int cost;
    bool use;
};

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;ll X;cin>>N>>M>>X;
    init(N);
    
    vector<edge> S(M);
    for(int i=0;i<M;i++){
        cin>>S[i].from>>S[i].to>>S[i].cost;
        S[i].from--;
        S[i].to--;
    }
    sort(all(S),[](edge a,edge b){
        return a.cost<b.cost;
    });
    ll sum=0,can=N-1,waste=0;
    
    for(int i=0;i<M;i++){
        int a=S[i].from,b=S[i].to,c=S[i].cost;
        if(check(a,b)){
            if(ma[root(a)]==c){
                can++;
                S[i].use=1;
            }else{
                waste++;
            }
        }else{
            unite(a,b,c);
            sum+=c;
            S[i].use=1;
        }
    }
    
    if(sum>X){
        cout<<0<<endl;
    }else if(sum==X){
        cout<<(rui(2,can)-2)*rui(2,waste)%mod<<endl;
    }else{
        ll ans=0,musi=0,cnt=0;
        
        for(int i=0;i<M;i++){
            if(S[i].use) continue;
            
            sum=0;
            can=N-1;
            waste=0;
            init(N);
            unite(S[i].from,S[i].to,0);
            sum+=S[i].cost;
            
            for(int j=0;j<M;j++){
                int a=S[j].from,b=S[j].to,c=S[j].cost;
                if(i==j) continue;
                if(check(a,b)){
                    if(ma[root(a)]==c){
                        can++;
                    }else{
                        waste++;
                    }
                }else{
                    unite(a,b,c);
                    sum+=c;
                    S[j].use=1;
                }
            }
            
            //cout<<sum<<endl;
            
            if(sum>X) musi++;
            else if(sum==X) cnt++;
        }
        
        cout<<(rui(2,cnt)-1)*rui(2,musi+1)%mod<<endl;
        
    }
}


Measured memory_bytes: 256
N = int(input())
l = []

for i in range(N):
    store,rank = map(str, input().split())
    number = i+1
    l.append([store,int(rank),number])

sorted_list = sorted(l, key=lambda x:(x[0],-x[1]))
for i in range(N):
    print(sorted_list[i][2])


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 MOD = 1e9 + 7;
const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}
ll intceil(ll a, ll b) {
   if (a == 0) return 0;
   if (b == 0) return -1;
   ll ret = a / b;
   if (a % b != 0) ret += 1;
   return ret;
}

int main() {
   int N, M, L;
   cin >> N >> M >> L;
   ll dp[N][N];
   fill(dp[0], dp[N], INF);

   for (int i = 0; i < N; i++) {
      dp[i][i] = 0;
   }

   int a, b;
   ll c;
   for (int i = 0; i < M; i++) {
      cin >> a >> b >> c;
      a--;
      b--;
      dp[a][b] = c;
      dp[b][a] = c;
   }
   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
            if (dp[i][k] == INF || dp[k][j] == INF) continue;
            dp[i][j] = llmin(dp[i][j], dp[i][k] + dp[k][j]);
         }
      }
   }
   /*
   for (int i = 0; i < V; i++) {
      if (dp[i][i] < 0) {
         cout << "NEGATIVE CYCLE" << endl;
         return 0;
      }
   }
   */
   ll dp2[N][N];
   fill(dp2[0], dp2[N], INF);

   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         if (dp[k][i] <= L) {
            dp2[k][i] = 1;
            dp2[i][k] = 1;
         }
      }
   }
   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
            if (dp2[i][k] == INF || dp2[k][j] == INF) continue;
            dp2[i][j] = llmin(dp2[i][j], dp2[i][k] + dp2[k][j]);
         }
      }
   }

   int Q;
   cin >> Q;
   int s, t;
   for (int i = 0; i < Q; i++) {
      cin >> s >> t;
      s--;
      t--;
      if (dp2[s][t] == INF) cout << "-1" << endl;
      else cout << dp2[s][t] - 1<< endl;
   }
   return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)
using namespace std;
int p[20][20];
int main()
{
	int n, d; scanf("%d%d", &n, &d);
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= d; j++)
        {
            scanf("%d", &p[i][j]);
        }
    }
    int ans = 0;
    for (int i = 1; i < n; i++)
        for (int j = i + 1; j <= n; j++)
        {
            int tmp = 0;
            for (int k = 1; k <= d; k++) tmp += (p[i][k] - p[j][k]) * (p[i][k] - p[j][k]);
            int sq = sqrt(tmp);
            if (sq * sq == tmp) ans++;
        }
    printf("%d\n", ans);
	return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

int gcd(int a, int b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

signed main()
{
	int n;
	cin >> n;

	vi a(n);
	rep(i, 0, n){
		cin >> a[i];
	}

	vi pre(n), suf(n);
	pre[0] = a[0];
	suf[n-1] = a[n-1];
	rep(i, 1, n) pre[i] = gcd(pre[i-1], a[i]);
	rep(i, 1, n) suf[n-1-i] = gcd(suf[n-i], a[n-1-i]);

	int ans = max(suf[1], pre[n-2]);
	rep(i, 1, n-1){
		chmax(ans, gcd(pre[i-1], suf[i+1]));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2560
#ABC087B - Coins
"""全探索でいける？"""
a = int(input())#500
b = int(input())#100
c = int(input())#50
x = int(input())#金額
 
ans = 0
 
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x == (i*500 + j*100 + k*50):
                ans += 1
 
print(ans)

Measured memory_bytes: 3060
//
// Created by Chmie on 2020/1/31.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    long long as=a.size();
    cout<<a[0];
    cout<<as-2;
    cout<<a[as-1]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <string.h>
#include <algorithm>

#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

static void Handstand();

int main()
{

	Handstand();

	fflush(stdout);
	return 0;
}

class SwitchPoint
{
public:
	char status;
	int manCnt;


	SwitchPoint() { Init(); }
	~SwitchPoint() {}
	void Init() {
		status = 0; manCnt = 0;
	}
};

static void Handstand()
{
	static char szS[100000] = { 0 };
	int N = 0, K = 0;

	scanf(" %d %d", &N, &K);
	scanf(" %s", szS);


	//	先頭
	SwitchPoint sp;
	sp.manCnt = 1;
	sp.status = szS[0];

	std::vector<SwitchPoint> vSp;
	vSp.push_back(sp);

	for (int i = 1; i < N; i++) {
		if (sp.status != szS[i]) {
			sp.status = szS[i];
			sp.manCnt = i + 1;

			vSp.push_back(sp);
		}
	}

	//	番兵的な
	if (sp.status == '0') {
		sp.status = '1';
	}
	else {
		sp.status = '0';
	}
	sp.manCnt = N + 1;
	vSp.push_back(sp);

	int lastIdx = 0;
	int rvsCnt = 0;
	int maxCnt = 0;
	int spCnt = vSp.size();
	for (int i = 0; i < spCnt; i++) {
		if (vSp[i].status == '0') {
			lastIdx = i + (2 * K);
		}
		else {
			lastIdx = i + (2 * K) + 1;
		}
		if (lastIdx >= spCnt) {
			lastIdx = spCnt - 1;
		}
		rvsCnt = vSp[lastIdx].manCnt - vSp[i].manCnt;
		if (maxCnt < rvsCnt) {
			maxCnt = rvsCnt;
		}
	}
	printf("%d\n", maxCnt);
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll kari[12345678], test[12345678];
signed main() {
	ll n, k, cnt = 0; string s, t;
	cin >> n >> k;
	for (int h = 0; h < n; h++) {
		cin >> test[h]; kari[h] = test[h];
	}
	for (int h = 0; h < k; h++) {
		vector<ll> a(n + 2); ll z = 0;
		for (int i = 0; i < n; i++) {
			a[max((ll)0, i - kari[i])]++;
			a[min((ll)n + 1, i + kari[i] + 1)]--;
		}
		for (int i = 0; i < n; i++) {
			if (i > 0) { a[i] += a[i - 1]; }
			test[i] = a[i];
		}
		for (int i = 0; i < n; i++) {
			kari[i] = test[i];
			if (test[i] != n) { z++; }
		}
		if (z == 0) { break; }
	}
	cout << test[0];
	for (int i = 1; i < n; i++) {
		cout << ' ' << test[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 8216
//2019.5.13 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
const int N=2e5+10;
namespace MAIN {
    struct E{
        int next,to;
        E() {}
        E(res next,res to):next(next),to(to) {}
    }edge[N<<1];
    int n,head[N],cnt,sg[N],dep[N],mx,ID;
    inline void addedge(const res &u,const res &v){
        edge[++cnt]=E(head[u],v),head[u]=cnt;
        edge[++cnt]=E(head[v],u),head[v]=cnt;
    }
    void dfs(res x,res fax,res depx){
        dep[x]=depx;
        if(dep[x]>dep[mx])mx=x;
        for(res i=head[x];~i;i=edge[i].next){
            res tox=edge[i].to;
            if(tox==fax)continue;
            dfs(tox,x,depx+1);
        }
    }
    inline void MAIN(){
        n=read(),sg[1]=1,sg[2]=0;
        for(res i=1;i<=n;i++)head[i]=-1;
        for(res i=3;i<=n;i++)sg[i]=min(sg[i-1],sg[i-2])^1;
        for(res i=1;i<n;i++){
            res u=read(),v=read();
            addedge(u,v);
        }
        dfs(1,0,1),ID=mx,mx=0,dfs(ID,0,1),puts(sg[dep[mx]]?"First":"Second");
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if ((i & 1) == 0 && (j & 1) == 1) {
                ++ans;
            }
            else if ((i & 1) == 1 && (j & 1) == 0) {
                ++ans;
            }
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;


int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
  }

  int s, t;
  cin >> s >> t;
  --s; --t;

  vector<vector<int>> dist(n, vector<int>(3, INF));
  queue<P> q;
  q.emplace(s, 0);
  dist[s][0] = 0;

  while (!q.empty()) {
    int v, c;
    tie(v, c) = q.front(); q.pop();
    int ndist = dist[v][c] + 1;
    int nc = (c + 1) % 3;

    for (int u : to[v]) {
      if (ndist >= dist[u][nc]) continue;
      dist[u][nc] = ndist;
      q.emplace(u, nc);
    }
  }

  int ans = dist[t][0] != INF ? dist[t][0] / 3 : -1;

  cout << ans << endl;
}

Measured memory_bytes: 14012
x,y = map(int,input().split())
if x * y == 1:
    print(1000000)
elif x*y == 2:
    print(500000)
elif x == 2 and y == 2:
    print(400000)
elif x*y == 3:
    print(400000)
elif x == 1 or y == 1:
    print(300000)
elif x == 2 and y == 3:
    print(300000)
elif x == 3 and y == 2:
    print(300000)
elif x == 3 and y == 3:
    print(200000)
elif x ==2 or y == 2:
    print(200000)
    
elif x == 3 or y == 3:
    print(100000)
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int P[N];
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    P[tmp] = i;
  }
  set<int> st;
  auto bef1=st.begin(), bef2=st.begin(), aft1=st.begin(), aft2=st.begin(), now=st.begin();
  int bef11, bef22, aft11, aft22;
  ll ans = 0;
  for(ll i=N;i>0;--i){
    st.insert(P[i]);
    if(i==N) continue;
    now = st.find(P[i]);
    if(now!=st.begin()) {
      bef1 = prev(now);
      bef11 = *bef1;
    }
    else {
      bef1 = st.begin();
      bef11 = -1;
    }
    if(bef1!=st.begin()) {
      bef2 = prev(bef1);
      bef22 = *bef2;
    }
    else {
      bef2 = st.begin();
      bef22 = -1;
    }
    if(now!=prev(st.end())) {
      aft1 = next(now);
      aft11 = *aft1;
    }
    else {
      aft1 = prev(st.end());
      aft11 = N;
    }
    if(aft1!=prev(st.end())) {
      aft2 = next(aft1);
      aft22 = *aft2;
    }
    else {
      aft2 = prev(st.end());
      aft22 = N;
    }
    ans += i * (aft22-aft11) * (*now-bef11) + i * (bef11 - bef22) * (aft11 - *now);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 8656
package main

import (
	"fmt"
)

func main() {
	var S string

	fmt.Scanln(&S)

	switch S {
	case "Sunny":
		fmt.Print("Cloudy")
	case "Cloudy":
		fmt.Print("Rainy")
	case "Rainy":
		fmt.Print("Sunny")
	}
}


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

static const int nums[32] = {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};

int main() {
  int k;
  scanf("%d", &k);
  printf("%d\n", nums[k - 1]);

  return 0;
}

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

class Program
{
    public void Proc()
    {
        string[] inpt = Console.ReadLine().Split(' ');
        int a = int.Parse(inpt[0]);
        int b = int.Parse(inpt[1]);

        string kigo = "";
        if(a == b)
        {
            kigo = "==";
        } else if(a > b)
        {
            kigo = ">";
        } else
        {
            kigo = "<";
        }
        Console.WriteLine("a " + kigo + " b");
    }



    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 8812
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	private final static long[] _753 = {7L, 5L, 3L};

	public static void main(String[] args) {

		Scanner sysin = new Scanner(System.in);
		final long n = sysin.nextLong();
		sysin.close();

		// nの桁数を計算
		int r = 1;
		{
			long v = n;
			while (v > 10) {
				v /= 10;
				r++;
			}
		}

		// n桁の7.5.3で構成された数値を作る
		List<Long> shichigosan = new ArrayList<>();
		List<Long> shichigosan_now = new ArrayList<>();
		List<Long> shichigosan_before = Arrays.stream(_753).boxed().collect(Collectors.toList());
		for (int i = 1; i < r; i++) {
			shichigosan_now.clear();
			for (long lb : shichigosan_before) {
				for (long la : _753) {
					shichigosan_now.add(lb * 10 + la);
				}
			}
			shichigosan_before.clear();
			shichigosan_before.addAll(shichigosan_now);
			shichigosan.addAll(shichigosan_now);
		}

		// n以下で、7.5.3を含む数値の個数を出力する
		System.out.println(
			shichigosan.stream()
			.filter(e -> e <= n)
			.map(String::valueOf)
			.filter((String s) -> {
				boolean result = true;
				for (long l : _753) {
					result &= s.contains(Long.toString(l));
				}
				return result; })
			//.peek(System.out::println)
			.count()
		);
	}
}


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

int main(){
   int s,w;
   cin >> s >> w;
   if(s <= w) cout << "unsafe" << endl;
   else cout << "safe" << endl;
   return 0;
}


Measured memory_bytes: 3636
/*=======================
Author    : Shounak Dey
Filename  : c.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	ll x;
	cin >> x;
	ll res = x-1;
	ll curr=2;
	while((curr*curr)<=x){
		if((x%curr)!=0){
			curr++;
			continue;
		}
		res = min(res,curr-1 + (x/curr)-1);
		curr++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
function main(){
  var debt = 100000;
 
  for(var i = 0; i < input[0]-0; i++){
    debt = Math.ceil((debt * 1.05)/1000) * 1000;
  }

  console.log(debt);
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 7644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

#include <deque>

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    Cins(int, n, b);
    ll c1 = 0, c2 = 0, c = 0;
    For(i, n){
        c += b[i]-a[i];
        if(a[i] > b[i]) c1 += a[i]-b[i];
        if(a[i] < b[i]){
            c2 += (b[i]-a[i]+1)/2;
            if(b[i]-a[i] % 2 == 1) c1 ++;
        }
    }
    CoutYn(max(c1, c2) <= c);
}





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

namespace AtCoderConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            // 標準入力から1行取得
            string input = Console.ReadLine();

            // 年齢を取得
            int age = int.Parse(input);

            // 出力文字列を宣言
            string output = "";

            // 7歳、5歳、3歳のいずれかの場合YES、そうでない場合NO
            if(age == 7 || age == 5 || age == 3)
            {
                output = "YES";
            }
            else
            {
                output = "NO";
            }

            // 標準出力に出力
            Console.WriteLine(output);
        }
    }
}

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

int main(){
    string s;
    cin >> s;

    if(s == "SUN"){
        cout << 7 << endl;
        return 0;
    }

    if(s == "MON"){
        cout << 6 << endl;
        return 0;
    }

    if(s == "TUE"){
        cout << 5 << endl;
        return 0;
    }

    if(s == "WED"){
        cout << 4 << endl;
        return 0;
    }

    if(s == "THU"){
        cout << 3 << endl;
        return 0;
    }

    if(s == "FRI"){
        cout << 2 << endl;
        return 0;
    }

    if(s == "SAT"){
        cout << 1 << endl;
        return 0;
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(), d.end());
  
  if(n%2) cout << 0 << endl;
  cout << d[n/2]-d[n/2-1] << endl;
  return 0;
}


Measured memory_bytes: 768
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
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 n = read::<usize>();
    let k = read::<usize>();
    let mut g = vec![vec![]; n];
    let mut sum = 0;
    let mut m = 0;
    for from in 1..n {
        g[0].push(from);
        m += 1;
        for to in from + 1..n {
            if sum < k {
                sum += 1;
            } else {
                g[from].push(to);
                m += 1;
            }
        }
    }
    if sum != k {
        println!("-1");
    } else {
        println!("{}", m);
        for from in 0..n {
            for &to in g[from].iter() {
                println!("{} {}", from + 1, to + 1);
            }
        }

    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
	string s;
	cin>>s;
	int n = s.length();
	int r = 0;
	for(int i=0;i<n;i++){
		int x = s[i]-'0';
		r = (r+x)%9;
	}
	if(r==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int main() {

	string a, b;
	cin >> a >> b;

	b.erase(--b.end());
	if (a == b) {
		cout << "Yes" << endl;
	}
	else {

		cout << "No" << endl;
	}

	return 0;

}




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

int main() {
  string S,T,U;
  cin >> S >> T;
  int A,B;
  cin >> A >> B >> U;
  if(S==U) {
    cout << A-1 << " " << B << endl;
  }
  else {
    cout << A << " " << B-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
N, K = map(int, input().split())
*A, = map(int, input().split())
A = [a-1 for a in A]

# Douling(ダブリング)
i = 1
to = [[a for a in A]]
while pow(2, i) < K:
    t = [to[i-1][to[i-1][j]] for j in range(N)]
    to.append(t)
    i += 1

i -= 1
ans = 0
while i >= 0:
    if K & (1 << i) > 0:
        ans = to[i][ans]
    i -= 1
print(ans+1)

Measured memory_bytes: 217944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Globalization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans = new int[51];
            var tmp = new int[2];
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            for(int i = 0; i < a[1]; i++)
            {
                tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ans[tmp[0]-1]++;
                ans[tmp[1]-1]++;
            }

            for (int i = 0; i < a[0]; i++)
            {
                Console.WriteLine(ans[i]);
            }



        }
    }
}


Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int a = Integer.parseInt(sa[1]);
		int b = Integer.parseInt(sa[2]);
		br.close();

		if (n < a + b - 1 || (long) a * b < n) {
			System.out.println(-1);
			return;
		}

		StringBuilder sb = new StringBuilder();
		int rem = b;
		int start = 0;
		int end = n;
		while (rem > 0) {
			start = Math.max(end - a + 1, rem);
			for (int i = start; i <= end; i++) {
				sb.append(i).append(' ');
			}
			end = start - 1;
			rem--;
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


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

using namespace std;

const int INF = 1LL << 30;

int main()
{
  int T;

  cin >> T;
  while(T--) {
    int N, D;
    cin >> N >> D;

    multiset< int > val;
    val.insert(D);
    for(int i = 0; i < N - 1; i++) {
      int k = *val.begin();
      val.erase(val.begin());
      val.insert(k ^ 127);
      val.insert(127);
    }
    cout << accumulate(begin(val), end(val), 0) << 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 std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

bool a[100001];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x;
		x--;
		if(x==i) a[i]=1;
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(a[i])
		{
			if(i+1<n&&a[i+1])
			{
				a[i]=0;
				a[i+1]=0;
				cnt++;
			}
			else
			{
				a[i]=0;
				cnt++;
			}
		}
	}
	cout<<cnt<<'\n';
}


Measured memory_bytes: 384
def base_convert(nl, ibase, obase):
    o = []
    while any(nl):
        c = 0
        for i in range(len(nl)):
            c = c * ibase + nl[i]
            nl[i],c = divmod(c,obase)
        o.append(c)
    o.reverse()
    return o

def convertList(lst):
    rev_lst = list(reversed(lst))
    for i,num in enumerate(rev_lst):
        if i < len(rev_lst)-1:
            if num <= 0:
                rev_lst[i+1] = rev_lst[i+1]-1
                rev_lst[i] = rev_lst[i] + 26
    return list(reversed(rev_lst))

dict1 = {
    0: '',
    1: 'a',
    2: 'b',
    3: 'c',
    4: 'd',
    5: 'e',
    6: 'f',
    7: 'g',
    8: 'h',
    9: 'i',
    10: 'j',
    11: 'k',
    12: 'l',
    13: 'm',
    14: 'n',
    15: 'o',
    16: 'p',
    17: 'q',
    18: 'r',
    19: 's',
    20: 't',
    21: 'u',
    22: 'v',
    23: 'w',
    24: 'x',
    25: 'y',
    26: 'z'
}

N = input()
N = list(map(int,[i for i in N]))
lst = base_convert(N,10,26)
lst_converted = convertList(lst)
ans = ''.join([dict1[i] for i in lst_converted])
print(ans)

Measured memory_bytes: 9292
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i--)
#define fir first
#define sec second
#define tct template<class type>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int maxn = 185, mod = 1e9 + 7;
int n, m, a[maxn + 5][maxn + 5], f[maxn + 5][17][maxn + 5][maxn + 5];
char s[maxn + 5][maxn + 5];

inline void red(int &x) { x += x >> 31 & mod; }
tct inline void cmax(type &x, type y) { x < y ? x = y : 0; }
tct inline void cmin(type &x, type y) { x > y ? x = y : 0; }

int sum(int u, int d, int l, int r) {
	return a[u][l] + a[d][r] - a[u][r] - a[d][l];
}

bool ok(int u, int d, int l, int r) {
	int x = sum(u, d, l, r);
	return x == 0 || x == (d - u) * (r - l);
}

int main() {
	scanf("%d %d", &n, &m);
	rep(i, 1, n) {
		scanf("%s", s[i] + 1);
		rep(j, 1, m) a[i][j] = s[i][j] == '#';
		rep(j, 1, m) a[i][j] += a[i][j - 1];
	}
	rep(i, 1, n) rep(j, 1, m) a[i][j] += a[i - 1][j];
	rep(l, 0, m - 1) rep(r, l + 1, m) rep(i, 0, 16) f[0][i][l][r] = 0;
	rep(i, 1, n) {
		rep(l, 0, m - 1) rep(r, l + 1, m) {
			f[i][0][l][r] = ok(i - 1, i, l, r) ? (s[i][r] == s[i - 1][r]) * f[i - 1][0][l][r] + 1 : 0;
		}
		rep(j, 1, 16) {
			rep(k, 0, m) f[i][j - 1][k][k] = i;
			rep(l, 0, m - 1) {
				int x = l;
				rep(r, l + 1, m) {
					while (x < r - 1 && f[i][j - 1][l][x + 1] >= f[i][j - 1][x + 1][r]) x++;
					f[i][j][l][r] = max(f[i][j - 1][l][r] + f[i - f[i][j - 1][l][r]][j - 1][l][r], max(f[i][j - 1][x][r], f[i][j - 1][l][x + 1]));
				}
			}
		}
	}
	rep(i, 0, 16) if (f[n][i][0][m] >= n) printf("%d\n", i), exit(0);
	return 0;
}

Measured memory_bytes: 449800
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%10==3){
    cout<<"bon"<<endl;
  }else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout<<"pon"<<endl;
  }else{
    cout<<"hon"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3612
abk = input().split()
a = int(abk[0])
b = int(abk[1])
k = int(abk[2])
if(a+b<=k):
    a = 0
    b =0
elif(a>=k):
    a = a-k
elif(a+b>=k):
    b = a + b- k
    a = 0
print(a,b)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i < (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)


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

  i64 N, A, B, i, j;
  cin >> N;
  vector<string> S(N);
  getchar();
  REP(0, N, i) {
    getline(cin, S[i]);
  }

  i64 ans = 0;
  B = 0;
  REP(0, N, A){
    bool flag = true;
    REP(0, N, i) {
      REP(0, N, j) {
	i64 i1, j1, i2, j2;
	i1 = (i - A + N) % N;
	j1 = (j - B + N) % N;
	  
	i2 = (j - A + N) % N;
	j2 = (i - B + N) % N;
	  
	if(S[i1][j1] != S[i2][j2]) {
	  flag = false;
	  break;
	}
      }
      if(!flag) {
	break;
      }
    }
    if(flag) {
      ans += N;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
s1=input()
s2=input()
dist=[[0 for i in range(len(s1)+1)] for j in range(len(s2)+1)]
for i in range(len(s1)+1):
    dist[0][i]=i
for i in range(len(s2)+1):
    dist[i][0]=i
for i in range(1,len(s2)+1):
    for j in range(1,len(s1)+1):
        k=1
        if s1[j-1]==s2[i-1]:k=0
        dist[i][j]=min(dist[i-1][j]+1,dist[i][j-1]+1,dist[i-1][j-1]+k)
print(dist[len(s2)][len(s1)])


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    ll ans=0;
    rep(j,n){
        auto it_a = lower_bound(a.begin(),a.end(), b[j]);
        ll i = it_a-a.begin();
        auto it_c = upper_bound(c.begin(),c.end(), b[j]);
        ll k = c.end() - it_c;
        ans+=i*k;
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

vi adj[MAXN];
int vis[MAXN];
int signboard[MAXN];

void solve() {
	int n,m;
	cin >> n >> m;

	F0R(i, m) {
		int a,b;
		cin >> a >> b;

		adj[a].pb(b);
		adj[b].pb(a);
	}

	queue<int> q;
	q.push(1);
	vis[1] = 1;
	
	while(!q.empty()) {

		//FOR(i, 2, n+9
		int cur = q.front();
		q.pop();
		//if(vis[cur]) continue;
		//vis[cur]  = 1;

		for(auto x: adj[cur]) {
			if(!vis[x]) {
				signboard[x] = cur;
				q.push(x);
				vis[x] = 1;
			}
		}
	}

	cout << "Yes\n";
	FOR(i, 2, n+1) cout << signboard[i] << "\n";
	
	
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 31968
def solve():
    N, K = list(map(int, input().split()))
    S = input()

    ans = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            ans += 1

    ans = min(ans + 2*K, N-1)
    print(ans)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
//https://atcoder.jp/contests/abc122/tasks/abc122_a
#include<iostream>
#include<string>
using namespace std;

int main() {
    string b,ans;
    cin >> b;
    if(b=="A"){
        ans='T';
    }else if(b=="T"){
        ans='A';
    }else if(b=="C"){
        ans='G';
    }else if(b=="G"){
        ans='C';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    int n;
    String[] a,b;
    String from,to;

    class E{
        String s;
        int cost;
        E(String s, int cost){
            this.s = s;
            this.cost = cost;
        }
    }

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            if(n==0) break;

            a = new String[n];
            b = new String[n];
            for(int i=0; i<n; i++){
                a[i] = sc.next();
                b[i] = sc.next();
            }
            from = sc.next();
            to = sc.next();

            System.out.println(getMin());
        }
    }

    int getMin(){
        Queue<E> q = new LinkedList<E>();
        q.add(new E(from,0));
        HashSet<String> set = new HashSet<String>();

        while(q.size()>0){
            E e = q.poll();
            String ss = e.s;
            int cost = e.cost;

            if(ss.equals(to)) return cost;
            if(set.contains(ss)) continue;
            set.add(ss);

            for(int i=0; i<a.length; i++){
                String s = ss;
                s = s.replaceAll(a[i],b[i]);
  
                if(ss.equals(s)) continue;
                if(s.length()>to.length()) continue;
                q.add(new E(s,cost+1));
            }
        }

        return -1;
    }

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

Measured memory_bytes: 13000
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;
char str[N][N];
int row[N];
int col[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> str[i] + 1;
		for (int j = 1; j <= m; j++)
		{
			row[i] |= str[i][j] == '#';
			col[j] |= str[i][j] == '#';
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (row[i] == 0) continue;
		for (int j = 1; j <= m; j++)
		{
			if (col[j])
				putchar(str[i][j]);
		}
		puts("");
	}
	return 0;
}


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

int main(int argc, char *argv[])
{
	int a, b, c;
	int distance;

	cin >> a >> b >> c >> distance;

	if (abs(c - a) <= distance ||
		(abs(a - b) <= distance && abs(c - b) <= distance)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int MAX = 1000000;

int main(){
    int r;
    cin >> r;
    printf("%.3f\n",r*2*M_PI);
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,h;cin>>n>>h;
    cin>>h;--h;
    for(int i=1;i<n;++i){
        int h2;cin>>h2;
        if (h2<h) {cout << "No";return 0;}
        if (h2>h) h=h2-1;
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> kagami(n);
   for (int i = 0; i < n; i++) {
    cin >> kagami.at(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = (i+1); j < n; j++) {
    if (kagami.at(i) == kagami.at(j))
      kagami.at(j) = 0;
    }
  }
  int count;
  for (int i = 0; i < n; i++) {
    if (kagami.at(i) == 0)
      count++;
  }
  cout << n - count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int sl = (int)(s.length());
    int tl = (int)(t.length());
    int mx = 0;
    for(int i = 0; i <= sl - tl; i++){
        int cnt = 0;
        for(int j = 0; j < tl; j++){
            if(s[i + j] == t[j]) cnt++;
        }
        mx = max(mx, cnt);
    }
    cout << tl - mx << "\n";
}

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

int main() {
    ios_base :: sync_with_stdio(false);

    //ifstream cin("testC.in");
    string a; cin >> a;
    int n = a.size();
    for(int i = 0; i < n; ++i)
        a[i] -= 'a';

    vector<vector<int>> nxt(n, vector<int> (27, n));
    
    for(int i = n - 1; i >= 0; --i) {
        nxt[i][a[i]] = i;
        for(int c = a[i] + 1; c < 27; ++c) {
            int self = nxt[i][c - 1] + 1;
            if(self >= n)
                continue;
            nxt[i][c] = nxt[self][c - 1];
        }

        for(int c = 0; c < 26; ++c) {
            if(nxt[i][26] + 1 < n)
                nxt[i][c] = min(nxt[i][c], nxt[nxt[i][26] + 1][c]);
        }   
    }
    
    vector<vector<int>> anc(21, vector<int> (n, 0));

    for(int i = 0; i < n; ++i)
        anc[0][i] = nxt[i][26];

    for(int lg = 1; lg < 21; ++lg) {
        for(int i = 0; i < n; ++i) {
            if(anc[lg - 1][i] >= n - 1) {
                anc[lg][i] = n;
            } else {
                anc[lg][i] = anc[lg - 1][anc[lg - 1][i] + 1];
            }
        }
    }
    
    int q; cin >> q;

    for(int i = 0; i < q; ++i) {
        int x, y; cin >> x >> y;
        x--, y--;
            
        bool good = false;
        int now = x;

        for(int lg = 20; lg >= 0; --lg) {
            if(anc[lg][now] <= y) {
                now = anc[lg][now] + 1;
                if(now == y + 1)
                    good = true;
            }
        }

        if(not good) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
}

Measured memory_bytes: 118136
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
long long f[maxn], x[maxn];
int main(){
	int n, E, T;
	cin >> n >> E >> T;
	for(int i = 1; i <= n; i++) cin >> x[i];
	multiset<long long> small, bigger;
	int j = 1;
	for(int i = 1; i <= n; i++){
		while(j < i && 2*(x[i] - x[j]) > T){
			small.erase(small.find(f[j - 1]));
			bigger.insert(f[j - 1] - 2 * x[j]);
			j++;
		}
		f[i] = T + f[i - 1];
		if(!small.empty()) f[i] = min(f[i], *small.begin() + T);
		if(!bigger.empty()) f[i] = min(f[i], *bigger.begin() + 2 * x[i]);
		small.insert(f[i - 1]);
	}
	cout << f[n] + E << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,answer=0;
  cin>>N;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){cin>>vec.at(i);}
  sort(vec.begin(),vec.end());
  for(ll i=1;i<N-1;i++){
    for(ll j=i+1;j<N;j++){
      for(ll k=0;k<i;k++){
        if(vec.at(k)>vec.at(j)-vec.at(i)){++answer;}
      }
    }
  }
  cout<<answer<<endl;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define w(x) cout<<x<<endl;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = pow(2,32);

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

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

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    #endif
	FAST();
    string s;
    cin>>s;
    ll sum=0;
    fo(i,s.size())
    {
        sum+=s[i]-'0';
        sum%=9;
    }
    if(sum)cout<<"No";
    else cout<<"Yes";	
}

Measured memory_bytes: 3692