akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int r,g,b,sum;
    cin >>r>>g>>b;

    sum = r*100+g*10+b;

    if(sum%4==0){
        cout <<"YES"<<endl;
    }else{
        cout << "NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
using namespace std;

#define INF ( 1 << 30 )
typedef pair < int , int > Pi;

int main()
{
  int N, Q;
  int stmp[1000000], comp[1000000], a;
  char buff[1024];
  scanf( "%d %d", &N, &Q);
  for(int i = 0 ; i < N ; i++ ){
    scanf( "%d", &stmp[i]);
    comp[i] = stmp[i];
  }
  sort( comp, comp + N);

  vector< int > sym;
  while(Q--){
    scanf("%s %d", buff, &a);
    if(*buff == 'A'){ //ADD

      sym.push_back(stmp[a - 1]);
      sort( sym.begin(), sym.end());

    } else if(*buff == 'R'){ //REMOVE

      sym.erase( lower_bound( sym.begin(), sym.end(), stmp[a - 1]));
      sort( sym.begin(), sym.end());

    } else { //CHECK

      int left = 0, right = INF;
      while(left != right){
        int center = ( left + right ) / 2;
        int pre = 0, BAN = 0;
        for(int i = 0 ; i < sym.size() ; i++ ){
          int p = distance( comp,lower_bound( comp, comp + N, sym[i] - center));
          BAN += max( p - pre, 0);
          pre = distance( comp, upper_bound( comp, comp + N, sym[i]));
        }
        BAN += max( N - pre, 0);
        if(BAN <= a) right = center;
        else left = center + 1;
      }
      if( left != INF) printf("%d\n", left);
      else puts("NA");

    }
  }
  return false;
}

Measured memory_bytes: 8884
#include<bits/stdc++.h>
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
    return (a.second > b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
int main()
{
     fast;
     //int t;
     //cin>>t;
     //while(t--)
     {
      ll i,j,c=0,d=0,sum=0,e=0,f=0,g=0,h=0,n,maxi=0;
       cin>>n;
       vector<ll> a(n);
       for(e=1;e<=n;e++)
       {
       for(i=1;i<=n;i++)
       {
           c=gcd(e,i);
           for(j=1;j<=n;j++)
           {
               d=gcd(c,j);
               sum+=d;
           }
       }
       }

       cout<<sum;
     }

}



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

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define siz(x) (x).size()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int a, int b) {
	if (b & 1)return a * mpow(a, b - 1);
	return mpow(a * a, b >> 1);
}
int mpow(int a, int b, int m) {
	if (b & 1)return a * mpow(a, b - 1, m) % m;
	return mpow(a * a % m, b >> 1, m) % m;
}
vector<int> graph;
void dfs(int cur, int prev = -1) {
	//visit[cur] = true;
	for (auto& i : graph) {
		if (i == prev)continue;
		dfs(i, cur);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, m; cin >> n >> m;
	ll s = 0;
	for (int i = 0; i < m; i++) {
		int x; cin >> x;
		s += x;
	}
	if (n - s < 0)cout << -1;
	else cout << n - s;
		
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=200010;
const ll mod=1e9+7;

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

int main(){
  int q;
  cin >> q;
while(q--){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  if(b>a){ cout << "No" << ln; continue; }
  if(b>d){ cout << "No" << ln; continue; }
  if(c>=b){ cout << "Yes" << ln; continue; }
  ll g = gcd(b,d);
  ll tmp = a%g + b -g;
  if(tmp>c){ cout << "No" << ln; continue; }
  cout << "Yes" << ln;
}
  return 0;
}

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

using namespace std;

#define _int64 long long

int main()
{
  vector<pair<_int64,_int64> > a;
  _int64 v1,v2,v3,v4,v,ans;
  _int64 i,j;
  scanf("%lld%lld%lld%lld",&v1,&v2,&v3,&v4);
  v1*=8;
  v2*=4;
  v3*=2;
  a.clear();
  a.push_back(make_pair(v1,2));
  a.push_back(make_pair(v2,4));
  a.push_back(make_pair(v3,8));
  a.push_back(make_pair(v4,16));
  scanf("%lld",&v);
  v*=8;
  sort(a.begin(),a.end());
  ans=0;
  for (i=0;i<a.size();i++)
  {
    //cout<<v<<" "<<a[i].first<<" "<<a[i].second<<endl;
    ans+=a[i].first/(16/a[i].second)*(v/a[i].second);
    v%=a[i].second;
    //cout<<v<<endl;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

bool isso(long long int a) {
	if (a == 1||a==0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}
int main() {
	while (1) {
		int N; cin >> N;
		if (N) {
			int anum = 0;
			{
				while (1) {
					if (isso(N - anum)) {
						break;
					}
					anum++;
				}
			}
			int bnum = 0;
			{
				while (1) {
					if (isso(N + bnum)) {
						break;
					}
					bnum++;
				}
			}
			cout << anum + bnum << endl;
		}
		else {
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2976
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define repf(i,s,e)  for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve(){
	int n,k;
	cin>>n>>k;

	function<int(int,int)> binpow=[&](int a,int b){
		int res=1;
		a=a%MOD;
		while(b){
			if(b&1)
				res=res*a%MOD;
			a=a*a%MOD;
			b >>=1;
		}
		return res;
	};

	vector<int> cnt(k+1,0);
	cnt[k]=1;
	int ans=k;
	for(int i=k-1;i>=1;i--){
		int num=k/i;
		cnt[i]=binpow(num,n);
		for(int j=i+i;j<=k;j+=i){
			cnt[i]=(cnt[i]-cnt[j]+MOD)%MOD;
		}
		ans=(ans+i*cnt[i])%MOD;
	}

	cout<<ans<<endl;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	if(fopen("input.txt", "r")){
	    freopen("input.txt", "r", stdin),
	    freopen("output.txt", "w", stdout);
	}
	
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> ryuka(N+1);
    ryuka[0]=2,ryuka[1]=1;
    rep(i,N+1){
        if(i>=2){
            ryuka[i]=ryuka[i-1]+ryuka[i-2];
        }
    }
    cout << ryuka[N] << endl;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}


const int mod = 998244353;
const int inf = 1'000'000'007;


int power(int x, int y) {
  if (y == 0) {
    return 1;
  }
  int z = power(x, y >> 1);
  z = z * 1ll * z % mod;
  if (y & 1) {
    z = z * 1ll * x % mod;
  }
  return z;
}

void solve() {
  string s;
  cin >> s;
  int bc = 0;
  ll ans = 0;
  for (int i = sz(s) - 1; i >= 0; --i) {
    if (i + 1 < sz(s) && s.substr(i, 2) == "BC") {
      ++bc;
    }
    if (s[i] == 'A') {
      ans += bc;
    } else if (i > 0 && s.substr(i, 2) != "BC" && s.substr(i - 1, 2) != "BC") {
      bc = 0;
    }
  }
  cout << ans << "\n";

}

int main() {
  #ifndef LOCAL58
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while(t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3768
using System;

class Program
{
    static void Main(string[] args)
    {
        int value = int.Parse(Console.ReadLine());

        int marbleCount = 0;

        while (value != 0)
        {
            marbleCount += value % 10;
            value /= 10;
        }

        Console.WriteLine(marbleCount);
    }
}


Measured memory_bytes: 11092
class IntArray2D(val size1: Int, val size2: Int) {
    private val innerArray = IntArray(size1 * size2)

    operator fun get(i1: Int, i2: Int): Int = innerArray[i2 + size2 * i1]

    operator fun set(i1: Int, i2: Int, v: Int) {
        innerArray[i2 + size2 * i1] = v
    }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val table = IntArray2D(10, 10)
    for (i in 1..n) {
        val si = i.toString()
        table[si.first() - '0', si.last() - '0'] += 1
    }
    var count = 0L
    for (i in 0 until 10) {
        for (j in 0 until 10) {
            count += table[i, j].toLong() * table[j, i].toLong()
        }
    }
    println(count)
}

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

typedef long long ll;

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

    ll A, B;
    cin >> A >> B;

    ll ans = 0;

    for(ll i = 1; i < 50; i++) {
        ll x = 1LL << i;
        ll ya = A % x;
        ll yb = B % x;
        ll za = (A / x) * x / 2LL;
        ll zb = (B / x) * x / 2LL;
        if(ya >= x / 2LL) {
            za += ya - (x / 2LL - 1LL);
        }
        if(yb >= x / 2LL) {
            zb += yb - (x / 2LL - 1LL);
        }

        ll z = zb - za;

        z %= 2LL;

        ans += z << (i - 1);
    }

    ans ^= A;

    cout << ans << endl;
}

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

using namespace std;

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

void make_all_case(vector<vector<char>> &cases, vector<vector<char>> &ops, vector<char> &new_case, int x){
    //ベースケース
    if(x == -1){
        cases.push_back(new_case);
        return;
    }
    //再帰ステップ
    for(char op : ops.at(x)){
        new_case.at(x) = op;
        make_all_case(cases, ops, new_case, x-1);
    }
}

bool calculate(vector<int> nums, vector<char> c){
    int res = nums.at(0);
    rep(i, c.size()){
        if(c.at(i) == '+'){
            res += nums.at(i+1);
        } else {
            res -= nums.at(i+1);
        }
    }
    return res == 7;
}

int main() {
    int S;
    cin >> S;
    vector<int> inputs(4);
    rep(i, 4){
        inputs.at(i) = S % 10;
        S /= 10;
    }
    reverse(inputs.begin(), inputs.end());
    
    vector<vector<char>> cases(0, vector<char>(3));
    vector<vector<char>> ops(3, vector<char>(2));
    rep(i, ops.size()){
        vector<char> op = {'+', '-'};
        ops.at(i) = op;
    }
    vector<char> new_case(3);
    make_all_case(cases, ops, new_case, 2);

    for(vector<char> c : cases){
        if(calculate(inputs, c)){
            cout << inputs.at(0);
            rep(i, c.size()){
                cout << c.at(i) << inputs.at(i+1);
            }
            cout << "=7" << endl;
            break;
        }
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> path(n, vector<bool>(n, false));
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        path[a][b] = true;
        path[b][a] = true;
    }
    vector<int> v(n);
	rep(i,n) v[i] = i;
    int ans = 0;
	do{
		if(v[0] != 0) continue;
        bool ok = true;
        rep(i,n-1){
            if(!path[v[i]][v[i+1]]){
                ok = false;
                break;
            }
        }
        if(ok) ans++;
	} while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<tuple<int, int, int>> p(N);
    int si = 0;
    for (int i = 0; i < N; i++)
    {
        int x, y, h; cin >> x >> y >> h;
        p[i] = make_tuple(x, y , h);
        if(h>0) si = i;
    }

    for (int i = 0; i <= 100; i++)
    {
        for (int j = 0; j <= 100; j++)
        {
            bool flag = true;
            int hight = get<2>(p[si]) + abs(i-get<0>(p[si])) + abs(j-get<1>(p[si]));
            for (int k = 0; k < N; k++)
            { 
                int kh = max(hight-abs(i-get<0>(p[k]))-abs(j-get<1>(p[k])),0); 
                if( kh != get<2>(p[k])){
                    flag = false;
                    break;
                }
            }
            if(flag == true){
                cout << i << " " << j << " " << hight<< endl;
                return 0;
            }
        }
    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{

	int N, M;
	cin >> N >> M;

	pairs(Z);
	fx(N) {
		pairsp(Z);
	}
	sorts(Z);

	priority_queue<int> A;

	int ans = 0;
	int index = 0;
	fx(M) {
		while (index<N&&Z[index].first==x+1)
		{
			A.push(Z[index].second);
			index++;
		}
		if (!A.empty()) {
			ans += A.top();
			A.pop();
		}

	}

	ce(ans)

    return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>



int main()
{
	long long  n;

	std::cin >> n;

	std::vector<long long> v(n);
	
	for (int i = 0; i < n; i++) {
		std::cin >> v[i];
	}
	
	long long count = 0;

	for (int i = 0; i < v.size(); i++) {
		if (v[i] == i + 1) {
			if (i == 0) {
				std::swap(v[0], v[1]);
			} else {
				if (i + 1 != n && v[i + 1] != i + 1) {
					std::swap(v[i + 1], v[i]);
				} else {
					std::swap(v[i - 1], v[i]);
				}
			}
			count++;
		}
	}

	

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 1024
H,W = map(int,input().split())
map = []
INF = 10**8
for _ in range(H):
    map.append(input())

dp = [[0 for i in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            if map[i][j] == '#':
                dp[i][j] = 1
        elif i == 0:
            flag = 0
            if map[i][j] == '#' and map[i][j-1] == '.':
                flag = 1
            dp[i][j] = flag + dp[i][j-1]
        elif j == 0:
            flag = 0
            if map[i][j] == "#" and map[i-1][j] == ".":
                flag = 1
            dp[i][j] = flag + dp[i-1][j]
        else:
            flag1 = 0
            flag2 = 0
            if map[i][j] == "#" and map[i][j-1] == ".":
                flag1 = 1
            if map[i][j] == "#" and map[i-1][j] == ".":
                flag2 = 1
            dp[i][j] = min(dp[i][j-1]+flag1,dp[i-1][j]+flag2)

print(dp[H-1][W-1])


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

struct Problem {

    UL P[100000][17];
    UL D[100000];
    vector<UL> E[100000];

    UL UP(UL u, UL d) {
        for (UL i = 16; i != -1; i--) if (d & (1 << i)) u = P[u][i];
        return u;
    }

    UL LCS(UL u, UL v) {
        if (D[u] > D[v]) u = UP(u, D[u] - D[v]);
        else if (D[u] < D[v]) v = UP(v, D[v] - D[u]);
        for (UL i = 16; i != -1; i--) {
            if (P[u][i] != P[v][i]) { u = P[u][i]; v = P[v][i]; }
        }
        if (u == v) return u;
        return P[u][0];
    }

    void Solve() {
        UL N; scanf("%d", &N);
        P[0][0] = 0;
        rep(u, N) {
            UL K; scanf("%d", &K);
            while (K--) {
                UL v; scanf("%d", &v);
                E[u].push_back(v); P[v][0] = u;
            }
        }
        {
            vector<UL> Q; Q.push_back(0); D[0] = 0;
            while (Q.size()) {
                UL p = Q.back(); Q.pop_back();
                for (UL e : E[p]) { D[e] = D[p] + 1; Q.push_back(e); }
            }
        }
        rep(i, 16) rep(v, N) P[v][i + 1] = P[P[v][i]][i];
        UL Q; scanf("%d", &Q);
        while (Q--) {
            UL u, v; scanf("%d%d", &u, &v);
            printf("%d\n", LCS(u, v));
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}




Measured memory_bytes: 15216
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    VI hash(11, 0);
    int a, b, c;
    cin >> a >> b >> c;
    hash[a]++;
    hash[b]++;
    hash[c]++;
    if(hash[5] == 2 and hash[7] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

signed main() {
  int n;
  std::cin >> n;
  n = 2*n;

  int l[n];
  for(int i = 0; i < n; i++)
    std::cin >> l[i];

  std::sort(l, l+n);

  int ans = 0;
  for(int i = n-2; i >= 0; i -= 2)
    ans += l[i];

  std::cout << ans << std::endl;
  
  return 0;
}


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

using namespace std;

int main(void) {
    int n;
    vector<int> a;
    cin >> n;
    for(int i =0; i < n; i++) {
        int aa;
        cin >> aa;
        a.push_back(aa);
    }
    sort(a.rbegin(), a.rend());
    int al = 0, bb = 0;
    for(int i =0; i < n; i++) {
        if (i % 2 == 0) {
            al += a[i];
        } else {
            bb += a[i];
        }
    }
    cout << al - bb << endl;
}


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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e6 + 5;
const int mod = 1e9 + 7;

int modExpo(int a,int b,int c){
	if(b == 0) return 1;
	int answer = 1;
	while(b){
		if(b & 1) answer = ((answer % c) * (a % c)) % c;
		a = ((a % c) * (a % c)) % c;
		b /= 2; 
	}
	
	return answer;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		
		int bills = n / 1000;
		if(n % 1000 == 0) cout << "0";
		else{
			cout << (bills + 1) * 1000 - n;
		}
	}	
	return 0;
}


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

int mcxitoi(string s){
  int c=1, ret=0;;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='m'){ret+=c*1000; c=1;}
    else if(s[i]=='c'){ret+=c*100; c=1;}
    else if(s[i]=='x'){ret+=c*10; c=1;}
    else if(s[i]=='i'){ret+=c; c=1;}
    else{c=s[i]-'0';}
  }
  return ret;
}

string itomcxi(int t){
  char c[4]={'i', 'x', 'c', 'm'};
  string ret="";
  int cnt=0;
  while(t!=0){
    if(t%10!=0){
      ret=c[cnt]+ret;
      if(t%10!=1)
        ret=(char)(t%10+'0')+ret;
    }
    t/=10;
    cnt++;
  }
  return ret;
}

int main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    string s1, s2;
    cin>>s1>>s2;
    cout<<itomcxi(mcxitoi(s1)+mcxitoi(s2))<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
n = int(input())
#a,b = map(int,input().split())
L = list(map(int,input().split()))

cnt = 0
min1 = L[0]
for i in range(n-1):
    min1 = min(min1,L[i])
    if L[i+1]<=min1:
        #print(L[i+1])
        cnt +=1
print(cnt+1)
    

Measured memory_bytes: 24744
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

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

typedef long long ll;

using namespace std;
int main(){
    int A, B, C;
    string ans;
    cin >> A >> B >> C;
	vector<bool> resFlag;
	REP(i, C + 1)
	{
		resFlag.push_back(false);
	}

    REP(i, 1000)
    {
    	int num = A * i;
    	int r = num % B;
    	if (r == C)
    	{
    		resFlag[r] = true;
    		break;

    	}
    	if (resFlag[r]) break;
    	else resFlag[r] = true;
    }

    ans = resFlag[C] ? "YES" : "NO";
    cout << ans << endl;

}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    string s1,s2;
    cin >> s1 >> s2;
    if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar(); }
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    return x * f;
}

typedef long long ll;

int main() {
    int n = read();
    ll sum3 = (n / 3ll * 3 + 3) * (n / 3) / 2, sum5 = (n / 5ll * 5 + 5) * (n / 5) / 2;
    ll sum3_5 = (n / 15ll * 15 + 15) * (n / 15) / 2;
    ll presum = (n + 1ll) * n / 2;
    std::printf("%lld\n",presum - sum3 - sum5 + sum3_5);
    return 0;
}

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main{
        public  static void main(String[] args){
                calc();
        }
        static int calc(){
                Scanner sc = new Scanner(System.in);
                int a=sc.nextInt();
                int b=sc.nextInt();
                int c,d;
                if((a+b)%2==0){
                        c=(a+b)/2;
                        if(c>0){
                                System.out.println(c);
                        return c;
                        }else{
                                d =c*(-1);
                                System.out.println(d);
                                return d;
                        }
                }else{
                        System.out.println("IMPOSSIBLE");
                }
                return 0;
        }
}

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

int main() {
	int N, K;

	cin >> N >> K;

	long long x = 0;
	long long y = 0;
	for (int i = 1; i <= N; i++) {
		if (i % K == 0)x++;
		if ((i % K) * 2 == K)y++;
	}

	cout << x * x * x + y * y * y << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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

score=[-1]*N

for i in range(M):
    s,c=map(int,input().split())
    s-=1

    if score[s]==-1 or score[s]==c:
        score[s]=c
    else:
        print(-1)
        sys.exit()
    
if N>1 and score[0]==0:
    print(-1)
    sys.exit()

for i in range(N):
    if score[i]==-1:
        score[i]=0

if score[0]==0 and N>1:
    score[0]=1

print("".join(map(str,score)))

Measured memory_bytes: 3064
#!/bin/env python3

N = int(input())

t_prev = x_prev = y_prev = 0
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()
    elif (abs(x_i - x_prev) + abs(y_i - y_prev)) > (t_i - t_prev):
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let a = read::<i32>();
  let b = read::<i32>();

  let a_is_even = a % 2 == 0;
  let b_is_even = b % 2 == 0;

  if a_is_even == b_is_even {
    println!("{}", (a+b)/ 2);
  } else {
    println!("IMPOSSIBLE");
  }

  
}



Measured memory_bytes: 4352
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the frined button
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define endl "\n"
#define int int64_t
#define ll long long
#define yes printf("YES\n")
#define no printf("NO\n")
#define push_back pb
int32_t main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/input.txt", "r", stdin);
        freopen("/media/AIMON/SSDVol/Progs/CodeForces/output.txt", "w", stdout);
    #endif*/
    long long a,b,c,d=0,e=0,i;
    cin>>a>>b;
    c=min(a,b);
    if(c==a)
    {
        for(i=0;i<b;i++)
        {
            cout<<c;
        }
        cout<<endl;
    }
    else
    {
       for(i=0;i<a;i++)
        {
            cout<<c;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int a[60], b[60];
bool arrive[60];
vector<int> G[60];
int cnt;
void dfs(int v, int parent, int x, int y) {
	cnt++;
	arrive[v] = true;
	for (int to : G[v]) {
		if (to == parent) continue;
		if ((to == x && v == y) || (to == y && v == x))continue;
		if (!arrive[to]) dfs(to, v, x, y);
	}
}

int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) arrive[j] = false;
		cnt = 0;
		dfs(0, -1, a[i], b[i]);
		if (cnt != N) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)


Measured memory_bytes: 18612
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length-1; i++) {
        tmp = input[i].split(" ")
        var a = tmp[0]
        var b = tmp[1]
        var c = tmp[2]
        if (a < b && b < c) {
            console.log("Yes")
        } else {
            console.log("No")
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15096
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;


int main(void)
{
    int n,m,c;
    cin >>n >>m >>c;

    vector<int> b;
    for(int i = 0; i < m; i++){
        int tmp;
        cin >>tmp;
        b.push_back(tmp);
    }

    int ct = 0;
    for(int i = 0; i < n; i++){
        int sum = c;
        for(int j = 0; j < m; j++){
            int tmp;
            cin >> tmp;
            sum += tmp * b[j];
        }
        if(sum > 0){
            ct++;
        }
    }

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

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii ;
const int mod = 1e9 + 7;

ll binPow(ll x, ll y, ll md = mod){
    ll res = 1;
    x %= mod;
    while(y){
        if(y & 1){
            res = (res * x) % mod;
        }
        y >>= 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve(){
   string s;
   cin >> s;
   int win = 0, lose = 0;
   for(int i = 0; i < s.length(); ++i){
       win += i % 2 && s[i] == 'g';
       lose += !(i % 2) && s[i] == 'p';
   }
   cout << win - lose << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(in) in.begin(),in.end()
using ll = long;
using namespace std;

int main(){
    int n, k; cin >> n >> k;
    vector<int> v(n); for(int i=0; i<n; i++) cin >> v[i];

    int res = 0;

    for(int ii=0; ii<=n; ii++) for(int jj=0; jj<=n; jj++){
        if(ii+jj > k) continue;
      	if(ii+jj > n) continue;
        int nk = k-ii-jj;
        vector<int> pp(0);
        int ans = 0;
        for(int i=0; i<ii; i++) { pp.push_back(v[i]); ans += v[i]; }
        for(int i=0; i<jj; i++) { pp.push_back(v[n-1-i]); ans += v[n-1-i]; }
        sort(all(pp));
        for(int i=0; i<min(nk,ii+jj); i++) {if(pp[i] >= 0) break; ans -= pp[i]; }
        res = max(res,ans);
    }

    cout << res << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define mod 1000000007
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(15);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double anM = 6.0 * m, anH = 30.0 * h + (m / 2.0);
    double theta = abs(anM - anH);
    double ans = a * a + b * b - 2 * a * b * cos(theta * (3.141592653589) / 180.0);
    cout << sqrt(ans);
    return 0;
}

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

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

	vector<int> b(n);
	b = a;
	sort(a.begin(), a.end());

	int m1 = a[(a.size() - 1) / 2 + 1];
	int m2 = a[(a.size() - 1) / 2];
	for (int i = 0; i < n; i++) {
		if (b[i] < m1) cout << m1 << endl;
		else cout << m2 << endl; 
	}

	return 0;
}


Measured memory_bytes: 3712
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int p2[4000], fact[4000], fact_m[4000];
long long int DP[3100][3100] = {};

long long int mul_pow(long long int num, long long int pow_num, long long int mod_num){
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
    long long int N;
    cin >> N >> MOD;
    p2[0] = fact[0] = fact_m[0] = 1;
    for(int i = 1; i < 4000; i++){
        p2[i] = p2[i - 1] * 2;
        p2[i] %= MOD;
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
        fact_m[i] = fact_m[i - 1] * mul_pow(i, MOD - 2, MOD);
        fact_m[i] %= MOD;
    }
    DP[0][0] = 1;
    for(int i = 1; i <= N; i++){
        DP[i][0] = 1;
        for(int j = 1; j <= N; j++){
            DP[i][j] = DP[i - 1][j] * (j + 1) + DP[i - 1][j - 1];
            DP[i][j] %= MOD;
        }
    }
    long long int ans = mul_pow(2, mul_pow(2, N, MOD - 1), MOD);
    long long int sig = -1;
    for(int i = 1; i <= N; i++){
        long long int P = 1, S = 0;
        for(int j = 0; j <= i; j++){
            S += DP[i][j] * P;
            S %= MOD;
            P *= p2[N - i];
            P %= MOD;
        }
        S *= mul_pow(2, mul_pow(2, N - i, MOD - 1), MOD);
        S %= MOD;
        long long int comb = (fact[N] * fact_m[i] % MOD) * fact_m[N - i] % MOD;
        S *= comb;
        S %= MOD;
        ans += S * sig + MOD * 10;
        ans %= MOD;
        sig *= -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 73984
// atcoder/abc072/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int x, t;
  while (cin >> x >> t) {
    cout <<  max(0, x - t) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    string s;
    cin >> s;
    string asn = "Yes";
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[0])  asn = "No";
    cout << asn << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;
 
// 并查集相关数据与算法
#define MAX_N 10000 + 16
int parent[MAX_N];
int height[MAX_N];
 
void init(const int& n)
{
	for (int i = 0; i < n; ++i)
	{
		parent[i] = i;
		height[i] = 0;
	}
}
 
int find(const int& x)
{
	if (parent[x] == x)
	{
		return x;
	}
	else
	{
		return parent[x] = find(parent[x]);
	}
}
 
void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y)
	{
		return;
	}
 
	if (height[x] < height[y])
	{
		parent[x] = y;
	}
	else
	{
		parent[y] = x;
		if (height[x] == height[y])
		{
			++height[x];
		}
	}
}
 
bool same(const int& x, const int& y)
{
	return find(x) == find(y);
}
// End Of 并查集
 
#define MAX_E MAX_N * MAX_N / 2 + 1
struct edge
{
	int u, v;
	double cost;
	edge(int u = 0, int v = 0, double cost = 0) : u(u), v(v), cost(cost) {}
	bool operator < (const edge & e2) const
	{
		return cost > e2.cost;
	}
};
 
edge es[MAX_E];
int V, E;
double kruskal()
{
	sort(es, es + E);    // 按照权值从小到大排序
	init(V);
	double res = 0;
	for (int i = 0; i < E; ++i)
	{
		edge e = es[i];
		if (!same(e.u, e.v))
		{
			unite(e.u, e.v);
		}
		else
		{
			res += e.cost;
		}
	}
 
	return res;
}
 
pair<int, int> pile[MAX_N];
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	cin >> V >> E;
	
	for (int i = 0; i < V; ++i)
	{
		cin >> pile[i].first >> pile[i].second;
	}
 
	for (int i = 0; i < E; ++i)
	{
		cin >> es[i].u >> es[i].v;
		--es[i].u; --es[i].v;
		int dx = pile[es[i].u].first - pile[es[i].v].first;
		int dy = pile[es[i].u].second - pile[es[i].v].second;
		es[i].cost = sqrt(dx * dx + dy * dy);
	}
 
	cout.setf(ios::showpoint);
	cout.precision(3);
	cout.setf(ios::fixed);
	cout << kruskal() << endl;
	return 0;
}


Measured memory_bytes: 6080
io = STDIN
a,b,c=io.gets.chomp.split.map(&:to_i)
def sim(a,b,c)
  cnt=0
while (a.even?&&b.even?&&c.even?)
  aa,bb,cc=a,b,c
  a,b,c=b/2+c/2,a/2+c/2,a/2+b/2
  return -1 if aa==a&&bb=b&&cc=c
  cnt+=1
end
return cnt
end

puts sim(*[a,b,c].sort)

Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
 
long long dp[5000+10][5000+10];
 
int main(){
	//freopen("input","r",stdin);
	//freopen("output","w",stdout);
	int n;
	string s;
	cin>>n>>s;
	int x = s.size();
	dp[0][0] = 1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=5000;j++){
			dp[i][j] = 2*dp[i-1][j+1] + dp[i-1][max(0,j-1)];
			dp[i][j] %= 1000000007;
		}
	}
	cout<<dp[n][x]<<endl;
	return 0;
}

Measured memory_bytes: 195968
x,n = map(int,input().split())
p = [int(i) for i in input().split()]
x_abs = 100000
ans = []
for i in range(-2,102):
    if i in p:
        continue
    if x_abs > abs(x-i):
        ans = i
        x_abs = abs(x-i)
    elif x_abs == abs(x-1):
        ans = min(ans, i)
print(ans)


Measured memory_bytes: 9192
x = ''
y = ''
 
while True:
  line = input()
  line = line.split()
  x = int(line[0])
  y = int(line[1])
 
  if x == 0 and y == 0:
    break
 
  if x >= y:
    print(y,end=' ')
    print(x)
 
  else:
    print(x,end=' ')
    print(y) 

Measured memory_bytes: 7600
import java.util.Scanner

object Main extends App { 
  type Item = (Int, Int)
  class DP(num:Int, wgt:Int, items:Array[Item]) {
    val inf = Int.MaxValue >> 1
    val sumOfValue = items.foldLeft(0)((sum:Int, item:Item) => { val (v,w)=item; v+sum })
    val memo = Array.fill(num+1)(Array.fill(sumOfValue+1)(inf))
    memo.foreach((a)=>a(0)=0)
    def solver():Int = {
      var maxValue = 0 
      for (i <- 1 to num; j <- 1 to sumOfValue) {
        val (v, w) = items(i-1)
        val w0 = memo(i-1)(j)
        val w1 = if (j < v) w else memo(i-1)(j-v) + w
        val wmin = w0 min w1
        if (wmin <= wgt) maxValue = maxValue max j
        memo(i)(j)= wmin
      }
      maxValue
    }
  }

  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val W = sc.nextInt
  val items = (for (i <- 1 to N) yield (sc.nextInt, sc.nextInt)).toArray

  val dp = new DP(N, W, items)
  
  println(dp.solver())

}


Measured memory_bytes: 67924
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7  
num = 2*(10**3) # 制約に合わせよう
g1, g2, inverse = [1, 1] , [1, 1], [0, 1]
 
for i in range(2, num + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)
    
n, k = map(int, input().split())
for i in range(1, k+1):
    print(cmb(n-k+1, i, mod) * cmb(k-1, i-1, mod) % mod)

Measured memory_bytes: 3572
n=int(input())
a=[]
x=[]
for _ in range(n):
    A=int(input())
    X=[list(map(int,input().split())) for _ in range(A)]
    a.append(A)
    x.append(X)
ans=0

for i in range(2**n):
    tmp=[0]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=1
    for k in range(n):
        for h in range(a[k]):
            hito=x[k][h][0]-1
            singi=x[k][h][1]
            if tmp[k]==1:
                if tmp[hito]!=singi:
                    break
        else:
            continue
        break # https://note.nkmk.me/python-break-nested-loops/
    else:
        ans=max(ans,sum(tmp))

print(ans)

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

 int main(){
 	int a , b;
 	scanf( "%d%d" , &a , &b );
 	int Temp = b;

 	while( b ){
 		b /= 10;
 		a *= 10; 
 	}

 	a += Temp;
 	int d = sqrt(a);

 	if( d * d == a ) puts( "Yes" );
 	else puts( "No" );

 	return 0;
 }

Measured memory_bytes: 384
n = int(input())
l = list(map(int, input().split()))
a = {}
b = {}
for i in range(n // 2):
    key_a = l[i * 2]
    key_b = l[i * 2 + 1]
    if key_a in a:
        a[key_a] = a[key_a] + 1
    else:
        a[l[i * 2]] = 1
    if key_b in b:
        b[key_b] = b[key_b] + 1
    else:
        b[key_b] = 1
a = sorted(a.items(), key=lambda x: x[1], reverse=True)
b = sorted(b.items(), key=lambda x: x[1], reverse=True)
ca_max = a[0][0]
cb_max = b[0][0]
ca_max_num = a[0][1]
cb_max_num = b[0][1]
same_num = ca_max_num + cb_max_num
if ca_max == cb_max:
    if len(a) > 1:
        next_ca_max = a[1][1]
    else:
        next_ca_max = 0
    if len(b) > 1:
        next_cb_max = b[1][1]
    else:
        next_cb_max = 0
    same_num = max(ca_max_num + next_cb_max, cb_max_num + next_ca_max)
print(n - same_num)

Measured memory_bytes: 23840
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class Inonoa{
        static void Main(){
            string[] x_a = Console.ReadLine().Split();
            int x = int.Parse(x_a[0]);
            int a = int.Parse(x_a[1]);
            if(x<a){
                Console.WriteLine(0);
            }else{
                Console.WriteLine(10);
            }
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

const int maxn=1e5+15;
ll n,m,k,cnt;
ll vis[maxn],s[maxn],x[maxn],num[maxn],be[maxn],p[maxn],a[maxn];
vector <ll> q[maxn];
void dfs(ll x,ll dep)//找环 
{
	num[x]=dep;vis[x]=1;be[x]=cnt;
	q[cnt].push_back(x);
	if (!vis[p[x]]) dfs(p[x],dep+1);
}
int main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",x+i);
	for (int i=1;i<n;i++) s[i]=x[i+1]-x[i];//差分序列 
	scanf("%lld%lld",&m,&k);
	for (int i=1;i<n;i++) p[i]=i;
	for (int i=1;i<=m;i++) {scanf("%lld",a+i);swap(p[a[i]],p[a[i]-1]);}//一次置换的结果，记录下一次置换兔子到哪了 
	for (int i=1;i<n;i++) if (!vis[i]) {dfs(i,0);++cnt;}
	ll now=x[1];
	printf("%lld\n",now);
	for (int i=1;i<n;i++)
	{
		now+=s[q[be[i]][(num[i]+k)%q[be[i]].size()]];
		printf("%lld\n",now);
	}
	return 0;
}

Measured memory_bytes: 13044
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll a,b;
  cin>>a>>b;
  if(b==1)
  	cout<<0;
  else
  {
    ll ans=a;
    if(ans>=b)
    {
    	cout<<1;
    	return 0;
    }
  	for(ll i=2;;i++)
  	{
  		ans+=a-1;
  		if(ans>=b)
  		{
  			cout<<i;
  			return 0;
  		}
  	}
  }
  return 0;
}

Measured memory_bytes: 3604