akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
#define PI acos(-1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NL printf("\n")
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


int main()
{
      //fast;
     int t=1;
     string s;


    while(t--)
    {
         int x,y;
         int n;
         int a[1001];
         cin >> x >> n;
         int res1,res2;
         map<int,int>mp;

         if(n==0){
            cout << x << endl;
            return 0;
         }
         for(int i = 1; i<=n; i++) {
                cin >> a[i];
                mp[a[i]]++;
         }
         int tmp = x;
         while(1){

            if(mp[tmp]==0){
                res1 = tmp;
                break;
            }
            tmp--;
         }
         tmp = x;
         while(1){

            if(mp[tmp]==0){
                res2 = tmp;
                break;
            }
            tmp++;
         }
         if(abs(x-res1)==abs(x-res2)){
            cout << min(res1,res2);
            return 0;
        }
       else if(abs(x-res1) > abs(res2-x)){
            cout << res2 << endl;
        }
        else cout << res1 << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 3640
/*input
782
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
#define pb push_back 
#define f first
#define s second
#define int ll
#define fr(j,n) for(int i=j;i<=n;i++)
#define reset(a) memset(a,0,sizeof(a))
#define minqueue priority_queue<int,vector<int>,greater<int> >
int const mod = 1e9+7;
int const inf = 2e18;


int power(int x, int y, int mod = inf)
{
    int ans = 1;
    x %= mod;
    while(y)
    {
        if(y&1)
            ans = (x * ans) % mod;

        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
int gcd(int a , int b)
{
	if(a==0)
	return b;
	return gcd(b%a,a);
}
signed main() {
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	string  s;
	cin>>s;
	for(int i=0;i<s.length();i++)
		{if(s[i]==s[0])
				{
					continue;
				}
				else
				{
					if(s[i]<s[0])
						{
							for(int i=0;i<s.length();i++)
							{
								cout<<s[0];
							}
							return 0;
						}						
					else
					{
						for(int i=0;i<s.length();i++)
						{
							cout<<char(s[0]+1);

						}
						return 0;
					}
				}

		}	
		cout<<s;



	  
return 0;
}


Measured memory_bytes: 256
// Last Change: 03/25/2019 23:26:19.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N;
  string S;
  cin >> N >> S;

  vector<pair<ll, ll>> info(N);

  ll cnt = 0;
  for (ll i = 0; i < N; ++i) {
    if (S[i] == 'W') {
      ++cnt;
    }
    info[i].first = cnt;
  }

  cnt = 0;
  for (ll i = N - 1; i >= 0; --i) {
    if (S[i] == 'E') {
      ++cnt;
    }
    info[i].second = cnt;
  }

  ll ans = INT64_MAX;
  for (ll i = 0; i < N; ++i) {
    if (i == 0) {
      ans = min(ans, info[i + 1].second);
    } else if (i == N - 1) {
      ans = min(ans, info[i - 1].first);
    } else {
      ans = min(ans, info[i - 1].first + info[i + 1].second);
    }
  }

  cout << ans << endl;

  NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 5372
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
typedef long long ll;
int n, m, k;
int a[maxn], b[maxn];
ll suma[maxn], sumb[maxn];
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        suma[i] = suma[i - 1] + a[i];
    }
    for (int i = 1; i <= m; i++) {
        scanf("%d", &b[i]);
        sumb[i] = sumb[i - 1] + b[i];
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if(suma[i] > k) break;
        int tmp = lower_bound(sumb, sumb + 1 + m, k - suma[i]) - sumb;
        if(sumb[tmp] != k - suma[i]) tmp--;
        ans = max(ans, i + tmp);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 8480
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;

int main()
{
    int n, w[100], min = 10000;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> w[i];
    }
    for(int i = 0; i < n - 1; i++)
    {
        int sum1 = 0, sum2 = 0;
        for(int j = 0; j <= i; j++)
        {
            sum1 += w[j];
        }
        for(int j = i + 1; j <= n - 1; j++)
        {
            sum2 += w[j];
        }
        if(min > abs(sum1 - sum2)) min = abs(sum1 - sum2);
    }
    cout << min;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  char s[5];
  char *result[2][2] = { "NA", "YYMM", "MMYY", "AMBIGUOUS" };
  fgets(s, 5, stdin);
  puts(result[(s[0]=='0'&&s[1]>='1')||(s[0]=='1'&&s[1]<='2')][(s[2]=='0'&&s[3]>='1')||(s[2]=='1'&&s[3]<='2')]);
  return 0;
}

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

using namespace std;

int n, k;
int a[212345];

int main() {
                                               

	cin >> n >> k;                                                                         
	for(int i = 1; i <= n; i++) {
	cin >> a[i]; 
	}

	for(int i = 1; i <= n; i++) {
		if(a[i] + a[i + 1] >= k){
			cout << "Possible" << endl;
			for(int j = 1; j < i; j++) 
				cout<<j << '\n';
			for(int j= n - 1; j >= i; j--)
				cout << j << '\n';
			return 0;
		}
	}
	cout<<"Impossible";
}




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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 x;
    cin >> x;

    cout << (x >= 30 ? "Yes" : "No") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> da(n);
	int x,y;
	rip(i,n-1,0){
		cin >> x >> y;
		x--;y--;
		da[x].push_back(y);
		da[y].push_back(x);
	}
	queue<int> q;
	vector<int> dis(n,-1);
	dis[0]=0;
	q.push(0);
	int now;
	while(!q.empty()){
		now=q.front();
		q.pop();
		for(auto i:da[now]){
			if(dis[i]<0){
				dis[i]=dis[now]+1;
				q.push(i);
			}
		}
	}
	rip(i,n,0){
		dis[i]=-1;
	}
	dis[now]=0;
	q.push(now);

	while(!q.empty()){
		now=q.front();
		q.pop();
		for(auto i:da[now]){
			if(dis[i]<0){
				dis[i]=dis[now]+1;
				q.push(i);
			}
		}
	}
	if(dis[now]%3==1){
		cout << "Second" << endl;
	}
	else{
		cout << "First" << endl;
	}
}


Measured memory_bytes: 13556
#include <algorithm>  //sort,二分探索,など
#include <array>
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <map>            //map(辞書)s
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())  // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
  string S;
  cin >> S;
  int N;
  cin >> N;
if(S[0]=='7'||S[1]=='7'||S[2]=='7'){
  cout << "Yes" << endl;
}
else{
  cout << "No" << endl;
}
}

Measured memory_bytes: 3608
N,K = map(int, input().split())

ans = 0
for i in range(1, N+1, 1):
    j = i
    c = 0
    if i<=K-1:
        while j<=K-1:
            j = j * 2
            c = c + 1
        ans = ans + (1/N)*((1/2)**c)
    else:
        ans = ans + (1/N)*((1/2)**c)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=3500;
int n,mod,a[N],inv[N],inv2[N],res[N];
int dp[N][N];
//
inline int add(int x,int y){x+=y;if(x>=mod)x-=mod;return x;}
inline int sub(int x,int y){x-=y;return (x<0)?x+mod:x;}
inline int mul(int x,int y){int ans=x*y;return ans%mod;}
inline int modpow(int x,int y){
	int ans=1;
	while(y){
		if(y&1)ans=mul(ans,x);
		x=mul(x,x);
		y>>=1;
	}
	return ans;
}
inline int modinv(int x){
	return modpow(x,mod-2);
}
int main(){
	n=getint();mod=n;
	rep(i,n)a[i]=getint();
	rep(i,N)inv[i]=modinv(i);
	rep(i,N)inv2[i]=modinv(sub(0,i));
	dp[n][0]=1;
	for(int i=n-1;i>=0;i--)for(int j=0;j<=n-i;j++){
		dp[i][j]=mul(dp[i+1][j],sub(0,i));
		if(j)dp[i][j]=add(dp[i][j],dp[i+1][j-1]);
		//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
	}
	rep(i,n)if(a[i]){
		int ans=1;
		rep(j,i)ans=mul(ans,inv[i-j]);
		for(int j=i+1;j<n;j++)ans=mul(ans,inv2[j-i]);
		int tmp=0;
		if(!i)tmp=dp[1][0];
		res[0]=add(res[0],mul(tmp,ans));
		for(int j=1;j<n;j++){
			tmp=mul(sub(dp[0][j],tmp),inv2[i]);
			if(!i)tmp=dp[1][j];
			res[j]=add(res[j],mul(tmp,ans));
		}
	}
	rep(i,n)printf("%d ",res[i]);
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    REP(i, n) {
        if(a[i] % 2 == 0) {
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            } 
        }
    }

    cout << "APPROVED" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int> > G(N);
    for (int n = 0; n < N-1; ++n) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    multiset<int> Set;
    int Res = 0;
    for (int n = 0; n < N; ++n) {
        int c;
        cin >> c;
        Set.insert(c);
        Res += c;
    }
    
    auto itEnd = Set.rbegin();
    Res -= *itEnd;
    cout << Res << endl;
    
    set<pair<int, int> > Num;
    vector<int> NumNow(N);
    for (int n = 0; n < N; ++n) {
        Num.insert({G[n].size(), n});
        NumNow[n] = G[n].size();
    }
    vector<int> Res2(N, -1);
    for (auto it = Set.begin(); it != Set.end(); ) {
        auto itV = Num.begin();
        if (Res2[itV->second] == -1) {
            Res2[itV->second] = (*it);
            ++it;
        }
        Num.erase(itV);
        for (int u : G[itV->second]) {
            if (Res2[u] == -1) {
                --NumNow[u];
                Num.insert({NumNow[u], u});
            }
        }
    }
    
    for (int n = 0; n < N; ++n) {
        cout << Res2[n] << '\n';
    }
    
    return 0;
}


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

using namespace std;

int main()
{
	// 入力
	long A, B, C, D;
	cin >> A >> B >> C >> D;
	
	long answer = 0;
	long B_Num = 0;
	long A_Num = 0;
	
	// B以下の整数の個数
	// B以下の C の倍数の個数と B 以下の D の倍数の個数を引き
	// 重複して引いた数
	// B / CとDの最小公倍数 = B / (C * D / 最大公約数)
	// 最大公約数の算出は__gcd()を利用する
	B_Num = B - ((B / C + B / D) - B / (C * D / __gcd(C, D)));
	
	// A - 1以下の整数の個数
	A--;
	// Aも同様に計算
	A_Num = A - ((A / C + A / D) - A / (C * D / __gcd(C, D)));
	
	
	// どちらも条件を満たす B 以下の整数から A - 1 以下の整数の個数を引いたものが答えとなる
	answer = B_Num - A_Num;
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2005;
const int MOD = 1e9 + 7;
int fat[2 * MAX];

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }
    return a;
}

inline int mult(int a, int b) {
    return (1LL * a * b) % MOD;
}

int f_exp(int x, int e) {
    if (e == 0) return 1;
    if (e & 1) return mult(x, f_exp(x, e - 1));
    return f_exp(mult(x, x), e / 2);
}

inline int inv(int x) {
    return f_exp(x, MOD - 2);
}

inline int comb(int n, int k) {
    if (k > n) {
        return 0;
    }
    return mult(fat[n], mult(inv(fat[k]), inv(fat[n - k])));
}

int boxes_ways(int balls, int boxes) {
    int stars = balls;
    int separators = boxes - 1;
    return comb(stars + separators, stars);
}

void preprocess() {
    fat[0] = 1;
    fori (i, 1, 2 * MAX) {
        fat[i] = mult(fat[i - 1], i);
    }
}

void solve() {
    preprocess();
    int n, k;
    cin >> n >> k;
    int b = k;
    int r = n - k;
    if (r == 0) {
        cout << 1 << '\n';
        fori (i, 1, k) {
            cout << 0 << '\n';
        }
        return;
    }
    fori (i, 1, k + 1) {
        // BRBRB
        // BRBRBR
        if (r + 1 < i) {
            cout << 0 << '\n';
            continue;
        }
        int b_rest = b - i;
        int r_rest = r - (i - 1);
        int ans = mult(boxes_ways(b_rest, i), boxes_ways(r_rest, i - 1));
        if (r >= i) {
            r_rest = r - i;
            ans = add(ans, mult(2, mult(boxes_ways(b_rest, i), boxes_ways(r_rest, i))));
        }
        if (r >= i + 1) {
            r_rest = r - (i + 1);
            ans = add(ans, mult(boxes_ways(b_rest, i), boxes_ways(r_rest, i + 1)));
        }
        cout << ans << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,M;

int main(){
    cin>>N>>M;
    out((1900*M+100*(N-M))*pow(2.0,(double)M));
}


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

int main(){
    int w,a,b; cin >> w >> a >> b;
    if(b-(a+w) > 0){
        cout << b-(a+w) << endl;
    }else if(a-(b+w) > 0){
        cout << a-(b+w) << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var n = data[0].replace( '\n', '' );
  var nums = data[1].replace( '\n', '' ).split( ' ' ).map( Number );
  var sum = 0;
  var max = -1000000;
  var min = 1000000;
  for( var i=0; i<nums.length; i++ ) {
    min = Math.min( min, nums[i] );    
    max = Math.max( max, nums[i] );
    sum += nums[i];
  }
  console.log( '%d %d %d', min, max, sum  );
});

Measured memory_bytes: 10204
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, s;
  cin >> k >> s;
  int ans = 0;
  REP(x, k+1) REP(y, k+1)
  {
    int z = s - x - y;
    if (0 <= z && z <= k) ans++;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
import numpy as np
a=np.array(a)
md = len(bin(max(a)))
ans = 0
for d in range(md):
    cnt1 = np.count_nonzero((a>>d)&1)
    ans += cnt1 * (n-cnt1) * (1<<d)
    ans %= mod

print(ans%mod)


Measured memory_bytes: 42212
N = int(input())
R = [[0, 0] for _ in range(N)]
B = [[0, 0] for _ in range(N)]
Map = [['.' for __ in range(2*N)] for _ in range(2*N)]
for i in range(N):
  R[i][1], R[i][0] = map(int, input().split())
  Map[R[i][1]][R[i][0]] = 'R'
for i in range(N):
  B[i][0], B[i][1] = map(int, input().split())
  Map[B[i][0]][B[i][1]] = 'B'
R.sort(reverse=True)
B.sort()
RF = [True for _ in range(N)]
BF = [True for _ in range(N)]
cnt = 0
for i in range(N):
  for j in range(N):
    if BF[j] == True:
      if R[i][1] < B[j][0] and R[i][0] < B[j][1]:
        cnt += 1
        RF[i] = False
        BF[j] = False
        break
print(cnt)

Measured memory_bytes: 9428
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[105];

int main() {
	scanf("%lld", &N);
	ll sum = 0;
	for(int i = 0; i < N - 1; i++) {
		scanf("%lld", &arr[i]);
	}
	sum = arr[0];
	for(int i = 0; i < N - 2; i++) {
		sum += min(arr[i], arr[i + 1]);
	}
	sum += arr[N - 2];
	printf("%lld\n", sum);

	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a == c or b == d) cout << 0 << endl;
  else cout << abs(d-b) + abs(c-a) - gcd(abs(d-b),abs(a-c)) << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main() {
    int K, N;
    cin >> K >> N;
    int first, prev, next, dmax = 0;
    cin >> first;
    prev = first;
    N--;
    while (N--) {
        cin >> next;
        dmax = max(dmax, next - prev);
        prev = next;
    }
    dmax = max(dmax, K - prev + first);

    cout << K - dmax << endl;
}

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

using namespace std;

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


int main(){
    long int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops, no-stack-protector")
#pragma GCC target("avx,avx2,fma")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename _def> using ordered_set=tree<_def, null_type, less<_def>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

constexpr int N=2e5+1;
vi adj[N];
int a[N], c[N], l[N], r[N];
int ans[N];
int n;

inline void NO() {
    cout<<"No\n";
    /*cout<<"infodump\n";
    rep(i, n) cout<<a[i]<<' '; cout<<endl;
    rep(i, n) cout<<c[i]<<' '; cout<<endl;
    rep(i, n) cout<<l[i]<<' '; cout<<endl;
    rep(i, n) cout<<r[i]<<' '; cout<<endl;*/
    exit(0);
}

constexpr int INF=5e8;
inline void init() {
    rep(i, n) a[i]=c[i]=-1, l[i]=-INF, r[i]=INF;
}

void dfs(int u, int par=-1) {
    for(int v: adj[u]) if(v!=par) dfs(v, u);
    if(a[u]!=-1) {
        c[u]=a[u]&1; l[u]=r[u]=a[u];
    }
    for(int v: adj[u]) if(v!=par) {
        l[u]=max(l[u], l[v]-1);
        r[u]=min(r[u], r[v]+1);
        if(l[u]>r[u]) NO();
        if(c[v]!=-1) {
            if(c[u]==-1) c[u]=c[v]^1;
            else if(c[u]==c[v]) NO();
        }
    }
    if(l[u]==r[u]&&c[u]!=-1&&(l[u]&1)!=(c[u]&1)) NO();
}

void dfs2(int u, int par=-1)  {
    if(par!=-1) {
        l[u]=max(l[u], l[par]-1);
        r[u]=min(r[u], r[par]+1);
    }
    for(int v: adj[u]) if(v!=par) {
        dfs2(v, u);
        l[u]=max(l[u], ans[v]-1);
        r[u]=min(r[u], ans[v]+1);
    }
    if(l[u]>r[u]) NO();
    for(int i=l[u]; i<=r[u]; i++) if(c[u]==-1||(i&1)==(c[u]&1)) {ans[u]=i; break;}
}

int32_t main() {
    fastio;
    cin>>n;
    rep(i, n-1) {
        int u, v; cin>>u>>v;
        adj[--u].pb(--v); adj[v].pb(u);
    }
    init();
    int k; cin>>k; rep(i, k) {int x, y; cin>>x>>y; a[--x]=y;}
    rep(i, n) if(a[i]!=-1) {
        dfs(i);
        dfs2(i);
        break;
    }
    cout<<"Yes\n";
    /*cout<<"infodump\n";
    rep(i, n) cout<<a[i]<<' '; cout<<endl;
    rep(i, n) cout<<c[i]<<' '; cout<<endl;
    rep(i, n) cout<<l[i]<<' '; cout<<endl;
    rep(i, n) cout<<r[i]<<' '; cout<<endl;*/
    rep(i, n) cout<<ans[i]<<endl;
}


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

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    int small;
    if(A>B) small=A;
    else small=B;

    int i;
    int GCM=1;
    for(i=1;i<=small; i++){
        if(A%i==0 && B%i==0) GCM=i;
    }

    if(C%GCM==0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N ; i++ ){
        for (int j = N - 1; j >= i + 1; j-- ){
            if(A[j].value < A[j-1].value){
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i = 0; i < N; i++){
        int minj = i;
        for ( int j =i; j < N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj]=t;
    }
}

void print(struct Card A[], int N){
    for ( int i = 0; i<N; i++){
        if (i>0) cout << " ";
        cout << A[i].suit <<A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i< N ; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for ( int i =0; i < N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i < N; i++) C2[i] = C1[i];
    
    bubble(C1,N);
    selection(C2,N);
    
    print(C1,N);
    cout<< "Stable"<<endl;
    print(C2,N);
    if (isStable(C1,C2,N)){
        cout<< "Stable"<<endl;
    } else {
        cout<< "Not stable"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  int x = 0;
  while (1 + x * (A - 1) < B) {
    ++x;
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N): par(N),size(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            size[i] = -1;
        }
            
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getsize(int x){
        return -size[root(x)];
    }
    int getNunion(){
        map<int,int> m;
        rep(i,par.size()){
            m[this->root(i)]++;
        }
        return int(m.size());
    }
};


int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> p(N), x(M), y(M);
    rep(i,N){
        cin >> p[i];
        p[i]--;
    }
    UnionFind tree(N);
    rep(i,M){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        tree.unite(x[i], y[i]);
    }
    ll cnt = 0;
    rep(i,N){
        if(tree.same(i, p[i])){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>
using namespace std;

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

    string y = s.substr(0, 4);
    string m = s.substr(5, 2);
    string d = s.substr(8, 2);
    int month = 0;
    if (m[0] == '0') {
        month = stoi(m.substr(1, 1));
    } else {
        month = stoi(m);
    }
    int year = stoi(y);
    int day = 0;
    if (d[0] == '0') {
        day = stoi(d.substr(1, 1));
    } else {
        day = stoi(d);
    }
    if (month < 4) {
        cout << "Heisei" << endl;
    } else if (month == 4 && day <= 30) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC121 C

N,M = map(int,input().split())

AB = [list(map(int,input().split())) for _ in range(N)]

cost = 0
count = 0
AB.sort()
for i in range(N):
    if count == M:
        break
    elif count < M:
        if AB[i][1] + count < M:
            cost += AB[i][0]*AB[i][1]
            count += AB[i][1]
        elif AB[i][1] + count == M:
            cost += AB[i][0]*AB[i][1]
            break
        else:
            cost += AB[i][0]*(M - count)
            break
print(cost)


Measured memory_bytes: 27760
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  string seq;

  for (;;) {
    cin >> seq;
    if (seq == "#") break;

    int slen = seq.size();
    int min_ss = INF;

    for (int i = 0; i < 2; i++) {
      int ss = 0;
      int lf = 4, rf = 6, lx = 0, rx = 2, nxt;

      int d0 = seq[0] - '0';
      int x0 = (d0 - 1) % 3;

      if (i == 0) {
	lf = d0, lx = x0;
	nxt = 1;
	if (lf == rf) rf = 3;
      }
      else {
	rf = d0, rx = x0;
	nxt = 0;
	if (rf == lf) lf = 1;
      }

      for (int j = 1; j < slen; j++) {
	int dj = seq[j] - '0';
	int xj = (dj - 1) % 3;

	if (nxt == 0) {
	  if (dj != rf && xj <= rx) {
	    lf = dj, lx = xj;
	    nxt = 1;
	  }
	  else {
	    rf = dj, rx = xj;
	    ss++;
	  }
	}
	else {
	  if (dj != lf && xj >= lx) {
	    rf = dj, rx = xj;
	    nxt = 0;
	  }
	  else {
	    lf = dj, lx = xj;
	    ss++;
	  }
	}
      }

      if (min_ss > ss) min_ss = ss;
    }

    cout << min_ss << endl;
  }

  return 0;
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, C, K; cin >> N >> C >> K;
	vector<ll>T(N);
	rep(i, 0, N)cin >> T[i];
	sort(all(T));
	int ans = 0, i = 0;
	while (i < N) {
		int j = upper_bound(all(T), T[i] + K) - T.begin() - 1;
		if (j - i + 1 > C) {
			j = i + C - 1;
		}
		ans++;
		i = j + 1;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
using namespace std;
int a[200005];
int main()
{
//    int n;
//    scanf("%d",&n);
//    for(int i=1;i<=n;i++)
//    {
//        scanf("%d",&a[i]);
//    }
//    int T;
//    scanf("%d",&T);
//    while(T--)
//    {
//        int n;
//        scanf("%d",&n);
//        for(int i=1;i<=n;i++)
//        {
//            scanf("%d",&a[i]);
//        }
//    }
    double x;
    scanf("%lf",&x);
    printf("%.10f\n",pi*2*x);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b; cin >> a >> b;
  auto f = [&](ll a) {
    if(a%2) {
      return (a+1)/2%2;
    } else {
      return ((a+1)/2%2)^a;
    }
  };
  cout << (f(a-1)^f(b)) << endk;
  return 0;
}


Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	fmt.Println(n*800 - 200*(n/15))
}


Measured memory_bytes: 640
N, M = map(int, input().split())
A = []
for i in range(0, N):
	A.append(list(map(int, input().split())))
max = 0
for i in range(0, 8):
	lst = []
	m = i
	for j in range(0, 3):
		lst.append(-1+2*(m%2))
		m //= 2
	A.sort(key = lambda v: v[0]*lst[0]+v[1]*lst[1]+v[2]*lst[2], reverse = True)
	sums = [0, 0, 0]
	for j in range(0, M):
		sums[0] += A[j][0]
		sums[1] += A[j][1]
		sums[2] += A[j][2]
	sum = abs(sums[0])+abs(sums[1])+abs(sums[2])
	if max < sum:
		max = sum
print(max)

Measured memory_bytes: 40560
#include<cstdio>
#include<queue>
using namespace std;

int n, k, c, g;
priority_queue<int> que[10];
int dp[10][2000];

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &c, &g);
    g--;
    que[g].push(c);
  }
  for (int i = 0; i < 10; i++) for (int j = 0; j < 2000; j++) dp[i][j] = -1;
  for (int i = 0; i < 10; i++) dp[i][0] = 0;
  int num = 1, sum = 0, money = 0;
  while (!que[0].empty()) {
    sum += que[0].top();
    money = sum + num * (num - 1);
    que[0].pop();
    dp[0][num++] = money;
  }
  for (int i = 1; i < 10; i++) {
    for (int j = 0; dp[i - 1][j] != -1; j++) dp[i][j] = dp[i - 1][j];
    num = 1, sum = 0, money = 0;
    while (!que[i].empty()) {
      sum += que[i].top();
      money = sum + num * (num - 1);
      que[i].pop();
      for (int j = 0; j + num <= k && dp[i - 1][j] != -1; j++)
        dp[i][j + num] = max(dp[i][j + num], dp[i - 1][j] + money);
      num++;
    }
  }
  printf("%d\n", dp[9][k]);
}



Measured memory_bytes: 2864
n, x = map(int, input().split())

A = [1] * (n + 1)
P = [1] * (n + 1)
for i in range(1, n + 1):
    A[i] = A[i - 1] * 2 + 3
    P[i] = P[i - 1] * 2 + 1

c = 0
for i in list(range(n+1))[::-1]:
    if i == 0:
        c += 1

    elif x == 1:
        break

    elif x <= A[i - 1] + 1:
        x -= 1

    elif x == A[i - 1] + 2:
        c += P[i - 1] + 1
        break

    elif x <= A[i] - 1:
        c += P[i - 1] + 1
        x -= A[i - 1] + 2

    elif x == A[i]:
        c += P[i]
        break

print(c)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int d[k];
    int have[n]={};
    vector<int>a;
    for(int i=0;i<k;i++){
        cin>>d[i];
        a.resize(d[i]);
        for(int j=0;j<d[i];j++){
            cin>>a[j];
            have[a[j]-1]=true;
        }
    }
    int tr=0;
    for(int i=0;i<n;i++)if(have[i]==0)tr++;
    cout<<tr<<endl;
    return 0;
}

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

using namespace std;

int main() {

	long long	n;
	cin >> n ;

	string s;
	vector<string> name;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H' ) {
			name.push_back(s);
		}
	}

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

	long long mcount=0;
	long long acount=0;
	long long rcount=0;
	long long ccount=0;
	long long hcount=0;

	for (int i = 0; i < name.size(); i++) {
		if (name[i][0] == 'M') { mcount++; }
		if (name[i][0] == 'A') { acount++; }
		if (name[i][0] == 'R') { rcount++; }
		if (name[i][0] == 'C') { ccount++; }
		if (name[i][0] == 'H') { hcount++; }
	}
	cout << mcount * acount*rcount +
		mcount * acount*ccount +
		mcount * acount*hcount +
		mcount*rcount*ccount+
		mcount*rcount*hcount+
		mcount*ccount*hcount+
		acount * rcount*ccount +
		acount * rcount*hcount +
		acount*ccount*hcount+
		rcount * ccount*hcount << endl;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size(),m = t.size();
    ll ans = 0;
    vector<int> a[26];
    for (int i = 0;i < n;++i) a[s[i]-'a'].push_back(i);
    int p = -1;
    for (int i = 0;i < m;++i) {
        int c = t[i]-'a';
        if (a[c].empty()) {
            cout << -1 << endl;
            return 0;
        }
        int j = upper_bound(a[c].begin(),a[c].end(),p)-a[c].begin();
        if (j < a[c].size()) {
            ans += a[c][j]-p;
        } else {
            j = 0;
            ans += n-p+a[c][0];
        }
        p = a[c][j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string r, g, b;
	cin >> r >> g >> b;
	int x = stoi(r + g + b);
	if (x % 4 == 0) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	string s; cin >> s;

	vl cnt(3);
	REP(i, s.size()) {
		cnt[s[i] - 'a']++;
	}
	ll num = (cnt[0] != 0) + (cnt[1] != 0) + (cnt[2] != 0);
	if (num == 1) {
		cout << (s.size() == 1 ? "YES" : "NO") << endl;
	} else if (num == 2) {
		cout << (s.size() <= 2 ? "YES" : "NO") << endl;
	} else {
		ll diff1 = abs(cnt[0] - cnt[1]);
		ll diff2 = abs(cnt[0] - cnt[2]);
		ll diff3 = abs(cnt[2] - cnt[1]);
		cout << (diff1 <= 1 && diff2 <= 1 && diff3 <= 1 ? "YES" : "NO") << endl;
	}

	return 0;
}


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

const int max_v = 55;
char board[max_v][max_v];

int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int dp[max_v][max_v];

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

    int h,w;
    cin >> h >> w;

    for(int i = 0; i < max_v; i++){
        for(int j = 0; j < max_v; j++) dp[i][j] = -1;
    }

    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> board[i][j];
            if(board[i][j] == '#') cnt++;
        }
    }

    queue<pair<int,int>> q;
    q.push({0,0});
    dp[0][0] = 1;

    while(!q.empty()){
        pair<int,int> p = q.front();
        q.pop();

        if(p.first == h - 1 && p.second == w - 1) break;

        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(nx >= 0 && nx < h && ny >= 0 && ny < w &&
               board[nx][ny] != '#' && dp[nx][ny]== -1){
                q.push({nx,ny});
                dp[nx][ny] = dp[p.first][p.second] + 1;
            }
        }
    }

    if(dp[h-1][w-1] == -1) {
        cout << -1 << endl;
        return 0;
    }

    cout << h * w - dp[h-1][w-1] - cnt << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K,ans=1;
  cin>>N>>K;
  ll A[N],S=0;
  REP(i,N){
    cin>>A[i];
    S+=A[i];
  }
  
  for(ll i=1; i<=sqrt(S); ++i){
    if(S%i==0){
      ll T=S/i,SUM[N+1],cnt=0;
      SUM[0]=0;
      vector<ll> B;
      REP(j,N){
        if(A[j]%T!=0) B.PB(A[j]%T);
      }
      SORT(B);
      RREP(j,B.size()) SUM[j]=SUM[j-1]+B[j-1];
      
      RREP(j,B.size()){
        if(SUM[j-1]==(B.size()-j+1)*T-(SUM[B.size()]-SUM[j-1])){
          if(K>=SUM[j-1]) chmax(ans,T);
        }
      }
      
      T=i,cnt=0;
      SUM[0]=0;
      vector<ll> C;
      REP(j,N){
        if(A[j]%T!=0) C.PB(A[j]%T);
      }
      SORT(C);
      RREP(j,C.size()) SUM[j]=SUM[j-1]+C[j-1];
      
      RREP(j,C.size()){
        if(SUM[j-1]==(C.size()-j+1)*T-(SUM[C.size()]-SUM[j-1])){
          if(K>=SUM[j-1]) chmax(ans,T);
        }
      }
    }
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 3768
antenna = []
antenna.append(int(input()))
antenna.append(int(input()))
antenna.append(int(input()))
antenna.append(int(input()))
antenna.append(int(input()))
k = int(input())

flg = 'Yay!'
for i in range(0, len(antenna)):
  for j in range(i+1, len(antenna)):
    if (antenna[j]-antenna[i])>k:
      flg = ':('
      break
print(flg)

Measured memory_bytes: 3064
#include <stdio.h>
#include <ctype.h>

int main(int argc, char *args[])
{
	char string_s[201];
	char string_p[101];
	int s_count = 0;
	int p_count = 0;
	int i,j;
	int ng_flag = 0;

	scanf("%s", string_s);
	scanf("%s", string_p);


	while( string_s[s_count] != 0 ) {
		s_count++;
	}

	for( i=0; i<s_count; i++ ) {
		string_s[s_count+i] = string_s[i];
	}
	string_s[s_count+i+1] = 0;
	s_count *= 2;

//	printf("%s\n", string_s);

	while( string_p[p_count] != 0 ) {
		p_count++;
	}

	for( i=0; i< s_count-p_count; i++ ) {
		ng_flag = 0;
		for( j=0; j<p_count; j++ ) {
			if( string_s[j+i] != string_p[j] ) {
				ng_flag = 1;
				break;
			}
		}
		if( ng_flag != 1 ) {
			break;
		}
	}
	if( ng_flag != 1 ) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

#define int ll

vector<int> v;
int n,k;

int cache[400][400];

int solve(int index, int del) {
	if(index<0) {
		if(del>=0) return 0;
		return inf;
	}
	if(cache[index][del]!=-1) return cache[index][del];
	int ans = inf;
	for(int i=0;i<=del;i++) {
		if(index-1-i==-1) {
			ans = min(ans, v[index]);
			break;
		}
		ans = min(ans, ((v[index]>=v[index-1-i])?(v[index]-v[index-1-i]):(0LL)) + solve(index-i-1,del-i));
	}
	return cache[index][del] = ans;
}

signed main() {
	fast;

	for(int i=0;i<400;i++) for(int j=0;j<400;j++) cache[i][j] = -1;

	cin>>n>>k;
	for(int i=0;i<n;i++) {
		int temp;
		cin>>temp;
		v.pb(temp);
	}

	int ans = inf;
	for(int i=0;i<=k;i++) ans = min(ans, solve(n-1-i,k-i));

	cout<<ans;

}

Measured memory_bytes: 1536