akhauriyash/Code-Regression huggingface dataset:
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)

ll mod = 1000000007;  // 10^9 + 7

MY_NAMESPACE(testbed)

struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main()
{
	ll modval = 1000000007;  // 10^9 + 7

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> pos, neg;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < 0)
			neg.push_back(a[i]);
		else
			pos.push_back(a[i]);
	}

	bool neg_answer = false;
	if (pos.size() == 0)
		neg_answer = (k % 2 == 1);
	else if (n == k)
		neg_answer = (neg.size() % 2 == 1);

	mint res = 1;
	ll negres = 1;
	ll posres = 1;
	if (neg_answer) {
		sort(a.begin(), a.end(), [](ll x, ll y) -> bool {
			return abs(x) < abs(y);
			});
		for (int i = 0; i < k; i++)
		{
			res *= a[i];
			negres *= a[i];
			negres %= modval;
			negres += modval;
			negres %= modval;
		}
	}
	else
	{
		sort(pos.begin(), pos.end());    // the biggest at last
		sort(neg.rbegin(), neg.rend());  // the biggest abs(negative) at last

		if (k % 2 == 1)
		{
			res = pos.back(); //pos.pop_back();
			posres = pos.back(); pos.pop_back();
		}

		vector<ll> p;
		while (pos.size() > 1)
		{
			ll tmp = pos.back(); pos.pop_back();
			tmp *= pos.back(); pos.pop_back();
			p.push_back(tmp);
		}
		while (neg.size() > 1)
		{
			ll tmp = neg.back(); neg.pop_back();
			tmp *= neg.back(); neg.pop_back();
			p.push_back(tmp);
		}
		sort(p.rbegin(), p.rend());

		for (int i = 0; i < k / 2; i++)
		{
			res *= p[i];
			ll pval = p[i];
			pval %= modval;
			posres *= pval;
			posres %= modval;
		}
	}

	if (neg_answer)
		cout << negres << "\n";
	else
		cout << posres << "\n";
		//cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
const int mod = 1e9 + 7;
vi fact(1e5 + 10);
vi ifact(1e5 + 10);
int binpow(int a,int b){
    int res = 1;
    while(b){
        if(b&1){
            res *= a;
            res %= mod;
        }
        b >>= 1;
        a = (a*a)%mod;
    }
    return res;
}

void facto(){
    fact[0] = 1;
    fact[1] = 1;
    for(int i = 2;i <= 1e5 + 4;++i){
        fact[i] = fact[i - 1]*i;
        fact[i] %= mod;
    }
    ifact[1e5 + 4] = binpow(fact[1e5 + 4],mod - 2);
    for(int i = 1e5 + 3;i >= 0; --i){
        ifact[i] = ifact[i + 1]*(i + 1);
        ifact[i] %= mod;
    }
}


int nCr(int n,int r){
    if(n < r)return 0;
    int num = fact[n]%mod;
    int den = (ifact[r]*ifact[n - r])%mod;
    return (num*den)%mod;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n,k;
    cin >> n >> k;
    
    vi a(n);
    ffor(i,n) cin >> a[i];

    facto();
    
    sort(all(a));

    int mini = 0,maxi = 0;

    ffor(i,n){
        mini += (a[i]*(nCr(n - i - 1LL,k - 1)));
        mini %= mod;
        // cout << mini << ' ';
    }
    reverse(all(a));
    ffor(i,n){
        maxi += (a[i]*(nCr(n - i - 1LL,k - 1)));
        maxi %= mod;
        // cout << maxi << ' ';
    }
    int z = maxi - mini;
    while(z < 0){
        z += mod;
    }
    cout << z%mod << ' ';

}

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

int main()
{   
   int n,t,a;
   cin>>n>>t>>a;
   int h[n];
   double diff=1000000.0;
   int ans;
   for(int i=0;i<n;i++){
       cin>>h[i];
       double temp=t-h[i]*0.006;
       double di=abs(temp-a);
       if(di<diff) {
           ans=i;
           diff=di;
       }
       
   }
   cout<<ans+1<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int>cnt(N,K-Q);
  while(Q--) {
    int A;cin >> A;A--;
    cnt[A]++;
  }
  for(int i = 0; i < N; i++) {
    if(cnt[i] <= 0) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 3768
a, b, c, d = map(int, input().split())
ans = 0
# 求める秒数は(二つのスイッチのうち先に離された方の時刻) - (二つのスイッチのうち後に押された時刻)となる．
_min = min(b, d)
_max = max(a, c)
ans = _min - _max
if ans < 0:
  print(0)
else:
  print(ans)

Measured memory_bytes: 2940
//
//  main.cpp
//  CP-C++
//
//  Created by ALOK KUMAR THAKUR on 05/05/20.
//  Copyright © 2020 ALOK KUMAR THAKUR. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define tc ll T;cin>>T;while(T--)
#define pb push_back
#define Max3(a,b,c) max(a,max(b,c))
#define Min3(a,b,c) min(a,min(b,c))
#define all(v) v.begin(),v.end()

struct cmp {
    bool operator() (ll a,ll b){
        return a < b;
    }
};

/*ll modp(ll a,ll p,ll n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    ll e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1)
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}

ll modInverse(ll n, ll p)
{
    return modp(n, p, p-2);
}
 
ll nCrModPFermat(ll n, ll r,ll p)
{
   // Base case
   if (r==0)
      return 1;
    
    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    ll fac[n+1];
    fac[0] = 1;
    for (ll i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;
  
    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}*/

int main() {
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll n; cin>>n;
    ll d1[n], d2[n];
    for(ll i=0;i<n;i++) cin>>d1[i]>>d2[i];
    ll cnt = 0, flag = 0;
    for(ll i=0;i<n;i++){
        if(d1[i] == d2[i])
            cnt++;
        else
            cnt = 0;
        if(cnt == 3){
            flag = 1;
            break;
        }
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


Measured memory_bytes: 3648
def dist(a, b):
	res = 0
	for i in range(D):
		res += (a[i] - b[i]) ** 2
	res = res ** 0.5
	return res


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		if dist(X[i], X[j]).is_integer():
			ans += 1
print(ans)

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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int n = in.nextInt();
        int m = in.nextInt();

        int[] a = new int[1001];
        int[] b = new int[1001];
        int[] c = new int[1001];

        int[][] dist = new int[101][101];
        for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                if(i==j) dist[i][j] = 0;
                else dist[i][j] = (int)1e7;
            }
        }

        for(int i=0;i<m;i++){
            a[i] = in.nextInt()-1;
            b[i] = in.nextInt()-1;
            c[i] = in.nextInt();
            dist[a[i]][b[i]] = c[i];
            dist[b[i]][a[i]] = c[i];
        }

        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    if(dist[i][k] + dist[k][j] < dist[i][j]){
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }
            }
        }

        int ans = m;
        for(int j=0;j<m;j++){
            boolean check = false;
            for(int i=0;i<n;i++){
                if(dist[i][a[j]]+c[j] == dist[i][b[j]] || dist[i][b[j]]+c[j] == dist[i][a[j]]) check = true;
            }
            if(check) ans--;
        }
        out.print(ans);

    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

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


Measured memory_bytes: 22740
while True:
    a, op, b = map(str, input().split())
    if op == '?':
        break
    elif op == '+':
        y = int(a) + int(b)
    elif op == '-':
        y = int(a) - int(b)
    elif op == '*':
        y = int(a) * int(b)
    elif op == '/':
        y = int(a) // int(b)
    print(y)


Measured memory_bytes: 5596
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>
#include<set>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long

/// 15 43
/// 18 24

    string s;
    bool bedem[200010];

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        cin>>s;
        int n=s.size();
        int prev=0;
        for(int i=0;i<n;i++){
            if( (s[i]=='B' && s[i+1]!='C') || ( s[i] == 'C' && s[i-1]!='B' ) ){
                bedem[i]=true;
            }
        }
        /// kad znamo gdje je bedem, sad  racunamo
        ll res=0,bc=0;
        for(int i=n-1;i>=0;i--){
            if( bedem[i] ){
                bc=0;
                continue;
            }
            else if( s[i]=='C' && s[i-1] == 'B' ){
                bc++;
                i--;    /// da bi se dvaput smanjio
                continue;
            }
            else if( s[i]=='A' ){
                res+=bc;
            }
        }
        cout<<res<<endl;

      return 0;
    }

    /*
    BCABCABCABCA
    BCBCABCABCAA
    BCBCBCABCAAA
    BCBCBCBCAAAA



    ABCBCBCBC

    AAABCABCBCBC
    AABCABCABCBC
    ABCABCABCABC
    BCABCABCABCA
    BCBCABCABCAA
    BCBCBCABCAAA
    BCBCBCBCAAAA


    AAABCBCBC
    AABCABCBC
    ABCABCABC
    BCABCABCA
    BCBCABCAA
    BCBCBCAAA

    AAABCBC
    AABCABC
    ABCABCA
    BCABCAA
    BCBCAAA


    AAABCBCBCBCBC
    AABCABCBCBCBC
    ABCABCABCBCBC
    BCABCABCABCBC
    BCBCABCABCABC
    BCBCBCABCABCA
    BCBCBCBCABCAA
    BCBCBCBCBCAAA
    3*5
    skroz drugacije kad posmatram, lakse se zakljuci. posmatramo pomjeranje A-ova sa pozicija skroz
    lijevo na pozicije skroz desno. Onda treba Na * Nbc poteza, i fakat se tako ispostavi


    za razne stringove gledamo koliko ukupno treba da se A-ovi i BC-ovi zamjene skroz

    proba za generalni
    BBBABCAABCABCCCBCABCA
    BBBBCAABCABCACCBCBCAA
    BBBBCABCABCAACCBCBCAA
    BBBBCBCABCAAACCBCBCAA
    BBBBCBCBCAAAACCBCBCAA

    */











Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

int main(void){
    int n,maxv=-1,temp,sum=0;
    cin>>n;
    rep(i,n){
        cin>>temp;
        if(temp>maxv)maxv=temp;
        sum+=temp;
    }
    if(maxv<sum-maxv)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(){
    int n, k, i, j;
    int d[100];
    int a[100][100];
    cin >> n >> k;
    for(i=0; i<k; i++){
        cin >> d[i];
        for(j=0; j<d[i]; j++){
            cin >> a[i][j];
        }
    }
    int count = 0;
    int check[100];
    for(i=0; i<k; i++){
        for(j=0; j<d[i]; j++){
            check[a[i][j]-1] += 1;
        }
    }
    for(i=0; i<n; i++){
//        cout << "check: " << check[i] << endl;
        if(check[i] == 0){
            count += 1;
        }
    }
    cout << count;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>

const int MIN = -2147483647;

using type = long long;

using namespace std;

type * vec;
int n;
long long ans = 0;

bool check_mon_up(type * start, type * end)
{
	if (end - start <= 1)
		return true;
	
	for (auto i = start; i < end - 1; i++)
		if (*i >= *(i + 1))
			return false;
	return true;
}

bool chec_mon_do(type * start, type * end)
{
	if (end - start <= 1)
		return true;

	for (auto i = start; i < end - 1; i++)
		if (*i <= *(i + 1))
			return false;
	return true;
}

type * m_find_max(type * start, type * end)
{
	int max = MIN;
	type * numb = nullptr;
	for (type * i = start; i < end; i++)
		if (max < *i) max = *i, numb = i;
	return numb;
}

void m_find_two_max(type * start, type * end, type *& max, type *& tax)
{
	int mm = MIN, mt = MIN;
	for (type * i = start; i < end; i++)
	{
		if (*i > mm)
		{
			mt = mm;
			mm = *i;
			tax = max;
			max = i;
		}
		else if (*i > mt)
		{
			mt = *i;
			tax = i;
		}
	}
}

void m_find_tax(type * start, type * end, type * max, type *& tax)
{
	int mm = *max, mt = MIN;
	for (type * i = start; i < end; i++)
		if (*i > mt)
			if (i != max)
			{
				tax = i;
				mt = *i;
			}
}

void fu(type * start, type * end, type * max)
{
	if (end - start == 1)
		return;
	type * tax = 0;
	m_find_tax(start, end, max, tax);
	if (tax == max)
		return;
	if (tax > max)
	{
		ans += (*tax) * (max - start + 1) * (end - tax);
		fu(start, tax, max);
	}
	else
	{
		ans += (*tax) * (tax - start + 1) * (end - max);
		fu(tax + 1, end, max);
	}
	return;
}

void func(type * start, type * end)
{
	if (end - start <= 1)
		return;
	if (end - start == 2)
	{
		ans += min(*(end - 1), *start);
		return;
	}

	if (check_mon_up(start, end))
	{
		for (int i = 0; i < end - start - 1; i++)
			ans += (*(start + i)) * (i + 1);
		return;
	}

	if (chec_mon_do(start, end))
	{
		for (int i = 1; i < end - start; i++)
			ans += (*(start + i)) * (end - start - i);
		return;
	}
	
	type * max = m_find_max(start, end);

	fu(start, end, max);

	func(start, max);
	func(max + 1, end);
	return;
}

void test(type * beg, type * end, long long & as)
{
	ans = 0;
	auto start = chrono::high_resolution_clock::now();
	func(beg, end);
	auto stop = chrono::high_resolution_clock::now();
	as += std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
}

int main()
{
	cin >> n;
	vec = new type[n];
	type * const start = vec;
	type * const end = vec + n;
	for (type * i = start; i < end; i++)
		cin >> *i;

	func(start, end);
//	cout << endl << ans << endl;

	cout << ans;
	
	//system("pause");
	return 0;
}

/*long long as = 0, nu = 1000;
	for (int i = 0; i < nu; i++)
		test(start, end, as);
	cout << endl << as / nu << endl;*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin>>N>>M;
    bool ans[N];
    int x[M],y[M];
    int a[N];
    rep(i,N){
        a[i]=1;
        ans[i]=false;
    }
    rep(i,M){
        cin>>x[i]>>y[i];
    }
    int cou=0;
    ans[0]=true;
    for(int i=0;i<M;i++){
        a[x[i]-1]--;
        a[y[i]-1]++;
        if(ans[x[i]-1]){
            ans[y[i]-1]=true;
        }
        if(a[x[i]-1]==0){
            ans[x[i]-1]=false;
        }
        
    }
    rep(i,N){
        if(ans[i]) cou++;
    }
    cout << cou << endl;



}


Measured memory_bytes: 2688
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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


    int k; cin >> k;

    if(k < 10){
        cout << k << endl;
        return 0;
    }

    int a,b,c,d,e,f,g,h,i,j;

    int count = 9;
    int number = 10;

    for(;;){

        j = number / 1000000000;
        i = (number / 100000000) % 10;
        h = (number / 10000000) % 10;
        g = (number / 1000000) % 10;
        f = (number / 100000) % 10;
        e = (number / 10000) % 10;
        d = (number / 1000) % 10;
        c = (number / 100) % 10;
        b = (number / 10) % 10;
        a = number % 10;

        if((number/1000000000 >0 && abs(j-i)>1)||(number/100000000 >0 && abs(i-h)>1)||(number/10000000 > 0 && abs(h-g)>1)||(number/ 1000000 >0 && abs(g-f)>1)||(number/100000 >0 && abs(f-e)>1)||(number/10000 >0 && abs(e-d)>1)){
            number += 1000;
            continue;
        }

        if((number/1000 ==0 || abs(d-c)<2) && (number/100 ==0 || abs(c-b)<2) && (number/10 ==0 || abs(b-a) <2)){
            count ++;
        }

        if(count == k){
            cout << number << endl;
            break;
        }

/*        if(a == b+1) number += 9;
        else number ++;
*/
        number ++;        
    }
}


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

int main(void){
    rep(i, 5){
        ll x;
        cin >> x;
        if(x == 0) cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

struct Button{
	int x1,x2,y1,y2;
	string link;
	Button(int x1_, int y1_, int x2_, int y2_, string link_){
		x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; link = link_;
	}
	Button(){}
};

void click(int x, int y, string& now, map<string, vector<Button> >& page, int& p, vector<string>& buff){
	vector<Button> B = page[now];
	string to;
	for(int i=0 ; i < B.size() ; i++ ){
		if( B[i].x1 <= x && x <= B[i].x2 && B[i].y1 <= y && y <= B[i].y2 ){
			to = B[i].link;
		}
	}
	if( !to.empty() ){
		now = to;
		while( p != buff.size()-1 ){
			buff.pop_back();
		}
		buff.push_back( to );
		p++;
	}
}

void back(string& now, int& p, const vector<string>& buff){
	if( p != 0 && !buff.empty() ){
		p--;
		now = buff[p];
	}
}

void forward(string& now, int& p, const vector<string>& buff){
	if( p+1 < buff.size() ){
		p++;
		now = buff[p];
	}
}

void show(const string& now){
	cout << now << endl;
}

int main(){
	int n;
	while( cin >> n , n ){
		int w, h;
		map<string, vector<Button> > page;
		vector<string> buff;
		string now;
		int p=0;
		
		cin >> w >> h;
		for(int i=0 ; i < n ; i++ ){
			int b;
			string title;
			cin >> title >> b;
			
			if( i == 0 ){
				now = title;
				buff.push_back( now );
			}
			for(int j=0 ; j < b ; j++ ){
				int x1, y1, x2, y2;
				string link;
				
				cin >> x1 >> y1 >> x2 >> y2 >> link;
				page[title].push_back( Button(x1, y1, x2, y2, link) );
			}
		}
		int m;
		cin >> m;
		for(int i=0 ; i < m ; i++ ){
			string s;
			cin >> s;
			if( s == "click" ){
				int x, y;
				cin >> x >> y;
				click( x , y , now , page , p , buff );
			}else if( s == "back" ){
				back( now , p , buff );
			}else if( s == "forward" ){
				forward( now , p , buff );
			}else if( s == "show" ){
				show( now );
			}
		}	
	}
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && b == c) || (a != b && b != c && c != a))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,k;
    
    cin>>a>>b>>c>>k;
    
    int sum=0;
    for(int i=0;i<k;i++){
        if(a>0){
            sum++;
            a--;
        }
        else if(a<=0 && b>0){
            b--;
        }
        else if(b<=0 && c>0){
            sum--;
            c--;
        }
    }
    
    cout<<sum<<endl;
}


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

int main(){
  int n; cin>>n;
  int num[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  sort(num,num+n);
  double ans=double(num[0]+num[1])/2.0;
  for(int i=2;i<n;i++){
    ans=(ans+num[i])/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 1000000007
#define vi vector < int >
#define pii pair < int, int >
#define INF (int)1e9
#define pb push_back
#define fastIO ios::sync_with_stdio(0); cin.tie(0);

int main()
{
    fastIO
    int n;
    cin >> n;
    
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon";
    else if(n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon";
    else
        cout << "bon";

    return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int x, t;
  scanf("%llu %llu", &x, &t);
  ULL ans = x-t <= 0 ? 0 : x-t;
  printf("%llu", ans);

  return 0;
}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n;
	cin >> n;
	int e, s = 0;
	int mx = -1;
	while (n--) { 
		cin >> e; s += e; 
		mx = max(mx, e);
	}
	cout << (mx < s-mx ? "Yes" : "No") << ende;
  return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve 2 = 2
solve x | odd x     = solve' x
        | otherwise = solve' $ x + 1

solve' :: Int -> Int
solve' x | isPrime x = x
         | otherwise = solve' $ x + 2

isPrime :: Int -> Bool
isPrime x | x < 2     = False
          | otherwise = go 2 x
 where
  go x y | x * x > y      = True
         | y `mod` x == 0 = False
         | otherwise      = go (x + 1) y


Measured memory_bytes: 3876
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  string S;
  cin >> S;
  
  if(S[2] == S[3] && S[4] == S[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
#define pb push_back
#define solid const auto &
#define enter cout<<endl
#define pii pair<int,int>
using namespace std;
typedef long long ll;
template<class T>il void rd(T &x){
    char ch;x=0;bool fl=false;while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
    for(x=numb;isdigit(ch=getchar());x=x*10+numb);(fl==true)&&(x=-x);}
template<class T>il void output(T x){if(x/10)output(x/10);putchar(x%10+'0');}
template<class T>il void ot(T x){if(x<0) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}
namespace Modulo{
const int mod=998244353;
il int ad(int x,int y){return x+y>=mod?x+y-mod:x+y;}
il int sub(int x,int y){return ad(x,mod-y);}
il int mul(int x,int y){return (ll)x*y%mod;}
il void inc(int &x,int y){x=ad(x,y);}
il void inc2(int &x,int y){x=mul(x,y);}
il int qm(int x,int y=mod-2){int ret=1;while(y){if(y&1) ret=mul(x,ret);x=mul(x,x);y>>=1;}return ret;}
template<class ...Args>il int ad(const int a,const int b,const Args &...args) {return ad(ad(a,b),args...);}
template<class ...Args>il int mul(const int a,const int b,const Args &...args) {return mul(mul(a,b),args...);}
}
//using namespace Modulo;
namespace Miracle{
const int N=2e5+5;
const ll inf=0x3f3f3f3f3f3f3f3f;
int n,q,A,B;
ll f[N],s[N];
ll x[N];
struct SegmentTree{
ll mi[4*N];
#define ls (x<<1)
#define rs (x<<1|1)
#define mid ((l+r)>>1)
void pushup(int x){
	mi[x]=min(mi[ls],mi[rs]);
}
void build(int x,int l,int r){
	if(l==r){
		mi[x]=inf;return;
	}
	mi[x]=inf;
	build(ls,l,mid);build(rs,mid+1,r);
}
void upda(int x,int l,int r,int p,ll c){
	if(l==r){
		mi[x]=min(mi[x],c);return;
	}
	if(p<=mid) upda(ls,l,mid,p,c);
	else upda(rs,mid+1,r,p,c);
	pushup(x);
}
ll query(int x,int l,int r,int L,int R){
	if(L<=l&&r<=R){
		return mi[x];
	}
	ll ret=inf;
	if(L<=mid) ret=min(ret,query(ls,l,mid,L,R));
	if(mid<R) ret=min(ret,query(rs,mid+1,r,L,R));
	return ret;
}

}sg[2];
ll dp(){
	memset(f,0x3f,sizeof f);
	memset(s,0,sizeof s);
	sg[0].build(1,1,n);sg[1].build(1,1,n);
	s[0]=0;s[1]=abs(x[1]-B);
	for(reg i=2;i<=q;++i) s[i]=s[i-1]+abs(x[i]-x[i-1]);
	
	sg[0].upda(1,1,n,A,-A);
	sg[1].upda(1,1,n,A,A);
	
	ll mi=0;
	for(reg i=1;i<=q;++i){
		if(i==q){
			return s[i]+mi;
		}else{
			f[i]=min(sg[0].query(1,1,n,1,x[i+1])+x[i+1]+s[i],sg[1].query(1,1,n,x[i+1],n)-x[i+1]+s[i]);
			sg[0].upda(1,1,n,x[i],f[i]-s[i+1]-x[i]);
			sg[1].upda(1,1,n,x[i],f[i]-s[i+1]+x[i]);
			
			mi=min(mi,f[i]-s[i+1]);
		}
	}
	return 23333;
}
int main(){
	rd(n);rd(q);rd(A);rd(B);
	for(reg i=1;i<=q;++i) rd(x[i]);	  
	ll ans=dp();swap(A,B);ans=min(ans,dp());
	printf("%lld\n",ans);
	return 0;
}

}
signed main(){
    Miracle::main();
    return 0;
}

/*
   Author: *Miracle*
*/

Measured memory_bytes: 17408
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }

  auto b = a;
  int ans = INF;
  rep(k, N) {
    rep(i, N) {
      chmin(b[i], a[(i + N - k) % N]);
    }

    int temp = 0;
    rep(i, N) {
      temp += b[i];
    }
    temp += x * k;
    chmin(ans, temp);
  }
  cout << ans << endl;
}

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

int main()
{
	int m,n, N;
	int dice[101][101];
	scanf("%d", &N);
	for (n = 0; n < N; n++)
	{
		for (m = 0; m < 6; m++)
		{
			scanf("%d", &dice[n][m]);
		}
	}
	int i = 4, tmp, j = 4;
	for (n = 0; n < N - 1; n++)
	{
		for (m = n + 1; m < N; m++)
		{
			while (i--)
			{
				if (dice[n][0] == dice[m][0]
					&& dice[n][1] == dice[m][1]
					&& dice[n][2] == dice[m][2]
					&& dice[n][3] == dice[m][3]
					&& dice[n][4] == dice[m][4]
					&& dice[n][5] == dice[m][5])
				{
					printf("No\n");
					return 0;
				}
				while (j--)
				{
					tmp = dice[n][1];
					dice[n][1] = dice[n][2];
					dice[n][2] = dice[n][4];
					dice[n][4] = dice[n][3];
					dice[n][3] = tmp;
					if (dice[n][0] == dice[m][0]
						&& dice[n][1] == dice[m][1]
						&& dice[n][2] == dice[m][2]
						&& dice[n][3] == dice[m][3]
						&& dice[n][4] == dice[m][4]
						&& dice[n][5] == dice[m][5])
					{
						printf("No\n");
						return 0;
					}
				}
				j = 4;
				if (i % 2 == 0)
				{
					tmp = dice[n][0];
					dice[n][0] = dice[n][1];
					dice[n][1] = dice[n][5];
					dice[n][5] = dice[n][4];
					dice[n][4] = tmp;
					if (dice[n][0] == dice[m][0]
						&& dice[n][1] == dice[m][1]
						&& dice[n][2] == dice[m][2]
						&& dice[n][3] == dice[m][3]
						&& dice[n][4] == dice[m][4]
						&& dice[n][5] == dice[m][5])
					{
						printf("No\n");
						return 0;
					}
				}
				if (i % 2 == 1)
				{
					tmp = dice[n][0];
					dice[n][0] = dice[n][2];
					dice[n][2] = dice[n][5];
					dice[n][5] = dice[n][3];
					dice[n][3] = tmp;
					if (dice[n][0] == dice[m][0]
						&& dice[n][1] == dice[m][1]
						&& dice[n][2] == dice[m][2]
						&& dice[n][3] == dice[m][3]
						&& dice[n][4] == dice[m][4]
						&& dice[n][5] == dice[m][5])
					{
						printf("No\n");
						return 0;
					}
				}
			}
			i = 4;
		}
	}

	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1048
init = input().split(' ')
init = [int(i) for i in init]
n,m,c = init[0],init[1],init[2]
b = input().split(' ')
b = [int(i) for i in b]

count = 0
try:
	while True:
		inp1 = input().split(' ')
		inp1 = [int(i) for i in inp1]
		score = c
		for j in range(m):
			score += inp1[j]*b[j]
		if score > 0:
			count+= 1
except:
	pass

print(count)

Measured memory_bytes: 3064
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n; cin >> n;
  string s,t;
  cin >> s >> t;
  string u;
  for(int i = 0; i < s.size(); i++) u += s[i], u += t[i];
  cout << u << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2e5 + 7;
const int ALP = 26;
const int INF = 1e9 + 239;

vector<int> pos[ALP];

int dp[N];
int wr[N];

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

	string s;
	cin >> s;
	int n = (int)s.size();
	s.push_back('?');
	n++;
	for (int i = 0; i < n; i++) {
		if (s[i] == '?') {
			for (int j = 0; j < ALP; j++) {
				pos[j].push_back(i);
			}
		} else {
			pos[s[i] - 'a'].push_back(i);
		}
	}
	dp[n - 1] = 1;
	wr[n - 1] = -1;
	for (int i = n - 2; i >= 0; i--) {
		int mn = INF;
		int wmn = -1;
		for (int c = 0; c < ALP; c++) {
			int v = *upper_bound(pos[c].begin(), pos[c].end(), i);
			if (mn > dp[v] + 1) {
				mn = dp[v] + 1;
				wmn = c;
			}
		}
		dp[i] = mn;
		wr[i] = wmn;
	}
	int ans = INF;
	int fr = -1;
	for (int c = 0; c < ALP; c++) {
		if (ans > dp[pos[c].front()]) {
			ans = dp[pos[c].front()];
			fr = c;
		}
	}
	// cout << ans << endl;
	string res;
	res.push_back(fr + 'a');
	{
		int pnt = pos[fr].front();
		while (pnt + 1 < n) {
			res.push_back('a' + wr[pnt]);
			int v = *upper_bound(pos[wr[pnt]].begin(), pos[wr[pnt]].end(), pnt);
			pnt	= v;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 2964
/* 最大公約数 */
#include<stdio.h>

int main(){
  int x,y;
  int i;
  int per;
  int gcd;
  int temp;

  scanf("%d%d",&x,&y);

  if(x>y){
    while(x%y!=0){
      gcd=x%y;
      x=y;
      y=gcd;
    }
  }
  else if(x<y){
    while(y%x!=0){
      gcd=y%x;
      y=x;
      x=gcd;
    }
  }
  else if(x==y){
    gcd=x;
  }

  printf("%d\n",gcd);
  
  return 0;
}



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

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

  int n, id[100100], x, l[100100], r[100100];
  cin >> n;
  for (int i = 1; i <= n; i++)
  {
    cin >> x;
    id[x] = i;
    l[i] = i - 1;
    r[i] = i + 1;
  }
  r[0] = 1;
  l[n + 1] = n;

  long long ans = 0;
  for (int i = 1; i <= n; i++)
  {
    int curL = l[id[i]], curR = r[id[i]];
    if (curL)
      ans += 1LL * (curR - id[i]) * (curL - l[curL]) * i;
    if (curR <= n)
      ans += 1LL * (id[i] - curL) * (r[curR] - curR) * i;
    l[curR] = curL;
    r[curL] = curR;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>

using namespace std;

#define chmin(a,b) a=min(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)

const int inf = 1e9;

int d[100][100];

int main()
{
	int N, K;
	
	while (scanf("%d %d", &N, &K), N || K) {
		fill(d[0], d[N], inf);
		rep(i, N) d[i][i] = 0;

		rep(i, K) {
			int t; scanf("%d", &t);
			if (t) {
				int a, b, c; scanf("%d %d %d", &a, &b, &c); a--; b--;
				d[a][b] = d[b][a] = min(d[a][b], c);
				rep(j, N) rep(k, N) {
					chmin(d[j][k], min(d[j][a] + d[a][b] + d[b][k], d[j][b] + d[b][a] + d[a][k]));
				}
			} else {
				int a, b; scanf("%d %d", &a, &b); a--; b--;
				printf("%d\n", d[a][b] != inf ? d[a][b] : -1);
			}
		}
	}
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    int *C = new int[N]{0};
    for (int a : A){
        ++C[a];
    }
    sort(C, C + N, greater<>());
    cout << N - accumulate(C, C + K, 0) << endl;
}

Measured memory_bytes: 4776
#include <iostream>
#include <cmath>
#include <algorithm>

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

using namespace std;

const int mod=1000000000+7;


int main() {
    
    int N,M;
    cin>>N>>M;
    
    int A[N+1];
    
    for(int i=0;i<=N;++i){
        A[i]=1;
    }

    int a;
    int p=-1;
    
    for(int i=1;i<=M;++i){
        cin>>a;
        if(p==a){cout<<0<<endl;return 0;}
        A[a]=0;
        p=a;
    }
    
    ll d[N+1];
    for(int i=0;i<=N;++i){
        d[i]=0;
    }
    d[0]=1;
    
    for(int i=1;i<=N;++i){
        
        if(A[i]==0)continue;
        if(i==1){
            d[i]=d[i-1];
        }else{
            d[i]=(d[i-1]+d[i-2])%mod;
        }
        
    }
    
    cout<<d[N]<<endl;
   
}


Measured memory_bytes: 4756
n ,L = map(int, input().split())
s = []
for i in range(n):
    s.append(i+L)
if s.count(0) == 0:
    
    if sum(s)>0:
        print(sum(s)-min(s))
    else:
        print(sum(s)-max(s))
else:
    print(sum(s))

Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x, y) memset(x, y, sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b > a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b < a)a = b; }
const int N = 2e5 + 10, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
const int top = 26;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n;
char s[N];
int last[top];
int nxt[N][top];
int f[N];
char ans[N]; int P;

int main()
{
	while (~scanf("%s", s + 1))
	{
		n = strlen(s + 1);
		for (int i = 0; i < top; ++i)last[i] = n + 1;

		f[n + 1] = 0;
		for (int i = n; i >= 1; --i)
		{
			int last_pos = i;
			for (int j = 0; j < top; ++j)
			{
				nxt[i][j] = last[j];
				gmax(last_pos, last[j]);
			}
			f[i] = f[last_pos] + 1;
			int x = s[i] - 'a'; last[x] = i; nxt[i][x] = i;
		}
		bool same = 1;
		int num = f[last[0]];
		for (int i = 1; i < top; ++i)
		{
			if (f[last[i]] != num)
			{
				same = 0;
				break;
			}
		}
		/*
		if(same)
		{
			for (int i = 0; i <= f[1]; ++i)
			{
				putchar('a');
			}puts("");
		}
		else
			*/
		{
			P = 0;
			int now = 1;
			while (now <= n)
			{
				int num = inf;
				int st = 0;
				for (int i = 0; i < top; ++i)
				{
					int first = nxt[now][i];
					if (f[first] < num)
					{
						st = i;
						num = f[first];
					}
				}
				ans[P++] = 'a' + st;
				now = nxt[now][st] + 1;
			}
			ans[P] = 0;
			puts(ans);
		}
	}
	return 0;
}
/*
【trick&&吐槽】


【题意】


【分析】


【时间复杂度&&优化】
abcdefghijklmnopqrstuvwxyz

*/

Measured memory_bytes: 21504
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  int large;
  int counter, high_count;
  int target;
  cin >> N;
  high_count = 0;
  target = 1;
  for(int i=1;i<N+1;i++){
    int aNumber = i;
    counter = 0;
    while(aNumber%2 == 0) aNumber /=2, counter++;
    if(counter> high_count){
      target=i;
      high_count = counter;
    }
  }

  cout << target << endl;
}


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


int main()
{
    int N;
    cin >> N;
    vector<int> t(N+2, 0), v(N+2, 0);
    for(int i = 1; i <= N; i++) cin >> t[i];
    for(int i = 1; i <= N; i++) cin >> v[i];
 
    
    // l[i] <= t <= r[i] についてチェックする
    // ただし、l[0] = l[1] = 0, r[N] = r[N+1] = tend
    vector<int> l(N+2, 0), r(N+2, 0);
    for(int i = 2; i < N+2; i++) l[i] = l[i-1] + t[i-1];
    for(int i = 1; i < N+2; i++) r[i] = r[i-1] + t[i];

    vector<double> maxv;
    for(double x = 0; x <= r[N+1]; x += 0.5) {
        double minv = 100;
        for(int i = 0; i < N+2; i++) {
            if( x <= l[i] )           minv = min( minv, v[i] + (l[i] - x) );
            if( l[i] < x && x < r[i]) minv = min( minv, (double) v[i] );
            if( r[i] <= x )           minv = min( minv, v[i] + (x - r[i]) );
        }
        maxv.push_back( minv );
    }
 
    double ans = 0;
    for(int i = 1; i < maxv.size(); i++) ans += 0.5 * (maxv[i] + maxv[i-1]) / 2;
    cout << fixed << setprecision(3) << ans << endl;
 
    return 0;
}

Measured memory_bytes: 896
package main

import "fmt"

func findGroup(i int) int {
	switch i {
	case 1, 3, 5, 7, 8, 10, 12:
		return 1
	case 4, 6, 9, 11:
		return 2
	case 2:
		return 3
	}
	return 0
}

func main() {
	var x, y int

	fmt.Scan(&x, &y)

	if findGroup(x) != findGroup(y) {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}

Measured memory_bytes: 512
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
     
const int maxn(305);
const int mod(998244353);

inline void Inc(int &x, int y) {
    x = x + y >= mod ? x + y - mod : x + y;
}

inline void Dec(int &x, int y) {
    x = x - y < 0 ? x - y + mod : x - y;
}

inline int Add(int x, int y) {
    return x + y >= mod ? x + y - mod : x + y;
}

inline int Sub(int x, int y) {
    return x - y < 0 ? x - y + mod : x - y;
}

inline int Pow(ll x, int y) {
    ll ret = 1;
    for (; y; y >>= 1, x = x * x % mod)
        if (y & 1) ret = ret * x % mod;
    return ret;
}

int n, m, ans, cnt, tot;
bitset <maxn> a, b[maxn];

inline void Insert() {
	int i;
	if (tot == m) return;
	for (i = 1; i <= m; ++i)
		if (a[i]) {
			if (!b[i][i]) {
				b[i] = a, ++tot;
				return;
			}
			a ^= b[i];
		}
	return;
}

int main() {
	int i, j, v;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; ++i) {
		a.reset();
		for (j = 1; j <= m; ++j) {
			scanf("%d", &v);
			if (v) a.set(j);
		}
		Insert();
	}
	ans = Pow(2, n), Dec(ans, Pow(2, n - tot));
	ans = (ll)ans * Pow(2, m - 1) % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())

#　Xの格桁の和を求める
def f(X):
  return sum(list(map(int, str(X))))

summedDigit = 0
sumArray = []
for A in range(N+1):
  if A > 0 and A != N:
    B = N - A
    summedDigit = f(A) + f(B)
    sumArray.append(summedDigit)

print(min(sumArray))






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

using ll = long long;

void solve(long long N){
    int cnt = 0;
    vector<int> v(N + 1);
    for(int i = 1;i <= 100;i++){
        for(int j = 1;j <= 100;j++){
            for(int k = 1;k <= 100;k++){
                if(i * i + j * j + k * k + i * j + j * k + i * k <= N){
                    v[i * i + j * j + k * k + i * j + j * k + i * k]++;
                }
            }
        }
    }
    for(int i = 1;i <= N;i++)
        cout<<v[i]<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3716
import bisect
N=int(input())
d=sorted(list(map(int,input().split())))
cnt=0
for i in range(N-1,1,-1):
  for j in range(i-1,0,-1):
    k=bisect.bisect_right(d,d[i]-d[j])
    if j-k>0:
      cnt+=j-k
print(cnt)



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

const int mod = 1e9 + 7;

// binary exponentiation O(log n)
ll mod_pow(int x, int y) {
  ll res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % mod;  // if right-most bit is 1
    x = x * x % mod;
    y >>= 1;  // right shift y by 1 bit
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  map<int, int> diffs;
  rep(i, n) {
    int pos;
    cin >> pos;
    diffs[pos]++;
  }

  for (int i = (n%2==0); i < n; i+=2) {
    if (i == 0) {
      if (diffs[i] != 1) {
        cout << 0 << endl;
        return 0;
      }
    }
    else if (diffs[i] != 2) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  rep(i, n/2) {
    ans = (ans * 2) % mod;
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int k, x;

signed main() {
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
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; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, M;
int a[1010], b[1010], c[1010];
int dis[110][110];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  fill_n((int*)dis, 110*110, INF);
  REP(i, N) dis[i][i] = 0;
  REP(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
  }
  REP(k, N) REP(i, N) REP(j, N) {
    chmin(dis[i][j], dis[i][k]+dis[k][j]);
  }
  int ans = 0;
  REP(e, M) {
    int p = a[e], q = b[e];
    int flag = 1;
    REP(i, N) REP(j, N) {
      flag &= (dis[i][j] != dis[i][p]+dis[q][j]+c[e]);
    }
    ans += flag;
  }
  cout << ans << endl;

  return 0;
}

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

const int mod=1e9+7;

int pw(int a,int t){
    int x=1;
    while(t>0){
        if(t&1)x=x*a%mod;
        a=a*a%mod,t/=2;
    }
    return x;
}
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    cout << (pw(10,n)-2*pw(9,n)%mod+pw(8,n)+mod)%mod;
}

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

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

int main() {
    fast_io;
    long long n,a,b,m,s,k;
    cin>>n>>a>>b;
    m=a+b;
    s=n%m;
    k=n/m;
    
    if(s>a) {
        s=a;
    }
    cout<<(k*a)+s<<endl;
}



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

using namespace std;

int req[5];
int freq[26];

int main()
{
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            set<pair<int, int>> s;
            s.insert({i, j});
            s.insert({N - 1 - i, j});
            s.insert({N - 1 - i, M - 1 - j});
            s.insert({i, M - 1 - j});
            if(*s.begin() == make_pair(i, j))
                req[s.size()]++;
            char c;
            scanf(" %c", &c);
            freq[c - 'a']++;
        }
    }
    for(int i = 0; i < 26; i++) {
        for(int j = 4; j >= 1; j--) {
            while(freq[i] >= j && req[j] >= 1) {
                freq[i] -= j;
                req[j] -= 1;
            }
        }
        if(freq[i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256