akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string  s; int k;
    cin >> s >> k;
    vb d(10,true);
    rep(i,k){
        int a; cin >> a;
        d[a]=false;
    }
    vint use;
    rep(i,10){
        if(d[i]==true) use.pb(i);
    }
    int n=use.size();
    map<int,bool> map;
    rep(i,n){
        map[use[i]]=true;
    }

    vb dp(1e5,0);
    rep(i,1e5){
        string t=to_string(i);
        bool can=true;
        rep(j,t.size()){
            if(map[t[j]-'0']==false)can=false;
        }
        if(can==true) dp[i]=true;
    }

    for(int i=stoll(s); ; i++){
        if(dp[i]==true){
            cout<<i<<endl;
            return 0;
        }
    }



}

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

using namespace std;

#define int long long
const int INF = 1LL << 58;

struct edge
{
  int to, cost;
};

signed main()
{
  int N, K, S;
  int X[2000], Y[2000], Z[2000];

  while(cin >> N >> K >> S, N) {
    for(int i = 0; i < N; i++) {
      cin >> X[i] >> Y[i] >> Z[i];
    }

    vector< edge > g[2000];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < i; j++) {
        int latte = max(0LL, S - abs(X[i] - X[j]));
        int malta = max(0LL, S - abs(Y[i] - Y[j]));
        int beeet = max(0LL, S - abs(Z[i] - Z[j]));
        int ukuku = latte * malta + malta * beeet + beeet * latte;
        if(latte > 0 && malta > 0 && beeet > 0) {
          g[i].emplace_back((edge) {j, ukuku});
          g[j].emplace_back((edge) {i, ukuku});
        }
      }
    }

    int ret = -1;
    for(int i = 0; i < N; i++) {
      bool v[2000] = {};
      function< void(int, int, int) > dfs = [&](int idx, int k, int sz)
      {
        if(v[idx]++) return;
        if(k == 0) {
          if(K >= 3) for(auto &e: g[idx]) if(e.to == i) sz += e.cost;
          ret = max(ret, sz);
        } else {
          for(auto &e : g[idx]) dfs(e.to, k - 1, sz + e.cost);
        }
        v[idx] = false;
      };
      dfs(i, K - 1, 0);
    }
    if(ret == -1) cout << -1 << endl;
    else cout << 6 * S * S * K - ret * 2 << endl;
  }
}

Measured memory_bytes: 3276
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;  
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair
#define se second
#define fi first
typedef long long ll;
typedef pair<int,int> PII;

void solve(){
	int n,m,k;
	int x,y,z;
	deque<int> q;
	cin >> n;
	rep(i,n){
		cin >> x;
		if(i&1) q.push_front(x); else q.push_back(x);
	}
	if (n&1) reverse(q.begin(), q.end());
	rep(i,n){
		cout << q[i];
		if(i<n-1) cout << ' '; else cout << endl;
	}
}

int main(int argc, char const *argv[])
{
	// #ifdef LOCAL
	// 	freopen("a.in", "r", stdin);
	// #endif
	solve();
	return 0;
}

Measured memory_bytes: 2944
# coding: utf-8
from collections import deque


def solve(*args: str) -> str:
    h, w = map(int, args[0].split())
    A = [[c == '.' for c in s] for s in args[1:]]

    Q = deque()
    for y in range(h):
        for x in range(w):
            if not A[y][x]:
                Q.append((x, y, 0))

    ret = 0
    while Q:
        x, y, n = Q.popleft()

        ret = max(ret, n)
        if 0 < x and A[y][x-1]:
            Q.append((x-1, y, n+1))
            A[y][x-1] = False

        if x+1 < w and A[y][x+1]:
            Q.append((x+1, y, n+1))
            A[y][x+1] = False

        if 0 < y and A[y-1][x]:
            Q.append((x, y-1, n+1))
            A[y-1][x] = False

        if y+1 < h and A[y+1][x]:
            Q.append((x, y+1, n+1))
            A[y+1][x] = False

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 154356
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  if(a*b%2 == 0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 long long int n;
  cin>>n;
  long long int a[n+1];
  map<long long int,long long int> mp;
  for(long long int i=1;i<=n;i++){
  	cin>>a[i];
  	mp[i+a[i]]++;
  }
  long long int count=0;
  for(long long int i=1;i<=n;i++){
  	long long int g=i-a[i];
  	count+=mp[g];
  }
  cout<<count<<"\n";
}

Measured memory_bytes: 27904
# list(map(int, input().split()))
# int(input())
from math import ceil
H, W = list(map(int, input().split()))
if H == 1 or W == 1:
    print(1)
elif (H * W) % 2 == 0:
    print(H * W // 2)
else:
    print(int(ceil(H * W / 2)))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a<<" "<<b<<" "<<3*c-a-b<<endl;
    cout<<c*4-a*2-b<<" "<<c<<" "<<a*2+b-c*2<<endl;
    cout<<a+b-c<<" "<<c*2-b<<" "<<c*2-a<<endl;
    return 0;
}

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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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

    int x;
    cin >> x;
    int a = 1;
    for (int i = 2; i <= 32; ++i)
    {
        for (int j = 2; j <= 10; ++j)
        {
            int c = (int)(pow((double)i, (double)j)+0.5);
            if (c <= x) a = max(a, c);
            else break;
        }
    }
    cout << a << endl;

    return 0;
}

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

using namespace std;

int main(void)
{
  int N, M, C;
  int cnt = 0;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int j = 0; j < M; j++){
    cin >> B[j];
  }
  for(int i = 0; i < N; i++){
    int ans = C;
    for(int j = 0; j < M; j++){
      int a;
      cin >> a;
      ans += a * B[j];
    }
    if(ans > 0){
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
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... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e3 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int r , c;
char s[ N ][ N ];
int a[ N ][ N ];
LL dp[ N ][ N ];

int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        cin >> r >> c;
        for( int i = 0; i < r; i++ ) cin >> s[i];
        for( int i = 0; i < r; i++ ) {
                for( int j = 0; j < c; j++ ) {
                        if( s[i][j] == '.' ) a[i+1][j+1] = 1;
                        else a[i+1][j+1] = -1;
                }
        }
        int f = 0;
        for( int i = 1; i <= c; i++ ) {
                if( a[1][i] == -1 ) f = 1;
                if( !f ) dp[1][i] = 1;
        }
        f = 0;
        for( int i = 1; i <= r; i++ ) {
                if( a[i][1] == -1 ) f = 1;
                if( !f ) dp[i][1] = 1;
        }
        for( int i = 2; i <= r; i++ ) {
                for( int j = 2; j <= c; j++ ) {
                        if( a[i][j] == -1 ) continue;
                        dp[i][j] += ( dp[i-1][j]%MOD + dp[i][j-1]%MOD )%MOD;
                        dp[i][j] %= MOD;
                }
        }
        cout << dp[r][c] <<endl;
        return 0;
}














Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int N;
	cin>>N;
	bool ans = true;
	for(int i=0;i<N;i++){
		ll k;
		scanf("%lld",&k);
		if(k&1)ans = false;
	}
	if(ans){
		cout << "second" << endl;
	}else{
		cout << "first" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
int main(int argc, char const *argv[])
{
	fast;
	string s, t;
	cin >> s;
	cin >> t;
	t.pop_back();
	if (s == t)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

int main(){
  int64_t N,K;
  cin>>N>>K;
  cout<<(N/K)*(N/K)*(N/K)+(1-K%2)*((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>
 
using namespace std;
 
typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;
 
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
 
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
 
#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )
 
#define fst first
#define snd second
 
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl
 
const double INF = DBL_MAX / 2;
 
int main()
{
    cin.tie( 0 );
    ios::sync_with_stdio( false );
 
    cout.precision( 3 );
    cout << fixed;
 
    while ( true )
    {
        int t, n, m, s, g;
        cin >> t >> n >> m >> s >> g;
 
        if ( !( t | n | m | s | g ) )
        {
            break;
        }
 
        s--;
        g--;
 
        VI tickets( t );
        FOR( tic, tickets )
        {
            cin >> tic;
        }
 
        VVI G( n, VI( n, -1 ) );
        REP( i, 0, m )
        {
            int a, b, d;
            cin >> a >> b >> d;
            a--;
            b--;
 
            G[a][b] = d;
            G[b][a] = d;
        }
        // 入力終わり
 
        vector< vector<double> > dp( n, vector<double>( 1 << t, INF ) );
        dp[s][0] = 0;
        REP( s, 0, 1 << t )
        {
            REP( i, 0, n )
            {
                REP( j, 0, n )
                {
                    if ( G[i][j] == -1 )
                    {
                        continue;
                    }
                    REP( k, 0, t )
                    {
                        if ( s & ( 1 << k ) )
                        {
                            continue;
                        }
                        double d = (double)G[i][j] / tickets[k];
                        dp[j][ s | ( 1 << k ) ] = min( dp[j][ s | ( 1 << k ) ], dp[i][s] + d );
                    }
                }
            }
        }
 
        double res = *min_element( ALL( dp[g] ) );
        if ( res == INF )
        {
            cout << "Impossible";
        }
        else
        {
            cout << res;
        }
        cout << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1364
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, m, issome = false;
    scanf("%d%d", &n, &m);
    vector<vector<int>> a(n, vector<int>(0));
    vector<int> b(n, 0), d;
    for(int i = 0, j, k; i < m; ++i)
    {
        scanf("%d%d", &j, &k);
        a[j - 1].push_back(k - 1);
        ++b[k - 1];
    }
    stack<int> c;
    for(int i = 0; i < n; ++i)
    {
        if(!b[i])
        {
            c.push(i);
        }
    }
    for(int i; !c.empty(); )
    {
        i = c.top();
        c.pop();
        d.push_back(i);
        for(int j = 0; j < a[i].size(); ++j)
        {
            if(!--b[a[i][j]])
            {
                c.push(a[i][j]);
            }
        }
    }
    for(int i = 0, nx = false; i < n - 1; ++i, nx = false)
    {
        printf("%d\n", d[i] + 1);
        for(int j = 0; j < a[d[i]].size(); ++j)
        {
            nx |= d[i + 1] == a[d[i]][j];
        }
        issome |= !nx;
    }
    printf("%d\n%d\n", d[n - 1] + 1, issome ? 1 : 0);
}



Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
typedef pair<int,int> P;
typedef pair<int,P> PP; 
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;}
const int MOD = 1e9+7;

signed main(){
  string s;
  cin>>s;
  int sum=0,ans=0;
  for(int i=0;i<sz(s);i++){
    if(s[i]=='A')sum++;
    else{
	 if(s[i]=='B'&&s[i+1]=='C'){
	   ans+=sum;
	   i++;
	 }else{
	   sum=0;
	 }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
import Data.Char (digitToInt)

main :: IO ()
main = do
  a <- getLine :: IO String 
  b <- getLine :: IO String
  putStr $ test a b 

test :: String -> String -> String
test as bs
  | as == bs = "EQUAL"
  | length as > length bs = "GREATER"
  | length as < length bs = "LESS"
  | otherwise = testEach as bs

testEach :: String -> String -> String
testEach (a:as) (b:bs)
  | digitToInt a > digitToInt b = "GREATER"
  | digitToInt a < digitToInt b = "LESS"
  | otherwise = testEach as bs



Measured memory_bytes: 508
N,M = map(int, input().split())
s = []
p = []
for i in range(M):
    _, *si = map(lambda x:int(x)-1, input().split())
    s.append(si)
c = list(map(int, input().split()))
# print(s)
ans = 0
for pattern in range(2**N):
    p = []
    for keta in range(N):
        if pattern & (1<<keta) > 0:
            p.append(1)
        else:
            p.append(0)
    # print("p:",p)

    for m in range(M):
        cnt = 0
        for si in s[m]:
            cnt += p[si]
        # print(m,cnt)
        if cnt%2 != c[m]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int xx=0,yy=0,tt=0;
    for (int i=1; i<=n; i++)
    {
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        if (abs(x-xx)+abs(y-yy)>t-tt||((abs(x-xx)+abs(y-yy))&1)!=((t-tt)&1)) 
        {
            puts("No");
            return 0;
        }
        xx=x; yy=y; tt=t;
    }
    puts("Yes");
    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int last_pos(const string& s,vector<tuple<char,char>>& qs,int p)
{
	for(auto q:qs){
		char t,d; tie(t,d)=q;
		if(p<0||s.size()<=p||s[p]!=t)
			continue;
		p=d=='L'?p-1:p+1;
	}
	return p;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,q;cin>>n>>q&&n|q;){
		string s; cin>>s;
		vector<tuple<char,char>> qs;
		rep(_,q){
			char t,d; cin>>t>>d;
			qs.emplace_back(t,d);
		}
		int l,r;
		{
			int lo=0,hi=n;
			while(lo<hi){
				int mi=(lo+hi)/2;
				if(last_pos(s,qs,mi)>=0)
					hi=mi;
				else
					lo=mi+1;
			}
			l=lo;
		}
		{
			int lo=0,hi=n;
			while(lo<hi){
				int mi=(lo+hi)/2;
				if(last_pos(s,qs,mi)==n)
					hi=mi;
				else
					lo=mi+1;
			}
			r=lo;
		}
		cout<<r-l<<endl;
	}
}


Measured memory_bytes: 1100
N = int(input())
A_list = []
XY_list = []
for i in range(N):
    a = int(input())
    xy = [list(map(int, input().split())) for i in range(a)]
    A_list.append(a)
    XY_list.append(xy)

result = 0

for i in range(2 ** N):
    bit = str(format(i, 'b')).zfill(N)
    flag = 0
    for j in range(N):
        if bit[j] == '1':
            for k in range(A_list[j]):
                man = XY_list[j][k][0]
                judge = XY_list[j][k][1]
                if int(bit[man - 1]) != judge:
                    flag = 1
                    break
        if flag == 1:
            break
    if flag == 0:
        tmp = 0
        for j in range(N):
            tmp += int(bit[j])
        if tmp > result:
            result = tmp
print(result)

Measured memory_bytes: 3064
#include <iostream>

int main(){
    int n, a, b;
    long long c = 0;
    std::cin >> n >> a >> b;
    for(int i = 1; i <= n; i++){
        int t1 = i;
        int t2 = 0;
        for(int j = 0; j < 5; j++){
            t2 += t1 % 10;
            t1 /= 10;
        }
        if(t2 >= a && t2 <= b){
            c+=i;
        }
    }
    std::cout << c << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"class Factorial:\n"
"    def __init__(self,n,mod):\n"
"        self.f=[1]\n"
"        for i in range(1,n+1):\n"
"            self.f.append(self.f[-1]*i%mod)\n"
"        self.i=[pow(self.f[-1],mod-2,mod)]\n"
"        for i in range(1,n+1)[::-1]:\n"
"            self.i.append(self.i[-1]*i%mod)\n"
"        self.i.reverse()\n"
"    def factorial(self,i):\n"
"        return self.f[i]\n"
"    def ifactorial(self,i):\n"
"        return self.i[i]\n"
"    def comb(self,n,k):\n"
"        return self.f[n]*self.i[n-k]%mod*self.i[k]%mod\n"
"mod=10**9+7\n"
"h,w,a,b=map(int,input().split())\n"
"f=Factorial(h+w,mod)\n"
"ans=0\n"
"for i in range(b,w):\n"
"    ans=(ans+f.comb(h-a-1+i,i)*f.comb(a-1+w-i-1,w-i-1))%mod\n"
"print(ans)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 19248
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str;
        str = sc.next();
        char[] c = str.toCharArray();
        char[] x1 = {c[0],c[1]};
        char[] x2 = {c[2],c[3]};
        boolean b1 = check(Integer.parseInt(new String( x1)));
        boolean b2 = check(Integer.parseInt(new String( x2)));
        
        String ans = "";
        
        if(b1 && b2){
            ans = "AMBIGUOUS";
        }else if(b1){
            ans = "MMYY";
        }else if(b2){
            ans = "YYMM";
        }else{
            ans = "NA";
        }
        System.out.println(ans);
        
        
    }
   static boolean check(int i){
        if(i > 0 && i < 13){
            return true;
        }
        return false;
    }
}

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

int main(){
    int M,D;
    cin >>M>>D;
    
    if(M<4){
        cout << 0 << endl;
        return 0;
    }
    
    
    int ans=0;
    
    for(int i=22; i<=D; i++){
        if(i%10<2)continue;
        
        if((i%10)*(i/10) <= M)ans++;
        
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

from itertools import permutations

Z = [i for i in range(1,N+1)]

M = tuple(permutations(Z,N))

a = M.index(P)
b = M.index(Q)

print(abs(a-b))

Measured memory_bytes: 7988
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n, ans = 0;
  std::string s;
  std::cin >> n >> s;


  std::set<char> x,y;
  rep(i,n) {
    int maxi = 0;
    for (int j = 0; j <= i; j++) {
      x.insert(s[j]);
    }
    for (int k = i+1; k < n; k++) {
      y.insert(s[k]);
    }
    for (char j = 'a'; j <= 'z'; j++) {
      if(x.count(j) && y.count(j))
        maxi++;
    }
    if(maxi > ans)
      ans = maxi;
    x.clear();
    y.clear();
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 10**18
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
from collections import deque
import math
from functools import reduce
from collections import defaultdict
MOD = 998244353


def li():
    return [int(x) for x in input().split()]

N, K = li()

L, R = [], []
for _ in range(K):
    l, r = li()
    L.append(l)
    R.append(r)

# dp[i]: i番目のマスにいく場合の数
dp = [0] * (N+1)
dp[1] = 1
# 区間 [left, right)の和はdpsum[right] - dpsum[left]
# 区間 [left, right]の和はdpsum[right+1] - dpsum[left]
# マス a~bは区間だと[a-1,b-1]に対応。よってマスliからriの和はdpsum[right] - dpsum[left - 1]
dpsum = [0] * (N+1)
dpsum[1] = 1
for i in range(2, N+1):
    for j in range(K):
        li = max(i - R[j], 1)
        ri = i - L[j]
        if ri >= 0:
            dp[i] += dpsum[ri] - dpsum[li-1]
            dp[i] %= MOD
    dpsum[i] = dpsum[i-1] + dp[i]
    dpsum[i] %= MOD

print(dp[N])


Measured memory_bytes: 77812
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

    int A, B, C;

    cin >> A >> B >> C;

    cout << min(C, B/A) << endl;

    return 0;
}


Measured memory_bytes: 256
object Main extends App {

  val n = scala.io.StdIn.readInt()
  val b = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  def solve(): Int = {
    val a = Array.fill(n)(0)
    for(i <- 0 until n) {
      if(i == 0) a(i) = b(i)
      else if(i < n-1) {
        a(i) = Math.min(b(i), b(i-1))
      } else {
        a(i) = b(i-1)
      }
    }
    a.sum
  }
  println(solve)
}


Measured memory_bytes: 27088
#include <iostream>
#include <string>
#include <map>
using namespace std;
bool contain(string&, char&);

int main() {
  map<char, string> loads;
  loads['A'] = "BD";
  loads['B'] = "AEC";
  loads['C'] = "BF";
  loads['D'] = "AEG";
  loads['E'] = "BDFH";
  loads['F'] = "CEI";
  loads['G'] = "DH";
  loads['H'] = "GEI";
  loads['I'] = "FH";
  int j;
  for(j = 0; j < 1000; ++j) {
    string key;
    cin >> key;
    bool ok = true;
    for(int i = 0; i < key.length() - 1; ++i) {
      if(!contain(loads[key[i]], key[i + 1])) {
        ok = false;
        break;
      }
    }
    if(ok) cout << key << endl;
  }
  return 0;
}



bool contain(string& a, char& b) {
  string::size_type pos = a.find(b);
  return !(pos == string::npos);
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int x = in.ni(), y = in.ni();
        if((4*x-y)%2==0&&(y-2*x)%2==0&&y-2*x>=0&&4*x-y>=0)out.println("Yes");
        else out.println("No");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

map<int, int> m;
void p(int n) {
  int size = n;
  for(int i=2;i*i <= size;i++) {
    while(n%i == 0) {
      n /= i;
      m[i]++;
    }
  }
  if(n > 1) m[n]++;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  FOR(i, 1, n+1) p(i);

  int ans = 0;

  MFOR(i, m) {
    ans += i->second >= 74;
    MFOR(j, m) {
      if(i->first == j->first) continue;
      ans += (i->second >= 24 && j->second >= 2);
      ans += (i->second >= 14 && j->second >= 4);
      MFOR(k, m) {
        if(i->first == k->first || j->first == k->first) continue;
        if(j->first >= k->first) continue;
        ans += (i->second >= 2 && j->second >= 4 && k->second >= 4);
      }
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
//  Created by liszt on 2019/07/27.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> a(n+1),b(n);
    
    for(int i=0;i<n+1;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    
    long long sum=0;
    for(int i=0;i<n;i++){
        if(b[i]<=a[i]){
            sum+=b[i];
            a[i]-=b[i];
        }else{
            sum+=a[i];
            b[i]-=a[i];
            sum+=min(a[i+1],b[i]);
            a[i+1]=max(0,a[i+1]-b[i]);
        }
    }
    
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
	long long a,b,c,ans;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)
	printf("0\n");
	else
	{
		if(a>b&&a>c)
		ans=b*c;
		else if(b>a&&b>c)
		ans=a*c;
		else ans=a*b;
		cout<<ans;
	}
	return 0;
}

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

int f(unsigned int a, unsigned int b) {
    unsigned int x = a & b;

    int ans = 0;

    for (int i = 0; i < 26; i++) {
        ans += (x & (1 << i) ? 1 : 0);
    }

    return ans;
}

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

    unsigned int x[n] = {};
    unsigned int y[n] = {};

    for (int i = 0; i < n - 1; i++) {
        x[i] |= (1 << (s[i] - 'a'));
        x[i] |= (i > 0 ? x[i - 1] : 0);
    }

    for (int i = n - 2; i >= 0; i--) {
        y[i] |= (1 << (s[i + 1] - 'a'));
        y[i] |= (i < n - 2 ? y[i + 1] : 0);
    }

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans = max(ans, f(x[i], y[i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,i,a,ct,max;
    int count(int x);
    while(~scanf("%d",&n))
    {
        max=n;
        a=count(n);
        for(i=n-1;i>0;i--)
        {
            ct=count(i);
            if(a<ct)
            {
                a=ct;
                max=i;
            }
        }
        printf("%d\n",max);
    }
    return 0;
}


int count(int x)
{
    int a=0;
    while(x%2==0)
    {
        a++;
        x=x/2;
    }
    return a;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define INF 1000000007
#define MOD 1000000007
#define BINF 1000000000000000001
#define int long long int
#define double long double

using namespace std;

int dp[20005][4];
int arr[4];
int cost[4];

int go(int n,int m)
{
    if(n==0)
     return 1;
    else if(n>0 and m==0)
     return 0;
    else if(dp[n][m]>=0)
     return dp[n][m];
    else
    {
        int ans=0;
        loop(i,0,arr[m]+1)
        {
            int c=cost[m]*i;
            if(c<=n)
             ans+=go(n-c,m-1);
        }
        dp[n][m]=ans;
        return dp[n][m];
    }
    
}

#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,c,x;
    
    cin>>a>>b>>c>>x;
    
    arr[1]=a;
    arr[2]=b;
    arr[3]=c;
    cost[1]=500;
    cost[2]=100;
    cost[3]=50;
    
    loop(i,0,x+1)
    {
        loop(j,0,4)
         dp[i][j]=-1;
    }
    int ans=go(x,3);
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
	
ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}
int main()
{
	int a, b;
	cin >> a >> b;
	if(a==b or b==1 or a%b==0){
		cout<<-1<<endl;
	}else{
		bool ans=true;
		int i=1;
		while(ans){
			ll tmp=a*i;
			if(tmp%a==0&&tmp%b!=0){
				ans=false;
				cout<<tmp<<endl;
			}
			i++;
		}
	}
}

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

int main(){
 
 while(1){

    int N,M;
    int po[21][21]={};

    cin>>N;
    if(N==0) break;
    int p,q;

    for(int i=0;i<N;i++){
      cin>>p>>q;
      po[p][q]=1;
    }

    cin>>M;

    char d;
    int j;
    int x2=10,y2=10;
    int f=0;

    for(int i=0;i<M;i++){
      cin>>d>>j;
      for(int s=0;s<j;s++){
	if(d=='N') y2+=1;
	else if(d=='E') x2+=1;
	else if(d=='S') y2-=1;
	else x2-=1;
	if(po[x2][y2]==1){
	  f++;
	  po[x2][y2]=0;
	}
      }
    }

    if(f==N) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
#define mod 1000000007
int main()
{	
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int w=1;
	// cin>>w;
	while(w--){
		int n;
		cin>>n;
		vi v(n);
		F(i,0,n){
			cin>>v[i];
		}
		vi dp(n);
		dp[0]=0;
		dp[1]=abs(v[0]-v[1]);
		F(i,2,n){
			dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
		}
		cout<<dp[n-1];
	}
}

Measured memory_bytes: 3980
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S, T := sc.nextStr(), sc.nextStr()
	sLen, tLen := len(S), len(T)
	dp := make([][]int, sLen+1)
	for i := 0; i <= sLen; i++ {
		dp[i] = make([]int, tLen+1)
	}
	for i := 1; i <= sLen; i++ {
		for j := 1; j <= tLen; j++ {
			if S[i-1] == T[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				if dp[i-1][j] < dp[i][j-1] {
					dp[i][j] = dp[i][j-1]
				} else {
					dp[i][j] = dp[i-1][j]
				}
			}
		}
	}

	ans := ""
	s, t := sLen, tLen
	for s > 0 && t > 0 {
		if dp[s][t] == dp[s][t-1] {
			t--
		} else if dp[s][t] == dp[s-1][t] {
			s--
		} else {
			ans = string(S[s-1]) + ans
			s--
			t--
		}
	}
	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 80512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}

template <class T>
inline void show(T a) {
    cout << a << endl;
}

typedef struct{
    ll x;
    ll y;
}idx;


//------------------------main function-------------------------------
void Main(){
    int a,b,c,d;
    cin >> a >> b;
    cin >> c >> d;
    if(b < d){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int x = sc.nextInt();
        final int y = sc.nextInt();

        for (int a = 0; a <= 100; a++) {
            for (int b = 0; b <= 100; b++) {
                if (a+b == x && 2*a + 4 * b == y) {
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}


Measured memory_bytes: 35704
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c;
    long long n;
    cin >> a >> b >> c >> n;
    long long ans=0;
    
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if((n-(i*a+j*b))<0)break;
            if((n-(i*a+j*b))%c==0)ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
ll N, A, B;
ll comb[51][51]; // comb[i][j] = i個からj個を取る場合の数
void comInit()
{
    comb[0][0] = comb[1][0] = comb[1][1] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A >> B;
    vector<double> v(N);
    rep(i, N) { cin >> v[i]; }
    sort(v.begin(), v.end(), greater<double>());
    comInit();

    double ave = accumulate(v.begin(), v.begin() + A, 0.0) / (double)A;

    ll res = 0;
    int x = 0, y = 0;
    if (v[0] != v[A - 1]) {
        rep(i, N) {
            if (v[A-1] == v[i]) {
                ++x; // 全体の中でv[A-]となる値
            }
        }
        rep(i, A) {
            if (v[A-1] == v[i]) {
                ++y; // Aまででv[A-]となる値
            }
        }
        res = comb[x][y]; // 全体でx個あるv[A-1]のうちy個を使う
    } else { // 少なくともA個は最大値がある
        rep(i, N) {
            if (v[i] == v[0]) {
                ++x; // 全体の中でv[0]となる値
            }
        }
        for (int i = A; i <= B; ++i) {
            res += comb[x][i]; // x < iとなったら0になるのでおk
        }
    }
    cout << fixed << setprecision(20)<< ave << endl;
    cout << res << endl;
    return 0;
}

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

int N;
int A[210];

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

    int res = 0;

    while (true){
        bool exist_odd = false;
        for (int i =0; i < N; ++i){
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i =0; i < N; ++i){
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main ()
  { 
  string s;
  cin>>s;
  int x=s.size();
  set<char>sad;
  for(int i=0;i<x;i++)
    { 
     sad.insert(s[i]);
    }
  if(x==sad.size())
    { 
    cout<<"yes"<<endl;
    }
  else { cout<<"no"<<endl;
        }
  }

Measured memory_bytes: 256
n = int(input())
arr = [int(x) for x in input().split()]
ans = []
xor = 0
for i, x in enumerate(arr):
    xor = xor ^ x
for i, x in enumerate(arr):
    temp = xor ^ x

    ans.append(temp)
for x in ans:
    print(x, end=" ")


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

int main(){
  long K, A, B;
  cin >> K >> A >> B;
  if(A>=B ||  B==A+1){
    cout << 1+K << endl;
    return 0;
  }
  if((K-A+1)%2==0){
    cout << A+((K-A+1)/2)*(B-A) << endl;
    return 0;
  }
  cout << A+((K-A)/2)*(B-A)+1 << endl;
  return 0;
}

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

using namespace std;

int main() {
  long long N, K;
  cin >> N >> K;
  long long ans = 0;
  for (int i = K + 1; i <= N; i++) {
    long long ci = K == 0 ? 0 : N / i * K + min(N % i, K - 1);
    ans += N - ci;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    int n, a, b;
    while(cin>>n>>a>>b){
        int mx, mn;
        mx=min(a, b);
        mn=max(0, a+b-n);
        cout<<mx<<" "<<mn<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
//
//  atcoder1.c
//  prg1
//
//  Created by k20043kk on 2020/07/25.
//

#include <stdio.h>
int main(){
    int a[3];
    int k;
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    scanf("%d",&k);
    int min,minn;
    for(int i=0;i<k;i++){
        min=a[0];
        minn=0;

        for(int j=0;j<3;j++){
           
            if(min>=a[j]){
                //printf("%d\n",min);
                min=a[j];
                minn=j;
            }
            
        }
        //printf("%d %d %d\n",a[0],a[1],a[2]);
        if(minn==2){
            a[2]=a[2]*2;
        }else if(minn==1){
            a[1]=a[1]*2;
        }if(minn==0){
            a[2]=a[2]*2;
        }
    }
    //printf("%d %d %d\n",a[0],a[1],a[2]);
    if(a[0] < a[1] && a[1]<a[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 1644