akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<int> V(n + 1), W(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> V[i] >> W[i];
    }
    lint q;
    cin >> q;
    vector<int> v(q), l(q);
    int L = 0;
    for (int i = 0; i < q; ++i) {
        cin >> v[i] >> l[i];
        chmax(L, l[i]);
    }
    int up = min(1LL << 11, n + 1);
    vector<vector<int>> dp(up, vector<int>(L + 1, 0));
    for (int i = 1; i < up; ++i) {
        int p = i / 2;
        for (int j = 0; j <= L; ++j) {
            chmax(dp[i][j], dp[p][j]);
            if (j - W[i] >= 0)
                chmax(dp[i][j], dp[p][j - W[i]] + V[i]);
        }
    }
    for (int i = 1; i < up; ++i) {
        for (int j = 1; j <= L; ++j) {
            chmax(dp[i][j], dp[i][j - 1]);
        }
    }
    for (int i = 0; i < q; ++i) {
        if (v[i] < (up)) {
            cout << dp[v[i]][l[i]] << "\n";
        } else {
            vector<lint> vv, ww;
            lint c = v[i];
            while (c >= (up)) {
                vv.push_back(V[c]);
                ww.push_back(W[c]);
                c /= 2;
            }
            int k    = vv.size();
            lint ret = 0;
            for (int j = 0; j < 1 << k; ++j) {
                lint vs = 0;
                lint ws = 0;
                for (int x = 0; x < k; ++x) {
                    if (j >> x & 1) {
                        vs += vv[x];
                        ws += ww[x];
                    }
                }
                if (ws <= l[i]) {
                    chmax(ret, vs + dp[c][l[i] - ws]);
                }
            }
            cout << ret << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 809432
N, M = gets.split(' ').map(&:to_i)

l, r = 1, 100000
M.times do
  al, ar = gets.split(' ').map(&:to_i)
  if al > l
    l = al 
  end
  if ar < r 
    r = ar
  end

  if l > ar || r < al
    l = 1
    r = 0
    break
  end
end
puts r - l + 1


Measured memory_bytes: 1788
#include <set>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string S; int n;
    
    set<string> T;
    
    scanf("%d", &n);
    
    while(n--)
    {
        cin >> S;
        
        int c = 0;
        
        for(int i = 1; i < S.size(); i++)
        {
            c += (S[i - 1] == S[i] ? 1 : 0);
        }
        
        if(c + 1 == S.size())
        {
            printf("1\n");
        }
        else
        {
            T.clear();
            
            for(int j = 1; j < S.size(); j++)
            {
                string A = S.substr(0, j);
                string B = S.substr(j, S.size() - j);
                
                string C = A; reverse(C.begin(), C.end());
                string D = B; reverse(D.begin(), D.end());
                
                T.insert(A + B);
                T.insert(B + A);
                T.insert(A + D);
                T.insert(D + A);
                T.insert(C + B);
                T.insert(B + C);
                T.insert(C + D);
                T.insert(D + C);
            }
            
            printf("%d\n", T.size());
        }
    }
    
    return 0;
}

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

int main (){
  long long int n, a, b;
  cin >> n >> a >> b;
  long long int k = n/(a+b);
  long long int r = n%(a+b);
  cout << k * a + min(r, a) << endl;
  return 0;
}

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

using namespace std;

#define ll long long

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

	ll K;
	cin >> K;

	for (int i = 0; i < min(K, (ll) S.size()); i++) {
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
	}

	cout << 1 << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define max(a,b) (a)>=(b)? (a) : (b) 
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double pi = 3.14159265358979323846;



#define F first
#define S second
const int MX = 1e5 + 10, MD = 1e9 + 7;
long long n, m, a[MX], ans, tmp, mx, t1, t2, ind, res;
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > mx) {
			mx = a[i];
			ind = i;
		}
	}
	ans = mx + 1;
	ll t = 50000000000000;
	for (ll i = 0; i < pow(10, 10); )
	{
		i++; t /= i;
	}
	if (mx % 2 == 0) {
		t1 = mx / 2;
		for (int i = 0; i < n; i++) {
			if (ind == i)continue;
			if (abs(a[i] - t1) < ans) {
				ans = abs(a[i] - t1);
				res = a[i];
			}
		}
	}
	else {
		t1 = mx / 2;
		t2 = mx / 2 + 1;
		for (int i = 0; i < n; i++) {
			if (ind == i)continue;
			if (abs(a[i] - t1) < ans) {
				ans = abs(a[i] - t1);
				res = a[i];
			}
			else if (abs(a[i] - t2) < ans) {
				ans = abs(a[i] - t2);
				res = a[i];
			}
		}
	}
	cout << mx << " " << res;

}






Measured memory_bytes: 1024
st=input()
a=[]
for i in range(0,4):
    a.append(int(st[i]))

for i in range(0,1<<3):
    temp=a[0]
    j=0
    for j in range(0,3):
        if i>>j&1 :temp+=a[j+1]
        else :temp-=a[j+1]
    if temp==7:
        ans=str(a[0])
        for k in range(0,3):
            if i>>k&1:ans+="+"
            else:ans+="-"
            ans+=str(a[k+1])
        ans+="=7"
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll d;
    cin >> d;
    vector<ll> z(26);
    for (int i = 0; i < 26; i++) {
        cin >> z[i];
    }
    vector<vector<ll>> x(d, vector<ll>(26));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> x[i][j];
        }
    }
    vector<ll> ans(d);
    for (int j = 0; j < d; j++) {
        ll mx = 0;
        ll atai = 0;
        for (int k = 0; k < 26; k++) {
            mx = max(x[j][k], mx);
            if (mx == x[j][k])atai = k;
        }
        ans[j] = atai+1;
    }
    for (int i = 0; i < d; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3724
#include <iostream>

using namespace std;

int main()
{
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int dx2 = x2- x1;
    int dy2 = y2- y1;
    
    int dx3 = -1*dy2;
    int dy3 = dx2;

    int dx4 = -1*dx2;
    int dy4 = -1*dy2;
    
    
    int x3 = x2+dx3;
    int y3 = y2+dy3;
    int x4 = x3+dx4;
    int y4 = y3+dy4;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
//054A
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b=0;
    cin >> a >> b;
    if (a==1){
        a = 14;
    }
    if (b==1){
        b = 14;
    }
    if (a>b){
        cout << "Alice";
    }else if(a==b){
        cout << "Draw";
    }else{
        cout << "Bob";
    }
}

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

int main(){
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  
  x3 = x2 - (y2 - y1);
  y3 = y2 - (x1 - x2);
  x4 = x3 + (x1 - x2);
  y4 = y3 - (y2 - y1);
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    //int ans1=0, ans2=0;
    //bool ans=false;
    int A,B;
    
    string s,t,u;

    cin>>s>>t;

    cin>>A>>B;

    cin>>u;
    
    if(u==s){
        A-=1;
    }else{
        B-=1;
    }
    
    cout<<A<<" "<<B<<endl;

   /*if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }*/

    return 0;
}

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

bool flag;

void solve(vector<int> C, int n){
	if( n == 0 ){
		flag = true;
		return;
	}
	if( flag ) return;
	
	for(int i=2 ; i < 9 ; i++ ){
		if( C[i-2] && C[i-1] && C[i] ){
			C[i-2]--; C[i-1]--; C[i]--;
			solve( C , n-3 );
			C[i-2]++; C[i-1]++; C[i]++;
		}
	}
	for(int i=0 ; i < 9 ; i++ ){
		if( C[i] >= 3 ){
			C[i] -= 3;
			solve( C , n-3 );
			C[i] += 3;
		}
	}
}

int main(){
	int T;
	cin >> T;
	for(int t=0 ; t < T ; t++ ){
		vector<int> R, G, B;
		int a[9];
		for(int i=0 ; i < 9 ; i++ ){
			cin >> a[i];
		}
		for(int i=0 ; i < 9 ; i++ ){
			char c;
			cin >> c;
			if( c == 'R' ) R.push_back( a[i] );
			if( c == 'G' ) G.push_back( a[i] );
			if( c == 'B' ) B.push_back( a[i] );
		}
		if( R.size() % 3 == 0 && G.size() % 3 == 0 && B.size() % 3 == 0 ){
			bool flag1, flag2, flag3;
			if( R.size() > 0 ){
				vector<int> C(9,0);
				for(int i=0 ; i < R.size() ; i++ ){
					C[ R[i]-1 ]++;
				}
				flag = false;
				solve( C , R.size() );
				flag1 = flag;
			}else{
				flag1 = true;
			}
			
			if( G.size() > 0 ){
				vector<int> C(9,0);
				for(int i=0 ; i < G.size() ; i++ ){
					C[ G[i]-1 ]++;
				}
				flag = false;
				solve( C , G.size() );
				flag2 = flag;
			}else{
				flag2 = true;
			}
			
			if( B.size() > 0 ){
				vector<int> C(9,0);
				for(int i=0 ; i < B.size() ; i++ ){
					C[ B[i]-1 ]++;
				}
				flag = false;
				solve( C , B.size() );
				flag3 = flag;
			}else{
				flag3 = true;
			}
			if( flag1 && flag2 && flag3 ){
				cout << 1 << endl;
			}else{
				cout << 0 << endl;
			}
		}else{
			cout << 0 << endl;
		}
	}
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    lint A, B, N;
    cin >> A >> B >> N;
    lint x = min(N, B - 1);
    lint ans = A * x;
    ans /= B;
    cou(ans);


}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<pair<int, int>>>;
vector<int> color;
/////black: 1, white: 0, undecided: -1

void dfs(const Graph &G, int u,int before_u, int this_color){
    color[u] = this_color;
    for (auto next: G[u]){
        int w = next.second;
        int next_u = next.first;
        if (next_u == before_u) continue;
        if (w % 2 == 1) dfs(G, next_u, u, 1 - this_color);
        else dfs(G, next_u, u, this_color);
        // color[next_u] = this_color;
        // dfs(G, next_u, u, this_color);
    }
}

int main() {
    int N;
    cin >> N;
    Graph G;
    G.assign(N, vector<pair<int, int>>());
    for (int i = 1; i < N; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    color.assign(N, 0);
    dfs(G, 0, -1, 1);
    for (auto c: color) cout << c << endl;
    return 0;
}

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

int32_t main()
{
	int n,m;
	cin>>n>>m;
	
	string a="",b="";
	for (int i=0;i<m;i++)
		a+=(to_string(n));
	for (int i=0;i<n;i++)
		b+=(to_string(m));
	
	if (b<a)	
		cout<<b<<'\n';
	else
		cout<<a<<'\n';
	
	
	
}



Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: isize,
        k: isize,
        d: isize,
    }

    let quot = isize::abs(x) / d;
    let remain = isize::abs(x) % d;

    let ans = if k < quot {
        isize::abs(x) - isize::abs(d * k)
    } else {
        let k2 = k - quot;
        if k2 % 2 == 0 {
            isize::abs(x) - isize::abs(d * quot)
        } else {
            isize::abs(isize::abs(x) - isize::abs(d * quot) - d)
        }
    };

    println!("{}", ans);
}


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

int main(){
  int N,v1,c1,dif,ans;
  vector<int> V;
  cin >> N;
  
  for ( int i = 0; i< N; i++){
    cin >> v1;
    V.push_back(v1);
  }
  for ( int i = 0; i< N; i++){
    cin >> c1;
    dif = V[i] - c1;
    if (dif > 0){
      ans = ans + dif;
    }
  }

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

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main(){
    int n;
    int a;
    int ans=0;
    scanf("%d",&n);
    for (int i = 0;i < n;i++){ 
        scanf("%d", &a); 
        ans^=a;
    }

    if(ans==0){
        printf("%s","Yes\n");
    }else{
        printf("%s","No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int const inf = (1LL<<31)-1;
int const B = 1024;
struct RMQ {
    int n;
    vector<int> Bmin;
    vector<vector<int>> dat;
    RMQ(int n_){
        n = n_;
        if(n%B) n += B-n%B;
        dat.assign(n/B,vector<int>(B,inf));
        Bmin.assign(n/B,inf);
    }
    void set(int idx, int x){
        get(idx) = x;
        Bmin[idx/B] = inf;
        for(int i=0;i<B;i++) Bmin[idx/B] = min(Bmin[idx/B], get(idx/B*B+i));
    }
    int & get(int idx){
        return dat[idx/B][idx%B];
    }
    int rmq(int l, int r){
        int res = inf;
        if(l/B != r/B){
            while(l%B){
                res = min(res, get(l));
                l++;
            }
            while(r%B){
                r--;
                res = min(res, get(r));
            }
            while(l<r){
                res = min(res, Bmin[l/B]);
                l+=B;
            }
        } else {
            while(l<r){
                res = min(res, get(l));
                l++;
            }
        }
        return res;
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    RMQ rmq(n);
    rep(i,q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c) cout << rmq.rmq(x,y+1) << endl;
        else rmq.set(x,y);
    }
}

Measured memory_bytes: 1524
#include <array>
#include <iostream>
#include <vector>

void printVector(std::vector<int> &a) {
  std::size_t n = a.size();
  for (std::size_t i = 0; i < a.size(); ++i) {
    std::cout << a.at(i);
    if (i < n - 1)
      std::cout << " ";
    else
      std::cout << std::endl;
  }
}

void countingSort(std::vector<int> &a, std::vector<int> &b, int k) {
  int n = a.size();
  std::vector<int> c(k + 1, 0);

  // C[i]にiの出現数を記録する
  for (int i = 0; i < n; ++i) {
    c.at(a.at(i))++;
  }

  // c[i]にi以下の数を出現数を記録する
  for (int i = 1; i <= k; ++i) {
    c.at(i) = c.at(i) + c.at(i - 1);
  }

  for (int i = n - 1; i >= 0; --i) {
    b.at(c.at(a.at(i)) - 1) = a.at(i);
    c.at(a.at(i))--;
  }
  printVector(b);
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n, 0), b(n, 0);
  for (int i = 0; i < n; ++i) {
    std::cin >> a.at(i);
  }

  countingSort(a, b, 10000);
}



Measured memory_bytes: 18384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
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;
}
using namespace std;

void solve(){
  string s;
  while(cin>>s){
    string t="";
    int n=s.size();
    rep(i,n){
      if(s[i]=='@'){
        int num=s[i+1]-'0';
        rep(j,num)t+=s[i+2];
        i+=2;
      }
      else t+=s[i];
    }
    cout<<t<<"\n";
  }
 return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}



Measured memory_bytes: 2984
x, y = map(int, input().split())

if x <= y:
    if 0 <= x * y:
        print(y - x)
    else:
        print(abs(x + y) + 1)
else:
    if 0 < x * y:
        print(x - y + 2)
    elif x * y <= 0:
        print(abs(y + x) + 1)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int gcd(int x, int y){
    return y ? gcd(y, x%y) : x;    
}

void Main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    
    vi l(n), r(n);
    l[0] = a[0];
    r[n-1] = a[n-1];
    
    rep(i, n-1){
        l[i+1] = gcd(l[i], a[i+1]);
    }
    rep3rev(i, n-2, 0){
        r[i] = gcd(r[i+1], a[i]);
    }
    
    /*
    rep(i, n){
        cout << l[i] << " " << r[i] << endl;
    }
    */
    
    int mx = -1;
    rep(i, n){
        int g;
        if(i == 0) g = r[1];
        else if(i == n-1) g = l[n-2];
        else g = gcd(l[i-1], r[i+1]);
        mx = max(mx, g);
    }
    cout << mx << endl;
}

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

Measured memory_bytes: 1408
with Ada.Text_IO;
with Ada.Integer_Text_IO;

procedure main is

   s, w : Integer;

begin

   Ada.Integer_Text_IO.Get(s, 0);
   Ada.Integer_Text_IO.Get(w, 0);
   
   if(s <= w)then
      Ada.Text_IO.Put_Line("unsafe");
   else
      Ada.Text_IO.Put_Line("safe");
   end if;

end main;


Measured memory_bytes: 3668
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

diff = [0] * N
neg = []
pos = []
for i in range(N):
    diff[i] = A[i] - B[i]
    if diff[i] < 0:
        neg.append(diff[i])
    else:
        pos.append(diff[i])

if sum(diff) < 0:
    print(-1)
    exit(0)

tobe_supplied = sum(neg)
pos.sort(reverse=True)

cnt = len(neg)

for p in pos:
    if tobe_supplied >= 0:
        break
    cnt += 1
    tobe_supplied += p    

print(cnt)

Measured memory_bytes: 24212
N = int(input())
S = input()
ss = [1 if s == 'W' else 0 for s in S]

def mul(a, b):
    return (a * b) % (10**9 + 7)

ans = 1
num = 0
for s in ss:
    if num % 2 == s:
        num += 1
    else:
        ans = mul(ans, num)
        num -= 1

if num > 0:
    ans = 0

for i in range(2, N + 1):
    ans = mul(ans, i)

print(ans)


Measured memory_bytes: 5096
n = int(input())
v = list(map(int, input().split()))

a = []
b = []

a_dic = {}
b_dic = {}

for i in range(n):
    if i % 2 == 0:
        if v[i] in a_dic.keys():
            a_dic[v[i]] += 1
        else:
            a_dic[v[i]] = 1
    else:
        if v[i] in b_dic.keys():
            b_dic[v[i]] += 1
        else:
            b_dic[v[i]] = 1

max_a = 0
max_b = 0

max_a_ind = 0
max_b_ind = 0
 
for i, val in a_dic.items():
    if val > max_a:
        max_a = val
        max_a_ind = i

for i, val in b_dic.items():
    if val > max_b:
        max_b = val
        max_b_ind = i

n_2 = int(n / 2)

ans = (n_2 - max_a) + (n_2 - max_b)

if (len(a_dic) == 1 and len(b_dic) == 1) and a_dic.keys() ==  b_dic.keys():
    print(n_2)

elif max_a_ind == max_b_ind:
    list_a = sorted(list(a_dic.values()), reverse=True)
    list_b = sorted(list(b_dic.values()), reverse=True)
    if list_a[0] > list_b[0]:
        ans = n_2 - list_a[0] + n_2 - list_b[1]
    elif list_a[0] < list_b[0]:
        ans = n_2 - list_a[1] + n_2 - list_b[0]
    else:
        ans = n_2 - list_a[0] + n_2 - max(list_a[1], list_b[1])
    print(ans)

else:
    print(ans)



Measured memory_bytes: 17656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(in) in.begin(),in.end()
using ll = long long;
using namespace std;
 
void chmax(ll &a, ll b) { if (a < b) a = b; return; }
using pll = pair<ll,ll>;
 
int main() {
    int n; cin >> n;
    vector<pll> a(n); rep(i,n) cin >> a[i].first, a[i].second = i;
    sort(all(a),greater<pll>());
 
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    rep(i,n) rep(j,n-i){
        chmax(dp[i+1][j], dp[i][j] + a[i+j].first * abs(a[i+j].second - i));
        chmax(dp[i][j+1], dp[i][j] + a[i+j].first * abs((n-1-j) - a[i+j].second));
    }
    ll ans = 0;
    rep(i,n+1) chmax(ans, dp[i][n-i]);
    cout << ans << endl;
}

Measured memory_bytes: 34656
#049_C
s = input()[::-1]
k = ['maerd', 'remaerd', 'esare', 'resare']

tmp = 0
flg = True
while tmp < len(s):
    check = False
    for x in k:
        if s[tmp: tmp + len(x)] == x:
            check = True
            tmp += len(x)
    if check == False:
        flg = False
        break
        
print('YES' if flg else 'NO')

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	cout<<(n+1)/2<<endl;
	return 0;
}

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

int main(){
    int M = 26;

    // input
    int N;
    string S;
    cin >> N >> S;
    vector<char> P(S.length());


    // calc
    vector<char> alp(M);
    int i=0;
    for( char c='A'; c<='Z'; c++ ){
        alp[i] = c;
        i++;
    }

    int k;
    for ( int j=0; j<S.length(); j++ ){
        for( i=0; i<M; i++ ){
            if( S[j] == alp[i] ){
                k = (i+N) % M;
                P[j] = alp[k];
            }
        }
    }

    // output
    for ( int j=0; j<S.length(); j++ ){
        cout << P[j];
    }
    cout << endl;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int a,b;
	int ave,t,x;
	while(~scanf("%d %d\n",&a,&b)){
		ave = (a+b)*1/2;
		t = (a+b)%2;
		if(t == 1) x = ave+1;
		else x = ave;
		printf("%d\n",x);
	}
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  long long sum = 0;
  for(int i = 1; i <= N; ++i){
    sum += (long long)i * (N / i) * (N / i + 1) / 2;
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }else if(a>b){
        cout<<"a > b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

// lint gcd(const lint a, const lint b) {
//     if (a < b) { return gcd(b, a); }
//     if (a % b == 0) {
//         return b;
//     } else {
//         return gcd(b, a % b);
//     }
// }
template <class T>
T gcd(T a, T b) {
    if (b > a) T tmp = a, a = b, b = tmp;
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int main() {
    lint N, K;
    cin >> N >> K;
    vector<lint> A(N, 0ll);
    rep(i, N) cin >> A[i];
    lint ma = -1;
    lint g  = 0;
    rep(i, N) {
        g  = gcd(g, A[i]);
        ma = max(ma, A[i]);
    }
    cout << (K % g == 0 and K <= ma ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}

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

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

const int lim = 1000000007;

int main(){
    int K, S;
    cin >> K >> S;
    ll ans = 0;
    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            int val = S - (x + y);
            if(val >= 0 && val <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second

vector<ll> primeFactors(ll n)  {  
    // Prll the number of 2s that divide n
    vector<ll> v;  
    while (n % 2 == 0)  {  
        v.push_back(2);  
        n = n/2;  
    }  
  
    // n must be odd at this poll. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, prll i and divide n  
        while (n % i == 0)  
        {  
            // cout << i << " "; 
            v.push_back(i); 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  {
        v.push_back(n);
        // cout << n << " ";  
    }
    return v;
}  


signed main() {
    ll t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll c = 0;
        vector<ll> v = primeFactors(n);
        unordered_map<ll,ll> mp;
        for(ll i=0;i<v.size();++i){
            // cout<<v[i];

            if(mp.find(v[i]) != mp.end()){
                ll m = v[i];
                int val = v[i];
                i++;
                while(i<v.size() && mp[m]!=0 && v[i]==val){
                    m*=v[i];
                    i++;
                }
                i--;
                if(mp[m]==0){
                    c++;
                    mp[m]++;
                }
            }
            else{
                mp[v[i]]++;
                c++;
            }
        }
        
        cout<<c;
    }
    
}

Measured memory_bytes: 3680
from heapq import heappush, heappop
import sys
input = sys.stdin.buffer.readline

N, M = map(int,input().split())
work = [[] for _ in range(10**5+1)]
ava = []
ans = 0

for i in range(N):
    A, B = map(int,input().split())
    work[A].append(-B)

for i in range(1, M+1):
    if len(work[i]) > 0:
        for j in work[i]:
            heappush(ava, j)
    if len(ava) > 0:
        ans -= heappop(ava)
print(ans)
       

Measured memory_bytes: 22112
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;

char s[100];
stack<int> stk;

int main()
{
    while(scanf("%s", s) != EOF ) {
        if ( s[0] == '+' ) {
            int y = stk.top();
            stk.pop();
            int x = stk.top();
            stk.pop();
            stk.push(x + y);
        } else if ( s[0] == '-' ) {
            int y = stk.top();
            stk.pop();
            int x = stk.top();
            stk.pop();
            stk.push(x - y);
        } else if ( s[0] == '*' ) {
            int y = stk.top();
            stk.pop();
            int x = stk.top();
            stk.pop();
            stk.push(x * y);
        } else {
            int x = atoi(s);
            stk.push(x);
        }
    }

    printf("%d\n", stk.top());
    return 0;
}

Measured memory_bytes: 1020
#優先度付きque
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
a = list(map(lambda x: x * (-1), a))  # 要素をすべて-1倍
heapq.heapify(a)

for i in range(m):
    #最大値の取り出し
    tem_num=heapq.heappop(a)*(-1)
    #最大値に割引券を使いheapqへ入れる
    heapq.heappush(a,(-1)*(tem_num//2))
print(-sum(a))

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

int main(){
  string S;
  cin>>S;
  int n=S.size();

  int sum=0;
  vector<int> d(n+3,0);
  for(int i=0;i<n;i++){
    d.at(i+3)=S.at(i)-'0';
  }

  reverse(d.begin(),d.end());

  int count=0;
  for(int i=0;i<n+1;i++){
    if(d.at(i)==0){
      continue;
    }else if(d.at(i)==10){
      d.at(i+1)++;
      continue;
    }else if(d.at(i)<5){
      count+=d.at(i);
    }else if(d.at(i)>5){
      count+=10-d.at(i);
      d.at(i+1)++;
    }else if(d.at(i)==5){
      if(d.at(i+1)>=5){
        count+=10-d.at(i);
        d.at(i+1)++;
      }else{
        count+=d.at(i);
      }
    }
  }

  cout<<count<<endl;
}


Measured memory_bytes: 5252
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 


int main(){

    

    string S;
    
    cin >> S;
    if(S=="ARC"){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    

}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import collections
N,X,Y = map(int,input().split())
ToltN=N*(N-1)/2
Dist=[[0 for i in range(N)] for i in range(N)]
c=[0]*N
for i in range(N):
    for j in range(i+1,N):
        MyDist=abs(i-(X-1))+abs(j-(Y-1))+1
        if MyDist<j-i:
            Dist[i][j]=MyDist
            c[MyDist-1]+=1
        else:
            Dist[i][j] = j-i
            c[j-i-1]+=1
for i in range(N-1):
    print(c[i])


Measured memory_bytes: 84544
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
#include <set>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)

int main() {
    ll ans=0, H, W, M;
    cin >> H >> W >> M;
    vector<ll> h(M), w(M);
    vector<ll> row(H+1), col(W+1);
    rep(i,M) {
        cin >> h[i] >> w[i];
        row[h[i]]++;
        col[w[i]]++;
    }
    auto r = *max_element(begin(row), end(row));
    auto c = *max_element(begin(col), end(col));
    std::set<ll> mr, mc;
    rep(i,H+1) {
        if (row[i] == r)
            mr.insert(i);
    }
    rep(i,W+1) {
        if (col[i] == c)
            mc.insert(i);
    }
    ll d = 0;
    rep(i,M) {
        if (mr.count(h[i]) && mc.count(w[i]))
            ++d;
    }
    ans = r + c;
    if ((ll)mr.size()*(ll)mc.size() == d)
        --ans;
    cout << ans << endl;
}


Measured memory_bytes: 40236
#include <stdio.h>

int main(void){
  int a, count = 0;
  scanf("%d", &a);
  int b = a;
  while(1){
    count += a % 10;
    a = a / 10;

    if(a == 0)
      break;
  }
  if(b % count == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n){
		ll ans=0,temp;
		for(int i=0;i<n;i++){
			cin>>temp;
			while(temp%2==0){
				ans++;
				temp>>=1;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        cin>>n>>k;
        vi v(n+1);
        for(i=1;i<=n;i++)
        {
            cin>>v[i];
        }
        ll dp[102][100005];
        vi vv;
        clr(dp,0);
        dp[0][0]=1;
        for(i=1;i<=n;i++)
        {
            for(j=0;j<=k;j++)
            {
                if(j-v[i]-1<0)
                {
                    dp[i][j]=(dp[i-1][j])%hell;
                    continue;
                }
                dp[i][j]=(dp[i-1][j]-dp[i-1][j-v[i]-1]+hell)%hell;
            }
            for(j=1;j<=k;j++)
                dp[i][j]=(dp[i][j]+dp[i][j-1])%hell;
        }
        cout<<dp[n][k];
    }
    return 0;
}

Measured memory_bytes: 80000
#include <iostream>

using namespace std;

int main() {
  long long K, A, B;
  cin >> K >> A >> B;
  long long ans = 1;
  long long ops = 0;
  while (ops < K) {
    if (ans >= A && B > A + 1 && ops + 1 < K) {
      ans += (B - A);
      ++ops;
    } else ++ans;
    ++ops;
  }
  cout << ans << endl;
  return 0;
}


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

bool has3(int x){
    while(x){
        if (x%10==3) return true;
        x/=10;
    } return false;
}

bool kake3(int x){
    if (x%3==0) return true;
    else return false;
}
    

int main(){
    int n;
    cin >> n;
    for (int i=1; i<=n; i++){
        if (has3(i)||kake3(i)){
            cout << " " << i ;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n, k;
    cin >> n >> k;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    bool lose[k + 1] = {};
    for (int i = 0; i <= k; i++) {
        int can_win = 0;
        for (int j = 0; j < n; j++) {
            if (i - as[j] >= 0 && lose[i - as[j]]) {
                can_win = 1;
                break;
            }
        }
        lose[i] = !can_win;
    }

    cout << (!lose[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 384
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int a, b;
	cin >> a >> b;
	if (a <= 5) {
		cout << "0\n";
	} else if (a <= 12) {
		cout << b / 2 << "\n";
	} else {
		cout << b << "\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    vector<ll> b= a ;
    reverse(b.begin(),b.end());
    vector<ll> w(n);
    w[0] = b[0];
    rep(i,n-1){
        w[i+1] = w[i]+b[i+1];
    }
    rep(i,n){
        if(w[i]>MOD) w[i]%=MOD;
    }
    reverse(w.begin(),w.end());
    rep(i,n-1){
        ans +=a[i]*w[i+1];
        ans%=MOD;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 7932
N = int(input())
number = list(map(int,input().split()))

def show(A):
    for t in range(len(A)):
        if t != N -1:
            print(number[t],'',end='')
        else:
            print(number[t])


for i in range(1,N):
    show(number)
    v = number[i]
    j = i -1
    while j >= 0 and number[j] > v:
        number[j+1] = number[j]
        j -= 1
    number[j+1] = v

show(number)




Measured memory_bytes: 6312
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {
			double[] nums = new double[11];
			nums[1] = Double.parseDouble(line);
			for (int i = 2; i < nums.length; i++) {
				if (i % 2 == 0)
					nums[i] = nums[i - 1] * 2;
				else
					nums[i] = nums[i - 1] / 3.0;
			}
			double sum = 0;
			for (double d : nums)
				sum += d;
			System.out.println(sum);
			line = null;
		}

	}

}

Measured memory_bytes: 16916
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	string t;
	cin >> t;
	rep(i, t.size()){
		if(t[i] == '?'){
			t[i] = 'D';
		}
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 3756
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)

def DefeatMonsters(i, j)
  if A[i] > B[j] then
    tmp = B[j]
    A[i] -= tmp
    B[j] = 0
    tmp
  else
    tmp = A[i]
    A[i] = 0
    B[j] -= tmp
    tmp
  end
end

ans = 0
N.times{|i|
  ans += DefeatMonsters(i, i)
  ans += DefeatMonsters(i + 1, i) if B[i] > 0
}

puts ans


Measured memory_bytes: 17564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
typedef long double ld;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  ll N,M;cin>>N>>M;
  print((100*(N-M)+1900*M)*(powl(2,M)))
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100
int a[N][N], b[N][N];

int main (){
    int n, i, j, k;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d", &a[i][0], &a[i][1]);
        if (a[i][1] != 0){
            for(j = 0; j < a[i][1]; j++){
                scanf("%d", &a[i][2+j]);
            }
        }
    }
    
    for ( i = 0; i < n; i++){
        for(j = 0; j < a[i][1]; j++){
            b[i][a[i][j+2]-1] = 1;
        }
    }
    
    
    for (i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            if (j != 0){
                printf(" ");
            }
            printf("%d", b[i][j]);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>

using namespace std;

int main(){
    string s;
    vector<string>S;
    int K;
    cin >> s >> K;
    int tmp = min(5,(int)s.size());
    for(int i = 1; i <= tmp; i++){
        for(int j = 0; j < s.size(); j++){
            S.push_back(s.substr(j,i));
        }
    }
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    // for(int i = 0; i < K; i++){
    //     cout << S[i] << endl;
    // }
    cout << S[K-1] << endl;

}

Measured memory_bytes: 1660