akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    s = input()
    l = {
        'Sunny': 'Cloudy',
        'Cloudy': 'Rainy',
        'Rainy': 'Sunny',
    }
    print(l[s])

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
char s[201000];
int main(){
	while (cin>>s){
		int ans=0;
		int i=0;
		while (s[i]){
			if (s[i]!='T') break;
			ans++;
			i++;
		}
		int left=0;
		for (;s[i];i++){
			int j,k;
			int cnt1=0,cnt2=0;
			for (j=i;s[j];j++){
				if (s[j]!='S') break;
				cnt1++;
			}
			for (k=j;s[k];k++){
				if (s[k]!='T') break;
				cnt2++;
			}
			cnt1+=left;
			left=0;
			//cout<<cnt1<<" "<<cnt2<<endl;
			if (cnt1>cnt2){
				left+=(cnt1-cnt2);
			}
			else{
				ans+=(cnt2-cnt1);
			}
			i=k-1;
		}
		ans+=left;
		cout<<ans<<endl;
	}
	return 0;
}

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

int dist[] = {0, 6, 13, 18, 23, 43, 58};
int cost[][7] = {
	{   0,  300,  500,  600,  700, 1350, 1650},
	{ 300,    0,  350,  450,  600, 1150, 1500},
	{ 500,  350,    0,  250,  400, 1000, 1350},
	{ 600,  450,  250,    0,  250,  850, 1300},
	{ 700,  600,  400,  250,    0,  600, 1150},
	{1350, 1150, 1000,  850,  600,    0,  500},
	{1650, 1500, 1350, 1300, 1150,  500,    0},};

int main() {
	int s, g;
	while(cin >> s, s) {
		int h, m;
		bool half = false;
		cin >> h >> m;
		if(17 * 60 + 30 <= h * 60 + m && h * 60 + m <= 19 * 60 + 30)
			half = true;
		cin >> g >> h >> m;
		if(17 * 60 + 30 <= h * 60 + m && h * 60 + m <= 19 * 60 + 30)
			half = true;

		half &= abs(dist[s-1] - dist[g-1]) <= 40;

		if(half)
			cout << ((cost[s-1][g-1] / 50) + 1) / 2 * 50 << endl;
		else
			cout << cost[s-1][g-1] << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int n;
void dfs(string s, char mx){
  if(s.size() == n){
    cout << s << endl;
    return;
  }
  
  for(char c = 'a'; c <= mx + 1; c++){
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}

int main(){
  cin >> n;
  
  dfs("", 'a' - 1);
  return 0;
}

Measured memory_bytes: 1536
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

A, B, C, D = gets_i_list
E = C.lcm(D)

# total = 0
# total += (B / C) - ((A-1) / C)
# total += (B / D) - ((A-1) / D)
# total -= (B / E) - ((A-1) / E)

n = B - A + 1
m = (B/C + B/D - B/E) - ((A-1)/C + (A-1)/D - (A-1)/E)
puts n-m


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

#define ALL(V) (V).begin(), (V).end()

template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

const ll INF = 5e15;

int main() {
    ll N, K;
    cin >> N >> K;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    V<ll> output;
    A.push_back(INF);
    ll prei = -1;
    for(ll loops = 0; loops < K + 1; loops++) {
        ll idx = N;
        for(ll i = 0; i < N; i++) {
            if(i == prei) continue;
            if(A[i] < A[idx]) idx = i;
        }
        for(ll i = 0; i < N; i++) {
            if(i == prei) continue;
            if(A[i] == 0) {
                cout << -1 << endl;
                return 0;
            }
            A[i]--;
            if(i == idx) continue;
            output.push_back(i + 1);
        }
        output.push_back(idx + 1);
        prei = idx;
    }
    cout << output.size() << endl;
    for(ll i = 0; i < output.size(); i++) cout << output[i] << " \n"[i + 1 == output.size()];
    return 0;
}


Measured memory_bytes: 256
a = input()
ar = []
for i in range(len(a)):
    ar.append(a[i])
n = len(ar)
ret = 0
for i in range(2**(n-1)):
    s = "+"
    tmp = ""
    for j in range(n):
        if (1 & (i >> j)) == 1:
            tmp += ar[j]
            tmp += s
        else:
            tmp += ar[j]
    stmp = tmp.split("+")
    ret += sum(int(k) for k in stmp)
print(int(ret))

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

int main() {
  string X;
  cin>>X;
  if(X.at(0)=='7'||X.at(1)=='7'||X.at(2)=='7')
  {cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;
  

}
 


Measured memory_bytes: 3604
def main():
    n = int(input())
    hts = list(map(int,input().split()))
    if n == 2:
        print(abs(hts[0]-hts[1]))
        return
    
    dp = [0]*n
    dp[0] = 0
    dp[1] = abs(hts[1]-hts[0])
    dp[2] = abs(hts[2]-hts[0])

    for i in range(3,n):
        dp[i] = min(dp[i-1]+abs(hts[i]-hts[i-1]),
                    dp[i-2]+abs(hts[i]-hts[i-2]))

    print(dp[-1])

main()

Measured memory_bytes: 13780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;

public class Main {
	public static void main(String[] args) throws IOException, ParseException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		final int D = Integer.parseInt(str);
		
		if (D == 25) {
			System.out.println("Christmas");
		} else if (D == 24) {
			System.out.println("Christmas Eve");
		} else if (D == 23) {
			System.out.println("Christmas Eve Eve");
		} else if (D == 22) {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}


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

int N, arr[20];

int main(){		
	int t = 0;
	scanf("%d", &N);
	for(int i = 0; i < N; i++) scanf("%d", &arr[i]);
	for(int i = 1; i < N - 1; i++){
		int a[] = {arr[i - 1], arr[i], arr[i + 1]};
		sort(a, a + 3);
		if(a[1] == arr[i]) t++;
	}
	printf("%d\n", t);
	return 0;
}


Measured memory_bytes: 256
import sys, heapq
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
A = list(map(int, input().split()))
a = [(-i, 1) for i in A]
heapq.heapify(a)

for i in range(M):
	b, c = map(int, input().split())
	heapq.heappush(a, (-c, b))
	
ans = 0

for i in range(N):
	pop = heapq.heappop(a)
	ans += pop[0]
	if pop[1] != 1:
		heapq.heappush(a, (pop[0], pop[1] - 1))

ans *= -1
print(ans)

Measured memory_bytes: 32804
N,K = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

s = sum([p[i] for i in range(K)])
data = [s]
for i in range(N-K):
    s = s-p[i]+p[i+K]
    data.append(s)
print((max(data)+K)/2)

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

using namespace std;

int main()
{
  long long n;
  cin>>n;
    long long cap;
    cin>>cap;
    long long v[n+1];
    long long w[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>w[i];
        cin>>v[i];
    }

    long long dp[n+1][cap+1];

    for(long long i=0;i<=cap;i++)
        dp[0][i]=0;

    for(long long i=0;i<=n;i++)
        dp[i][0]=0;


    for(int i=1;i<=n;i++)
    {
        for(long long j=1;j<=cap;j++)
        {
            int wp=j-w[i];
            dp[i][j]=dp[i-1][j];
            if(wp>=0)
                dp[i][j]=max(dp[i][j],dp[i-1][wp]+v[i]);
        }
    }

    cout<<dp[n][cap];




}


Measured memory_bytes: 79104
#include<cstdio>
#include<stack>
#include<cstring>
using namespace std;
#define INF 0x3f3f3f3f
struct node
{
    int id;
    char c;
} a[20005];

struct st
{
    int val;
    int h;
} sum;

char s[20005];
int ans[20005];
int main()
{
    scanf("%s", s);
    int len=strlen(s);
    for(int i=0; i<len; i++)
    {
        a[i].c=s[i];
        a[i].id=i;
    }
    stack<node> Q;
    stack<st> T;
    int res=0, h=0, s=0;

    for(int i=0; i<len; i++)
    {
        if(a[i].c=='_') continue;
        if(a[i].c=='\\')
        {
            if(a[i].c=='\\') h--;
            Q.push(a[i]);
        }
        else
        {
            h++;
            while(!Q.empty())
            {
                node temp;
                temp=Q.top();
                Q.pop();
                if(temp.c=='\\')
                {
                    sum.val+=a[i].id-temp.id;
                    sum.h=h;
                    break;
                }
            }
        }

        if(sum.val!=0)
        {
            while(!T.empty())
            {
                st temp;
                temp=T.top();
                if(temp.h!=INF && temp.h+1==sum.h)
                {
                    T.pop();
                    sum.val+=temp.val;
                }
                else break;
            }
            if(Q.empty()) sum.h=INF;
            T.push(sum);
        }
        sum.val=0;

    }
    while(!T.empty())
    {
        st temp;
        temp=T.top();
        T.pop();
        ans[res++]=temp.val;
        s+=temp.val;
    }
    printf("%d\n", s);
    printf("%d", res);
    for(int i=res-1; i>=0; i--) printf(" %d", ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
int main(){
map<pair<string,int>,int> R;
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
  string t;
    int s;
    cin>>t>>s;
    pair<string,int>p(t,-s);
    R[p]=i+1;
  
  }for(auto p:R){
  auto k=p.first;
    auto v=p.second;
    cout<<v<<endl;
  
  }
  
  return 0;
}

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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795



ll binPowM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
return ans%m;
}
ll f(ll x,ll y,ll a)
{
  return (a&x)*(a&y);
}

int main()
{
ll a=0,b=0,x,flag=0;
cin>>x;
for(int i=1;i*i<=x;i++)
{
    if(x%i==0)
    {
        for(int j=-1000;j<=1000;j++)
        {
            a=j;
            b=j-i;
            if((a*a*a*a*a)-(b*b*b*b*b)==x)
            {
            
                flag=1;
                break;
            }
            
        }
    }
    if(flag)break;
}
cout<<a<<" "<<b<<"\n";
  return 0;
}





Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
#define MK make_pair
#define PB push_back
using namespace std;

typedef long long LL;
typedef pair<int ,int> PII;
const int N=4000+10;
const LL MOD= 998244353;

LL c[N][N], pw[N];
int n,k;

LL C(int m , int n){
	if ( m<0 || n<0) return 0;
	return c[m][n];
}
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	for (int i=0; i<=4000; ++i){
		c[i][0] = 1;
		for (int j=1; j<=i; ++j) c[i][j] = (c[i-1][j] + c[i-1][j-1])%MOD;		
	}
	cin>>k>>n;
	pw[0] =1;
	for (int i=1; i<=n+k; ++i) pw[i] = pw[i-1]*2%MOD;
	for (int ii,r, mid,i=2; i<=2*k; ++i){
		if ( i<=k ){
			ii= (i-1)/2;
			mid = (i-1)&1;
			r= k-i+1;
		} else{
			int len = 2*k-i+1;
			ii= len/2; mid= len&1;
			r= k-len;
		}
		LL ans= 0;
		for (int j=0;j<= ii;++j){
//			if ( r+j==0) continue;
			ans = (ans + C(ii,j)*C(n-j+r+j-1,n-j)%MOD*pw[j])%MOD;
			#ifdef che
			debug("%d ball %d box, c== %lld\n", n-j, r+j,C(ii,j)*C(n-j+r+j-1,n-j));
			#endif
			if ( mid){
				ans= (ans + C(n-j+r+j-2,n-j-1)*C(ii,j)%MOD*pw[j])%MOD;
				#ifdef che
				debug("%d ball %d box, c==%lld\n", n-j-1, r+j,C(n-j+r+j-2,n-j-1)*C(ii,j));
				#endif
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 123904
N, W = [int(i) for i in input().split()]
dp = [[0 for j in range(W + 1)] for i in range(N + 1)]
v = w = 0
for i in range(N - 1, -1, -1):
    v, w = [int(i) for i in input().split()]
    for j in range(0, W + 1):
        if j < w :
            dp[i][j] = dp[i + 1][j]
        else :
            dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w] + v)
print(dp[0][W])

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

int main()
{
	double n,m;
	ll d;
	
	cin >> n >> m >> d;
	double ans = 0;
	if(d==0)
	{
		ans = 1.0/n*(m-1);
	}
	else
	{
		ans = 2*(n-d)/n/n*(m-1);
	}
	printf("%.10lf\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_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(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    vl data(4);
    rep(i,4) cin >> data[i];
    ll ans = 0;
    rep(i,MAX(data)){
        if(data[0] <= i && i < data[1] && data[2] <= i && i < data[3])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	cout << (n - 30) / 2 << endl;
	return 0;
}


Measured memory_bytes: 3076
#include<iostream>
typedef long long ll;
using namespace std;

const int MOD = 2019;

int main() {
    ll L, R, ans = MOD;
    cin >> L >> R;
    for (ll i = L; i < min(R, L + MOD); i++) {
        for (ll j = i + 1; j <= min(R, L + MOD); j++) {
            ans = min(ans, (i * j % MOD));
        }
    }
    cout << ans << endl;
}

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

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

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

const int MAXN = 200005;
const int INF = 0x7f7f7f7f;

int A[MAXN];
int L[MAXN];
int Re[MAXN];
bool Vis[MAXN];

int main()
{
    int N;
    long long K;
    cin >> N >> K;
    for(int i = 1; i <= N; ++i)
        cin >> A[i];

    int r = 0, pos = 1;
    Vis[1] = true;
    L[0] = 1;
    Re[1] = 0;

    while(1)
    {
        pos = A[pos];
        L[++r] = pos;

        if(Vis[pos])
            break;
        Re[pos] = r;
        Vis[pos] = true;
    }

    K = min(K, 1ll * Re[pos]) + max(0ll, K - Re[pos]) % (r - Re[pos]);

    cout << L[K] << endl;

    return 0;
}


Measured memory_bytes: 6020
n,m = map(int,input().split())
A = [[i,list(map(int,input().split()))] for i in range(m)]
B = []
i = 0
x = 0
for a in sorted(A,key=lambda l:(l[1][0],l[1][1])):
    if i==a[1][0]:
        x += 1
        B.append([a[0],str(a[1][0]).zfill(6)+str(x).zfill(6)])
    else:
        x = 1
        B.append([a[0],str(a[1][0]).zfill(6)+str(x).zfill(6)])
        i = a[1][0]
for b in sorted(B):
    print(b[1])

Measured memory_bytes: 54748
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int h,n,x,sum;
int main(){
	cin>>h>>n;
	for(int i=1;i<=n;++i){
		cin>>x;
		sum+=x;
	}
	if(h>sum) cout<<"No";
	else cout<<"Yes";
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(e, x) for (auto &e : x)
#define eb(x...) emplace_back(x)
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

	int x; cin >> x;
	x -= 400;
	x /= 200;
	x = 8 - x;
	cout << x;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}

static void ABC074C_SugarWater();

#if 1
int main()
{
	ABC074C_SugarWater();
	fflush(stdout);
	return 0;
}
#endif

static void ABC074C_SugarWater()
{
	int A, B, C, D, E, F;
	get2int(A, B);
	get2int(C, D);
	get2int(E, F);

	double pcnt = 0.0;
	int sAns = 0, wAns = 0;

	int aLim = (F / (A * 100)) + 1;
	int bLim = (F / (B * 100)) + 1;
	int cLim = (((F / 100) + 1) * E) / C;
	int dLim = (((F / 100) + 1) * E) / D;
	for (int a = 0; a <= aLim; a++) {
		for (int b = 0; b <= bLim; b++) {
			for (int c = 0; c <= cLim; c++) {
				for (int d = 0; d <= dLim; d++) {
					int water = (100 * A * a) + (100 * B * b);
					int sugar = (c * C) + (d * D);
					int sLimit = (water / 100) * E;
					int totalWeight = water + sugar;
					
					if ((totalWeight <= F) && (sugar <= sLimit)) {
						double now = (double)sugar / (double)(totalWeight);
						if (pcnt < now) {
							pcnt = now;
							sAns = sugar;
							wAns = totalWeight;
						}
					}
				}
			}
		}
	}
	if (wAns == 0) wAns = tp_min(100 * A, 100 * B);
	printf("%d %d\n", wAns, sAns);
}


Measured memory_bytes: 256
n=int(input())
b=input().split()
a=[0 for i in range(n+1)]
for i in range(1,n+1):
  a[i]=int(b[i-1])

a[0]=10**10

m=int((n-2)/2)

a=sorted(a,reverse=True)

comfort=a[1]
if(n==2):
  print(comfort)
else:
  
  for i in range(2,m+2):
    comfort+=(2*a[i])

  if(n%2 ==0):
    print(comfort)
  else:
    print(comfort+a[m+2])



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

using namespace std;


int main()
{
  std::string S;
  cin >> S;

  for(int i = 0;
      i < S.length() - 1;
      ++i)
    {
      if(S[i] == S[i + 1])
        {
          cout << "Bad" << endl;
          return 0;
        }
    }

  cout << "Good" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<stw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    ll a,b;cin>>a>>b;
    if(a==1||b==1){
        cout << 1 << endl;
        exit(0);
    }
    if(a*b%2==1){
        cout << (a*b+1)/2 << endl;
    }else{
        cout << a*b/2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p%i == 0) return false;
	}
	return true;
}
 
int n;
 
int main() {
	cin >> n;
	for (int i = 11; i <= 55555 && n>0 ; i += 10) {
		if (isprime(i) == true) {
          printf("%d ",i),n--;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
unsigned long long a, b, c;

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

    if (a >= c || b >= c) {
        cout << "No";
        return 0;
    }

    unsigned long long st = 4 * a * b;
    unsigned long long dr = (c - a - b) * (c - a - b);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e5+8;
int A[inf];
int val[inf][3];
int n;
int dp[inf][4];

int f(int index, int prev){
     if(index==n) return 0;
     int&ans=dp[index][prev];
     if(ans!=-1) return ans;
     
     ans=0;
     for(int i=0;i<3;i++){
          if(i == prev) continue;
          ans=max(ans, val[index][i]+f(index+1, i));
     }
     return ans;
}

int main(){
     memset(dp, -1, sizeof(dp));
     cin>>n;
     for(int i=0;i<n;i++){
          cin>>val[i][0]>>val[i][1]>>val[i][2];
     }
     cout<<f(0, 3);
}

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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 51 , mod = 1e9+7 ;
long long adj[N][N] , ans[N][N] ,t[N][N], n , k , temp;
int exp(long long k)
{
	for(int i = 1; i <= n ; ++i)
		ans[i][i] = 1;
	while(k)
	{
		if(k&1)
		{
			for(int p = 1 ; p <= n ; ++p)
			{
				for(int q = 1 ; q <= n ; ++q)
				{
					temp = 0;
					for(int r = 1 ; r <= n ; ++r)
						temp = (temp + (ans[p][r] * adj[r][q])%mod)%mod;
					t[p][q] = temp;
				}
			}
			for(int p = 1 ; p <= n ; ++p)
				for(int q = 1 ; q <= n ; ++q)
					ans[p][q] = t[p][q];	
		}
		for(int p = 1 ; p <= n ; ++p)
		{
			for(int q = 1 ; q <= n ; ++q)
			{
				temp = 0;
				for(int r = 1 ; r <= n ; ++r)
					temp = (temp + (adj[p][r] * adj[r][q])%mod)%mod;
				t[p][q] = temp;
			}
		}
			for(int p = 1 ; p <= n ; ++p)
				for(int q = 1 ; q <= n ; ++q)
					adj[p][q] = t[p][q];
			k >>= 1;
		}
	int cnt = 0;
	for(int p = 1 ; p <= n ; ++p)
		for(int q = 1 ; q <= n ; ++q)
			if(ans[p][q]) cnt = (cnt + ans[p][q])%mod;

	return cnt;

}

int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	cin >> n >> k ;
	for(int i = 1 ; i <= n ; ++i)
		for(int j = 1 ; j <= n ; ++j)
			cin >> adj[i][j];

	cout << exp(k);


	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

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

constexpr ll MOD = 1e9 + 7;

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

    string n;
    int k;
    cin >> n >> k;

    ll dp[110][2][2][5]; //idx,started?,same?,not0
    memset(dp, 0, sizeof(dp));

    dp[0][0][0][0] = 1;
    dp[0][1][1][1] = 1;
    if (n[0] > '1')
        dp[0][true][false][1] = n[0] - '1';

    for (int i = 1; i < n.size(); i++)
    {
        dp[i][false][false][0] = 1;

        for (int s = 1; s <= k; s++)
        {
            if (s == 1)
            {
                dp[i][true][false][s] += dp[i - 1][false][false][0] * 9;
            }
            else
            {
                if (n[i] > '0')
                    dp[i][true][true][s] += dp[i - 1][true][true][s - 1];
                if (n[i] > '1')
                {
                    dp[i][true][false][s] += dp[i - 1][true][true][s - 1] * (n[i] - '1');
                }
                dp[i][true][false][s] += dp[i - 1][true][false][s - 1] * 9;
            }

            if (n[i] == '0')
                dp[i][true][true][s] += dp[i - 1][true][true][s];
            else
                dp[i][true][false][s] += dp[i - 1][true][true][s];

            dp[i][true][false][s] += dp[i - 1][true][false][s];
        }
    }

    ll res = 0;
    for (int i = 0; i < 2; i++)
        res += dp[n.size() - 1][true][i][k];

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define int long long
#define P pair<int,int>

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    string s;
    cin >> s;

    int n = s.size();

    bool flag = true;
    string t = s;
    reverse(all(t));
    if(t != s) flag = false;

    string s1 = s.substr(0,(n - 1) / 2);
    string s2 = s1;
    reverse(all(s2));
    if(s1 != s2) flag = false;

    s1 = s.substr(n / 2 + 1,(n - 1) / 2);
    s2 = s1;
    reverse(all(s2));
    if(s1 != s2) flag = false;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e3 + 10;
const int MOD=1e9 + 7;
int n,m,dp[MAX][MAX];
string S[MAX];
bool vis[MAX];
bool valid(int i,int j)
{
    return i>=0&&i<n&&j>=0&&j<m;
}
int dfs(int x,int y)
{
    if(valid(x,y)==0 || S[x][y]=='#')return 0;
    if(x==n-1&&y==m-1)return 1;
    if(dp[x][y]!=-1)return dp[x][y];
    int ans=0;
    ans+=dfs(x+1,y)%MOD;
    ans+=dfs(x,y+1)%MOD;
    return dp[x][y]=ans%MOD;
}
int main ()
{
    memset(dp,-1,sizeof dp);
    cin >> n >> m;
    for(int i=0;i<n;i++)cin>>S[i];
 
    cout<<dfs(0,0);
    return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String[] b = a.split("");
	    int c =0;
	    
	    for(int i=0;i<3;i++){
	    if(b[i].equals("1"))
	    	c++;
	    }		
	    System.out.println(c);


	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip> 
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(j, a, b) for (int j = a; j >= b; j--)
using namespace std;
const int MAX = 100001; 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a, b, c;
    cin >> a >> b>> c;
    long long k =  4*a*b, C = c-a-b;
    if(C<0){
        cout << "No" << endl;
        return 0;
    }
    C*=C;
    if(k<C){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
 
import java.util.*;
import java.lang.*;
import java.io.*;

@SuppressWarnings("unchecked")
public class Main implements Runnable {

  static BufferedReader in;
  static PrintWriter out;
 
  public static void main(String[] args) {
      new Thread(null, new Main(), "whatever", 1<<29).start();
  }

  public long getMoves(long a, long b) {
    long left=Math.min(a,b);
    long right=Math.max(a,b);
    long cnt=0;

    long firstSetOfMoves=left-1;
    left-=firstSetOfMoves;
    right-=firstSetOfMoves;
    cnt+=firstSetOfMoves;

    cnt+=1;
    right-=1;

    if(right!=left) {
      cnt+=((right-left)/2);
    }

    return cnt;
  }
 
  public void run() {
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out, false);
 
    try
    {
      // in = new BufferedReader(new FileReader("class_treasurer.txt"));
      // out = new PrintWriter("output.txt");

      int t,x1;
      long n,a,b;
      String str;
      String[] token;

      str=in.readLine().trim();
      token=str.split(" ");
      n=Long.parseLong(token[0]);
      a=Long.parseLong(token[1]);
      b=Long.parseLong(token[2]);

      if(Math.abs(a-b)%2==0) {
        out.println(Math.abs(a-b)/2);
      }
      else {
        out.println(Math.min(getMoves(a, b), getMoves(n-a+1, n-b+1)));
      }

      out.flush();
      out.close();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 



int main()
{
    int N;
    map<string, int> m;
    
    cin >> N;
    rep(i, N){
        string S;
        cin >> S;
        m[S]+= 1;
    }
    int ans = 0;
    for( auto i = m.begin(); i != m.end() ; ++i ) {
        ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 19260
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

#define INF INT_MAX / 2

int main() {
	int n, m;
	int c[20];
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> c[i];
	int dp[50000 + 1];
	fill_n(dp, n + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < m; i++)
		for (int j = c[i]; j <= n; j++)
			dp[j] = min(dp[j], dp[j - c[i]] + 1);

	cout << dp[n] << endl;

	return 0;
}

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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

vector<int> z_func(string &s) {
  vector<int> z(len(s), 0);
  int l = 0, r = 1;
  rep(i, 1, sz(z) - 1) {
    if (i <= r)
      z[i] = min(z[i - l], r - i);
    while (i + z[i] < len(s) && s[z[i]] == s[i + z[i]])
      z[i]++;
    if (i + z[i] > r)
      l = i, r = i + z[i]; 
  }
  return z;
}

bool is_good(string s) {
  auto z = z_func(s);
  rep(i, 1, len(s) / 2) {
    bool can_divide = len(s) % i == 0 && z[i] == i * (len(s) / i - 1);
    if (can_divide) return false;
  }
  return true;
}

void solve() {
  string s;
  cin >> s;

  string rev_s = s;
  reverse(all(rev_s));

  auto z = z_func(s);
  auto rev_z = z_func(rev_s);

  rep(i, 1, len(s) / 2) {
    bool can_divide = len(s) % i == 0 && z[i] == i * (len(s) / i - 1);
    if (!can_divide) continue;

    if (i == 1) {
      cout << len(s) << nl << 1;
      return;
    } 

    vector<bool> can_divide_left(sz(z), true);
    can_divide_left[0] = false;
    rep(j, 1, sz(z) - 1) {
      if (z[j] >= j) {
        for (int k = j; k < j + z[j]; k += j)
          if (k + j < sz(z) && z[k] >= j)
            can_divide_left[k + j] = false;
          else
            break;
      }
    }

    vector<bool> can_divide_right(sz(z), true);
    can_divide_right[sz(z) - 1] = false;
    per(j, sz(z) - 2, 0) {
      int l = len(s) - j - 1;
      if (rev_z[l] >= l) {
        for (int k = j; k > j - rev_z[l]; k -= l)
          if (k - l >= 0 && rev_z[len(s) - k - 1] >= l)
            can_divide_right[k - l] = false;
          else
            break;
      }
    }

    int res = 0;
    rep(j, 1, len(s) - 1) {
      if (can_divide_left[j] && can_divide_right[j - 1]) {
        res++;
      }
    }

    cout << 2 << nl << res;
    return;
  }

  cout << 1 << nl << 1;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}

Measured memory_bytes: 8184
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 2e9;

ll dist[505][505];

void warchall_floyd(int N){
    rep(k,N)rep(i,N){
        if(dist[i][k] == INF) continue;
        rep(j,N){
            if(dist[k][j] == INF) continue;
	        chmin(dist[i][j], dist[i][k]+dist[k][j]);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, R;
    cin >> n >> m >> R;
    rep(i,n){
        rep(j,n) dist[i][j] = INF;
        dist[i][i] = 0;
    }
    vector<int> r(R);
    rep(i,R){
        cin >> r[i];
        r[i]--;
    }
    int a, b;
    ll c;
    rep(i,m){
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    warchall_floyd(n);
    vector<int> v(R);
    rep(i,R) v[i] = i;
    ll ans = INF;
    do{
		ll path = 0;
        rep(i,R-1){
            path += dist[r[v[i]]][r[v[i+1]]];
        }
        chmin(ans, path);
	} while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int d[n];
    rep(i, n) cin>>d[i];
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans += d[i]*d[j];
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 3644
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		while(N--!=0){
			String str = cin.next();
			HashSet<String> s = new HashSet<String>();
			for(int i = 0;i<str.length()-1;i++){
				String s1 = str.substring(0,i+1);
				String s2 = str.substring(i+1,str.length());
				s.add(s1+s2);
				s.add(r(s1)+s2);
				s.add(r(s1)+r(s2));
				s.add(s1+r(s2));
				s.add(s2+s1);
				s.add(r(s2)+s1);
				s.add(r(s2)+r(s1));
				s.add(s2+r(s1));
			}
			System.out.println(s.size());
		}
	}
	static String r(String s){
		String re = "";
		for(int i = 0; i <s.length();i++){
			re = s.charAt(i)+re;
		}
		return re;
	}
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n, k;
  cin >> n >> k;
  int a;
  int res = 0;
  for(int i = 1; i <= n; i ++ ){
    cin >> a;
    res += (a >= k);
  }
  cout << res;
  return 0;
}

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

using namespace std;

int rd() {
	int x = 0, f = 1; char c = getchar();
	while (c > '9' || c < '0') f = c == '-' ? -1 : 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
	return x * f;
}

long long n, a[200010], ans;

int main() {
	n = rd();
	for (int i = 1; i <= n; i ++) a[i] = a[i - 1] + rd();
	ans = 1e18;
	for (int i = 1; i < n; i ++) ans = min(ans, abs(a[n] - a[i] - a[i]));
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    ll n,k;
    cin>>n>>k;
    cout<<min(n%k,k-n%k)<<endl;

    

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[101][101];

int main(){
  int r, c, i, j, a;
  
  scanf("%d%d", &r, &c);
  
  for(i=0; i<r; i++)//scan array A
    for(j=0; j<c; j++){
      scanf("%d", &a);
      A[i][j] = a;
    }

  for(i=0; i<r; i++){//cal the sum of r
    for(j=0; j<c; j++)
      A[i][c] += A[i][j];
    A[r][c] += A[i][c];
  }
  for(j=0; j<c; j++)//cal the sum of c
    for(i=0; i<r; i++)
      A[r][j] += A[i][j];

  
  for(i=0; i<=r; i++){//print the answer
    for(j=0; j<=c; j++){
      printf("%d", A[i][j]);
      if(j != c) putchar(' ');
    }
    putchar('\n');
  }
  
  return 0;
}

Measured memory_bytes: 644
#include<iostream>
using namespace std;
int main(){
int a=0,b=0,c=0;
while(cin>>a>>b){
	if(a+b==0){
		cout<<c<<endl;
		c=0;
	}
	else{
	for(int x=1;x<=a+b;x=x*10){
		c=c+1;	
	}
	cout<<c<<endl;
	c=0;
}
}
}
	

Measured memory_bytes: 2920
s=gets.chomp
while s.size>0
  case
  when s[0,5] == 'dream'
    if s[5,2] == 'er'
      if s[7,1] == 'a'
        s = s[5,s.size]
      else
        s = s[7,s.size]
      end
    else
      s = s[5,s.size]
    end
  when s[0,5] == 'erase'
    if s[5,1] == 'r'
      s = s[6,s.size]
    else
      s = s[5,s.size]
    end
  else
    break
  end
end

if s.size == 0
  puts 'YES'
else
  puts 'NO'
end

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

#define dbg(x) cout << #x"=" << x << endl;

int main(){
   // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    string a,b;
    cin >> a >> b;
    cout << b << a << endl;
    return 0;
}

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

typedef struct{
	int p, no;
	long y;
}city;

int comp(const void *a, const void *b){
	if((*((city**)a))->p != (*((city**)b))->p)return (*((city**)a))->p > (*((city**)b))->p;
	else return (*((city**)a))->y > (*((city**)b))->y;
}

int main(void){
	int n, m;
	scanf("%d %d", &n, &m);
	city **ctys = malloc(sizeof(city*) * m), **input = malloc(sizeof(city*) * m);
	for(int i = 0; i < m; i++){
		ctys[i] = input[i] = malloc(sizeof(city));
		scanf("%d %ld", &(input[i]->p), &(input[i]->y));
	}
	qsort(ctys, m, sizeof(city*), comp);
	int tmp = 0;
	int count = 0;
	for(int i = 0; i < m; i++){
		if(tmp != ctys[i]->p){
			tmp = ctys[i]->p;
			count = 0;
		}
		count++;
		ctys[i]->no = count;
	}
	for(int i = 0; i < m; i++)
		printf("%06d%06d\n", input[i]->p, input[i]->no);
	return 0;
}


Measured memory_bytes: 6132
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define scn(x) scanf("%I64d",&x)
# define scan(x) scanf("%d",&x)
# define print(x) printf("%d ",x)
# define prnt(x) printf("%I64d ",x);
# define eol printf("\n")
# define IOS ios_base :: sync_with_stdio(0)
# define pe "Possible"
# define ie "Impossible"
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define rep1(n) for (int qwerty = 1;qwerty <= n;++qwerty)
# define CF
# ifdef CF
# define DEBUG
# endif // CF
# ifdef DEBUG
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
# define aprint(x,y,z) for (int i = x;i <= y;++i) cerr << z[i] << ' ';cerr << '\n'
# else
# define pp(n) ;
# define ppp(v) ;
# define aprint(x,y,z);
# endif // DEBUG
# define rep(n) for (int i = 1;i <= n;++i)
const int mod = 1e9 + 7;
int D[14][2005];
int h[2005];
vector < int > s[2005];
int S[2005];
void dfs(int node = 1,int prev = 0)
{
    h[node] = h[prev] + 1;
    D[0][node] = prev;
    for (auto it : s[node])
        if (it != prev)
            dfs(it,node),S[node]++;
}
int shift(int a,int b)
{
    for (int k = 12;k+1;--k)
        if ((b >> k)&1)
            a = D[k][a];
    return a;
}
int lca(int a,int b)
{
    if (h[a] > h[b])
        a = shift(a,h[a] - h[b]);
    else
        b = shift(b,h[b] - h[a]);
    for (int k = 12;k+1;--k)
        if (D[k][a] != D[k][b])
            a = D[k][a],b = D[k][b];
    if (a == b) return a;
    return D[0][a];
}
int d[2005][2005];
vector < pair < int , int > > V;
int main(void)
{
    # ifdef CF
    # endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,k;
    IOS;
    fi>>n>>k;
    rep1(n - 1)
    {
        int a,b;
        fi>>a>>b;
        V.push_back({a,b});
        s[a].push_back(b);
        s[b].push_back(a);
    }
    dfs();
    for (int T = 1;T < 13;++T)
        for (int i = 1;i <= n;++i)
            D[T][i] = D[T-1][D[T-1][i]];
    for (int i = 1;i <= n;++i)
        for (int j = 1;j <= n;++j)
            d[i][j] = h[i] + h[j] - 2 * h[lca(i,j)];
    int ans = 1e9;
    for (int i = 1;i <= n;++i)
    {
        int cnt = 0;
        for (int j = 1;j <= n;++j)
            cnt += d[i][j] > k / 2;
        ans = min(ans,cnt);
    }
    if (k&1)
    for (auto edge : V)
    {
        int cnt = 0;
        for (int i = 1;i <= n;++i)
            cnt += min(d[i][edge.x],d[i][edge.y]) > (k / 2);
        ans = min(ans,cnt);
    }
    fo << ans << '\n';
    return 0;
}

Measured memory_bytes: 16256
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
connections = [[] for _ in range(N)]
for a, b in AB:
    connections[a - 1].append(b - 1)
    connections[b - 1].append(a - 1)
    
markers = [-1] * N
    
queue = [0]
steps = [-1] * N
steps[0] = 0
while len(queue) >= 1:
    room = queue.pop(0)
    for r in connections[room]:
        if steps[r] >= 0:
            continue
        queue.append(r)
        steps[r] = steps[room] + 1
        markers[r] = str(room + 1)
    
print("Yes")
print("\n".join(markers[1:]))

Measured memory_bytes: 68744
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c = 0;
    cin >> a >> b;
    ll k = gcd(a,b);
    rep(i,2,(ll)sqrt(k)+1){
        if (k%i == 0){
            c++;
            while(k%i == 0) k /= i;
        }
    }
    if (k != 1) c++;
    PRINT(++c);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int fact(int n){
    int res = 1;
    for (int i = 2; i * i <= n; i++){
        int num = 0;
        while(n % i == 0){
            n /= i;
            num++;
        }
        res *= (num + 1);
    }
    if (n != 1){
        res *= 2;
    }
    
    return res;
    
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2){
        if (fact(i) == 8){
            ans++;
            // cout << i << endl;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
hist = [input()]
res = 'No'
s = hist[0][-1]
for _ in range(N-1):
  w = input()
  if w in hist or w[0] != s:
    break
  s = w[-1]
  hist.append(w)
else:
  res = 'Yes'
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
#define M_PI 3.1415
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
 int a, b, c;
 cin >> a >> b >> c;

 int dif = (a - b);
if(dif >= c){
  c = 0; 
} else {
  c -= dif;
}

cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 201234
#define ll long long
map<ll,int>id;
ll bit[N];
int n,k,a[N];ll s[N],sb[N],sd[N];
int main(){
	int i,j=n;
	ll ans=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",a+i),s[i]=s[i-1]+a[i];
	for(i=1;i<=n;i++)sb[i]=s[i]=sd[i]=s[i-1]+a[i]-k;
	sort(sb+1,sb+n+1);
	int ln=unique(sb+1,sb+n+1)-sb-1;
	for(i=1;i<=ln;i++)id[sb[i]]=i;
	for(i=1;i<=n;i++)s[i]=id[s[i]];
	for(i=1;i<=n;i++){
		for(j=s[i];j;j-=j&-j)ans+=bit[j];
		for(j=s[i];j<=ln;j+=j&-j)bit[j]++;
		ans+=sd[i]>=0; 
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 19840
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", line => {
  let arr = line.split(/\s/).map(x => parseInt(x));
  let ans = 0;

  for (let i = 0; i < 2; i++) {
    arr.sort((a, b) => b - a);
    ans += arr[0]--;
  }
  console.log(ans);
});


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

int main()
{
	ll K;
	cin >> K;
	cout << 50 << endl;
	rep(i,50)
	{
		ans[i] = 49 - K;
	}
	rep(i,50)
	{
		ans[i] += (K/50) * 51;
	}
	rep(i,K%50)
	{
		ans[i] += 51;
	}
		rep(i,50)
	{
		if (i != 0) cout << " ";
		cout << ans[i];
	}
	return 0;
}

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

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

using namespace std;

int main() {
    int n, m;
    while(1) {
        cin >> n >> m;
        if (n == 0) break;
        vector<int> s1(n);
        vector<int> s2(m);
        int ss1 = 0;
        int ss2 = 0;

        REP(i, n) {cin >> s1[i]; ss1 += s1[i];}
        REP(i, m) {cin >> s2[i]; ss2 += s2[i];}

        int ans1 = -1;
        int ans2 = -1;
        int mn = 1000000;
        REP(i, n) REP(j, m) {
            if (ss1 - s1[i] + s2[j] == ss2 - s2[j] + s1[i]) {
                if (mn > s1[i] + s2[j]) {
                ans1 = s1[i];
                ans2 = s2[j];
                mn = s1[i] + s2[j];
                }
            }
        }
        if (ans1 == -1) {
            cout << -1 << endl;
        } else {
            cout << ans1 << " " << ans2 << endl;
        }
    }
}


Measured memory_bytes: 3080