akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
int N;

int main(int argc, const char * argv[]) {
    cin >> N;
    output((double)ceil(N/2.0) / N);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#define lmid l,m,rt<<1
#define rmid m+1,r,rt<<1|1
#define LL long long
#define rl r-l+1
using namespace std;
struct node
{
    int v;
    int next;
}edge[400005];
int head[200005];
int cnt;
void add(int u,int v)
{
    edge[cnt].v=v;
    edge[cnt].next=head[u];
    head[u]=cnt++;
}
bool flag;
int vis[200005];
int n,m;
void dfs(int x,int y)
{
    if(x==n&&y==2)
    {
        flag=true;
        return;
    }
    if(y>=2)
        return;
    for(int i=head[x];~i;i=edge[i].next)
    {
        node e=edge[i];
        if(!vis[e.v])
        {
            vis[e.v]=1;
            dfs(e.v,y+1);
            vis[e.v]=0;
        }
    }
}
int main()
{
    flag=false;
    cnt=1;
    memset(head,-1,sizeof(head));
    memset(vis,0,sizeof(vis));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        add(a,b);
        add(b,a);
    }
    dfs(1,0);
    if(flag)
        cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 4992
N,K=map(int,input().split())
mod=7+10**9
ans=0
l=list(range(0,N+1))
for i in range(1,N+1):
    l[i]+=l[i-1]
for i in range(K,N+2):
    ans+=(l[-1]-l[-((1+i)%(N+2))]-l[i-1]+1)%mod
print(ans%mod)

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

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

        vector<int> ans_s;
        vector<int> vsi;
        vector<char> vsc;
        for(int i = 0; i < S.size(); i++)
        {
                bool flag = false;
                int idx = -1;
                for(int j = 0; j < vsc.size(); j++)
                {
                        if(S[i] == vsc[j])
                        {
                                flag = true;
                                idx = j;
                        }
                }
                if(flag == true)
                {
                        ans_s.push_back(vsi[idx]);
                }
                else
                {
                        ans_s.push_back(vsi.size());
                        vsi.push_back(vsi.size());
                        vsc.push_back(S[i]);
                }
        }

        vector<int> ans_t;
        vector<int> vti;
        vector<char> vtc;
        for(int i = 0; i < T.size(); i++)
        {
                bool flag = false;
                int idx = -1;
                for(int j = 0; j < vtc.size(); j++)
                {
                        if(T[i] == vtc[j])
                        {
                                flag = true;
                                idx = j;
                        }
                }
                if(flag == true)
                {
                        ans_t.push_back(vti[idx]);
                }
                else
                {
                        ans_t.push_back(vti.size());
                        vti.push_back(vti.size());
                        vtc.push_back(T[i]);
                }
        }

        bool flag = true;
        for(int i = 0; i < ans_s.size(); i++)
        {
                if(ans_s[i] != ans_t[i]) flag = false;
        }

        if(flag == true) cout << "Yes" << endl;
        else cout << "No" << endl;

        return 0;
}

Measured memory_bytes: 2940
#include <bits/stdc++.h>
        #define ll long long  int
        #define N 1001
        #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
        #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
        #define po pop_back
        #define pb push_back
        #define pp pair<ll,ll>
        #define lb lower_bound
        #define fi first
        #define se second
        #define debug(x) cout << #x << " = " << x << endl
        #define ub upper_bound
        #define ibs ios_base::sync_with_stdio(false)
        #define cti cin.tie(0)
        #define all(x) x.begin(),x.end()
        #define PI 3.14159265
        #define cot cout.tie(0)
        using namespace std;
         /**
          * @author :: Sawlani
          *
          *
          **/
          int main()
          {
              string s;
              cin >> s;
              ll ans=0;

              f(i,0,s.length()/2-1)
              {
                  if(s[i]!=s[s.length()-i-1])
                    ans++;

              }

              cout << ans << endl;
               }


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			int m=in.nextInt();
			if((n|m)==0)
				return;
			int b[] = new int[m+1];
			int ans[]=new int[m+1];
			boolean a[] = new boolean[m+1];
			Arrays.fill(a, true);
			for(int i=1; i<=n;i++)
				for(int j=1;j<=m;j++)
					b[j]+=in.nextInt();
			for(int i=1;i<=m;i++)
			{
				int max =-1;
				int mxin = i;
				int j;
				for( j=1;j<=m;j++)
				{
					if(b[j]>max&&a[j])
					{
						max=b[j];
						mxin = j;
					}
				}
				ans[i]=mxin;
				a[mxin]=false;
			}
			for(int i=1;i<=m;i++)
				if(i!=m)System.out.print(ans[i]+" ");
				else System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
//	string ans="";
	vector<long long int>v;
	while(n>0){
		n--;
		v.push_back(n%26);
		n=n/26;
	//	n--;
	}
	reverse(v.begin(),v.end());
	for(long long int i=0;i<v.size();i++){
		cout<<char('a'+v[i]);
	}
}

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

void ac()
{
  string contest;

  getline(cin, contest);
  while(contest != "ARC" && contest != "ABC")
  {
    getline(cin, contest);
  }

  if(contest == "ARC")
  {
    cout << "ABC" << endl;
  }

  else
  {
    cout << "ARC" << endl;
  }


}
  int main()
  {
    ac();
  }


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

long long t[2001][2001] = {};

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

    int n;
    cin>>n;

    vector<pair<long long, int>> v(n);

    for(int i = 0; i < n; i++)
    {
        cin>>v[i].first;
        v[i].second = i;
    }

    sort(v.begin(), v.end(), greater<pair<long long, int>>());

    for(int i = 1; i <= n; i++)
        t[0][i] = -1e18;

    for(int i = 1; i <= n; i++)
        for(int j = 0; j <= n; j++)
            t[i][j] = max((t[i-1][j] + ((long long)abs(n-i+j-v[i-1].second))*v[i-1].first), (long long)(j > 0 ? (t[i-1][j-1] + ((long long)abs(j-1-v[i-1].second))*v[i-1].first) : 0));

    long long meg = 0;
    for(int i = 0; i <= n; i++)
        meg = max(meg, t[n][i]);

    cout<<meg<<"\n";

    return 0;
}


Measured memory_bytes: 34972
//ITP1_9_A_19140837_Ojima_Yukiya.cpp
//提出日 2020/6/17 wednesday
//プログラミング基礎演習2 CS 第６回課題 ITP1_9_A
//学修番号 19140837　小島優希也

#include <iostream>
using namespace std;

int main(void) {
    string s;
    int counta = 0;
    string w;
    cin >> w;
    int distance = 'a' - 'A';
    while (true) {
        cin >> s;
        bool match = false;
        if (s.size() == w.size()) {
            for (int i = 0; i < s.size(); i++) {
                if (s.at(i) >= 'A' && s.at(i) <= 'Z') {
                    if (w.at(i) == s.at(i) || w.at(i) == s.at(i) + distance) {
                        match = true;
                    }
                    else {
                        match = false;
                        break;
                    }
                }
                else if (s.at(i) >= 'a' && s.at(i) <= 'z') {
                    if (w.at(i) == s.at(i) || w.at(i) == s.at(i) - distance) {
                        match = true;
                    }
                    else {
                        match = false;
                        break;
                    }
                }
            }
        }
        if (match) {
            counta++;
        }
        if (s == "END_OF_TEXT") {
            break;
        }
    }
    cout << counta << endl;
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector <int> G;

void insertionSort(int A[],int n,int g)
{
  for (int i=g;i<n;i++)
    {
      int v=A[i];
      int j=i-g;
      while(j>=0&&A[j]>v)
	{
	  A[j+g]=A[j];
	  j-=g;
	  cnt++;
	}
      A[j+g]=v;
    }
}

void shellSort(int A[], int n)
{
  for(int h=1; ; )
    {
      if(h>n)
	break;
      G.push_back(h);
      h=3*h+1;
    }
  for(int i=G.size()-1;i>=0;i--)
    {
      insertionSort(A,n,G[i]);
    }
}

int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
      scanf("%d",&A[i]);
  cnt=0;

  shellSort(A,n);

  cout << G.size() << endl;
  for(int i=G.size()-1;i>=0;i--)
    {
      printf("%d",G[i]);
      if(i)
	printf(" ");
    }
  printf("\n");
  printf("%d\n",cnt);
  for(int i=0;i<n;i++)
    printf("%d\n",A[i]);

  return 0;
}
      



Measured memory_bytes: 7156
# -*- coding:utf-8 -*-
"""解説
？進数の計算

 1  0  1 1
-8  4 -2 1
----------
-8 + -2 + 1 = -9

                    1   -2    4    -8      16
1のとき表現できる数  1~1 -2~1  2~5 -10~-3   6~21
0のとき表現できる数  0~1  0~1 -2~1  -2~5  -10~5
                   ----------------------------
                   0~1  -2~1 -2~5 -10~5  -10~21      


(1) -9のときを考える
-9は2で割り切れないので、0bit目は必ず1になる。(※1)

-9を-2進数で表現すると、 

?????1

になるはず。

ということは?????0は-10である。

?????の部分はいくつか？と考えたとき、
一桁減らすので、-2で割るとよい。（-2進数なので。10進数のときは10で割るでしょ？）

よって、?????の部分は5

(2) 5のときを考える
5は2で割り切れないので、0bit目は必ず1になる(※2)

5を-2進数で表現すると、

????1

になる。

ということは????0は4である。

????の部分はいくつか？と考えたとき、
一桁減らすので、-2で割る。

よって、????の部分は-2

(3) -2のときを考える
-2は2で割り切れるので、0bit目は0である。(※3)

-2を-2進数で表現すると、

???0

???の部分はいくつか？と考えたとき、
一桁減らすので、-2で割る。

よって、???の部分は1

(4) 1のときを考える
1は2で割り切れないので、0bit目は1(※4)

1を-2進数で表現すると、

??1

??0は0

??の部分はいくつか？と考えたとき、当然0でしょう。

よって、答えは、
(※4)(※3)(※2)(※1)で、
1011
になる。

この一連の計算を一般化すればよい。

"""
def solve():
    N = int(input())
    ans = ""
    
    if N==0:
        print(N)
        return

    while N!=0:
        if N%2 != 0:
            # 2で割り切れない
            ans = "1" + ans
            N -= 1
            N //= -2
        else:
            ans = "0" + ans
            N //= -2
    
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);











ll fact[1000005];
ll inv[1000005];


inline ll fun(ll x,ll y){
    return mul(mul(fact[x],inv[x-y]),inv[y]);
}

int main(){

    int n;
    cin>>n;
    int g=__gcd(360,n);
    cout<<360/g<<endl;
   
   
   
    
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 3664
#!/usr/bin/env python
# coding: utf-8


def main():
    N, K = list(map(int, input().split()))
    lc = list(map(int, list(input())))
    l, r = 0, 0
    k = 0
    bc = 1
    ret = 0
    for i, c in enumerate(lc):
        if c == 0 and bc == 1:
            if k == K:
                ret = max(ret, i-l)
                c2 = lc[l]
                while c2 == 1 and l < N-1:
                    l += 1
                    c2 = lc[l]
                while c2 == 0 and l < N-1:
                    l += 1
                    c2 = lc[l]
            else:
                k += 1
        bc = c
    ret = max(ret, N-l)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4788
N=int(input())
S=input()
cnt=S.count('R')*S.count('G')*S.count('B')
for i in range(N-2):
    for j in range(i+1, N-1):
        k=2*j-i
        if k<N:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]: cnt-=1
print(cnt)

Measured memory_bytes: 9040
H,W = list(map(int,input().split()))
N = int(input())
A = list(map(int,input().split()))
ans = []
for i,a in enumerate(A,1):
    ans += [i]*a
for i in range(H):
    print(" ".join(map(str,ans[i*W:(i+1)*W][::(-1)**i])))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;
const ll nmax = 100001;

ll n, m; 

ll notop[nmax];
ll h[nmax];

bool dfs(ll v, const graph &G){
    
    for(auto nv : G[v]){
        
      	
        if(h[v]<=h[nv]){
          
          notop[v]++; return false;
        }
        
    }
    return true;
}

int main(){
    cin >> n >> m;
    for(ll i=0; i<n; ++i){cin >> h[i];}

    graph g(n);
    for(ll i=0; i<m; ++i){
        ll a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    
    memset(notop, 0, sizeof(notop));
    ll res = 0; 
    for(ll i=0; i<n; ++i){
        
        if(notop[i]!=0){continue;}
        if(dfs(i, g)){
            res++; 
        } 
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 10656
n=int(input())

nums=list(map(int,input().split()))

nums=sorted(nums)

#print(nums)

center=int((n/2)+1)
ans=center-1
#print(nums[ans])
cnt=(nums[ans]-nums[ans-1]-1)
#print(cnt)

if nums[ans]==nums[ans-1]:
    print("0")
else:
    print(cnt+1)


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

int main(){
	int a, b;
	cin >> a >> b;
	if(a <= 0 && b >= 0){
		cout << "Zero\n";
		return 0;
	}
	if(b > 0){
		cout << "Positive\n";
	} else {
		int c = b-a;
		cout << ((c%2) ? "Positive\n" : "Negative\n");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;

    ll ans = 0;

    ll base = 1e12;
    
    for(ll i = 1; i <=n; ++i){
        ll res = base;

        for(ll j = i; j < k; j*=2)res /= 2;

        ans += res; 
    }
    printf("%.10f", double(ans)/double(n)/double(base));
}

Measured memory_bytes: 3720
# -*- coding: utf-8 -*-
n = int(input())
bl = list(map(int, input().split()))
al = [0]*n

al[0] = bl[0]
al[n-1] = bl[-1]
for i in range(1,n-1):
    al[i] = min(bl[i-1],bl[i])

print(sum(al))

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  cout << ((n % 10 == 9 || n >= 90) ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3580
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 2e3 + 10;
int n;
vector<int> graph[MAXN];
int dist[MAXN];
const int INF = 1e9;
int cnt[MAXN];

void solve(){
    cin>>n;

    int X,Y; cin>>X>>Y;
    graph[X].push_back(Y);
    graph[Y].push_back(X);

    FOR(i,1,n-1){
        graph[i].push_back(i+1);
        graph[i+1].push_back(i);
    }

    int ans = 0;
    FOR(i,1,n){
        FOR(j,1,n) dist[j] = INF;

        dist[i] = 0;
        queue<int> q; q.push(i);

        while(q.size() > 0){
            int top = q.front();
            q.pop();
            for(int v:graph[top]){
                if(dist[v] != INF) continue;
                dist[v] = dist[top] + 1;
                q.push(v);
            }
        }
        
        FOR(j,1,n) cnt[dist[j]]++;
    }

    FOR(i,1,n-1) cout<<cnt[i]/2<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 384
def inpl():
    return list(map(int, input().split()))


S = input()

flag = True
for i in range(len(S)):
    if i % 2 == 0 and S[i] in 'RUD':
        continue
    elif i % 2 == 1 and S[i] in 'LUD':
        continue
    flag = False

print('Yes' if flag is True else 'No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define LLFOR(i, a, b) for(long long i = (a); i < (b); ++i)
#define LLRFOR(i, a, b) for(long long i = (a); i >= (b); i--)
#define SORT(v, n) sort(v, v+n)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define LLREP(i, n) for(long long i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)
#define LLRREP(i, n) for(long long i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T MAX(T a,T b){if(a>b){return a;}return b;}
template <typename T>
inline T MIN(T a,T b){if(a<b){return a;}return b;}
template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
inline int ctoi(char c) {if (c >= '0' && c <= '9') {return c - '0';}return 0;}

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

   int n, a, b, ans = 0;
   cin >> n >> a >> b;

   FOR(i, 1, n+1){
      int sum = 0;
      string str = to_string(i);
      REP(j, str.size()) sum += ctoi(str[j]);
      if(sum >= a && sum <= b) ans += i;
   }

   cout << ans << endl;
   rtn 0;
}

Measured memory_bytes: 256
S=input().replace("BC","D").split("B")
T=[]
for t in S:
    for u in t.split("C"):
        T.append(u)
#print(T)
ans=0
for s in T:
    n=len(s)
    k=0
    for i in range(n):
        if s[i]=="D":
            ans+=(i-k)
            k+=1
print(ans)

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

#define int long long
#define double long double
#define pb push_back
#define pob pop_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
#define Ptest(x) return cout << x << endl, 0;

typedef vector <int> vi;
typedef pair <int, int> ii;
typedef vector <vi > vvi;
typedef vector <ii > vii;

const int N = 2e5 + 5, mod = 1e9 + 7, inf = 1e18 + 7;

int n;
int a[N], l[N], r[N], deq[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	cin >> n;
    for (int i = 1; i <= n; i++){
    	cin >> a[i];
    }
    deq[0] = 0;
    int top = 0;
    for (int i = 1; i <= n; i++){
        while(top > 0 && a[deq[top]] >= a[i]){
			top--;
		}
        l[i] = deq[top] + 1;
        top++;
        deq[top] = i;
    }    
    deq[0] = n + 1;
    top = 0;
    for (int i = n; i >= 1; i--){
        while(top > 0 && a[deq[top]] >= a[i]){
			top--;
		}
        r[i] = deq[top] - 1;
        top++;
        deq[top] = i;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        ans += (i - l[i] + 1) * (r[i] - i + 1) * a[i];
    }
    cout << ans;
}

/*
----------------------------------+
INPUT:                            |
==============================    |
3
1 2
2 3
==============================    |
4
1 2
1 3
1 4
==============================    |
7
1 2
2 3
2 4
4 5
4 6
6 7
==============================    |
----------------------------------+
OUTPUT:                           |
==============================    |
3
7
3
==============================    |
4
15
13
4
==============================    |
7
67
150
179
122
45
7
==============================    |
----------------------------------+
*/

Measured memory_bytes: 6528
import bisect
# ソートしている(a < b < c)として，三角形の存在条件は以下になる
def triangle_check(a, b, c):
    if c < a + b:
        return True
    else:
        return False
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
cnt = 0
for i in range(N - 2):
    for k in range(i + 1, N - 1):
        tmp = bisect.bisect_left(L, L[i] + L[k])
        ans += max(tmp - 1 - k, 0)
print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());

    B[N-1] = A[N-1];
    for(int i=N-2; i>=0; i--) B[i] = B[i+1] + A[i];

    for(int i=0; i<N-1; i++){
        if(A[i] > 2*B[i+1]){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys

stdin = sys.stdin

ni = lambda: int(ns())
nl = lambda: list(map(int, stdin.readline().split()))
nm = lambda: map(int, stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
p = nl()
q = [0]*(n+1)
for i in range(n):
    q[p[i]] = i+1
    
ans = 0
l = [0] + [i for i in range(n+1)]
r = [i+1 for i in range(n+1)] + [n+1]

for i in range(1,n+1):
    v = q[i]
    l1,r1 = l[v],r[v]
    l2,r2 = l[l1],r[r1]
    ans += i*((v-l1)*(r2-r1) + (r1-v)*(l1-l2))
    l[r1] = l1
    r[l1] = r1
  
print(ans)


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

typedef long long ll;
///vector<pair<string, int>>;

int main(){
 ll a, b, c, d;
 cin >> a >> b >> c >> d;
 ll cn, dn, cd, both;
 ll zero =0;
 cn = max(b/c, zero)-max((a-1)/c,zero);  //a~bのうちのcの倍数
 dn = max(b/d, zero)-max((a-1)/d, zero); //a~bのうちのdの倍数
 cd = c * d / gcd(c, d);
 both = max(b/cd,zero)-max((a-1)/cd, zero); //a~bのうちのc*dの倍数
 ll ans = (b - a+1) - (cn + dn - both);
 cout << ans << endl;
}




Measured memory_bytes: 3564
#include <iostream>
#include <vector>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> A(N+10, 0);
    rep (i, 0, N-1) {
        int in; cin >> in;
        ++A[in];
    }

    rrep (i, 1, N) {
        cout << A[i] << endl;
    }
}

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

int main() {
  string a, b;
  cin >> a >> b;

  sort(a.begin(), a.end());
  sort(b.rbegin(), b.rend());

  if (a < b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] A = new int[N];
		int cnt = 0;
		for(int i = 0;i < N;i++) {
			A[i] = Integer.parseInt(sc.next());
			if(A[i]%2!=0) {
				cnt++;
			}
		}
		sc.close();
		StringBuilder sb = new StringBuilder();
		if(cnt%2 == 0) {
			sb.append("YES");
		}else {
			sb.append("NO");
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 49696
#include<bits/stdc++.h>
using namespace std;
long long dp[1005][1005];
char a[1005][1005];
long mod=1000000007;
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h,w;
    memset(dp,0,sizeof(dp));
    cin>>h>>w;
    for (int i = 0; i <h ; ++i) {
        for (int j = 0; j <w ; ++j) {
            cin>>a[i][j];

        }

    }
    for (int l = 1; l <h ; ++l) {
        if (a[l][0]=='.')
        dp[l][0]=1;
        else break;
    }
    for (int k = 1; k <w ; ++k) {
        if (a[0][k]=='.')
        dp[0][k]=1;
        else break;
    }
    for (int m = 1; m <h ; ++m) {
        for (int i = 1; i < w; ++i) {
            if (a[m][i]=='.')
            dp[m][i]=dp[m-1][i]+dp[m][i-1];
            dp[m][i]= dp[m][i]%mod;
        }

    }
    cout<<dp[h-1][w-1]<<endl;


    return 0;
}

Measured memory_bytes: 9088
n,k = map(int,input().split())
num = 0
q = []
for i in range(n):
    a,b = map(int,input().split())
    q.append((a,b))
q.sort()
for i in range(n):
    a, b = q[i][0], q[i][1]
    num += b
    if num >= k:
        print(a)
        exit()



Measured memory_bytes: 54036
fun main(args: Array<String>) {
    val (H,W) = readLine()!!.split(" ").map{ i -> i.toInt() }
    val s = Array(H){readLine()!!.toCharArray()}

    for( h in 0..H-1){
        for( w in 0..W-1){
            print(if(s[h][w]=='#') "#" else count(h,w,s))
        }
        println()
    }
}

fun count(h: Int, w: Int, s: Array<CharArray>): Int {
    var count = 0
    for(i in h-1..h+1){
        if(i < 0 || i >= s.size) continue
        for(j in w-1..w+1){
            if( j < 0 || j >= s[0].size)continue
            if(s[i][j]=='#')count++
        }
    }
    return count
}

Measured memory_bytes: 37484
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	int n;
	ll a[100000];
	cin >> n;
	int num = 1;
	cin >> a[0];
	for(int i=1;i<n;i++){
		ll b;
		cin >> b;
		if(a[num-1]!=b){
			a[num] = b;
			num++;
		}
	}
	int ans = 1;
	for(int i=1;i<num-1;i++){
		if (a[i-1] < a[i] && a[i] > a[i + 1]){
			ans++;
			i++;
		}else if (a[i-1] > a[i] && a[i] < a[i + 1]){
			ans++;
			i++;
		} 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(){
char a[101],b[101],c[101],m,n;
scanf ("%s %s %s",&a,&b,&c);
m=strlen(a);
n=strlen(b);
if(a[m-1]==b[0]&&b[n-1]==c[0]){
	printf("YES");
}
else{
	printf("NO");
}
return 0;
}


Measured memory_bytes: 1704
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef long long i64,ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(l);i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

class Main{
public:
	
	void run(){
		while(true){
			int N;cin >> N;if(N==0)break;
			vector<int> ps(N),js(N-1);
			REP(i,N) cin >> ps[i];
			REP(i,N-1) cin >> js[i];

			sort(ALL(ps));sort(ALL(js));
			
			ll sum=0;REP(i,ps.size())sum+=ps[i];
			ll Mv=0;
			for(int j=0;j<N-1;j++){
				Mv=max(Mv,(N-j)*sum);
				sum+=js[N-2-j];
			}
			Mv=max(Mv,sum);
			
			cout << Mv <<endl;
		}
	}
};

 int main(){
	//ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2010;
const int mod = 1e9 + 7;
int n;
ll dp[N];
ll sum[N];
int main(){
    cin >> n;
    dp[1] = dp[2] = 0;
    dp[3] = dp[4] = dp[5] = 1;
    for(int i = 6;i<=n;i++){
        dp[i] = 1;
        for(int j = 3;j<=i-3;j++){
            dp[i] = (dp[i] + dp[j]) % mod;
           
        }
    }
    // for(int i = 1;i<=n;i++){
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
typedef long long ll;
const int mod=1e9+7;
const int N=2e5+5;
ll po(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod,b>>=1;
	}
	return ans;
}
ll inv(ll x){return po(x,mod-2);}
ll jc[N<<1],jcinv[N<<1];
inline ll c(ll a,ll b)
{return jc[a]*jcinv[b]%mod*jcinv[a-b]%mod;}



int n;
struct Edge{
	int nxt,to;
}e[N<<1];
int cnt=1,head[N];
void inline add(int u,int v)
{
	e[cnt]={head[u],v};
	head[u]=cnt++;
}

ll sz[N];//子树大小
ll f[N];//走完子树的方法数
ll ans[N];
void dfs1(int u,int fa)
{
	f[u]=1;
	for(int i=head[u];i;i=e[i].nxt)
	{
		int v=e[i].to;
		if(v==fa) continue;
		dfs1(v,u);
		sz[u]+=sz[v];
		f[u]=f[u]*c(sz[u],sz[v])%mod*f[v]%mod;
	}
	sz[u]++;
}
void dfs2(int u,int fa,ll ffa)
{
	ans[u]=f[u]*c(n-1,n-sz[u])%mod*ffa%mod;
	for(int i=head[u];i;i=e[i].nxt)
	{
		int v=e[i].to;
		if(v==fa) continue;
		dfs2(v,u,f[u]*inv(f[v])%mod*inv(c(sz[u]-1,sz[u]-sz[v]-1))%mod*ffa%mod*c(n-sz[v]-1,n-sz[u])%mod);
	}
}

int main()
{
	jc[0]=jcinv[0]=jc[1]=jcinv[1]=1;
	for(int i=2;i<(N<<1);i++)
	{
		jc[i]=jc[i-1]*i%mod;
		jcinv[i]=po(jc[i],mod-2);
	}
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	dfs1(1,0);
	dfs2(1,0,1);
	for(int i=1;i<=n;i++)
	{
		printf("%lld\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 18176
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
int modpow(int x, int k, int MOD) {
  int a = 1;
  while (k) {
    if (k&1) a = (1LL*a*x)%MOD;
    x = (1LL*x*x)%MOD;
    k>>=1;
  }
  return a;
}
const int NUM = 5;
const int B = 3213212;
const vector<int> hashes = {
  1000000007,
  1000000009,
};
struct Hash {
  vector<int> data;
  Hash(int x) {
    data.resize(hashes.size(), x);
  }
  Hash() {
    data.resize(hashes.size(), 0);
  }
};
Hash add(Hash a, int b) {
  rep(i, hashes.size()) a.data[i] = (0LL+a.data[i]+b) % hashes[i];
  return a;
}
Hash add(Hash a, Hash b) {
  rep(i, hashes.size()) a.data[i] = (0LL+a.data[i]+b.data[i]) % hashes[i];
  return a;
}
Hash mul(Hash a, Hash b) {
  rep(i, hashes.size()) a.data[i] = (1LL*a.data[i]*b.data[i]) % hashes[i];
  return a;
}
Hash inv(Hash a) {
  Hash ret;
  rep(i, hashes.size()) ret.data[i] = modpow(a.data[i], hashes[i]-2, hashes[i]);
  return ret;
}


int N;
string S;
Hash pB[500001];
Hash memo[250000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  pB[0] = Hash(1);
  for (int i=1; i<=500000; i++) pB[i] = mul(pB[i-1], B);
  Hash minus1;
  rep(i, hashes.size()) minus1.data[i] = hashes[i]-1;

  cin >> N >> S;
  int p = 250000;
  Hash hash(0);
  map<vector<int>, int> mp;
  rep(i, N) {
    if (S[i] == '+') hash = add(hash, pB[p]);
    if (S[i] == '-') hash = add(hash, mul(pB[p], minus1));
    if (S[i] == '>') p++;
    if (S[i] == '<') p--;
    memo[i] = hash;
    mp[hash.data]++;
  }

  const Hash ONE = pB[250000];
  Hash invB = inv(B);
  long long sum = 0;

  Hash a(1), b(0); // h -> h*a+b
  rep(l, N) {
    Hash h = add(mul(hash, a), b);
    sum += mp[h.data];

    if (S[l] == '+') b = add(b, mul(a, ONE)); // all -= ONE
    if (S[l] == '-') b = add(b, mul(a, mul(ONE, minus1))); // all += ONE
    if (S[l] == '>') a = mul(a, B); // all /= B
    if (S[l] == '<') a = mul(a, invB); // all *= B
    mp[memo[l].data]--;
  }
  cout << sum << "\n";
  return 0;
}


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

using namespace std;

int main(){
	string message = "No";
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(a-b) <= d && abs(b-c) <= d){
		message = "Yes";
	}
	if(abs(a-c) <= d){
		message = "Yes";
	}

	cout << message << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

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

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    fastio;
    ll n,k,c;cin>>n>>k>>c;
    string s;cin>>s;
    vector<int> v,vv;
    rep(i,0,n)if(s[i]=='o')v.pb(i+1),vv.pb(-i-1);
    reverse(all(vv));
    set<int> ss;
    int cur=0;
    bool cant=0;
    int SZ=v.size();
    int sz=ss.size();
    while(sz<k)
    {
        //cout<<sz<<endl;for(auto x:ss)cout<<x<<" ";cout<<endl;
        int lst=cur;
        if(sz<k)
        {
            ss.insert(v[cur]);//cout<<"****************"<<v[cur]<<endl;
            cur=lower_bound(all(v),v[cur]+c+1)-v.begin();
        }
        if(sz==k || cur==SZ)break;
    }
    set<int> sss;
    cur=0;
    sz=sss.size();
    while(sz<k)
    {
        int lst=cur;
        if(sz<k)
        {
            sss.insert(-vv[cur]);//cout<<"****************"<<vv[cur]<<endl;
            cur=lower_bound(all(vv),vv[cur]+c+1)-vv.begin();
        }
        if(sz==k || cur==SZ)break;
    }
    int sz1=ss.size(),sz2=sss.size();
    if(sz1==k && sz2==k)
    {
        for(auto x: ss)
            if(sss.count(x))cout<<x<<endl;
    }
}


Measured memory_bytes: 22024
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

const int MAX=1e6;
vector<pll>g[MAX];
bool vis[MAX];
int ans[MAX];
void dfs(pll u){
    vis[u.ft]=true;
    for(auto &x:g[u.ft]){
        if(!vis[x.ft]){
            if(x.sd%2==0){
                ans[x.ft]=ans[u.ft];
            }else{
                ans[x.ft]=!ans[u.ft];
            }
          dfs(x);
        }
    }
}
int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

int a,b;
cin>>a>>b;
if(a<=5){
    cout<<0<<endl;
}else if(a>=6 && a<=12){
    cout<<b/2<<endl;
}else{
    cout<<b<<endl;
}
}


Measured memory_bytes: 27064
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int aa[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>aa[i];
  sort(aa+1,aa+n+1);
  
  long sm=0;
  for(int i=1;i<=n-k;i++)sm+=aa[i];
  cout<<sm<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    ll a[2*n],candy[n];
    for(i=0;i<n;i++){
        candy[i]=0;   
    }
    for(i=0;i<2*n;i++){
        scanf("%lld",&a[i]);
        if(i<n) candy[n-1]+=a[i];
        if(i==2*n-1) candy[n-1]+=a[i];
    }
    for(i=n-2;i>=0;i--){
        candy[i]=candy[i+1]+a[n+i]-a[i+1];
    }
    // for(i=0;i<n;i++){
    //     printf("%lld ",candy[i]);
    // }
    qsort(candy,n,sizeof(ll),compare);
    printf("%lld\n",candy[n-1]);
    return 0;
}


Measured memory_bytes: 128
//
// ABC121C
//
//

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<long long, long long> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

int main() {
    int N,M;
    cin >> N >> M;

    vector<pair_t> mp(N);
    long long A,B;
    vector<long long> av2(N), bv2(N);
    for (int i = 0; i < N; i++) {
    	cin >> A >> B;
      mp[i] = make_pair(A, B);
		}
    sort(mp.begin(), mp.end(), comp);
    for (int i = 0; i < N; i++) {
      av2[i] = mp[i].first;
      bv2[i] = mp[i].second;
   }
//   for (int i =0; i<N; i++) {
//  	 cout << av2[i] << "-" << bv2[i] << endl;
//   }

   long long cost=0;
   long long m =M;
   for (int i =0; i <N; i++) {
   	 if(bv2[i]>= m) {
       cost = cost + av2[i] * m;
//       cout << av2[i] << "*" << m << endl;;
       break;
     } else {
       cost = cost + av2[i] * bv2[i];
       m = m - bv2[i];
 //      cout << av2[i] * bv2[i] << endl;
     }
   }
		cout << cost << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n];
	int i,j;
	for(i=0;i<n;i++)
		cin>>a[i];
	long long dp[n][n][2];
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			int k = j+i;
			if(k>n-1)
				continue;
			if(j==k)
			{
				dp[j][k][0] = a[j];
				dp[j][k][1] = -a[j];
			}
			else
			{
				dp[j][k][0] = max(a[j]+dp[j+1][k][1],a[k]+dp[j][k-1][1]);
				dp[j][k][1] = min(-a[j]+dp[j+1][k][0],-a[k]+dp[j][k-1][0]);				
			}
		}
	}
	cout<<dp[0][n-1][0];
	return 0;

}


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

int main() {
  string S,T;
  cin >> S >> T ;
  int A ,B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S){
    cout << A-1<< " " << B;
  }else{
    cout << A << " "<< B-1;
  }
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = [[i, "r"] for i in p]
green = [[i, "g"] for i in q]
white = [[i, "w"] for i in r]

total = sorted(red + green + white)[::-1]

ans = 0
cnt = 0
r_cnt = 0
g_cnt = 0
for t in total:
    if t[1] == "r" and r_cnt == X:
        continue
    if t[1] == "g" and g_cnt == Y:
        continue
    ans += t[0]
    if t[1] == "r":
        r_cnt += 1
    elif t[1] == "g":
        g_cnt += 1
    cnt += 1
    if cnt == X + Y:
        break

print(ans)

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

vector<ll> vec;

void dfs(ll x){
  if(x<1e11){
    vec.push_back(x*10+7);
    dfs(x*10+7);
    vec.push_back(x*10+5);
    dfs(x*10+5);
    vec.push_back(x*10+3);
    dfs(x*10+3);
  }
}
bool wh(ll x){
  int a=0,b=0,c=0;
  while(x>0){
    if(x%10==7){
      a++;
    }
    if(x%10==5){
      b++;
    }
    if(x%10==3){
      c++;
    }
    x/=10;
  }
  if(a>0&&b>0&&c>0){
    return true;
  }
  else{
    return false;
  }
}
  
int main(){
  vec.push_back(0);
  dfs(0);
  sort(vec.begin(),vec.end());
  ll n;
  cin>>n;
  int ans=0;
  for(int i=0;i<vec.size();i++){
    if(vec[i]>n){
      break;
    }
    if(wh(vec[i])==true){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 10604
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

bool veq(vector<int> a, vector<int>b){
    rep(i,0,sz(a)-1){
        if(a[i] != b[i])return false;
    }
    return true;
}

int main(){
    int a,b,n;
    cin >> n;
    vector<int> p(n),q(n),c(n);
    rep(i,0,n-1)cin >> p[i];
    rep(i,0,n-1)cin >> q[i];
    rep(i,0,n-1)c[i] = i+1;
    int count = 1;
    do{
        if(veq(c,p)) a = count;
        if(veq(c,q)) b = count;
        count++;
    }while(next_permutation(c.begin(),c.end()));

    int ans = abs(a-b);

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * 800 - n / 15 * 200;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int n,i;
	int min = 1000000;
	int max = -1000000;
	long long int sum = 0;
	int a[10000];
	
	scanf("%d\n",&n);

	for (i = 0; i < n; i++) {
		scanf("%d ", &a[i]);

		sum += a[i];

		if (min > a[i]) {
			min = a[i];
		}

		if (max < a[i]) {
			max = a[i];
		}
		
	}

	printf("%d %d %lld\n", min, max, sum);
	
	return(0);

}


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

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define sz(x) int((x).size())
#define fi first
#define se second

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))
#define mp(a,b) make_pair(a,b)

// useful bits
#define IN(i,l,r) (i >= l && i <= r);
#define relax(a,b) a = max(a,b);
#define relaxi(a,b) a = min(a,b);

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) 
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(0, i)(rng)



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
//	freopen("output.txt", "w" , stdout);
	/* freopen("in.txt" , "r" , stdin); */
	/* clock_t start = clock(); */
	#endif
	int a, b;
	cin >> a >> b;
	int ans = 0;
	ans += a > b? a--: b--;
	ans += a>b? a--:b--;
	cout << ans << endl;

	#ifndef ONLINE_JUDGE
	/* cout << setprecision(12) << ld(clock()-start) / CLOCKS_PER_SEC << endl; */
	#endif
	return 0;
}



Measured memory_bytes: 256