akhauriyash/Code-Regression huggingface dataset:
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
	



int main(){
   IOS

   
   ll N; cin>>N;

	ll ans = 0;

   
	for(ll i = 1; i * i <= N; i++){
		if(N%i == 0){
			if(i == 2)ans++;
			else if(i != 1){
				ll x = N;
				while(!(x%i)){
					x/=i;
				}
				if(x % i == 1)ans++;
			}
		}
	}
	ans++;	//For k = N;

	N--;

	for(ll i = 1; i * i <= N; i++){
		if(N%i == 0){
			if(i != 1)ans++;
			if(i != N/i)ans++;
		}
	}

	cout<<ans<<"\n";








}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
	if(b&1)
		res = res * a % mod;
		a = a * a % mod;
	b >>= 1;
	}

	return res;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
const int MOD = 1000000007;
int main() {
  long long dp[100005][13];
  char s[100005];
  scanf("%s", s);
  int n = strlen(s);

  dp[0][0] = 1;
  rep(i, n) {
    int c;
    if(s[i] == '?') c = -1;
    else c = s[i] - '0';

    rep(j, 10) {
      if(c != -1 && c != j) continue;
      rep(k, 13) {
        dp[i+1][(k * 10 + j) % 13] += dp[i][k];
      }
    }

    rep(j, 13) {
      dp[i+1][j] %= MOD;
    }
  }

  cout << dp[n][5] << endl;
}

Measured memory_bytes: 10496
#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 if(a==b)cout<<"a == b"<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3104
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        for _ in range(num): return []
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list,zip(*read_all))

#################

#強連結成分分解
#label：グループ数
#group[i]：i個目のノードが所属するグループ
def scc(N, G, RG):
    used = [False]*N
    group = [None]*N
    order = []
    def dfs(S):
        i_order = []
        temp_order = []
        level = 0
        while S:
            v1 = S.pop()
            if used[v1[0]]:
                continue
            if v1[1]<level:
                for _ in range(len(temp_order)-v1[1]):
                    x = temp_order.pop()
                    i_order.append(x)
                level = v1[1]
            level += 1
            if not used[v1[0]]:
                for v1_to in G[v1[0]]:
                    if not used[v1_to]:
                        S.append((v1_to,level))
                temp_order.append(v1[0])
                used[v1[0]] = True
        for t in reversed(temp_order):
            i_order.append(t)
        return i_order
    for i in range(N):
        if not used[i]:
            i_order = dfs([(i,0)])
            order += i_order
    def rdfs(S,col):
        used[S[0]] = True
        while S:
            v1 = S.pop()
            for v1_to in RG[v1]:
                if not used[v1_to]:
                    used[v1_to] = True
                    S.append(v1_to)
            group[v1] = col
    used = [False]*N
    label = 0
    for s in reversed(order):
        if not used[s]:
            rdfs([s], label)
            label += 1
    return label, group

N,M = II()
X,Y,Z = Line(M,3)
 
graph = [[] for _ in range(N)]
for i in range(M):
    graph[X[i]-1].append(Y[i]-1)
    graph[Y[i]-1].append(X[i]-1)
    
label,group = scc(N,graph,graph)
print(label)

Measured memory_bytes: 87260
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
int N, M, K;
vector<int> A, B;
string S;
void input() {
  int i, j, k, x, y;
  ;
  cin >> S;
}
void solve() {
  ;
  int state = 0;
  char a = 'A', k = 'K', h = 'H', b = 'B', r = 'R', i = 'I';
  for (auto x : S) {
    switch (state) {
      case 0:
        if (x == a) {
          state = 1;
          break;
        }
        if (x == k) {
          state = 2;
          break;
        }
        state = 100;
        break;
      case 1:
        if (x == k) {
          state = 2;
          break;
        }
        state = 100;
        break;
      case 2:  // AK
        if (x == i) {
          state = 3;
          break;
        }
        state = 100;
        break;
      case 3:  // AKI
        if (x == h) {
          state = 4;
          break;
        }
        state = 100;
        break;
      case 4:  // AKIH
        if (x == a) {
          state = 5;
          break;
        }
        if (x == b) {
          state = 6;
          break;
        }
        state = 100;
        break;
      case 5:  // AKIHA
        if (x == b) {
          state = 6;
          break;
        }
        state = 100;
        break;
      case 6:  // AKIHAB
        if (x == a) {
          state = 7;
          break;
        }
        if (x == r) {
          state = 8;
          break;
        }
        state = 100;
        break;
      case 7:  // AKIHABA
        if (x == r) {
          state = 8;
          break;
        }
      case 8:  // AKIHABAR
        if (x == a) {
          state = 9;
          break;
        }
        state = 100;
        break;
      case 9:
        state = 100;
        break;
      case 100:
        break;
      default:
        break;
    }
  };

  if (state == 9 || state == 8) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int gcd(int a, int b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main(){
	int n,X; cin >> n >> X;
	vector<int> xv;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		xv.push_back(x);
	}
	xv.push_back(X);
	sort(xv.begin(), xv.end());

	int ans = xv[1] - xv[0];
	for(int i = 2; i < n + 1; i++){
		ans = gcd(xv[i] - xv[i-1],ans);
	}
	cout << ans << endl;

}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int t[N],v[N];
  //  const int tmax=20010;
  const int vmax=103;
  double dp[vmax*2];
  double ndp[vmax*2];
  
  rep(i,N){ cin >> t[i];  }
  rep(i,N) cin >> v[i];
  rep(i,vmax*2){
    dp[i]=-100000.;
  }
    dp[0]=0.;    
  rep(i,N){
    rep1(j,t[i]*2){
      rep(i,vmax*2) ndp[i]=-100000.;
      ndp[0]=max(dp[1]+0.125,dp[0]);	    
      rep1(k,v[i]*2){
	if(dp[k+1]!=-100000.&& k+1<=v[i]*2) ndp[k]=dp[k+1]+(k)/2.*0.5+0.125;
	if(dp[k]!=-100000.) ndp[k]=max(dp[k]+(k)/2.*0.5,ndp[k]);
	if(dp[k-1]!=-100000.){
	  ndp[k]=max(dp[k-1]+(k)/2.*0.5-0.125,ndp[k]);
	}
      }
      //      cout << ndp[v[i]*2] << endl;
      swap(dp,ndp);
    }
  }
  std::cout << std::fixed;
  std::cout << std::setprecision(4) <<  dp[0] << endl;
  return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;


int main()
{
   ll a,b,c,k;
   scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
   if(k&1)
    cout<<b-a<<endl;
   else cout<<a-b<<endl;

    return 0;
}




Measured memory_bytes: 256
from collections import Counter
N, M = map(int, input().split())
A = list(map(int, input().split()))

def gcd(x, y):
    '''
    最大公約数の計算
    '''
    if y == 0:
        return x
    return gcd(y, x % y)

def lcm(x, y):
    '''
    最小公倍数の計算
    '''
    return (x * y) // gcd(x, y)

nlcm = 1
for a in A:
    nlcm = lcm(a, nlcm)
judge = True
for a in A:
    half = nlcm // 2
    if half % a != a // 2:
        judge = False
        break
if judge:
    # 存在するパターン
    print((M+nlcm//2)//nlcm)
else:
    print(0)


Measured memory_bytes: 63856
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 15;
const int M = 500;
const int MOD = 1e9 + 7;
const int alpha = 26;

int n, m;
int a[M], b[M], c[M];
int cp[N][N];
int sub[(1 << N)];
int dp[N][(1 << N)];

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n >> m;
    int si = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cp[i][j] = -1e9;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
        cp[a[i]][b[i]] = c[i];
        cp[b[i]][a[i]] = c[i];
        si += c[i];
    }
    for (int mask = 0; mask < (1 << n); mask++)
    {
        for (int i = 0; i < n; i++) dp[i][mask] = -1e9;
        for (int i = 0; i < m; i++)
        {
            if ((1 << a[i]) & mask && (1 << b[i]) & mask)
            {
                sub[mask] += c[i];
            }
        }
        if (mask & 1)
        {
            dp[0][mask] = sub[mask];
        }
    }
    for (int mask = 0; mask < (1 << n); mask++)
    {
        for (int lst = 0; lst < n; lst++)
        {
            if (dp[lst][mask] >= 0)
            if ((1 << lst) & mask)
            for (int upmask = mask; upmask < (1 << n); upmask = (upmask + 1) | mask)
            {
                int adds = upmask - mask;
                for (int lst2 = 0; lst2 < n; lst2++)
                {
                    if ((1 << lst2) & adds)
                    {
                        dp[lst2][upmask] = max(dp[lst2][upmask], dp[lst][mask] + cp[lst][lst2] + sub[adds]);
                    }
                }
            }
        }
    }
    cout << si - dp[n - 1][(1 << n) - 1];
}


Measured memory_bytes: 2304
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define mod 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
    return (x&(-x));
}
const int MOD = 2019;
void solve(){
    string s; cin>>s;
    ll n = s.size();
    ll suffix=0;
    int power_of_ten = 1;
    map<int,int> cur_suffix;
    ll ans=0;
    cur_suffix[suffix]++;
    for(ll i=n-1;i>=0;i--)
    {
        int digit = s[i]-'0';
        suffix = (suffix + digit*power_of_ten)%MOD;
        power_of_ten = (10*power_of_ten)%MOD;
        ans+=cur_suffix[suffix];
        cur_suffix[suffix]++;
    }
    cout<<ans;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
        solve();
    }
}

Measured memory_bytes: 3728
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string S;
ll N,ans=0;

int main(){
    cin>>S;
    N = S.length();
    ll now=N-1;
    for(int i=N-i;i>=0;i--){
        if(S[i]=='B'){
            ans+=now-i;
            now--;
        }
    }
    out(ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int ans=0;
    int m=0;
    int tmp=0;
    
    cin >> n;
    
    vector<int> a(n);
    
    for(int i=0; i<=n-1; i++){
        
        cin >> a[i];
        
    }
    
    sort(a.begin(), a.end());
    
    for(int i=0; i<=n-1; i++){
        
        if(m!=a[i]){
            
            ans += 1;
            m = a[i];
            tmp = 1;
            
        } else {
            
            tmp += 1;
            
            if(tmp%2==0){
                
                ans -= 1;
                
            } else {
                
                ans += 1;
                
            }
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 640
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
using namespace std;
const int inf=2e9;
int n=1407,k=38;
int main()
{
//	freopen("output.txt","w",stdout);
	cout<<n<<" "<<k<<endl;
	for (int i=0;i<k;i++)
	{
		cout<<1<<" ";
		for (int j=0;j<k-1;j++)
		{
			cout<<j+2+(k-1)*i;
			if (j!=k-2)
			{
				cout<<" ";
			}
		}
		cout<<endl;
	}
	for (int i=0;i<k-1;i++)
	{
		for (int j=0;j<k-1;j++)
		{
			cout<<i+2<<" ";
			for (int p=1;p<k;p++)
			{
				cout<<(p*i+j)%(k-1)+2+(k-1)*p;
				if (p!=k-1)
				{
					cout<<" ";
				}
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn=100;
int x,y,d[105][105],f[105][105];
int main()
{
    scanf("%d%d",&x,&y);
    for (int i=1;i<=x;++i)
        for (int j=1;j<=y;++j)
            scanf("%d",&d[i][j]);
    for (int a=0;a<=maxn;++a)
        for (int b=0;b<=maxn;++b)
            for (int i=1;i<=x;++i)
                for (int j=1;j<=y;++j)
                    f[a][b]=max(f[a][b],d[i][j]-a*i-b*j);
    for (int i=1;i<=x;++i)
        for (int j=1;j<=y;++j) {
            int dis=10000000;
            for (int a=0;a<=maxn;++a)
                for (int b=0;b<=maxn;++b)
                    dis=min(dis,f[a][b]+a*i+b*j);
            if (dis!=d[i][j]) return 0*puts("Impossible");
        }
    puts("Possible");
    printf("%d %d\n",maxn+maxn+2,maxn+maxn+(maxn+1)*(maxn+1));
    for (int i=1;i<=maxn;++i) printf("%d %d X\n",i,1+i);
    for (int i=1;i<=maxn;++i) printf("%d %d Y\n",maxn+1+i,maxn+2+i);
    for (int i=1;i<=maxn+1;++i)
        for (int j=1;j<=maxn+1;++j)
            printf("%d %d %d\n",i,maxn+maxn+3-j,f[i-1][j-1]);
    printf("%d %d\n",1,maxn+maxn+2);
    return 0;
}


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

#define MAX 100005
#define NIL -1

class Node{
    public:
    int p,l,r,d;
};

Node T[MAX];
int n;

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << T[u].d << ", ";

    if(T[u].p == NIL) cout << "root, ";
    else if(T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    int i,c;
    for(i = 0, c = T[u].l;c != NIL;i++, c = T[c].r){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u,int p){
    T[u].d = p;
    if(T[u].r != NIL) rec(T[u].r,p);
    if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(int argc, char const *argv[])
{
    int v,d,l,r,c;
    cin >> n;

    for(int i = 0;i < n;i++) T[i].p = T[i].l = T[i].r = T[i].d = NIL;

    for(int i = 0;i < n;i++){
        scanf("%d %d",&v,&d);
        //cin >> v >> d;

        for(int j = 0;j < d;j++){
            scanf("%d",&c);
            //cin >> c;
            if(j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }

    for(int i = 0;i < n;i++){
        if(T[i].p == NIL) r = i;
    }

    rec(r,0);

    for(int i = 0;i < n;i++) print(i);

    return 0;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int ab, bc, ca;

int main(void) {
  // Here your code !
  scanf("%d %d %d", &ab, &bc, &ca);

  printf("%d\n", ab * bc / 2);

  return 0;
}


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

int main()
{
    int N, A, B;
    int p1, p2;

    cin >> N >> A >> B;
    p1 = A * N;
    p2 = B;

    if (p1 >= p2)
    {
        cout << p2 << endl;
    }
    else
    {
        cout << p1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define eb emplace_back
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int a[n] = {0};
    for(int i=0;i<m;i++)
    {
        int x, y;
        cin >> x >> y;
        a[x-1]++;
        a[y-1]++;
    }
    for(int i=0;i<n;i++)
        cout << a[i] << '\n';
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
void solve();
int main()
{
    solve();
    /*
    int n;
    string s;
    cin >> n >> s;
    regex re("ABC");
    smatch m;
    int count = 0;
    while (regex_search(s, m, re)) {
        count++;
        s = m.suffix();
    }
    cout << count << endl;
    return 0;
    */
}

void solve()
{
    int n;
    string s;
    cin >> n >> s;
    string ptn = "ABC";
    int ans = 0;
    for (int i = 0; i < n-2; i++){
        if (s.substr(i, 3) == ptn) ans++;
    }
    cout << ans << endl;
}

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


int main(){
    string s;cin>>s;
    rep(i,0,s.size()){
        cout<<'x';
    }
    cout<<endl;
}

    









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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

const int INF = 1001001001;
int cnt[1005][1005];
char s[1005][1005];
int h, w;

void bfs(P p, int c, queue<P> &sq) {
  queue<P> q;
  q.push(p);
  sq.push(p);
  cnt[p.first][p.second] = c;
  while (!q.empty()) {
    P u = q.front();
    q.pop();
    rep(i, 4) {
      int ni = u.first + dy[i];
      int nj = u.second + dx[i];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (cnt[ni][nj] != INF) continue;
      cnt[ni][nj] = c;
      q.push({ni, nj});
      sq.push({ni, nj});
    }
  }
}

void skip(queue<P> &sq, int c) {
  queue<P> tmp(sq);
  queue<P> clear;
  swap(sq, clear);
  while (!tmp.empty()) {
    auto u = tmp.front();
    tmp.pop();
    for (int dy = -2; dy <= 2; ++dy) {
      for (int dx = -2; dx <= 2; ++dx) {
        int ni = u.first + dy;
        int nj = u.second + dx;
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        if (cnt[ni][nj] != INF) continue;
        cnt[ni][nj] = c;
        sq.push({ni, nj});
      }
    }
  }
}

int main() {
  cin >> h >> w;
  P c, d;
  cin >> c.first >> c.second, --c.first, --c.second;
  cin >> d.first >> d.second, --d.first, --d.second;
  rep(i, h) rep(j, w) cin >> s[i][j];

  rep(i, 1005) rep(j, 1005) cnt[i][j] = INF;

  int e = 0;
  queue<P> sq;
  sq.push(c);
  while (!sq.empty() && cnt[d.first][d.second] == INF) {
    queue<P> tmp(sq);
    queue<P> clear;
    swap(sq, clear);
    while (!tmp.empty()) {
      P u = tmp.front();
      tmp.pop();
      bfs(u, e, sq);
    }
    ++e;
    skip(sq, e);
  }

  int ans = cnt[d.first][d.second];
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, x, a, t = 0, ans = 1;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> a;
    t += a;
    if (t <= x) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan =  new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int k = scan.nextInt();
		
		for(int i=0;i<k;i++) {
			if(a>=b) {
				b = b*2;
			}else if(b>=c){
				c = c*2;
			}
		}
		
		if(a<b && b<c && a<c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


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

int main(){
  int N,res,even;
  cin >> N;
  long a[N];
  res = 0;
  even = 0;
  
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(a[i]%2==0){
      even = even + 1;
      if(a[i]%3==0|a[i]%5==0){
        res = res + 1;
      }
    }
  }
  
  if(even==res){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
  
  return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a.at(i);
	int ans = 0;
	int count = 1;
	rep(i, N - 1) {
		if (a.at(i) == a.at(i + 1)) count++;
		else {
			ans += count / 2;
			count = 1;
		}
	}
	ans += count / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

MAX_N = 110000

N = iin()

dp = [10**10 for _ in range(MAX_N)]
dp[0] = 0

for i in range(1, N+1):
    pow6 = 1
    while pow6 <= i:
        dp[i] = min(dp[i], dp[i-pow6]+1)
        pow6 *= 6
    pow9 = 1
    while pow9 <= i:
        dp[i] = min(dp[i], dp[i-pow9]+1)
        pow9 *= 9
print(dp[N])


Measured memory_bytes: 72044
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)
//string 変数　　変数.size()で数字化


int main(void)
{
	int ball, col;
	cin >> ball >> col;
	long long a = col;
	col--;
	for (int i = 0; i < ball - 1; i++) {
		a *= col;
	}
	cout << a << endl;

}

Measured memory_bytes: 256
from collections import Counter

mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

s = ['SUN', 'MON','TUE','WED','THU','FRI','SAT']

def main():
    n, m = map(int, input().split())
    s = input()
    s = list(reversed(s))
    i = 0
    ans = []
    while i < n:
        next = i
        for j in range(i+1, min(i+m+1, n+1)):
            if s[j] == '0':
                next = j
        if next == i:
            print(-1)
            return
        ans.append(next-i)
        i = next
    print(' '.join(str(i) for i in reversed(ans)))
main()


Measured memory_bytes: 54068
#include <stdio.h>
#define N 10000
#define Q 500
 
int main(){
  
  int i,j,c=0,n,q;
  int S[N],T[Q];
   
  scanf("%d",&n);  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
   
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){ //n>q
	c++;
	break;
      }
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 640
{-# OPTIONS_GHC -O2 #-}
import Control.Applicative
import Data.List
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BS
import Data.Maybe (fromJust)

f :: [Int] -> Int
f xs = length $ filter (== True) $ zipWith (==) (zipf xs) (zipf $ tail xs)
    where zipf xs = zipWith (<) xs (tail xs)

main :: IO()
main = interact $ show.f.map read.words.last.lines


Measured memory_bytes: 508
k, n = map(int, input().split())
dat = list(map(int, input().split()))
d = []
c = dat[0]
for i in range(n):
    d.append(dat[i] - c)
    c = dat[i]
d.append(k - dat[-1] + dat[0])
d.sort(reverse=True)
#print(d)
print(sum(d[1:]))

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

using namespace std;
using lint = long long;

int main() {
    lint H, W;
    cin >> H >> W;

    lint ans;
    if (H == 1 or W == 1) {
        ans = 1;
    } else {
        ans = (H * W + 1) / 2;
    }

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


Measured memory_bytes: 256
while True:
    i = list(map(int, input().split()))
    if i[0] == 0 and i[1] == 0:
        break
    else:
        for j in range(i[0]):
            for k in range(i[1]):
                if j == 0 or j == i[0]-1:
                    print("#", end='')
                elif k == 0 or k == i[1]-1:
                    print("#", end='')
                else:
                    print(".", end='')
            print("\n", end='')
        print("\n", end='')


Measured memory_bytes: 7020
#include <cstdio>
#include <ctype.h>
#define DEBUG
const int bufSize = 1e6;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize],*p1 = buf,*p2 = buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,bufSize,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    r=0;
    for(c = nc();!isdigit(c);) c = nc();
    for(;isdigit(c);c=nc()) r = r * 10 + c - 48;
    return r;
}
const int maxn = 2e7 + 100;
char s[maxn];
int n;
int f1[maxn],f2[maxn];
inline int popcount(int x)
{
    int ans = 0;
    while(x) ans += x & 1,x>>=1;
    return ans;
}
inline int opt(int x)
{
    int ans = 0;
    while(x) x %= popcount(x),++ans;
    return ans;
}
int main()
{
    read(n);
    scanf("%s",s + 1);
    int t = 0,t1 = 0,t2 = 0;
    for(int i = 1;i<=n;++i) t += (s[i] == '1');
    t1 = t + 1,t2 = t - 1;
    f1[n] = f2[n] = 1;
    for (int i = n - 1; i; --i) 
    {
        f1[i] = (f1[i + 1] * 2) % t1;
        if(t2 != 0) f2[i] = (f2[i + 1] * 2) % t2;
    }
    int temp1 = 0,temp2 = 0;
    for(int i = 1;i<=n;++i)
    {
        temp1 <<= 1,temp2 <<= 1;
        temp1 += s[i] - 48,temp1 %= t1;
        if(t2 != 0) temp2 += s[i] - 48,temp2 %= t2;
    }
    for (int i = 1; i <= n; ++i)
    {
        if(s[i] == '1')
        {
            if(t2 == 0)
            {
                printf("0\n");
                continue;
            }
            int val = ((temp2 - f2[i]) % t2 + t2) % t2;
            printf("%d\n",opt(val) + 1);
        }
        else 
        {
            int val = (temp1 + f1[i] + t1) % t1;
            printf("%d\n",opt(val) + 1);
        }
    }
    return 0;
}

Measured memory_bytes: 3500
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >>A >> B;
  cout << A*B/gcd(A,B) << endl;

}


Measured memory_bytes: 256
r,c=map(int,input().split())
lst=[]
for i in range(r):
    lst.append(list(map(int,input().split())))
for j in range(r):
    a=0
    for k in range(c):
        a+=lst[j][k]
    lst[j].append(a)
lst2=[]
for l in range(c+1):
    b=0
    for n in range(r):
        b+=lst[n][l]
    lst2.append(b)
lst.append(lst2)

for m in range(r+1):
    for o in range(c+1):
        if o==c:
            print(lst[m][o])
        else:
            print(lst[m][o],end=" ")


Measured memory_bytes: 6224
from functools import lru_cache
import sys
sys.setrecursionlimit(10**6)
n=int(input())
@lru_cache(None)
def solve(n):
    
    if n==0:
        return 0
    if n==1:
        return 1
    ans=n
    cur=6
    while cur<=n:
        ans=min(ans,1+solve(n-cur))
        cur*=6
    cur=9
    while cur<=n:
        ans=min(ans,1+solve(n-cur))
        cur*=9
    return ans
print(solve(n))


Measured memory_bytes: 46564
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	m = n-1
	r = 1
	while 26^r<=m
		m -= 26^r
		r += 1
	end
	a = zeros(Int,r)
	for i in 0:r-1
		a[i+1] = div(m,26^i)%26
	end
	for i in 0:r-1
		print(Char(97+a[r-i]))
	end
	println("")
end

main()

Measured memory_bytes: 158140
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){

    int N,X[200010]={},c,tmp,Y[200010]={};

    cin >> N;
    c=N/2;
    for(int i=0;i<=N-1;i++){
        cin >> X[i];
    }

    memcpy(Y,X,sizeof(int) * N);

    sort(X,X+N);

    for(int i=0;i<N;i++){
        
        if(Y[i]<X[c]){
            cout <<X[c]<<endl;
        }else{
            cout <<X[c-1]<<endl;
        }

    }

    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=int(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il bool getmin(T &x,const T &y){return y<x?x=y,true:false;}
template<typename T> il bool getmax(T &x,const T &y){return y>x?x=y,true:false;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int N=400005;

int a[N],n;

int main(){
//	fileio("test");
	scanf("%d",&n);
	int l=N/2,r=l-1;
	rep(i,1,n){
		int x;
		scanf("%d",&x);
		if(i&1) a[++r]=x;else a[--l]=x;
	}
	if(n&1){
		per(i,r,l) printf("%d ",a[i]);puts("");
	}else{
		rep(i,l,r) printf("%d ",a[i]);puts("");
	}
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>; //pop_back pop_front push_back push_front front back clear empty
using L = vector<long long>;
using M = map<int,long long>;  //erase  (でキーごと削除) 追加削除検索O(log(N))
using A = vector<vector<long long>>;
using U = unordered_map<int,long long>; //map  (との違いはkeyの順番を保持していない)
using PQL = priority_queue<long long>; //erase  (でキーごと削除) push pop top 
using PQG = priority_queue<long long,L,greater<long long>>; //erase  (でキーごと削除) push pop top 

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vdel(vector,a) vector.erase(vector.begin()+a)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define max max<unsigned long>
#define min min<unsigned long>
#define inf 1000000000000000000+10
#define setans long long ans=0;

long long MOD=1000000007;

template <typename PQ>
long long pqsum(PQ pq){long long tmp=0;while(!pq.empty()){tmp+=pq.top();pq.pop();};return tmp;};

template <typename T>
void print(T a){for (auto b:a){cout<<b<<" ";};cout<<endl;}
template <>
void print(unsigned long a){cout<<a<<endl;}
template <>
void print(char a){cout<<a<<endl;}
template <>
void print(bool a){cout<<a<<endl;}
template <>
void print(long long a){cout<<a<<endl;}
template <>
void print(A a){for (auto b:a){for (auto c:b){cout<<c<<" ";}cout<<endl;};cout<<endl;}
template <>
void print(string a){cout<<a<<endl;}



//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ
//printf("%.16f", ans); 誤差落ち対応君

bool is_integer( double x ){
  return std::floor(x)==x;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    long long n,d;
    cin>>n>>d;

    A a(n,L(d,0));
    for(long long i=0  ;i<n  ;i++){
        for(long long j=0  ;j<d  ;j++){
            cin>>a[i][j];
        }
    }
    setans;
    double tmp;
    for(long long i=0  ;i<n-1  ;i++){
        for(long long j=i+1  ;j<n  ;j++){
            tmp=0;
            for(long long r=0  ;r<d  ;r++){
                tmp+=pow(a[j][r]-a[i][r],2);
            }
            if (is_integer(pow(tmp,0.5))){
                ans+=1;
            }
        }
    }
    print(ans);
}

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

a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i] - i - 1)

b.sort()
median = b[n // 2]

c = []
for i in range(n):
    c.append(abs(b[i] - median))

print(sum(c))


Measured memory_bytes: 27680
N, K = map(int, input().split())
A = list(map(int,input().split()))
P = 0
Q = [0] + [1 for _ in range(N-1)]
R = [-1] + [0 for _ in range(N-1)]
L = 0
for i in range(K):
    P = A[P]-1
    if Q[P] == 0:
        L = i - R[P]
        S = (K - R[P] - 1) % L
        G = 0
        for j in range(S + R[P] + 1):
            G = A[G]-1
        print(G+1)
        exit()
    if Q[P] == 1:
        R[P] = i
        Q[P] = 0
print(P+1)

Measured memory_bytes: 32216
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define P push
#define R return
#define C continue
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define SI size()
#define F first
#define S second
#define W while
using namespace std;
long long MOD=1e9+7;
long long INF=1e16+7;
ll a[100003];
ll m=0;
ll am[100003];
ll p=1  ;
int main(){
    am[1]=1;
    for(int i=2;i<=1e5;i++){
        am[i]=am[i-1]*i;
        am[i]%=MOD;
    }
    ll n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    ll res=1;
    for(int i=0;i<n-1;i++){
        ll x=a[i];
        if(x<p){
            res*=m+1;
            res%=MOD;
        }
        else{
            m++;
            p+=2;
        }
    }
    res*=am[m+1];
    res%=MOD;
    cout<<res;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

void Main() {
	int a, b;
	cin >> a >> b;

	if (a>=13) {
		cout << b;
		return;
	}
	if (a<=5) {
		cout << 0;
		return;
	}
	else {
		cout<<b / 2;
		return;
	}
}

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


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


int n,K;
pi ar[100005];

lint solve(int L){
  lint res=0;
  REP(i,n) if((ar[i].fr&L)==ar[i].fr){
    res+=ar[i].sc;
  }
  return res;
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>n>>K;
  REP(i,n){
    cin>>ar[i].fr>>ar[i].sc;
  }

  lint res=solve(K);

  REP(d,32) if(K>>d&1){
      int want=K^(1<<d);
      want|=(1<<d)-1;
      chmax(res,solve(want));
    }
  cout<<res<<endl;

  return 0;
}






Measured memory_bytes: 1024
#include <cstdio>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	deque<int> d(N);
	for(int i = 0; i < N; i++) scanf("%d", &d[i]);
	
	int times = min(N, K);
	long max_value = 0;
	for(int a = 0; a <= times; a++) {
		for(int b = 0; b <= times - a; b++) {
			vector<int> have;
			long value = 0;
			for(int i = 0; i < a; i++) {
				int tmp = d[i];
				have.push_back(tmp);
				value += tmp;
			}
			for(int i = 0; i < b; i++) {
				int tmp = d[N-1-i];
				have.push_back(tmp);
				value += tmp;
			}
			
			sort(have.begin(), have.end());
			for(int i = 0; i < min(K - a - b, (int)have.size()); i++) {
				if(have[i] < 0) value -= have[i];
			}
			if(max_value < value) max_value = value;
		}
	}
	
	printf("%ld", max_value);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[200005];
int main(){
    scanf("%d",&n);
    ll sum = 0;
    for (int i =0 ;i < n; i++) {
        scanf("%d",&a[i]);
    }
    int cur = n-1;
    sort(a,a+n,greater<int>());
    for (int i = 0; i < n; i++){
        if (cur){
            cur--;
            sum += a[i];
        }
        if (i == 0) continue;
        if (cur){
            cur--;
            sum += a[i];
        }
    }
    printf("%lld",sum);



}


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

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<(1<<n);i++)
    {
        cout<<i<<":";
        for(int j=0;j<n;j++)
        {
            if((i>>j)&1)cout<<" "<<j;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define oo int(1e9)
#define all(s) s.begin(), s.end()
using namespace std;
typedef unsigned long long ll;
typedef double db;
const ll MOD = (ll)(1e9) + 7;
ll dp[10001][100][2];
int D;
int n;
string K;

ll calc(int id,int sum_digit,int tight,const string& K){
    if (id == K.size()) return (sum_digit == 0);
    if (dp[id][sum_digit][tight] != -1 && tight == 0) return dp[id][sum_digit][tight];
    int limit = (tight) ? (K[id] - '0'): 9;
    ll ans = 0;
    for (int dig = 0; dig <= limit; dig ++){
        int newtight = ((K[id] - '0') == dig) ? tight : 0;
        ans = (ans + calc(id + 1,(sum_digit + dig) % D,newtight,K) ) % MOD;
    }
    return dp[id][sum_digit][tight] = ans;
}


int main() {
	cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
    cin >> K;
    cin.ignore();
    cin >> D;
    memset(dp,-1,sizeof(dp));
    cout << (calc(0,0,1,K) - 1 + MOD) % MOD;
	return 0;
}

Measured memory_bytes: 16896
n,x=[int(k) for k in input().split()]
count=0
while n or x:
    for i1 in range(1,x//3+1):
        if i1 > n:
            break
        for i2 in range(i1+1,(x-i1)//2+1):
            if i2>n:
                break
            i3=(x-i1-i2)
            if i2<i3 and i3<=n:
                count+=1
    n,x=[int(k) for k in input().split()]
    print(count)
    count=0    



Measured memory_bytes: 5604
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int a, b;
    cin >> a >> b;

    int time = a * b;
    if (time % 2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;

    return 0;
}

Measured memory_bytes: 256
// Aizu Vol-2 0201: Wrought Gold Master
// 2017.8.17 bal4u@uu
// ??¢?????????????????????????????\????????????????????£?????????

#include <stdio.h>
#include <string.h>

#define HSIZ 499
typedef struct { char *w; int k; } HASH;
HASH hash[HSIZ + 5];

int lookup(char *w)
{
	int i, l;
	HASH *tp;
	i = (101 * *w + 103 * *(w + (l = strlen(w)) - 1) + 107 * l) % HSIZ;
	tp = hash + i;
	if (tp->w != NULL) {
		int inc = *w + (*(w + 1) << 1);
		while (1) {
			if (!strcmp(tp->w, w)) return tp->k;
			i += inc; if (i >= HSIZ) i -= HSIZ;
			tp = hash + i;
			if (tp->w == NULL) break;
		}
	}
	return -1;
}

int insert(char *w, int k)
{
	int i, l;
	HASH *tp;
	i = (101 * *w + 103 * *(w + (l = strlen(w)) - 1) + 107 * l) % HSIZ;
	tp = hash + i;
	if (tp->w != NULL) {
		int inc = *w + (*(w + 1) << 1);
		while (1) {
			if (!strcmp(tp->w, w)) return -1;
			i += inc; if (i >= HSIZ) i -= HSIZ;
			tp = hash + i;
			if (tp->w == NULL) break;
		}
	}
	tp->w = w, tp->k = k;
	return 0;
}

typedef struct { char a[102]; int m, k, i[102]; } MONO;
MONO mono[205]; int no;

int combi(int a)
{
	int i, k, c = -1;
	k = mono[a].k;
	if (k > 0) for (c = i = 0; i < k; i++) c += combi(mono[a].i[i]);
	if (c < 0 || (mono[a].m >= 0 && mono[a].m < c)) c = mono[a].m;
	return c;
}

int main()
{
	int i, j, k, N, M;
	char b[102];

	while (scanf("%d", &N) == 1 && N) {
		memset(hash, 0, sizeof(hash)), no = 0;
		while (N-- > 0) {
			scanf("%s%d", mono[no].a, &(mono[no].m));
			mono[no].k = 0; insert(mono[no].a, no);
			no++;
		}
		scanf("%d", &M);
		while (M--) {
			scanf("%s%d", mono[no].a, &k);
			if ((i = lookup(mono[no].a)) < 0) insert(mono[no].a, no), mono[no].m = -1, i = no++;
			mono[i].k = k;
			for (j = 0; j < mono[i].k; j++) scanf("%s", b), mono[i].i[j] = lookup(b);
		}
		scanf("%s", b);
		printf("%d\n", combi(lookup(b)));
	}
	return 0;
}

Measured memory_bytes: 652