akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll l, r;
  cin >> l >> r;

  const ll mod = 2019;

  ll ans = INF;
  ll ir = min(r, l + mod - 1);
  FOR(i, l, ir) {
    ll jr = min(r, i + mod);
    FOR(j, i + 1, jr) {
      ans = min(((i % mod) * (j % mod)) % mod, ans);
      // ans = min((i * j) % mod, ans);
    }
  }
  COUT(ans);

}

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

/*
5 2
3 1 2 5
2 2 3
1 0
*/


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

#define ll long long
#define ld long double
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update > ost;
// name.find_by_order( x ) or name.order_of_key( x )

const int maxn = 3e3 + 10, maxv = 2e5 + 10, maxlog = 20;
const int inf = 1e9 + 1;
const int MOD = 1e9 + 7;
const ll INF = 4e18 + 1;
const double eps = 1e-9;

void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }

int n, m, k;
ll cost[ maxn ][ maxn ];
ll dp[ maxn ][ maxn ][ 4 ];

ll rek( int x, int y, int kol ) {
	if ( x == n - 1 && y == m - 1 ) {
		return 0;
	}
	if ( dp[ x ][ y ][ kol ] != -1 ) return dp[ x ][ y ][ kol ];
	
	//cout << x << ' ' << y << ' ' << kol << "\n";
	
	ll ret = 0;
	if ( y + 1 < m && cost[ x ][ y + 1 ] && kol ) ret = max( ret, rek( x, y + 1, kol - 1 ) + cost[ x ][ y + 1 ] );
	if ( y + 1 < m ) ret = max( ret, rek( x, y + 1, kol ) );
	if ( x + 1 < n ) ret = max( ret, rek( x + 1, y, 3 ) );
	if ( x + 1 < n && cost[ x + 1 ][ y ] ) ret = max( ret, rek( x + 1, y, 2 ) + cost[ x + 1 ][ y ] );
	
	return dp[ x ][ y ][ kol ] = ret;
}

void solve() {
	cin >> n >> m >> k;
	for( int i = 0;i < k;i++ ) {
		int x, y;
		ll c;
		cin >> x >> y >> c;
		x--;y--;
		cost[ x ][ y ] = c;
	}
	
	memset( dp, -1, sizeof dp );
	ll ans = rek( 0, 0, 3 );
	if ( cost[ 0 ][ 0 ] ) ans = max( ans, rek( 0, 0, 2 ) + cost[ 0 ][ 0 ] );
	cout << ans << "\n";
}

int main() {
	int t = 1;
	//cin >> t;
	while ( t-- ) solve();
	return 0;
}


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

map< int, int > prime_factor(ll n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  int x;
  cin >> x;
  while(1){
    if(prime_factor(x).size()==1){
      bool ok = 1;
      for(auto p:prime_factor(x)){
        if(p.second!=1)ok=0;
      }
      if(ok){
        cout << x << endl;
        return 0;
      }else x++;
    }
    else x++;
  }
  return 0;
}


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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define pi 3.1415926536
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

pair<int, int> p[100005];

ll XOR(ll x)
{
    switch (x % 4)
    {
    case 0:
        return x;
    case 1:
        return 1;
    case 2:
        return x + 1;
    case 3:
        return 0;
    }
}

int main()
{
    ll n, m;
    cin >> n >> m;
    n -= 1;
    ll ans = (XOR(m) ^ XOR(n));
    cout << ans << endl;
    return 0;
}

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

int main(void){
	int i,n;
	long long sum=0;

	cin>>n;

	for(i=1;i<=n;i++){
			sum+= (i%3 && i%5) ? i : 0;
	}

	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long s;
    cin >> s;
    
    long long sum = 0;
    long long n = 10;
    long long d = 1;
    long long p = 0;
    
    while (n < s) {
        d++;
        n *= 10;
    }
    n = 1L << (d - 1);
    
    while (p < n) {
        long long _s = s;
        long long _d = 10;
        
        for (int i = 0; i < d; i++) {
            if ((p&(1<<i)) == 0) {
                _d *= 10;
            } else {
                sum += (_s%_d);
                _s /= _d;
                _d = 10;
            }
        }
        sum += _s;
        
        p++;
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 256
def abc069_c():
    n = int(input())
    a = list(map(int, input().split()))
    two = 0
    four = 0
    odd = 0
    for v in a:
        if v % 2 == 0:
            if v % 4 == 0:
                four += 1
            else:
                two += 1
        else:
            odd += 1

    if four >= odd or (four + odd == n and odd - four == 1):
        print("Yes")
    else:
        print("No")


abc069_c()

Measured memory_bytes: 15020
def main():
    H,W = map(int,input().split())
    S = list()
    INF = 10**18
    S.append([-INF]*(W+2))
    for i in range(H):
        line = list(input())
        for j,c in enumerate(line):
            if c == '.':
                line[j] = 0
            else:
                line[j] = -INF

        S.append([-INF]+line+[-INF])
    S.append([-INF]*(W+2))
    for i in range(1,H+1):
        for j in range(1,W+1):
            if S[i][j] < 0:
                S[i-1][j-1] += 1
                S[i-1][j] += 1
                S[i-1][j+1] += 1
                S[i][j-1] += 1
                S[i][j+1] += 1
                S[i+1][j-1] += 1
                S[i+1][j] += 1
                S[i+1][j+1] += 1
    
    out = ''
    for i in range(1,H+1):
        for j in range(1,W+1):       
            out += '#' if S[i][j] < 0 else str(S[i][j])
        out += '\n'
    print(out)
                
main()

Measured memory_bytes: 73576
def main():
  s, k = input(), int(input())
  
  count_1 = 0
  tmp = ''
  for l in s:
    if l == '1':
      count_1 += 1
    else:
      tmp = l
      break
  if count_1 < k:
    ans = tmp
  else:
    ans = 1
    
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
from collections import defaultdict as ddict
tot = 10**12
n,c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
clr = [list(map(int, input().split())) for _ in range(n)]
l = [ddict(int) for _ in range(3)]
for y in range(n):
  for x in range(n):
    l[(x+y)%3][clr[y][x]] += 1
for c1 in range(c):
  for c2 in range(c):
    if c1 == c2:
      continue
    for c3 in range(c):
      if c1==c3 or c2==c3:
        continue
      ctot = 0
      cl = [c1,c2,c3]
      for i in range(3):
        for x in l[i]:
          ctot += d[x-1][cl[i]]*l[i][x]
      if tot > ctot:
        tot = ctot
print(tot)

Measured memory_bytes: 5876
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

template <typename T>

void testVector(T& v) {
  REP(i, SZ(v)) {
    cout << i << ":" << v << endl;
  }
}


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */

string S;
int ans = 700;

/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

  cin >> S;
  REP(i, 3) {
    if (S[i] == 'o') ans += 100;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [0]*n
p = [0]*n
l = [[] for i in range(n)]

for i in range(n):
    s[i],p[i] = input().split()
    l[i] = [s[i],int(p[i]),i+1]

l.sort(key=lambda x:x[1],reverse = True)
l.sort(key=lambda x:x[0])

for i in l:
    print(i[2])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    ll N = 0;
    cin >> N;
    vector<ll > A(N);
    vector<ll > B(N);
    vector<ll > C(N - 1);

    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    for(ll i = 0; i < N; i++){
        cin >> B[i];
    }
    for(ll i = 0; i < N-1; i++){
        cin >> C[i];
    }

    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ans += B[A[i]-1];
        if(A[i] == A[i+1] - 1){
            ans += C[A[i] - 1];
        }
    }

    cout << ans << endl;


} 

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

int main(){
	int mayors[50]{0};

	for(;;){
		int n, p;
		cin >> n >> p;
		if (n == 0) break;

		for (int i = 0; i < n; i++) mayors[i] = 0;
		int bowlp = p;
		int turn = 0;
		for(;;){
			if (bowlp == 1 && mayors[turn] == p - 1) break;
			else if (bowlp == 0){
				bowlp += mayors[turn];
				mayors[turn] = 0;
			}
			else{
				mayors[turn]++;
				bowlp--;
			}

			if (turn == n - 1) turn = 0;
			else turn++;
		}
		cout << turn << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	int flag1=0,flag2=0;
	if(a==5)
		flag1++;
	else if(a==7)
		flag2++;
	if(b==5)
		flag1++;
	else if(b==7)
		flag2++;
	if(c==5)
		flag1++;
	else if(c==7)
		flag2++;
	if(flag1==2&&flag2==1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;
  return gcd(b,a%b);
}

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

  ll n,a,b;
  std::cin>>n>>a>>b;

  ll ans=0;

  ans+=(n/(a+b))*a;

  if(n%(a+b)>a)ans+=a;
  else ans+=n%(a+b);

  std::cout<<ans<<"\n";

  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,r)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define eb emplace_back
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
#define priend(a) {cout<<(a)<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  string s1,s2,s3; cin>>s1>>s2>>s3;
  cout<<char(s1[0]-32)<<char(s2[0]-32)<<char(s3[0]-32)<<'\n';
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
bool hasThree( int n ) {
    if (n == 0)
        return false;
    if (n % 10 == 3)
        return true;
    return hasThree( n / 10 );
}
 
   
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0)
            cout << ' ' << i;
        else if (hasThree( i ))
            cout << ' ' << i;
    }
    cout << endl;
}

Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<llll> vllll;
typedef vector<int> vi;
typedef vector<ull> vull;

// TIMER
std::clock_t __start;
double __duration;
void start_timer() { __start = std::clock(); }
void print_timer() {
	__duration = (std::clock() - __start) / (double)CLOCKS_PER_SEC;
	std::cout << "Duration (msec): " << __duration * 1000 << '\n';
}
// END TIMER

//PI
// fast input
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
//char _;

template <class T>
T min_(T a, T b) { return (a < b ? a : b); }
template <class T>
T max_(T a, T b) { return (a > b ? a : b); }
double EPS = 1e-9;
bool eq_(const double& lhs, const double &rhs) {
	return (fabs(lhs - rhs) < EPS);
}

const int INF = int(2e9);
const ll INF_LL = LLONG_MAX;


bool is_set(int num, int bit) {
	return (num & (1 << bit)) != 0;
}

void split(string st, vector<ll>& summands) {
	string curr = "";
	for (int i = 0; i < st.size(); ++i) {
		if (st[i] != '+')
			curr.push_back(st[i]);
		else {
			stringstream ss(curr);
			ll num;
			ss >> num;
			summands.push_back(num);
			curr = "";
		}
	}
	if (!curr.empty()) {
		stringstream ss(curr);
		ll num;
		ss >> num;
		summands.push_back(num);
	}
}

ll eval(string st) {
	vector<ll> summands;
	split(st, summands);
	ll res = 0;
	for (ll num : summands) 
		res += num;
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string st;
	cin >> st;
	ll res = 0;
	int places = st.size() - 1;
	int ways = pow(2, places);
	for (int i = 0; i < ways; ++i) {
		string curr = st;
		int inserted = 0;
		for (int bit = 0; bit < places; ++bit) {
			if (is_set(i, bit)) {
				curr.insert(curr.begin() + 1 + bit + inserted, '+');
				inserted++;
			}
		}
		res += eval(curr);
	}
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
 
ll R, G;
 
int main(void) {
  cin >> R >> G;
  cout << G * 2 - R << endl;
}

Measured memory_bytes: 256
N,A,B = map(int, input().split())
V = [int(v) for v in input().split()]

V.sort(reverse=True)
s = 0
for i in range(A):
    s += V[i]
    idx = i
    
av = s/A
for i in range(A, B):
    if V[i] < av:
        break
    s += V[i]
    av = s/(i+1)
    idx = i
    
cnt_up = 0
cnt_same = 0
for i in range(N):
    if V[i] > V[idx]:
        cnt_up += 1
    elif V[i] == V[idx]:
        cnt_same += 1
        
print(av)

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


if cnt_up > 0:
    ans = cmb(cnt_same, A-cnt_up)
else:
    ans = 0
    for i in range(A, B+1):
        if cnt_same < i:
            break
        ans += cmb(cnt_same, i)
        
print(ans)

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

int main()
{
	char b; cin >> b;

	if (b == 'A')      b = 'T';
	else if (b == 'T') b = 'A';
	else if (b == 'C') b = 'G';
	else               b = 'C';
	
	cout << b << endl;

	return 0;
}

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

int main() {
    int N,A,B;
    string S;

    cin >> N >> A >> B;
    cin >> S;

    int acnt = 0;
    int bcnt = 0;
    int tsuuka = A + B;

    for (int i=0; i<N; i++){
        if (S.at(i) == 'c'){
            cout << "No" << endl;
        }

        if (S.at(i) == 'a'){
            if (acnt + bcnt < tsuuka){
                cout << "Yes" << endl;
                acnt++;
            }
            else
            {
                cout << "No" << endl;
            }
            
        }

        if (S.at(i) == 'b'){
            if (acnt + bcnt < tsuuka && bcnt < B){
                cout << "Yes" << endl;
                bcnt++;
            }
            else{
                cout << "No" << endl;
            }
        }

    }

}


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

int main() {
  string S,T;
  cin>>S>>T;
  int sai=T.size();
  for(int i=0;i<S.size()-T.size()+1;i++){
    int ksai=T.size();
    for(int j=i;j<i+T.size();j++){
      if(T.at(j-i)==S.at(j)) ksai--;
    }
    sai=min(sai,ksai);
  }
  cout<<sai<<endl;
    
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {FIN

	ll n, w, i, j;
	cin >> n >> w;
	vvll dp(n + 1, vll(w + 1));
	vll ws(n), vs(n);

	for (i = 0; i < n; i++)
		cin >> ws[i] >> vs[i];

	for (i = 1; i <= n; i++) {
		for (j = 1; j <= w; j++) {
			dp[i][j] = dp[i - 1][j];
			if (ws[i - 1] <= j)
				dp[i][j] = max(dp[i][j], vs[i - 1] + dp[i - 1][j - ws[i - 1]]);
		}
	}

	cout << dp[n][w] << "\n";

	return 0;
}

Measured memory_bytes: 83108
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
ll a[maxn]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	cout<<a[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <stdint.h>

int64_t qs[100001];
std::map<int64_t,int64_t> map;

int64_t sum[100001];

int main(){
  int64_t N,Q;
  scanf("%ld %ld",&qs[0],&Q);
  for(int64_t i=1;i<=Q;i++){
    scanf("%ld",&qs[i]);
  }
  map[qs[Q]]=1;
  for(int64_t i=Q;i>=0;i--){
    int64_t Q=qs[i];
    while(map.rbegin()->first>Q){
      int64_t x=map.rbegin()->first;
      int64_t cnt=map.rbegin()->second;
      map.erase(map.rbegin()->first);
      map[x%Q]+=cnt;
      map[Q]+=cnt*(x/Q);
    }
  }
  for(auto it:map){
    sum[it.first]=it.second;
  }
  for(int64_t i=qs[0];i>0;i--){
    sum[i-1]+=sum[i];
  }
  for(int64_t i=1;i<=qs[0];i++){
    printf("%ld\n",sum[i]);
  }
  return 0;
}


Measured memory_bytes: 9344
/******* VIVEK PAl *******/
/*************************/
#include <bits/stdc++.h>
#define prime 1000000007
#define mod 998244353
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
/****** END OF HEADER ******/
/***************************/
int maxN=2e+3 + 8;
void solve()
{
    string str; cin>>str;
    if(str[2]==str[3] && str[4]==str[5]) printf("Yes\n");
    else printf("No\n");
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T=1, t; 
  //cin>>T;
  t = T;
  while(T--)
  {
      //printf("Case #%d: ", t-T);
      solve();
  }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    string str = "";
    while (N != 0) {
        /* N を 2 で割ったあまりを求める */
        int r = N % 2;
        if (r < 0) r += 2; // N がマイナスだと r がマイナスになったりするので 2 を足す

        /* N から余りを取り除いて -2 で割る */
        N = (N - r) / (-2);

        /* 答えに追加 */
        str += (char) ('0' + r);
    }
    /* 向きが逆なので反転 */
    reverse(str.begin(), str.end());
    if (str == "") str = "0"; // N = 0 のときは空文字列になってしまうので例外処理
    cout << str << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a[10];
    rep(0,i,9)cin>>a[i+1];
    ll n;
    cin>>n;
    bool T[10];
    rep(0,i,9)T[i+1]=false;
    rep(0,i,n){
        ll b;
        cin>>b;
        rep(0,j,9)if(a[j+1]==b)T[j+1]=true;
    }
    //rep(0,i,9)cout<<T[i+1]<<endl;
    bool ans=(T[1]&&T[2]&&T[3])||(T[4]&&T[5]&&T[6])||(T[7]&&T[8]&&T[9])||(T[1]&&T[4]&&T[7])||(T[2]&&T[5]&&T[8])||(T[3]&&T[6]&&T[9])||(T[1]&&T[5]&&T[9])||(T[3]&&T[5]&&T[7]);
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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() {
    ll N, H;
    cin >> N;
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }

    rep(i, 1, N) {
        if (a[i-1] > a[i]) {
            cout << "No" << endl;
            return 0;
        } else {
            if (a[i] != a[i-1]) {
                --a[i];
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;
#define int long long
typedef long double db;
const db eps = 1e-8;
int N,L;

int T[500005],V[500005];
int vv[500005];db tt[500005];
int ql,qr;
char buf[1<<20],*p1,*p2;
#define GC (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
inline int R()
{
	char t=GC;
	int x=0;
	while(!isdigit(t)) t=GC;
	while(isdigit(t)) x=x*10+t-48,t=GC;
	return x;
}
main() {
	N = R(); L = R();
	for(int i=1;i<=N;i++) {
		T[i] = R(); V[i] = R();
	}
	printf("%lld\n",T[1]);
	ql = qr = 1;
	vv[1] = V[1];
	tt[1] = T[1];
	db ANS = 1.0l * V[1] * T[1];
	for(int i=2;i<=N;i++) {
		int VO = L + V[i];
		while(VO>L) {
			int yo = min(vv[ql],VO-L);
			ANS -= tt[ql] * yo;
			vv[ql] -= yo;
			VO -= yo;
			if(vv[ql]==0) ql++;
		}
		ANS += 1.0l * V[i] * T[i];
		printf("%.8Lf\n",1.0l*ANS/(db)L);
		if(T[i]-tt[qr]<eps) {
			db to = T[i]; db vo = V[i];
			while(ql<=qr&&to-tt[qr]<eps) {
				to = (1.0l*to*vo+tt[qr]*vv[qr])/(vv[qr]+vo);
				vo += vv[qr];
				qr--;
			}
			++qr;
			vv[qr] = vo;
			tt[qr] = to;
		} else {
			++qr;
			vv[qr] = V[i];
			tt[qr] = T[i];
		}
	}
}

Measured memory_bytes: 30080
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k;
string s;
vector<lo> v;

inline lo solve(){
	scanf("%lld %lld",&n,&m);
	if(abs(n-m)<2){printf("Brown\n");return 0;}
	printf("Alice\n");
	return 0;
}

int main(void){
	solve();
	
	return 0;
}


Measured memory_bytes: 256
<>=~$";$G=$';map{$i+=100;for$k(reverse@a=/ /..1e3){$p[$k]+=$-=$_>$k?0:$p[$k-$_]+$i*$_+($_==$`&&$')-$p[$k]for 1..$`}}<>;printf grep$p[$_]>=$G,@a

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

bool visited[100005];
ll value[100005];
vector < pair<int,ll> > vec[100005];

void dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < vec[v].size() ; i++) {
        if (visited[vec[v][i].first] == false) {
            value[vec[v][i].first] = vec[v][i].second + value[v];
            dfs(vec[v][i].first);
        }
    }
}

int main() {
    int n, a, b, q, k, x, y;
    ll c;

    cin >> n;
    fill(visited, visited+n, false);

    for (int i = 0; i < n-1; i++) {
        cin >> a >> b >> c;
        vec[a].push_back(make_pair(b, c));
        vec[b].push_back(make_pair(a, c));
    }

    cin >> q >> k;
    value[k] = 0;
    dfs(k);

    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        cout << value[x] + value[y] << endl;
    }

    return 0;
}

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

int main() {
    double money = 100;
    int result;
    int n;
    
    cin >> n;
    for(int i = 0; i < n; i++) {
        money *= 1.05;
        money = ceil(money);
    }
    result = int(money * 1000);
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int x, flag = 1;
  cin >> s;
  x = s.length();
  for (int i = 0; i < x; i+=2)
  {
    if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
      continue;
    else
    {
      flag = 0;
      break;
    }
  }
  for (int i = 1; i < x; i+=2)
  {
    if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
      continue;
    else
    {
      flag = 0;
      break;
    }
  }
  if (flag == 1)
    cout <<"Yes"<<endl;
  else
    cout << "No"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int s[111][111];
int main(void){
  int a,k;
  for(k = 0; cin >> a; k++){
    s[k][0] = a;
    for(int i = 1; getchar()==','; i++){
      cin >> s[k][i];
    }
  }

  int n=2,p=1;
  //cout << s[0][0] << endl;
  for(int i = 1; i < k; i++){
    for(int j = 0; j < n; j++){
      a = 0;
      if(k/2 >= i && j > 0) a = max(a,s[i-1][j-1]);
      if(k/2 < i && j+1 < p) a = max(a,s[i-1][j+1]);
      if(j < p) a = max(a,s[i-1][j]);
      s[i][j] += a;
      //cout << s[i][j] << ",";
    }
    //cout << endl;
    p = n;
    n += (k/2>i)?1:-1;
  }
  cout << s[k-1][0] << endl;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
int main()
{
int x;
cin >> x;
if(x>=400 && x<=599)
cout << "8" << endl;
else if(x<800)
cout << "7" << endl;
else if(x<1000)
cout << "6" << endl;
else if(x<1200)
cout <<"5" << endl;
else if(x<1400)
cout << "4" << endl;
else if(x<1600)
cout << "3" << endl;
else if(x<1800)
cout << "2" << endl;
else if(x<2000)
cout << "1" << endl;
return 0;
}

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

const int MAXN = 2e5;

int N;
int A[MAXN + 10];
int lcs[MAXN + 10];

int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%d", &A[i]);
  for(int i = N-1; i >= 0; i--) lcs[A[i]] = lcs[A[i]+1] + 1;
  printf("%d\n", N - *max_element(lcs+1, lcs+N+1));
}



Measured memory_bytes: 1792
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_STR_MAX		100000									// 最大文字数
#define D_CHK_CNT		4										// チェック文字列数

// 内部変数
static char sc1Str[D_STR_MAX + 5];								// 文字列
static char sc2Chk[D_CHK_CNT][16];								// チェック文字列
static int si1Chk[D_CHK_CNT];									// チェック文字列長

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 改行カット
int
fCutCfLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return 0;
}

// 作成可能かチェック
int
fChk(
)
{
	int i;

	// 現在位置
	int liNNo = strlen(sc1Str);

	while (liNNo > 0) {
		 
		// チェック文字列と比較
		int liRet = -1;
		for (i = 0; i < D_CHK_CNT; i++) {

			// 比較位置
			int liCNo = liNNo - si1Chk[i];
			if (liCNo < 0) {
				continue;
			}

			// 比較
			if (memcmp(&sc1Str[liCNo], sc2Chk[i], si1Chk[i])) {		// 不一致
				continue;
			}

			// 一致
			liRet = 0;
			liNNo = liCNo;											// 現在位置更新
			break;
		}
		if (liRet != 0) {
			return -1;
		}
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 文字列取得
#ifdef D_TEST
	fgets(sc1Str, sizeof(sc1Str), szpFpT);
#else
	fgets(sc1Str, sizeof(sc1Str), stdin);
#endif

	// 改行カット
	fCutCfLf(sc1Str);

	// チェック文字列
	strcpy(sc2Chk[0], "dream");
	strcpy(sc2Chk[1], "dreamer");
	strcpy(sc2Chk[2], "erase");
	strcpy(sc2Chk[3], "eraser");

	// チェック文字列長
	for (i = 0; i < D_CHK_CNT; i++) {
		si1Chk[i] = strlen(sc2Chk[i]);
	}

	// 作成可能かチェック
	int liRet = fChk();

	// 結果セット
	if (liRet == 0) {
		sprintf(lc1Out, "YES\n");
	}
	else {
		sprintf(lc1Out, "NO\n");
	}

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

unsigned int mod;

struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt;

int N;
const int MN = 3010;
mint S[MN][MN];
mint C[MN][MN];
using ll = long long;
ll ex(ll x,ll p,ll mod){
	ll a = 1;
	while(p){
		if(p%2) a=a*x%mod;
		x=x*x%mod;
		p/=2;
	}
	return a;
}

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

	S[0][0] = 1;
	rep1(n,N+1){
		S[n][1] = S[n][n] = 1;
		for(int k=2;k<n;k++) S[n][k] = S[n-1][k-1] + S[n-1][k]*k;
	}
	rep(i,N+1){
		C[i][0] = C[i][i] = 1;
		rep1(j,i-1) C[i][j] = C[i-1][j-1] + C[i-1][j];
	}


	mint ans = 0;
	rep(K,N+1){
		mint sm = 0;
		rep(r,K+1){
			sm += S[K+1][r+1] * ex(2,(N-K)*r,mod);
		}
		sm *= ex(2,ex(2,N-K,mod-1),mod);
		sm *= C[N][K];
		if(K%2==0) ans += sm;
		else ans -= sm;
//		show(sm);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 71040
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int R, G;

int main() {
  cin >> R >> G;
  cout << 2 * G - R;
}


Measured memory_bytes: 3604
import sys
count = 0
def merge(A, left, mid, right):
    global count
    L = A[left:mid]
    R = A[mid:right]
    L.append(sys.maxint)
    R.append(sys.maxint)
    i = 0
    j = 0
    t = 0
    for k in xrange(left, right):
        if L[i] <= R[j]:
            count += t
            A[k] = L[i]
            i += 1
        else:
            t += 1
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) / 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(raw_input())
A = map(int, raw_input().split())
mergeSort(A, 0, n)
print count

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

#define A



#ifdef A

int main(void) {
	int n;

	cin >> n;

	if (n % 10 == 9)
	{
		cout << "Yes" << endl;
		return 0;
	}
	n /= 10;
	if (n % 10 == 9)
	{
		cout << "Yes" << endl;
		return 0;
	}

	cout <<"No" <<endl;
	return 0;
}
#endif // A

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<char>> ans(h + 1, vector<char>(w + 1, '0'));
    rep(i, h) cin >> s[i];
    rep(i, h) rep(j, w)
    {
        if (s[i][j] == '.')
            continue;
        for (int a = i - 1; a <= i + 1; a++)
        {
            for (int b = j - 1; b <= j + 1; b++)
            {
                if (a < 0 || h <= a || b < 0 || w <= b)
                    continue;
                if (s[a][b] == '#')
                    ans[a][b] = '#';
                if ('0' <= ans[a][b] && ans[a][b] <= '9')
                    ans[a][b] += 1;
            }
        }
    }
    rep(i, h)
    {
        rep(j, w) cout << ans[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define arr(n) array<int,n>
#define INF 1e9
typedef long long ll;
typedef pair<int,int> pii;

int main(){
  int N;
  cin >> N;
  int a[N];
  int b[1000007] = {};
  rep(i,N){
    cin >> a[i];
    b[a[i]]++;
  }
  sort(a,a+N);
  int ans = N;
  
  rep(i,N){
    if(b[a[i]] > 1){
      ans--;
      continue;
    }
    bool f = false;
    int v = 10;
    for(int c=2; c<v; c++){
      if(a[i]%c==0 and (b[a[i]/c]) > 0){
        f = true;
        break;
      }
    }
    if(f){
      ans--;
      continue;
    }
    int x = *lower_bound(a,a+N,a[i]/v + 1);
    int j = 0;
    while(a[j] < x){
      if(j!=i and a[i]%a[j] == 0){
        ans--;
        break;
      }
      j++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8328
#include <iostream>
#include <string>
#include <math.h>

int main(){
    int l, n, m;
    std::cin >> l >> n >> m;
    if(((l==n)&&(l!=m))||((l==m)&&(l!=n))||((m==n)&&(l!=m))){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	static Integer dp[];

	static int minimumJumps(int ar[], int i, int k)
	{
		if(i==0)
			return 0;

		if(dp[i]!=null)
			return dp[i];

		int min=Integer.MAX_VALUE;
		int st=Math.max(i-k, 0);

		for(int j=st;j<i;j++)
		{
			if(dp[j]==null)
				min = Math.min(min, minimumJumps(ar, j, k)+Math.abs(ar[i]-ar[j]));
			else
				min = Math.min(min, dp[j]+Math.abs(ar[i]-ar[j]));
		}
		return dp[i]=min;
	}

	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		int ar[]=new int[n];
		for(int i=0;i<n;i++)
			ar[i]=scan.nextInt();

		dp=new Integer[n];

		int ans = minimumJumps(ar, ar.length-1, k);
		System.out.println(ans);
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

ll N, A, B;

ll solve() {
    ll r = A + B;
    ll ans = (N / r) * A;
    return ans + min(A, N%r);
}

int main() {
    cin >> N >> A >> B;
    cout << solve() << endl;
}

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

using ll = long long;
using pii = pair<ll, ll>;

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(n);
    vector<pii> vs;
    for(int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        vs.emplace_back(a[i], i);
        vs.emplace_back(b[i], i);
    }
    ll ans = min(accumulate(begin(a), end(a), 0LL), accumulate(begin(b), end(b), 0LL));
    sort(begin(vs), end(vs));
    vector<bool> used(n);
    bool ok = false;
    ll sum = 0;
    for(int i = 0; i < n; ++i) {
        sum += vs[i].first;
        ok |= used[vs[i].second];
        used[vs[i].second] = true;
    }
    if(ok) {
        ans = sum;
    }
    for(int i = 0; i < n; ++i) {
        if(vs[i].second == vs[n].second) {
            ans = min(ans, sum - vs[i].first + vs[n + 1].first);
        } else {
            ans = min(ans, sum - vs[i].first + vs[n].first);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 7920
#include <cstdio>
#include <vector>

int main() {
  int N, L;
  scanf("%d %d", &N, &L);

  std::vector<int> a(N);
  for (int i=0; i<N; ++i)
    scanf("%d", &a[i]);

  int last=-1;
  for (int i=0; i<N-1; ++i)
    if (a[i+1] + a[i] >= L) {
      last = i;
      break;
    }

  if (last == -1)
    return !printf("Impossible\n");

  printf("Possible\n");
  for (int i=1; i<=last; ++i)
    printf("%d\n", i);
  
  for (int i=N-1; i>last; --i)
    printf("%d\n", i);

  return 0;
}


Measured memory_bytes: 1152
#include<iostream>
    #include<cstring>
    #include<cstdio>
    #include<cstdlib>
    using namespace std;
    const int N=100000;
    int a[N];
    int n,m;
    int main()
    {
            n=m=0;
            for(int i=1;i<=4;i++)
            {
                cin>>a[i];
                if(i<=2)
                    n+=a[i];
                else
                    m+=a[i];
            }
            if(m==n)
                cout<<"Balanced"<<endl;
            else if(n<m)
                cout<<"Right"<<endl;
            else
                cout<<"Left"<<endl;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

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

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int cnt = 0;
	while(true) {
		if(cnt) {
			a -= d;
		} else {
			c -= b;
		}
		if(a <= 0 || c <= 0) {
			if(cnt) cout << "No" << endl;
			else cout << "Yes" << endl;
			break;
		}
		cnt ^= 1;
	}	
	
}





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

int main() {
  int N;
  cin >> N;
  int x = 100000000;
  int sum = 0;
  int K = N;
  for ( int i = 0 ; i < 9 ; i++) {
    int S, A;
    S = N / x;
    N = N % x;
    sum += S;
    x /= 10;
      }
  if ( K % sum == 0 ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  // ここにプログラムを追記
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	char c;
	if(a+b==15)
		c='+';
	else if(a*b==15)
		c='*';
	else
		c='x';
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256