akhauriyash/Code-Regression huggingface dataset:
/*
 * src.cpp
 *
 *  Created on: 2016/08/25
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;

const int MAX_N=1e5,MAX_SQRTS=3e3;
const ll MAX_S=1e10;

int N;
ll S[MAX_N];

bool pflg[MAX_SQRTS+1];
vector<ll> prime;

ll bsearch(ll x){
	ll l=0,r=prime.size();
	while (l<r){
		ll mid=(l+r)/2;
		if (prime[mid]*prime[mid]==x){
			return mid;
		}
		if (prime[mid]*prime[mid]<x){
			l=mid+1;
		}else{
			r=mid;
		}
	}
	return -1;
}

ll pa(ll x){
	//xのペアを求める
	ll res=1;
	for (int i=0;prime[i]*prime[i]*prime[i]<=MAX_S;i++){
		ll p=prime[i];
		if (x%(p*p)==0){
			x/=p*p;
			res*=p;
		}else if (x%p==0){
			x/=p;
			res*=p*p;
		}
		if (res>MAX_S){
			return -1;
		}
	}
	ll sqrt=bsearch(x);
	if (sqrt==-1){
		res*=x*x;
	}else{
		res*=sqrt;
	}
	return res;
}

void sieve(){
	memset(pflg,true,sizeof(pflg));
	pflg[0]=pflg[1]=false;
	for (int i=2;i<=MAX_SQRTS;i++){
		if (!pflg[i]) continue;
		prime.push_back(i);
		for (int j=i*2;j<=MAX_SQRTS;j+=i){
			pflg[j]=false;
		}
	}
}

map<ll,bool> mflg;
map<ll,int> mp;

int main(){
	scanf("%d",&N);
	REP(i,N){
		scanf("%lld",&S[i]);
	}
	sieve();
	REP(i,N){
		for(int j=0;j<prime.size();j++){
			ll p=prime[j];
			while(S[i]%(p*p*p)==0){
				S[i]/=p*p*p;
			}
		}
		mp[S[i]]++;
		mflg[S[i]]=true;
	}
	int ans=0;
	for(map<ll,int>::iterator ite=mp.begin();ite!=mp.end();ite++){
		if (ite->first==1){
			continue;
		}
		ll pa=ite->first*ite->first;
		for(int i=0;i<prime.size();i++){
			ll p=prime[i];
			while (pa%(p*p*p)==0){
				pa/=p*p*p;
			}
		}
		ans+=max<ll>(ite->second,mp[pa]);
		ite->second=0;
		mp[pa]=0;
	}
	if (mp[1]>0){
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 25728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct P{
    int oya;
    int point;
};

ll dp[200010];

int main() {
    int n, q; cin >> n >> q;
    vector<vector<int>> v(n,vector<int>());
    rep(i,n-1){
        int a, b; cin >> a >> b;
        v[a-1].push_back(b-1);
    }
    vector<int> vq(n,0);
    rep(i,q){
        int node, point; cin >> node >> point;
        vq[node-1] += point;
    }
    dp[0] = vq[0];
    
    rep(i,n){
        rep(j,v[i].size()){
            dp[v[i][j]] = vq[v[i][j]] + dp[i];
        }
    }

    rep(i,n) cout << dp[i] << " ";
    cout << endl;


    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N, M;
    cin >> N >> M;

    vector<vector<int>> g(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        g[from].push_back(to);
        g[to].push_back(from);
    }

    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    vector<int> ans(N);
    vector<int> visited(N, 0);
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int cur = p.first;
        int parent = p.second;
        if (visited[cur] == 1) continue;
        visited[cur] = 1;
        ans[cur] = p.second;

        for (const auto& adj: g[cur]) {
            if (visited[adj] == 1) continue;
            q.push(make_pair(adj, p.first));
        }
    }

    cout << "Yes" << endl;
    for (int k = 1; k < N; k++) {
        cout << ans[k] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 11284
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
bool t[N];
vector<vector<int> > g;

void dfs(int u, int p) {

	for (int i = 0; i < g[u].size(); i++) {
		int v = g[u][i];
		if (v != p) {
			dfs(v, u);
		}
	}
	if (p >= 0 && !t[u] && !t[p]) {
		t[u] = t[p] = 1;
	}
}

int main() {

//	freopen("readin.txt", "r", stdin);

	int n;
	scanf("%d", &n);
	g.resize(n);
	for (int i = 0, a, b; i < n - 1; i++) {
		scanf("%d%d", &a, &b);
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++) {
		if (!t[i]) {
			puts("First");
			return 0;
		}
	}
	puts("Second");
	return 0;
}


Measured memory_bytes: 5888
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(3e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

ll fact[INIT]={0};

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    fact[0]=1;
    FORI(i,1,INIT)
    {
        fact[i]=(fact[i-1]*i)%MOD;
    }
    ll R1,C1,R2,C2;
    cin>>R1>>C1>>R2>>C2;
    ll ans=0;
    FORI(i,C1,C2+1)
    {
        ans=(ans + (fact[i+R2+1]*modInverse((fact[R2]*fact[i+1])%MOD))%MOD - (fact[i+R1]*modInverse((fact[R1-1]*fact[i+1])%MOD))%MOD +MOD)%MOD;
    }
    cout<<ans<<endl;

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 23680
//テンプレ
#include <bits/stdc++.h>
#define int long long
#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()

using namespace std;
constexpr int MOD = 1e9+7;
constexpr int INF = 1LL << 60;
template <class T = int> inline T in() { T x; cin >> x; return (x);}
template <class T = int> inline void out (const T& x){ cout << x << '\n' ;}
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
//

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

    int N = in();
    int K = in();
    vector<int> h(N);
    REP(i,N)cin >> h[i];   
    sort(h.begin(),h.end());
    int ans = INF;
    REP(i,N-K+1) chmin(ans,h[i+K-1]-h[i]);
    out(ans);

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 60;

int main()
{
  ld a, b;
  cin >> a >> b;
  cout << (ll)(a * b) << endl;
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    bool ans = true;
    if (S[2] != S[3]) ans = false;
    if (S[5] != S[4]) ans = false;
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    long long t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    if (a1 > b1) {
        swap(a1, b1);
        swap(a2, b2);
    }

    if (a1 == b1 || t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
        cout << "infinity" << endl;
    } else if (t1 * a1 + t2 * a2 < t1 * b1 + t2 * b2) {
        cout << "0" << endl;
    } else {
        long long d1 = t1 * b1 - t1 * a1;
        long long d2 = (t1 * a1 + t2 * a2) - (t1 * b1 + t2 * b2);
        cout << 2 * (d1 / d2) - (d1 % d2 == 0 ? 1 : 0) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main(){
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    int num=0;
    for(int i=2;i<n;i++){
        if(a[i]>a[i-1] && a[i]<a[i+1]) num++;
        else if(a[i]<a[i-1]&& a[i]>a[i+1]) num++;
    }
    cout<<num<<endl;
}


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

int main() {
  string a, b; cin >> a >> b;
  
  int ab = stoi(a + b);
  
  bool judge = false;
  for (int i = 0; i <= 400; i++) if (ab == i * i) judge = true;
  
  if (judge) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <random>

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


typedef int64_t int64;


using namespace std;

/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    /// caide keep
    template<int N>
    struct bytetype {
        
    };

    /// caide keep
    template<>
    struct bytetype<4> {
        
    };

    /// caide keep
    template<>
    struct bytetype<3> {
        
    };

    /// caide keep
    template<>
    struct bytetype<2> {
        
    };

    /// caide keep
    template<>
    struct bytetype<1> {
        
    };

    /// caide keep
    template<>
    struct bytetype<0> {
        
    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vector(istream& in, size_t n) {
    vector<T> ret(n);
    for (size_t i = 0; i < n; ++i) {
        ret[i] = next<T>(in);
    }
    return ret;
}


map<int64, int64> pair_num;
map<int64, int> dict;
vector<int> primes;

vector<int64> primes3;


void factorize3(int64 x) {
    FOR(i, primes3.size()) {
        while (x % primes3[i] == 0) {
            x /= primes3[i];
        }
    }
    int64 xr = x * x;
    int64 number = x;
    FOR(i, primes3.size()) {
        while (xr % primes3[i] == 0) {
            xr /= primes3[i];
        }
    }
    int64 rev_number = xr;
    pair_num[number] = rev_number;
    pair_num[rev_number] = number;
    dict[number]++;
}

bool u[4001];

void prepare() {
    if (!primes.empty())
        return;
    primes3.reserve(4000);
    for (int i = 2; i < 4000; ++i) {
        if (!u[i]) {
            primes3.push_back(i * 1LL * i * 1LL * i);
            for (int j = i + i; j < 4000; j += i) {
                u[j] = true;
            }
        }
    }
}

void solve(istream& in, ostream& out) {
    prepare();
    dict.clear();
    int n = next<int>(in);
    vector<int64> a = next_vector<int64>(in, n);
    for (int64 el : a) { factorize3(el); }
    int res = 0;
    for (auto v : dict) {
        if (v.first == 1) {
            ++res;
            continue;
        }
        int64 rev_v = pair_num[v.first];
        res += max(v.second, dict[rev_v]);
        dict.erase(rev_v);
    }
    out << res << endl;
}


int main() {
    solve(cin, cout);
    return 0;
}



Measured memory_bytes: 19840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m;
	cin >> n >> m;
	int a[m], sum = 0;
	for(int i = 0; i < m; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if(sum > n) {
		cout << -1;
	}
	else {
		cout << (n - sum);
	}

	return 0;
}

Measured memory_bytes: 3672
import re

S1 = input()						# 5
T = input()						# 5

S = re.sub(r'\?', '.', S1)

X="UNRESTORABLE"

#print(S, T)

N = len(S)-len(T)+1

A=-1

for i in range(N):
	s = S[i:(len(T)+i)]
	m = re.match(s, T)
	if m:
		A = i
	#print(i, s, A)

#print(A)

if A==-1:
	ans = X
else:
	ans = S[0:A] + T + S[(A + len(T)):len(S)]
	ans = re.sub(r'\.', 'a', ans)

#print(S1)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define MOD 1000000007

typedef long lint;
typedef pair<lint, lint> P;
bool lessPair(const P& l, const P& r){return l.second < r.second;}
bool morePair(const P& l, const P& r){return l.second > r.second;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint K; cin >> K;

    vector<P> sushi(N);
    
    REP(i, N) {
      lint t; cin >> t;
      lint d; cin >> d;

      sushi[i] = P(t,d);
    }

    sort(sushi.begin(), sushi.end(), morePair);

    vector<lint> res(N+1, 0);
    vector<lint> best_kind(N+1, 0);
    vector<lint> rest;

    lint min_kind = 0;
    lint res_val = 0;
    REP(i, K) {
      lint kind = sushi[i].first;
      lint val = sushi[i].second;

      if(best_kind[kind] == 0) {
        best_kind[kind] = val;
        res[kind] = val;
        min_kind++;
      } else {
        rest.push_back(val);
      }
      res_val += val;
    }

    res[min_kind] = res_val + min_kind*min_kind;

    lint max_kind = min_kind;
    FOR(i, K, N) {
      lint kind = sushi[i].first;
      lint val = sushi[i].second;

      if(rest.size() == 0) break;

      //PRINT(best_kind[kind]);

      if(best_kind[kind] == 0) {
        best_kind[kind] = val;
        res_val += val;
        res_val -= rest[rest.size()-1];
        rest.pop_back();
        max_kind++;

        res[max_kind] = res_val + max_kind*max_kind;
        if(rest.size() == 0) break;
      } else {
      }
    }

    //    EACHPRINT(res, lint);

    lint m = *max_element(res.begin()+min_kind, res.begin()+max_kind+1);

    PRINT(m);
    
    return 0;
}


Measured memory_bytes: 4092
// ------------------------------------
// Date:2018/ 2/26
// Problem:AGC 013 SortedArrays a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

using ll = long long;

#define MOD 1000000007

int main()
{
  int N,last,next,state = -1,cnt = 0;
  cin >> N;
  REP(i,N) {
    cin >> next;
    if (state == -1) {
      last = next;
      state = 0;
    } else if (state == 0) {
      if (next < last) {
        state = 2;
      } else if (next > last) {
        state = 1;
      }
    } else if (state == 1) {
      if (next < last) {
        ++cnt;
        state = 0;
      }
    } else {
      if (next > last) {
        ++cnt;
        state = 0;
      }
    }
    last = next;
  }
  cout << ++cnt << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <sstream>
#include <complex>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using iii = pair<int, ii>;
using viii = vector<iii>;

using ll = long long int;
using vc = vector<char>;
using vb = vector<bool>;
using ib = pair<int, bool>;
using vib = vector<ib>;

#define MOD 1000 * 1000 * 1000 + 7
#define INF 1000 * 1000 * 1000
#define X real()
#define y imag()

bool resuelveCaso() {
	int n;
	cin >> n;
	if (!cin) return false;
	int k;
	cin >> k;

	if (n % k == 0) cout << "0\n";
	else cout << "1\n";

	return true;
}

int main() {
	while (resuelveCaso()) {}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <cmath>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;
#define REP(i,n) for(ll i=0;i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)
 
struct node{
	node * left = nullptr;
	node * right = nullptr;
	int v;
};
 
ll parse_int(int & index, string & s){
	string si;
	while ('0' <= s[index] && '9' >= s[index] ){
		si.push_back(s[index]);
		index++;
	}
 
	return stoi(si);
}
 
node * parse(int & index, string & s){
	if (s[index] == ')') return nullptr;
	auto current = new node;
	index++; // (
	current->left = parse(index, s);
	index++; // )
	index++; // [
	current->v = parse_int(index, s);
	index++; // ]
	index++; // (
	current->right = parse(index, s);
	index++; // )
 
	return current;
}
 
node * bfs(node * a, node * b){
	node * current = new node;
	if (a->left && b->left){
		current->left = bfs(a->left, b->left);
	}
	if (a->right && b->right){
		current->right = bfs(a->right, b->right);
	}
	current->v = a->v + b->v;
	return current;
}
 
string output(node * current){
	if (!current) return "";
	string s = "(";
	s += output(current->left);
	s += ")[";
	s += to_string(current->v);
	s += "](";
	s += output(current->right);
	s += ")";
	return s;
}
 
int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	string A, B;
	cin >> A >> B;
	int indexa = 0, indexb = 0;
	auto a = parse(indexa, A);
	auto b = parse(indexb, B);
	auto c = bfs(a,b);
	cout << output(c) << endl;
	return 0;
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    int count=0;
    int maxcount=-1;
    
    for(auto a:s){
        if(a=='A' || a=='C' || a=='G' || a=='T') count++;
        else {
            maxcount=max(maxcount,count);
            count=0;
        }
        
        if(a==s.at(s.size()-1)){
            maxcount=max(maxcount,count);
        }
        
    }
    
    cout<<maxcount<<endl;
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !

import fileinput

for line in fileinput.input():
    (hight,width) = map(int,line.split(" "))
    
    if hight == 0 and width == 0:
        break
    
    for a in range(hight):
        for b in range(width):
            print("#", end="")
        print("")
    print("")

Measured memory_bytes: 9128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int max = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            max = Math.max(max, a);
            min = Math.min(min, a);
        }
        System.out.println(max - min);
    }
}

Measured memory_bytes: 22228
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    F = [list(map(int, input().split())) for i in range(N)]
    P = [list(map(int, input().split())) for i in range(N)]
    profit = -10**10
    # bit全探索
    # https://qiita.com/gogotealove/items/11f9e83218926211083a#%E4%BE%8B%E9%A1%8C-1
    n = 10
    # 昇順での探索だよ
    for i in range(1, 2 ** n):
        bag = [0] * N
        cnt = 0

        """        
        10進数表記　2進数表記
        0           000
        1           001
        2           010
        3           011
        4           100
        5           101
        6           110
        7           111
        """

        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                for k in range(N):
                    if F[k][j] == 1:
                        bag[k] += 1
        for l in range(N):
            cnt += P[l][bag[l]]
        profit = max(profit, cnt)
    print(profit)


resolve()

Measured memory_bytes: 42480
#include <bits/stdc++.h>
using namespace std;
const long long k=1e11;
#define ll long long
void min_s(ll &a,ll b){
	a=min(a,b);
}
int main() {
	ll n,m;
	cin>>n>>m;
	ll w[n],p[n];
	ll sum=0;
	
	for(ll i=0;i<n;i++){
		cin>>w[i]>>p[i];
		sum+=p[i];
	}
	
	vector<ll>v(sum+1,k);
	v[0]=0;
	for(ll i=0;i<n;i++){
		for(ll j=sum-p[i];j>=0;--j){
			min_s(v[j+p[i]],v[j]+w[i]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=sum;i++){
		//cout<<v[i]<<' ';
		if(v[i]<=m){
			ans=max(ans,i);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n;
    while(cin>>n){
        if(n==0){break;}
    vector<pll> A(n);
    const ll C=30000;
    for(auto &I:A){cin>>I.F>>I.S; I.S+=C;}
    vector<pair<pair<ll,ll>,pll>> B;
    for(int i=1;i<=n;i++){
        if(A[i%n].F==A[i-1].F){
            if(A[i-1].S<A[i%n].S){B.push_back({{A[i%n].F,3},{A[i-1].S,A[i%n].S}});}
            else{B.push_back({{A[i%n].F,2},{A[i%n].S,A[i-1].S}});}
        }
    }
    vector<pll> S(4);
    for(auto &I:S){cin>>I.F>>I.S; I.S+=C;}
    for(int i=1;i<=4;i++){
        if(S[i%4].F==S[i-1].F){
            if(S[i-1].S<S[i%4].S){B.push_back({{S[i%4].F,1},{S[i-1].S,S[i%4].S}});}
            else{B.push_back({{S[i%4].F,0},{S[i%4].S,S[i-1].S}});}
        }
    }
    sort(B.begin(),B.end());
    vector<bool> in(2*C,false);
    vector<bool> sq(2*C,false);
    ll bef=-E;
    ll ans=0;
    for(auto &I:B){
        for(int i=0;i<2*C;i++){
            if(in[i] && !sq[i]){ans+=I.F.F-bef;}
        }
        if(I.F.S>>1&1){
            for(ll i=I.S.F;i<I.S.S;i++){in[i]=!in[i];}
        }
        else{
            for(ll i=I.S.F;i<I.S.S;i++){sq[i]=!sq[i];}
        }
        bef=I.F.F;
        //cout<<bef<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main()
{
	int q,inv=0,t,f;
	string s,smae="";
	char c;
	cin>>s>>q;
	s.reserve(310000);
	smae.reserve(210000);
	rep(i,q){
	    cin>>t;
	    if(t==1)inv++;
	    if(t==2){
	        cin>>f>>c;
	        if((f+inv)%2)smae.push_back(c);
	        else s.push_back(c);
	    }
	}
	if(inv%2){
	    int k=s.size();
	    rep(i,k){
	        cout<<s[k-1-i];
	    }
	    cout<<smae;
	}
	else {
	    int j=smae.size();
	    rep(i,j){
	        cout<<smae[j-1-i];
	    }
	    cout<<s;
	}
	return 0;
}

Measured memory_bytes: 924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=1e5+10;
ll a[Maxn];
map <ll,ll> mp;
set <ll>   S;
//struct Node{
//    ll a;
//    friend bool operator <(const Node A,const Node B){
//        return A.a>B.a;
//    }
//};
//multiset <Node>  S;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
//    S.insert((Node){1});
//    S.insert((Node){1});
//    auto it=S.begin();
//    cout<<it->a;
//    (it->a);
//    cout<<
//    S.insert((Node){4});
//    S.insert((Node){5});
//    S.insert((Node){7});
//    S.insert((Node){8});
//    auto it=S.lower_bound((Node){0});
//    if(it==S.end()){
//        cout<<121<<endl;
//    }
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)    cin>>a[i];
    S.insert(a[1]);
    mp[a[1]]++;
    for(ll i=2;i<=n;i++) {
        ll temp=a[i];
        auto it=S.lower_bound(temp);
        if(it==S.begin()){
            if(temp!=*it)   S.insert(temp);
            mp[temp]++;
        }else{
            it--;
            if(*it==temp){
                if(it!=S.begin()){
                    it--;
                    ll now=*it;
                    if(mp[now]==1)  S.erase(it);
                    mp[now]--;
                    S.insert(temp);
                    mp[temp]++;
                }else{
                    mp[temp]++;
                }
            }else{
                ll now=*it;
                if(mp[now]==1)  S.erase(it);
                mp[now]--;
                S.insert(temp);
                mp[temp]++;
            }
        }
    }
    ll ans=0;
    for(auto it=S.begin();it!=S.end();it++){
        ll now=*it;
        ans+=mp[now];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 15072
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> anser(n, 0);
  REP(i, q) {
    int a;
    cin >> a;
    a--;
    anser[a]++;
  }

  REP(i, n) {
    if (k - q + anser[i] > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 1024
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(D)]
res = 1<<29
for bit in range(1<<D):
  ans = 0
  num = 0
  for j in range(D):
    if bit&(1<<j):
      ans += pc[j][0]*(j+1)*100+pc[j][1]
      num += pc[j][0]
  if ans >=G:
    res = min(num,res)
  else:
    for j in range(D-1,-1,-1):
      if bit&(1<<j):
        continue
      else:
        for i in range(pc[j][0]):
          if ans>=G:
            break
          ans += 100*(j+1)
          num +=1
    res = min(num,res)
print(res)

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

int main() {
  string s;

  int cnt = 0;

  cin >> s;

  if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cnt++;

  for (int i = 0; i < s.length(); i++) {
    if (s[i - 1] == 'R' && s[i] == 'R') {
      cnt++;
    }
  }

  cout << cnt;

  return 0;
}

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

int N, a[200001], b[200001];

int main() {
    cin >> N;
    rep(i, N) cin >> a[i+1];

    vector<int> ans;
    for (int i = N; i > 0; i--) {
        int sum = 0;
        for (int j = i + i; j <= N; j += i) {
            sum ^= b[j];
        }
        if (sum ^ a[i]) {
            b[i] = 1;
            ans.push_back(i);
        }
    }

    cout << ans.size() << endl;
    rep(i, ans.size()) {
        cout << ans[i] << (i != ans.size() - 1 ? " " : "\n");
    }
}

Measured memory_bytes: 2936
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<int> Node;
typedef vector<Node> Graph;
int V1, V2;
Graph G;
int dist[1002];
int match[1002];
const int NIL = 1001;
bool BFS(){
  queue<int> que;
  REP(v, V1){
    if(match[v] == NIL){
      dist[v] = 0;
      que.push(v);
    }else{
      dist[v] = INF;
    }
  }
  dist[NIL] = INF;
  while(!que.empty()){
    int v = que.front(); que.pop();
    if(dist[v] < dist[NIL]){
      for(int i = 0; i < G[v].size(); i++){
        int u = G[v][i];
        if(dist[match[u]] == INF){
          dist[match[u]] = dist[v] + 1;
          que.push(match[u]);
        }
      }
    }
  }
  return dist[NIL] != INF;
}

bool DFS(int v){
  if(v != NIL){
    for(int i = 0; i < G[v].size(); i++){
      int u = G[v][i];
      if(dist[match[u]] == dist[v] + 1 && DFS(match[u])){
        match[u] = v;
        match[v] = u;
        return true;
      }
    }
    dist[v] = INF;
    return false;
  }
  return true;
}

int Hopcroft_Karp(){
  REP(v, G.size()) match[v] = NIL;
  int matching = 0;
  while(BFS()){
    REP(v, V1){
      if(match[v] == NIL && DFS(v)){
        matching ++;
      }
    }
  }
  return matching;
}
int main(){
  while(scanf("%d %d", &V1, &V2) && (V1 != 0 || V2 != 0)){
    G = Graph(V1 + V2);
    static int blue[500];
    static int red[500];
    if(V1 > V2){
      REP(i, V1) scanf("%d", blue + i);
      REP(i, V2) scanf("%d", red + i);
      REP(u, V1) REP(v, V2){
        if(__gcd(blue[u], red[v]) != 1) {
          G[u].push_back(V1 + v);
          //G[V1 + v].push_back(u);
        }
      }
    }else{
      swap(V1, V2);
      REP(i, V2) scanf("%d", blue + i);
      REP(i, V1) scanf("%d", red + i);
      REP(v, V2) REP(u, V1){
        if(__gcd(blue[v], red[u]) != 1) {
          G[u].push_back(V1 + v);
          //G[V1 + v].push_back(u);
        }
      }
    }
    printf("%d\n", Hopcroft_Karp());
  }
  return 0;
}

Measured memory_bytes: 2192
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  dv(c,char,3,3,0);
  rep(i,0,3){
    rep(j,0,3){
      cin>>c.at(i).at(j);
      if(i==j)nou(c.at(i).at(j));
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,c,ngo;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a > b){
        ngo = a;
        a = b;
        b = ngo;
    } 
    
    if(b > c){
        ngo = b;
        b = c;
        c = ngo;
    }

    if(a > b){
        ngo = b;
        b = a;
        a = ngo;
    }
    
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 1024
sheet=[list(map(int,input().split())) for i in range(3)]
n=int(input())
number=[int(input()) for i in range(n)]
answer="No"

for i in range(3):
   for j in range(3):
      if sheet[i][j] in number:
        sheet[i][j]=0

if sheet[0][0]+sheet[1][1]+sheet[2][2]==0 or sheet[2][0]+sheet[1][1]+sheet[0][2]==0:
  answer="Yes"
else:        
  for i in range (3):
    if sheet[i]==[0,0,0]:
      answer="Yes"
    elif sheet[0][i]==0 and sheet[1][i]==0 and sheet[2][i]==0:
      answer="Yes"

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    int r,g;
    
    cin>>r>>g;
    
   
    cout<<2*g-r; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int dp[N],a[N];
int32_t main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		dp[i]=1e18;
	}
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>=max(1LL,i-k);j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n]<<endl;
	

}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main() {

int h,w,n;
 cin>>h>>w>>n;
  int c=0,m=0; 
  if(h>=w){rep(i,w){m+=h;c++;if(m>=n)break;}}
  else{rep(i,h){m+=w;c++;if(m>=n)break;}}
  if(n==0){c=0;}
  cout<<c<<endl;
  
}


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

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

void alpha(){

	ll h, n, a;
	cin>>h>>n;

	ll sum=0;
	ll temp=0;
	loop(i,0,n){
		cin>>temp;
		sum+=temp;
	} 

	if(sum>=h) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	
	return;

}

int main(){

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


    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int i;
    int ans = 0;
    int temp = 0;
    for(i = 0;i < s.size();++i){
        if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T'){
            ++temp;
        }else{
            if(temp > ans){
                ans = temp;
            }
            temp = 0;
        }
    }
    if(temp > ans){
        ans = temp;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int to, dist;
  edge(){}
  edge(int to, int dist):to(to), dist(dist){}
};

int N, M, C;
string S, D;
vector< tuple<string, string, int> > road;
vector< vector<edge> > graph;
map<string, int> city;
set<int> st;
vector< vector<int> > mindist;

struct stat {
  int now, dist, gas;
  stat(){}
  stat(int now, int dist, int gas):now(now), dist(dist), gas(gas){}
  bool operator < (const stat s) const {
    return dist > s.dist;
  }
};

int dijkstra(int sz) {
  mindist.clear();
  mindist.resize(sz, vector<int>(C+1, inf));
  priority_queue<stat> que;
  mindist[0][C] = 0;
  que.emplace(0, 0, C);
  while(que.size()) {
    stat s = que.top(); que.pop();
    int now = s.now, dist = s.dist, gas = s.gas;
    if(now == 1) return dist;
    if(mindist[now][gas] < dist) continue;
    for(edge& e : graph[now]) {
      int ngas = gas - e.dist;
      if(ngas < 0) continue;
      if(st.count(e.to)) ngas = C;
      if(e.dist + dist < mindist[e.to][ngas]) {
	mindist[e.to][ngas] = e.dist + dist;
	que.emplace(e.to, mindist[e.to][ngas], ngas);
      }
    }
  }
  return -1;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> N >> M >> C, N || M || C) {
    city.clear();
    st.clear();
    road.clear();
    graph.clear();
    C *= 10;
    cin >> S >> D;
    city[S] = 0;
    city[D] = 1;
    int cnt = 2;
    rep(i, N) {
      string a, b; int d;
      cin >> a >> b >> d;
      if(!city.count(a)) city[a] = cnt++;
      if(!city.count(b)) city[b] = cnt++;
      road.emplace_back(a, b, d);
    }
    graph.resize(cnt);
    rep(i, N) {
      string a, b; int d;
      tie(a, b, d) = road[i];
      graph[city[a]].emplace_back(city[b], d);
      graph[city[b]].emplace_back(city[a], d);
    }
    rep(i, M) {
      string s;
      cin >> s;
      st.insert(city[s]);
    }
    cout << dijkstra(cnt) << endl;
  }

  return 0;
}

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

int main() {
    int k;
    cin >> k;

    int tmp = 7 % k;
    int cnt = 1;
    for(int i = 0; i < k; i++) {
        if (tmp == 0) {
            break;
        }
        tmp = (tmp*10+7) % k;
        cnt++;
    }
    if (tmp != 0) {
        cnt = -1;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3620
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

x = inint()

ans = 0

for i in range(1,10**5):
    if i*(i+1)/2 >= x:
        print(i)
        break



Measured memory_bytes: 63176
// https://atcoder.jp/contests/dp/tasks/dp_h

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

double expected_count(long long c1, long long c2, long long c3, vector<vector<vector<double>>>& dp, long long n) {
	if (c1 == 0 && c2 == 0 && c3 == 0) {
		return 0.0;
	}
	if (dp[c1][c2][c3] >= 0.0) {
		return dp[c1][c2][c3];
	}
	long long c = c1 + c2 + c3;
	double expected_c = 1.0 / ((double)c / (double)n);
	long long total_next = 0;
	double total_next_c = 0.0;
	if (c1 > 0) {
		total_next += c1;
		total_next_c += expected_count(c1 - 1, c2, c3, dp, n) * (double)c1;
	}
	if (c2 > 0) {
		total_next += c2;
		total_next_c += expected_count(c1 + 1, c2 - 1, c3, dp, n) * (double)c2;
	}
	if (c3 > 0) {
		total_next += c3;
		total_next_c += expected_count(c1, c2 + 1, c3 - 1, dp, n) * (double)c3;
	}
	if (total_next > 0) {
		expected_c += total_next_c / (double)total_next;
	}
	return dp[c1][c2][c3] = expected_c;
}

int main (int argc, char* argv[]) {
	long long n;
	cin >> n;

	long long c1 = 0;
	long long c2 = 0;
	long long c3 = 0;
	for (long long i = 0; i < n; i++) {
		long long c;
		cin >> c;
		switch (c) {
			case 0:
				break;
			case 1:
				c1++;
				break;
			case 2:
				c2++;
				break;
			case 3:
				c3++;
				break;
		}
	}

	vector<vector<vector<double>>> dp(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1, -1.0)));
	cout << setprecision(10) << expected_count(c1, c2, c3, dp, n) << endl;
}


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

ll f(ll x)
{
    if(x % 4 == 0) return x;
    if(x % 4 == 1) return 1L;
    if(x % 4 == 2) return x + 1L;
    else return 0L;
}

int main()
{
    ll a, b;
    cin >> a >> b;
	ll ans = f(a-1) ^ f(b);
    cout << ans << endl;
}


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

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N, X, M;
  cin >> N >> X >> M;

  // main procedure
  unordered_set<ll> Xs;
  vector<ll> Xv;
  Xs.insert(X);
  Xv.push_back(X);

  ll x = X;
  ll i = 1;
  ll j = 0;
  vector<ll> s;
  s.push_back(X);
  while (i < N) {
    x = (x * x) % M;
    if (Xs.count(x) != 0) {
      j = distance(Xv.begin(), find(ALL(Xv), x));
      break;
    } else {
      Xs.insert(x);
      Xv.push_back(x);
      s.push_back(s.back() + x);
    }
    i++;
  }

  ll sj = (j != 0 ? s[j - 1] : 0);
  ll r = (N - j) % (i - j);
  ll ans =
      (s.back() - sj) * ((N - j) / (i - j)) + (j + r != 0 ? s[j + r - 1] : 0);

  // output
  cout << ans << endl;

  return 0;
}

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

using std::vector;
using std::greater;
using std::priority_queue;

const int N=2e5+10;

struct Node {
	int l,r;
	bool operator < ( const Node &A ) const {
		return r<A.r;
	}
	bool operator > ( const Node &A ) const {
		return r>A.r;
	}
}p[N];

int n,m;

void Init() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%d%d",&p[i].l,&p[i].r);
}

bool cmpl( const Node &A , const Node &B ) { return A.l<B.l || (A.l==B.l && A.r<B.r); }

priority_queue<Node,vector<Node>,greater<Node> >Q,T;
void Solve() {
	std::sort(p+1,p+n+1,cmpl);int t=1,inq=0,cant=0;
	while (p[t].l==0 && t<=n) T.push(p[t]),++t;
	for (int i=1;i<=m;++i) {
		while (p[t].l==i && t<=n) {
			if (inq<i) { inq++; if (cant) cant--; Q.push(p[t]); }
			else {
				Q.push(p[t]);
				T.push(Q.top()); Q.pop();
			}
			++t;
		}
		while (inq+cant<i && !T.empty()) {
			Node w=T.top(); 
			if (w.r>i) { cant=i-inq; break;}
			inq++,Q.push(T.top()),T.pop();
		}
	}
	printf("%d\n",n-inq);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 6256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val X = in.nextInt
  def maxExp(i: Int, cur: Int = 1): Int = if (i * cur <= X) maxExp(i, i * cur) else cur
  println(
    if (X < 4) 1
    else (2 to math.sqrt(X).toInt).map(maxExp(_)).max
  )
}

Measured memory_bytes: 55420
n = int(input())
L = []
for i in range(n):
    x, y = map(int, input().split())
    L.append([x, y])

import itertools
import math

ans = 0
for i in itertools.permutations(range(n)):
    for j in range(n-1):
        ans += math.sqrt((L[i[j+1]][0]-L[i[j]][0])**2+(L[i[j+1]][1]-L[i[j]][1])**2)
for i in range(1,n+1):
    ans /= i
print(ans)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    
    int C0 = 0;
    int C1 = 0;
    int C2 = 0;
    int C3 = 0;
    
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        if(S == "AC")
            C0++;
        if(S == "WA")
            C1++;
        if(S == "TLE")
            C2++;
        if(S == "RE")
            C3++;
    }
    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;
}

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

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

  int count = 0;
  char cur_char = ' ';
  for (int i = 0; i < n; i++) {
    if (s[i] != cur_char) {
      count++;
      cur_char = s[i];
    }
  }
  cout << count << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
int main(){while(1){
  int D,E;
  scanf("%d %d",&D,&E);
  if(D==0)break;
  double e=(double)E;
  double min=1000000000;
  for(int i=0;i<D;i++){
    double I=(double)i;
    double J=(double)D-I;
    if(fabs(sqrt(I*I+J*J)-e)<min)min=fabs(sqrt(I*I+J*J)-e);
  }
  printf("%.10f\n",min);
}
return 0;
}



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

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

  vector<int> A(N);

  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }

  int B,C;
  int count=10001;
  
  for(int i=0;i<N;i++){
    B=0;
    C=0;
    for(int j=0;j<i;j++){
      B+=A.at(j);
    }
    for(int j=i;j<N;j++){
      C+=A.at(j);
    }

    //cout << B <<" " << C << endl;

    if(B>=C){
      count=min(count,B-C);
    }
    else{
      count=min(count,C-B);
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256