akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    while (1) {
        string s, t;
        cin >> s;
        if (s == ".") return 0;
        cin >> t;
        
        if (s == t) cout << "IDENTICAL" << endl;
        else {
            int s_idx = 0, t_idx = 0, diff = 0;
            while (s_idx < s.size()) {
                if (s[s_idx] != t[t_idx] || t_idx == t.size()) {
                    diff = -1;
                    cout << "DIFFERENT" << endl;
                    break;
                }
                else if (char(s[s_idx]) == '"') {
                    string a, b;
                    s_idx++;  t_idx++;
                    while (char(s[s_idx]) != '"') {
                        a += s[s_idx];
                        s_idx++;
                    }
                    while (char(t[t_idx]) != '"') {
                        b += t[t_idx];
                        t_idx++;
                    }
                    if (a != b) diff++;
                }
                s_idx++;  t_idx++;
            }
            if (diff == 1 && t_idx == t.size()) cout << "CLOSE" << endl;
            else if (diff != -1) cout << "DIFFERENT" << endl;
        }
        
    }
    
    
    
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
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;}
// head
const int mxN = 5e3;
int n;
// dp[i][j]: There are i heads coin among the first j coins
// dp[i][j] += dp[i-1][j-1] * p[j] + dp[i][j-1] * (1-p[j]);
double p[mxN], dp[mxN][mxN];
int main() {
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	rep(i, 0, n) cin >> p[i + 1];
	dp[0][0] = 1.0;
	
	//All heads
	rep(i, 1, n+1)
		dp[i][i] = p[i] * dp[i-1][i-1];
	//All tails
	rep(i, 1, n+1)
		dp[0][i] = (1-p[i]) * dp[0][i-1];
	
	rep(j, 1, n+1){
		rep(i, 1, j){
			dp[i][j] += dp[i-1][j-1] * p[j] + dp[i][j-1] * (1-p[j]);
		}
	}
	double ans = 0;
	rep(i, n/2+1, n+1) ans += dp[i][n];
	printf("%.10lf\n", ans);
}




Measured memory_bytes: 118528
#import <Foundation/Foundation.h>
int main() {
    int n;
    scanf("%d ",&n);
    int ans=0;
    char prev='0';
    for(int i=0;i<n;i++){
        char c = getchar();
        if(prev!=c) ans++;
        prev=c;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 7504
#include <cstdio>
#include<iostream>
#include <algorithm>
#define reg register
using namespace std;
const int MaxN=200001;
int a[MaxN],b[MaxN];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i],b[i]=a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
	{
		if(b[i]==a[n])
			printf("%d\n",a[n-1]);
		else
			printf("%d\n",a[n]);
	}
	return 0;
}

Measured memory_bytes: 3200
N,M = map(int,input().split())

if N == 1 and M == 1:
  print(1)
  exit()
if N == 1:
  print(M-2)
  exit()
if M == 1:
  print(N-2)
  exit()

ans = (M-2)*(N-2)
print(ans)

Measured memory_bytes: 9080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7

n,k = map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

def dfs(now,pre):
    available_color = 0  # 子ノードに使用可能な色の数
    if pre == -1:
        available_color = k-1
    else:
        available_color = k-2
    if k < len(graph[now]):
        return 0
    res = 1
    for son in graph[now]:
        if son == pre:continue
        res *= available_color
        available_color -= 1
        res %= MOD
    for son in graph[now]:
        if son == pre:continue
        res *= dfs(son,now)
        res %= MOD

    return res

ans = (k*dfs(0,-1)) % MOD
print(ans)

Measured memory_bytes: 87344
#include <cstdio>
#include <vector>

using namespace std;

template <class RandomIt>
size_t bsort(RandomIt first, RandomIt last) {
    /* Bubble sort */
    size_t times=0;
    for (RandomIt it=first; it<last; ++it)
        for (RandomIt it2=last-1; it2>it; --it2)
            if (it2[0] < it2[-1]) {
                swap(it2[0], it2[-1]);
                ++times;
            }

    return times;
}

int main() {
    size_t N;
    scanf("%zu", &N);

    vector<int> A(N);
    for (size_t i=0; i<N; ++i)
        scanf("%d", &A[i]);

    size_t t=bsort(A.begin(), A.end());

    for (size_t i=0; i<N; ++i)
        printf("%d%c", A[i], i<N-1? ' ':'\n');

    printf("%zu\n", t);
    return 0;
}

Measured memory_bytes: 2684
fun main(args: Array<String>) {
    var (s,t) = readLine()!!.split(" ")
    var (a,b) = readLine()!!.split(" ").map { it.toInt() }
    var u = readLine()!!
    if(s.equals(u))a -=1
    if(t.equals(u))b -=1
    println(a.toString()+" "+b.toString())
}

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

using namespace std;
int main()
{
    int a, b, x;
    cin >> a;
    cin >> b;
    cin >> x;
    double tai = (double)x;
    double tai2 = a*a*b - x;
    double y;
    double d;
    if(x>=b*a*(double)a/2.){
        y = 2*tai2/(double)(a*a);
        d = atan((double)y/(double)a)*180.0/M_PI;
    }
    else{
        y = 2*tai/(double)(b*a);
        d = atan((double)b/(double)y)*180.0/M_PI;
    }
    printf("%.6lf",d);
}

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


using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

typedef pair<ll, ll> P;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];

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

    vector<vector<int>> ms(m);
    for (int i : numbers) ms[i % m].push_back(i);
    ll ans = 0;
    rep(i, m) {
        int j = m - i;
        if (i == 0 || i + i == m) {
            ans += ms[i].size() / 2;
            continue;
        }

        if (i < j) continue;

        vector<int> &v = ms[i], &u = ms[j];
        if (v.size() < u.size()) swap(v, u);

        map<int, int> mp;
        for (int k : v) mp[k]++;


        int pc = 0;
        for (auto e : mp) pc += e.second / 2;
        int noko = (v.size() - u.size()) / 2;

        int k = min(pc, noko);

        int now = k + u.size();
        ans += now;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
	

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

	ll ans = 0;
	for(ll i = 2; i*i <= x; i++){
		if(x%i == 0){
			ll p = 1;
			ll aux = 0;
			while(x%i == 0){
				x/=i;
				aux++;
				if(aux == p){
					ans++;
					aux = 0;
					p++;
				}
			}
		}
	}

	if(x > 1) ans++;

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int k; cin>>k;
  queue <LL> q;
  for1(i,9) q.push(i);
  while(--k){
    LL x(q.front());
    q.pop();
    if(x%10) q.push(x*10 + x%10 - 1);
    q.push(x*10 + x%10);
    if(x%10<9) q.push(x*10 + x%10 + 1);
  }
  cout<<q.front()<<endl;
   return 0;
}



Measured memory_bytes: 1792
from collections import defaultdict
import heapq as hq
from itertools import permutations
def dijkstra(E, D, start,W):
    q = []
    V = [-1]*N
    V[start] = 0
    # for i in range(start):
    #     V[i] = W[i][start]
    #     for e in E[i]:
    #         if e > start:
    #             hq.heappush(q, (V[i] + D[(i,e)], e))
    for e in E[start]:
        if V[e] == -1:
            hq.heappush(q, (D[start, e],e))
    # print(V, q)
    while q:
        d, v = hq.heappop(q)
        if V[v] >= 0:
            continue
        V[v] = d
        for e in E[v]:
            if V[e] == -1:
                hq.heappush(q, (D[v,e]+d, e))
    return V
N, M, r = map( int, input().split())
R = list( map( int, input().split()))
d = defaultdict( int)
E = [ [] for _ in range(N)]
for _ in range(M):
    a, b, c = map( int, input().split())
    a, b = a-1, b-1
    d[(a,b)] = d[(b,a)] = c
    E[a].append(b)
    E[b].append(a)
W = [ [-1]*N for i in range(N)]
# for i in range(N):
#     W[i] = dijkstra(E,d,i,W)
    # print(W)
for i in range(r):
    W[R[i]-1] = dijkstra(E,d,R[i]-1,W)

ans = 10**9
for P in permutations( range(r)):
    now = R[P[0]]-1
    cans = 0
    for i in range(1,r):
        cans += W[now][R[P[i]]-1]
        now = R[P[i]]-1
    if cans < ans:
        ans = cans
print( ans)


Measured memory_bytes: 75480
import sys

def gcd(n,m):
    if m==0:
        return n
    else:
        return gcd(m,n%m)

n,m=list(map(int,input().split()))
s=input()
t=input()

x=gcd(n,m)

if x==n:
    for i in range(0,m+1,n):
        if t[i]!=s[i//n]:
            print(-1)
            sys.exit()
    print(n*m//x)
elif x==m:
    for i in range(0,n+1,m):
        if s[i]!=t[i//m]:
            print(-1)
            sys.exit()
    print(n*m//x)
elif x!=1:
    i=0
    j=0
    while i<n and j<m:
        if s[i]!=t[j]:
            print(-1)
            sys.exit()
        else:
            i+=(n//x)
            j+=(m//x)
    print(n*m//x)
else:
    if s[0]!=t[0]:
        print(-1)
        sys.exit()
    print(n*m)

Measured memory_bytes: 3316
def main():
    p = [] #pasta
    j = [] #juice

    for _ in range(3):
        p.append(int(input()))
    for _ in range(2):
        j.append(int(input()))

    p.sort()
    j.sort()

    ans = p[0] + j[0] - 50
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 7780
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int median(int a, int b, int c) {
    vi xs{a, b, c};
    sort(all(xs));
    return xs[1];
}

int top(vi P) {
    while (P.size() > 1) {
        vi Q;
        for (int i=1; i+1<(int)P.size(); i++) {
            Q.pb(median(P[i-1], P[i], P[i+1]));
        }
        P = Q;
    }
    return P[0];
}

int main() {
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    n=2*n-1;
    if (x<=1 || x>=n) return cout<<"No\n", 0;
    vi P(n);
    P[n/2-1] = x+1;
    P[n/2] = x;
    P[n/2+1] = x-1;
    vi used(n+1);
    used[x-1] = 1;
    used[x] = 1;
    used[x+1] = 1;
    for (int i=0, y=1; i<n; i++) {
        if (P[i]) continue;
        while (used[y]) y++;
        P[i] = y++;
    }
    cout << "Yes\n";
    for (int y:P) cout<<y<<'\n';
    /*
    assert(top(P) == x);
    set<int> s(all(P));
    assert((int)s.size() == n);
    assert(*s.begin() == 1);
    assert(*s.rbegin() == n);
    */
}


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

using namespace std;
using ll = long long;
using P = pair<char,int>;
using PL = pair<ll,ll>;
const vector<P> in = {{'1', 2}, {'2', 5}, {'3', 5}, {'4', 4}, {'5', 5}, {'6', 6}, {'7', 3}, {'8', 7}, {'9', 6}};
const int INF = 1e9;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> use(m);
    for(int i = 0; i < m; i++) {
        int t; cin >> t; t--;
        use[i] = in[t];
    }   
    sort(use.begin(), use.end(), greater<P>());

    vector<int> dp(n + 1, -INF); //マッチをi本使って作れる最大の桁数
    dp[0] = 0;
    
    for(int i = 0; i < n; i++) {
        for(auto j : use) {
         	if(i + j.second > n)continue;
            dp[i + j.second] = max(dp[i + j.second], dp[i] + 1);
        }
    }
    //cerr << dp[n] << endl;

    //上の桁から見ていって
    string ans = "";
    int cur = n;

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

        for(auto j : use) {
            if(cur - j.second < 0)continue; //使えない
            if(dp[cur - j.second] == dp[cur] - 1) {
                ans.push_back(j.first);
                cur -= j.second;
                break;
            }
        }
    }
    if((int)ans.size() != dp[n]) {
        return 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int ll;
int main()
{
   // ifstream cin("/Users/rajdeepdhingra/Downloads/59.txt");
    ll n,m;
    cin>>n>>m;
    ll a[n+1];
    a[0]=0;
    ll dp[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
/*    for(auto x :a)
    {
        cout<<x<<" ";
    }
    cout<<endl;  */
    dp[0]=a[0];
    for(ll i=1;i<=n;i++)
    {
        dp[i] = dp[i-1] + a[i];
    }
    ll start=1;
    ll end=200001;
    ll sum=0;
    while(start<end)
    {
        ll mid;
        mid = (start+end)/2;
        //mid = 49;
        //cout<<mid<<endl;
        ll cc=0;
        ll pos=1;
        for(ll i=n;i>=1;i--)
        {
            while(pos<=n and (a[i]+a[pos])<mid)
            {
                pos++;
            }
        //    cout<<i<<" "<<a[i]<<" "<<pos<<" "<<a[pos]<<"\n";
            if(pos==n+1)
            {
                break;
            }
            else
            {
                cc+= (n-pos+1);
            }
        }
    //    cout<<mid<<" "<<cc<<"\n";
        if(cc<m)
        {
            end=mid;
        }
        else
        {
            start=mid+1;
        }
    }
    ll j=1;
    start--;
    ll cc=0;
    for(ll i=n;i>=1;i--)
    {
        while(j<=n and a[j]+a[i]<start)
        {
            j++;
        }
        if(j==n+1)
            break;
        else
        {
            cc += (n-j+1);
            sum+= (n-j+1)*a[i] + dp[n]-dp[j-1];
        }
    }
    sum = sum - (cc-m)*start;
    cout<<sum<<"\n";
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

vll a,p;

ll fac(ll n, ll x){
	if(n==0){
		if(x<=0) return 0;
		else return 1;
	}
	else if(x<=1+a[n-1]) return fac(n-1,x-1);
	else return p[n-1]+1+fac(n-1,x-2-a[n-1]);
}

int main()
{
	ll n,x;
	cin >> n >> x;
	a.pb(1);
	p.pb(1);
	rep(i,n){
		a.pb(a[i]*2+3);
		p.pb(p[i]*2+1);
	}
	cout << fac(n,x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		int min = 500, max = 0;
		for(int i = 0; i < n; i++){
			int sum = 0;
			for(int j = 0; j < 5; j++){
				int tmp = 0;
				cin >> tmp;
				sum += tmp;
			}
			if(min > sum) min = sum;
			if(max < sum) max = sum;
		}
		cout << max << " " << min << endl;
	}
	return 0;
}

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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n,m;
ll c;
vector<pair<int,ll>> G[100010];
ll d[100010];
pair<ll,int> node[100010];
ll sum[100010];


void solve() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> m >> c;
    REP(i,m) {
        int from, to;
        ll cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        G[from].pb({to,cost});
        G[to].pb({from,cost});
    }

    REP(i,n) {
        d[i] = INF;
    }

    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    pq.push({0,0});
    d[0] = 0;
    while (!pq.empty()) {
        pair<ll,int> tp = pq.top();
        pq.pop();
        if (tp.fi > d[tp.se]) continue;
        for (int i = 0; i < G[tp.se].size(); i++) {
            pair<int,ll> to = G[tp.se][i];
            if (d[to.fi] > to.se + tp.fi) {
                d[to.fi] = to.se + tp.fi;
                pq.push({d[to.fi], to.fi});
            }
        }
    }

    REP(i,n) {
        node[i] = {d[i], i};
    }
    sort(node, node + n);
    
    set<int> st;
    st.insert(0);
    REP(i,n) {
        if (i == 0) continue;
        sum[i] = sum[i-1];
        for (int j = 0; j < G[node[i].se].size(); j++) {
            pair<int,ll> to = G[node[i].se][j];
            if (st.count(to.fi)) {
                sum[i] += to.se;
            }
        }
        st.insert(node[i].se);
    }
    ll ans = INF;
    REP(i,n) {
        ans = min(ans, sum[n-1] - sum[i] + c * node[i].fi);
    }
    cout << ans << endl;
}


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

    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }

    /* AOJ */
    solve();

    return 0;
}


Measured memory_bytes: 23660
K = int(input())
l = [0]*(10**5+10)
l[1:10] = list(range(1,10))
def res(now):
    if int(now[-1])==0:
      for a in range(0,2):
        ret=str(now)+str(a)
        yield ret
    elif int(now[-1])==9:
      for a in range(8,10):
        ret=str(now)+str(a)
        yield ret
    else:
      for a in range(int(now[-1])-1,int(now[-1])+2):
        ret=str(now)+str(a)
        yield ret
        
start = 1
end = 9
while True:
  tmp = []
  for a in l[start:end+1]:
    tmp += list(res(str(a)))
  b = len(tmp)
  start = end+1
  end = start+b-1
  if end<=10**5+5:
    l[start:end+1]=tmp
  else:
    l[start:10**5+5]=tmp[:10**5+5-start]
    break
print(int(l[K]))

Measured memory_bytes: 67660
#include<iostream>

using namespace std;

int main(void)

{
    long long int n, time, i, a;
    cin>>time>>n;
    int sum = 0;
    for(i = 0; i < n; i++){
        cin>>a;
        sum += a;
    }
    a = time-sum;
    if(a < 0){
        cout<<"-1\n";
    }
    else{
        cout<<a<<endl;
    }
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int h, w, k, sx, sy;
char c[805][805];
int far[805][805];
struct info {
	int x, y, far;
};
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
void bfs() {
	queue<info>que;
	que.push({ sx,sy,0 });
	rep(i, h)rep(j, w)far[i][j] = inf;
	far[sx][sy] = 0;
	while (!que.empty()) {
		info p = que.front(); que.pop();
		if (far[p.x][p.y] < p.far)continue;
		rep(i, 4) {
			int nx = p.x + dx[i], ny = p.y + dy[i];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w || c[nx][ny] == '#')continue;
			if (far[nx][ny] > p.far + 1) {
				far[nx][ny] = p.far + 1; que.push({ nx,ny,p.far + 1 });
			}
		}
	}
}
signed main() {
	cin >> h >> w >> k;
	rep(i, h)rep(j, w) {
		cin >> c[i][j];
		if (c[i][j] == 'S') { sx = i, sy = j; }
	}
	bfs();
	int ans = inf;
	rep(i, h)rep(j, w) {
		if (far[i][j] > k)continue;
		int fa = min({ i,j,h - 1 - i,w - 1 - j });
		int memo;
		if (fa % k == 0)memo = fa / k;
		else memo = fa / k + 1;
		chmin(ans, memo + 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int ans(7 % k);
  int cur(7 % k);
  int res(1);
  while (ans) {
    cur = cur * 10 % k;
    ans = (ans + cur) % k;
    res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iomanip>
#include <utility>
#include <algorithm>
#include <type_traits>
#include <set>
#include <string>
#include <iostream>
#include <fstream>
#include <cassert>
#include <memory>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <queue>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <forward_list>
#include <iomanip>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <sstream>
#include <numeric>

using namespace std;
#define MFOR(i,end) for(size_t i = 0, end_i = (end); i < end_i; ++ i)

int N,T;
int a[10000000];

int main()
{
	std::cin >> N >> T;
	for (size_t i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	int max_score = 0;
	int count = 0;
	int min_value = a[0];
	for (size_t i = 1; i < N; ++i)
	{
		if (min_value + max_score < a[i]) {
			max_score = a[i] - min_value;
			count = 1;
		}
		else if (min_value + max_score == a[i]) {
			++count;
		}
		else {
			min_value = std::min(min_value, a[i]);
		}
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N;
    int T[N];
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
    }
    cin >> M;
    vector<pair<int, int>> p(M);
    for (int i = 0; i < M; ++i) {
        pair<int, int> pa;
        cin >> pa.first >> pa.second;
        p[i] = pa;
    }

    for (int i = 0; i < M; ++i) {
        int answer = 0;
        for (int j = 0; j < N; ++j) {
            if (p[i].first - 1 == j) {
                answer += p[i].second;
            } else {
                answer += T[j];
            }
        }
        cout << answer << endl;
    }

    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int  INF =  1e9;
const ll LINF = 1e18;
const ll MOD = 1e9+7;
const int SIZE = 100;

template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}

template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
 
ll fac[SIZE], inv[SIZE], facinv[SIZE];
void make() {
	fac[0] = fac[1] = 1; inv[1] = 1; facinv[0] = facinv[1] = 1;
	for (ll i = 2; i < SIZE; i++) {
		fac[i] = (fac[i-1] * i) % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		facinv[i] = facinv[i-1] * inv[i] % MOD;
	}
}
ll combi(ll a, ll b) {
	if (a < b) return 0;
	return fac[a] * (facinv[b] * facinv[a-b] % MOD) % MOD;
}

int main() {
	ll n, p;
	ll ki, gu;
	ki = gu = 0;
	scanf ("%lld %lld", &n, &p);
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		if (a[i] % 2 == 0) {
			gu++;
		} else {
			ki++;
		}
	}
	
	make();
	if (p == 0) {
		if (ki == 0) {
			printf("%lld\n", (ll)pow(2, n));
			return 0;
		} else {
			printf("%lld\n", (ll)pow(2, n-1));
			return 0;
		}
	} else {
		if (ki >= 1) {
			printf("%lld\n", (ll)pow(2, n-1));
			return 0;
		} else {
			printf("%lld\n", (ll)0);
			return 0;
		}
	}
	return 0;
}


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

int main(){
    ll n; 
    cin >> n;
    map<char, ll> c;
    rep(i, 0, n){
        string s; cin >> s;
        if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')c[s[0]]++;
    }
    if(c.size() < 3){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    rep(i, 0, c.size()-2){
        rep(j, i+1, c.size()-1){
            rep(k, j+1, c.size()){
                auto itr = c.begin();
                ans += next(itr,i)->second*next(itr,j)->second*next(itr,k)->second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cmath>
#include<iostream>

using namespace std;
 
int main(){
int a[4],b[4];

	while(cin >>a[0]>>a[1]>>a[2]>>a[3]){
		cin >>b[0]>>b[1]>>b[2]>>b[3];

		int ht=0, br=0;

		for(int i=0; i<4; i++){
			if(a[i]==b[i]) ht++;
			for(int j=0; j<4; j++)
				if(a[i]==b[j]) br++;
		}

		cout<<ht<<" "<<br-ht<<endl;
	}
    return 0;
}

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

using namespace std;

int v[11][11];
int e[10005];


int calculate_e(int i, int j, int k, int l) {
	return v[v[v[v[0][i]][j]][k]][l];
}

int main() {
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> v[i][j];
		}
	}

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				for (int l = 0; l < 10; l++) {
					size_t idx = i * 1000 + j * 100 + k * 10 + l; 
					e[idx] = calculate_e(i, j, k, l);
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 10000; i++) {
		int d1 = i / 1000;
		int d2 = (i % 1000) / 100;
		int d3 = (i % 100) / 10;
		int d4 = i % 10;
		bool x = true;
		if (v[e[d2 * 1000 + d1 * 100 + d3 * 10 + d4]][e[i]] == 0 && d1 != d2) x = false;
		if (v[e[d1 * 1000 + d3 * 100 + d2 * 10 + d4]][e[i]] == 0 && d2 != d3) x = false;
		if (v[e[d1 * 1000 + d2 * 100 + d4 * 10 + d3]][e[i]] == 0 && d3 != d4) x = false;
		if (v[e[d1 * 1000 + d2 * 100 + d3 * 10 + e[i]]][d4] == 0 && e[i] != d4) x = false;
		// First digit
		for (int j = 0; j < 10; j++) {
			if (j == d1) continue;
			if (v[e[j * 1000 + d2 * 100 + d3 * 10 + d4]][e[i]] == 0) {
				x = false;
			}
		}
		// Second digit
		for (int j = 0; j < 10; j++) {
			if (j == d2) continue;
			if (v[e[d1 * 1000 + j * 100 + d3 * 10 + d4]][e[i]] == 0) {
				x = false;
			}
		}
		// Third digit
		for (int j = 0; j < 10; j++) {
			if (j == d3) continue;
			if (v[e[d1 * 1000 + d2 * 100 + j * 10 + d4]][e[i]] == 0) {
				x = false;
			}
		}
		// Forth digit
		for (int j = 0; j < 10; j++) {
			if (j == d4) continue;
			if (v[e[d1 * 1000 + d2 * 100 + d3 * 10 + j]][e[i]] == 0) {
				x = false;
			}
		}
		// Fifth digit
		for (int j = 0; j < 10; j++) {
			if (e[i] == j) continue;
			if (v[e[d1 * 1000 + d2 * 100 + d3 * 10 + d4]][j] == 0) {
				x = false;
			}
		}

		if (!x) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3160
N = int(input())
A = list(map(int, input().split()))
from fractions import gcd
from math import ceil
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations
ans = 0
d = Counter(A)
if N%2==1:
    for i in range(0,N,2):
        # print(i)
        if i==0:
            if d[i]!=1:
                # print('A',A)
                break
        elif d[i]!=2:
            # print('B',i)
            break
    else:
        ans = pow(2,(N-1)//2,10**9+7)
else:
    for i in range(1,N,2):
        if d[i]!=2:
            # print(i)
            break
    else:
        ans = pow(2,N//2,10**9+7)
print(ans)

Measured memory_bytes: 15260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}
using namespace output;
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	FOR(i, K, N) {
		print((arr[i] > arr[i-K]) ? "Yes" : "No");
	}
}

Measured memory_bytes: 3952
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;
const int MOD = 1e9 + 7;
int main() {
    int n;
    cin >> n;
    long long p = 1;
    FOR(i, 0, n) {
        p = (p * (i + 1)) % MOD;
    }
    cout << p << endl;
    return 0;
}

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

  int n,t=0,xa=0,ya=0,r=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int t0,x,y,len;
    cin>>t0>>x>>y;
    t=t0-t;
    len=abs(xa-x)+abs(ya-y);
    if(len>t) r++;
    else if((t+len)%2) r++;
    t=t0;
    xa=x;
    ya=y;
    //   cout<<r<<endl;                                                                                                        
  }
  if(!r) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

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


Measured memory_bytes: 3592
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = IR(5)
print(5 + (n - 1) // min(L))

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

typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int n; cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int dp[n + 1];
    dp[1] = 0, dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; ++i) {
        int k = abs(a[i] - a[i - 2]) + dp[i - 2], m = abs(a[i] - a[i - 1]) + dp[i - 1];
        dp[i] = min(k, m);
    }
    cout << dp[n] << "\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stack>

using namespace std;
int main(int argc, char const* argv[])
{
	stack<int> data;
	int n;

	while( cin >> n ){
		if( n != 0 ) data.push( n );
		else{
			cout << data.top() << endl;
			data.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>

//https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_b?lang=en

int main()
{
    std::ios::sync_with_stdio(false); // toggler av synkronisjon mellom c og c++ data streams. kan ikke blade de etter skrudd av
    std::cin.tie(NULL);               //gj;r at man ikke venter på cout og de can printe samtidig tror jeg

    int N;
    std::cin >> N;

    int A;
    std::cin >> A;

    int B;
    std::cin >> B;

    int placesLeft = A + B;
    int overseasPlaces = B;

    char c;
    std::cin.get(c);
    for (int i = 0; i < N; i++)
    {
        std::cin.get(c);

        if (c == 'a')
        {
            if (placesLeft-- > 0)
            {
                std::cout << "Yes\n";
                continue;
            }
        }
        else if (c == 'b')
        {
            if (overseasPlaces-- > 0)
            {
                if (placesLeft-- > 0)
                {
                    std::cout << "Yes\n";
                    continue;
                }
            }
        }

        std::cout << "No\n";
    }
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

void solve()
{
	string str;
	while(getline(cin, str))
	{
		if(str == "END OF INPUT")
		{
			break;
		}
		str += ' ';
		int n = str.size();
		string temp;
		for(int i = 0; i < n; ++i)
		{
			if(str[i] == ' ')
			{
				cout << temp.size();
				temp.clear();
			}
			else
			{
				temp += str[i];
			}
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,K; cin>>N>>K;

    int64_t ans=K;
    rep(n,2,N+1) ans*=K-1;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

int N;

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

    cin >> N;

    string lval;
    int l = 0;
    cout << l << endl;
    cin >> lval;
    if (lval == "Vacant") return 0;

    int r = N - 1;
    cout << r << endl;
    string rval;
    cin >> rval;
    if (rval == "Vacant") return 0;

    while (r > l) {
        int m = (r + l) / 2 / 2 * 2;
        if (m == l) m++;
        cout << m << endl;

        string ans;
        cin >> ans;
        if (ans == "Vacant") return 0;

        if (ans == lval) {
            l = m;
        } else {
            r = m;
        }
    }

    return 0;
}


Measured memory_bytes: 852
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            long[] NK = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);

            long res = NK[0] % NK[1];
            long temp = Math.Abs(res - NK[1]);
            if (temp < res)
                res = temp;

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N, M;
	int A[50], B[50], C[50], D[50];
	int i, j;
	int dis = 1000000000;
	int ner, num[50] = {0};
	scanf("%d%d", &N, &M);
	for (i = 0; i < N; i++) {
		scanf("%d%d", &A[i], &B[i]);
	}
	for (j = 0; j < M; j++) {
		scanf("%d%d", &C[j], &D[j]);
	}

	int f[50][50];
	for (i = 0; i < N; i++) {
		ner = dis;
		for (j = 0; j < M; j++) {
			f[i][j] = abs(A[i] - C[j]) + abs(B[i] - D[j]);
			if (ner > f[i][j]) {
				ner = f[i][j];
				num[i] = j + 1;
			}
		}
	}
	for (i = 0; i < N; i++) {
		printf("%d\n", num[i]);
	}

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

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

int fun (int a, int n) {
    if (a >= 0) return a;
    return n;
}

int main (void) {
    int n, k;
    scanf("%d %d", &n, &k);

    int lr[n][2], i, j;
    long int a, sum[n + 1];
    sum[0] = 1;
    sum[n] = 0;
    for (i = 0; i < k; i++) {
        scanf("%d %d", &lr[i][0], &lr[i][1]);
        lr[i][1]++;
    }

    for (i = 1; i < n; i++) {
        a = 0;
        for (j = 0; j < k; j++) {
            if (i - lr[j][0] >= 0)
                a += sum[i - lr[j][0]] - sum[fun(i - lr[j][1], n)];
        }
        sum[i] = (sum[i - 1] + a) % 998244353;
    }

    if (sum[n - 1] < sum[n - 2]) sum[n - 1] += 998244353;
    printf("%ld\n", sum[n - 1] - sum[n - 2]);
    return 0;
}

Measured memory_bytes: 3264
// 文字列
import 'dart:io';

void main() {
  String s = stdin.readLineSync();
  String newS;
  bool isMatch;
  isMatch = false;
  while (true) {
    if (s.endsWith("dream")) {
      // 最後に特定のstringがあるか
      newS = s.substring(0, s.length - 5); // 文字列の一部を抜き出す
      isMatch = true;
    } else if (s.endsWith("dreamer")) {
      newS = s.substring(0, s.length - 7);
      isMatch = true;
    } else if (s.endsWith("erase")) {
      newS = s.substring(0, s.length - 5);
      isMatch = true;
    } else if (s.endsWith("eraser")) {
      newS = s.substring(0, s.length - 6);
      isMatch = true;
    } else if (s.length == 0) {
      isMatch = true;
      break;
    } else {
      isMatch = false;

      break;
    }
    s = newS;
  }
  if (isMatch == true) {
    print("YES");
  } else {
    print("NO");
  }
}


Measured memory_bytes: 19064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, ww;
vector<pair<lli, lli>> v;
vector<lli> dp;
int main() {
  cin >> n >> ww;
  init_n(v, n);
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second;
  init_n(dp, ww+1, 0);
  for (lli i=0; i<n; ++i) {
    for (lli w = ww; w >= v[i].first; --w) {
      dp[w] = max(dp[w], dp[w-v[i].first] + v[i].second);
    }
  }
  cout << dp[ww] << endl;
  return 0;
}


Measured memory_bytes: 1024