akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int w,d;
  cin >> w >>d;
  while(w!=0){
    bool used[w],can_no;
    int sum=0;
    int h0[w],h1[d];
    fill(used,used+w,false);
    for(int i=0;i<w;i++){
      cin >> h0[i];
      sum+=h0[i];
    }
    for(int i=0;i<d;i++){
      cin >> h1[i];
      can_no=false;
      for(int j=0;j<w;j++){
        if(used[j]==false&&h1[i]==h0[j]){
          can_no=true;
          used[j]=true;
          break;
        }
      }
      if(can_no==false){
        sum+=h1[i];
      }
    }
    cout << sum<<endl;
    cin >> w >>d;
  }
}



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

using namespace std;
using ll = long long;

const int MAX_V = 100100;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, W;
  cin >> N >> W;
  vector<ll> weight(N), value(N);
  for (int i = 0; i < N; i++)
    cin >> weight[i] >> value[i];
  vector<vector<ll>> dp(N + 1, vector<ll>(MAX_V + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int v = 0; v <= MAX_V; v++) {
      dp[i + 1][v] = min(dp[i + 1][v], dp[i][v]);
      if (v - value[i] >= 0)
        dp[i + 1][v] = min(dp[i + 1][v], dp[i][v - value[i]] + weight[i]);
    }
  }
  int res = 0;
  for (int v = 0; v <= MAX_V; v++) {
    if (dp[N][v] <= W) res = v;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 80256
#include<iostream>
using namespace std;
int main()
{
    int n;
    int count = 0;
    cin >> n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n-1;i++){
        cin >> c[i];
    }
    int old = 2000;
    for(int i=0;i<n;i++){
        count +=  b[a[i]-1];
        if(old+1==a[i]){
            count +=  c[old-1];
        }
        old = a[i];
    }
    cout << count;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const int INF = numeric_limits<int>::max();

struct Edge {
    int to, cost;
};

struct Graph {
    vector<vector<Edge>> edge; // 辺（隣接ノード番号, 重み）
    vector<int> d; // 最短距離
    Graph(int v) {
        edge.assign(v, vector<Edge>());
        d.assign(v, INF);
    }
};

int main()
{
    int v, e, r;
    cin >> v >> e >> r;
    Graph g(v);
    for (int i = 0; i < e; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        g.edge[s].push_back({t, d});
    }

    g.d[r] = 0;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(P(0, r));
    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int d = p.first;
        int u = p.second;
        if (d > g.d[u]) continue;
        for (auto e : g.edge[u]) {
            if (g.d[u] + e.cost < g.d[e.to]) {
                g.d[e.to] = g.d[u] + e.cost;
                pq.push(P(g.d[e.to], e.to));
            }
        }
    }

    for (auto d : g.d) {
        if (d == INF) {
            cout << "INF" << endl;
        } else {
            cout << d << endl;
        }
    }
}


Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

int main() {
   string S;
   cin>>S;
   string A=S.substr(2,S.size()-3);
   
   int ans=0;
   int count=0;

   for(int i=0;i<A.size();i++){
       if(A[i]=='C'){
           ans++;
       }
   }
   for(int i=0;i<S.size();i++){
       if(S[i] >= 'a' && S[i] <= 'z'){
           count++;
       }
   }

   if(S[0]=='A'&&ans==1&&count==S.size()-2){
       cout<<"AC"<<endl;
   }
   else{
       cout<<"WA"<<endl; 
   }
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N, K;
    string S;

    cin >> N >> K >> S;

    switch (S[K-1]) {
        case 'A':
            S[K-1] = 'a';
            break;
        case 'B':
            S[K-1] = 'b';
            break;
        case 'C':
            S[K-1] = 'c';
            break;
    }

    cout << S << endl;
}

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

int main(){
  int a,b;
  int s=0;
  cin>>a>>b;
  for(int i=a;i<b+1;i++){
    if(i%10==i/10000 && (i-i%10)/10%10==(i-i%1000)/1000%10)
      s += 1;
  }
  
  cout<<s<<endl;
  return 0;
}
    
  

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

int main()
{
  string a;
  cin >> a;
  
  for (int i=0; i<a.size(); i++)
  {
    if (a[i] == '?')
      cout << 'D';
    else
      cout << a[i];
  }
  
  return 0;
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**9)
from collections import defaultdict

N, M = map(int, input().split())

"""
距離が３つ離れたやつを縮めて１にする処理。
・与えられたグラフが２部グラフの場合、あるノードから奇数個辺をたどった先は違う色で、偶数個辺をたどれば同じ色なので、
３→１変えてそこから先に２進んだ先とつないでも別の色としかつながることができない。異なる色どうしは全てつながることができる
・２部グラフでない場合、あるノードからあるノードに行くのに奇数回移動していく道筋と偶数回移動していく道筋が存在することになるから、
そこを起点にすれば最終的に全てのノードが繋がる
"""

es = defaultdict(list)

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


color = [0] * N

def dfs(a, c):
    color[a] = c
    for b in es[a]:
        if color[b] == c:
            return False
        if color[b] == 0 and not dfs(b, -c):
            return False

    return True



if dfs(0, 1):
    tmp = color.count(1)

    print(tmp*(N-tmp) - M)
else:
    print(N*(N-1)//2 - M)

Measured memory_bytes: 37360
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  int m = 0;
  for (int i = 0; i < N; ++i) if (A[i] < 0) ++m;
  
  if (m % 2 == 0) {
    int ans = 0;
    for (int i = 0; i < N; ++i) {
      if (A[i] < 0) ans -= A[i];
      else ans += A[i];
    }
    cout << ans << endl;
  } else {
    int MIN = 1000000000;
    int num;
    for (int i = 0; i < N; ++i) {
      if (abs(A[i]) < MIN) {
        MIN = abs(A[i]);
        num = i;
      }
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
      if (i != num) ans += abs(A[i]);
      else ans -= abs(A[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
wordlist = [input()]
f = 0
i = 1
while i < n:
    w = input()
    if w[0] != wordlist[-1][-1]:
        f = 1
    if w in wordlist:
        f = 1
    wordlist.append(w)
    i += 1
if f == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>


int main()
{
	ll i,j,k,n,m;
	cin>>n>>m;
	ll arr[m];
	ll sum=0;
	for(i=0;i<m;i++)
	{
		cin>>arr[i];
		sum+=arr[i];
	}
	if(sum>n)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<n-sum<<endl;
	}
	return 0;



}

Measured memory_bytes: 3696
import java.util.Scanner;


public class Main {

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

		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		
		int sum1 = 0;
		int sum2 = 0;
		long sum3 = 0;
		int max = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			y[i] = sc.nextInt();

			sum1 += Math.abs(x[i]- y[i]);
			sum2 += (x[i]- y[i]) * (x[i]- y[i]);
			sum3 += Math.abs((x[i]- y[i]) * (x[i]- y[i]) * (x[i]- y[i]));
			max = Math.max(max, Math.abs(x[i]- y[i]));
		}
		
		System.out.println(sum1);
		System.out.println(Math.sqrt(sum2));
		System.out.println(Math.pow(sum3, (double)1/3));
		System.out.println(max);

		sc.close();
	}
}

Measured memory_bytes: 20416
def gcd(a,b):
    if a>b:
        r=a%b
        if r==0:
            return b
        return gcd(b,r)
    elif a<b:
        r=b%a
        if r==0:
            return a
        return gcd(a,b%a)
    else:
        return a
k=int(input())
sum=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum+=gcd(i,gcd(j,l))
print(sum)


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

int main() {
  int i,N;
  cin >> N;
  string c;
  for(int i=0;i<N;i++){
	cin >> c;
    if(c=="Y"){
    break;
    }
    }
  if(c=="Y"){
  cout << "Four";
  }
  else{
  cout << "Three";
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
struct edge{long from,to,cost;};
long bellman_ford(int start){
    long n,m,a;
    cin>>n>>m;
    edge es[m];
    for(int i=0;i<m;i++){
        cin>>es[i].from>>es[i].to>>es[i].cost;
        es[i].from--;es[i].to--;es[i].cost*=-1;
    }
    vector<long>dist(n,0x7fffffffffffff);
    dist[start]=0L;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dist[es[j].to]>dist[es[j].from]+es[j].cost){
                dist[es[j].to]=dist[es[j].from]+es[j].cost;
            }
        }
    }
    
    bool f[n]={};
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(dist[es[j].from]==0x7fffffffffffff)continue;
            if(dist[es[j].to]>dist[es[j].from]+es[j].cost){
                dist[es[j].to]=dist[es[j].from]+es[j].cost;
                f[es[j].to]=true;
            }
            if(f[es[j].from]==true)f[es[j].to]=true;
        }
    }
    return f[n-1]?0x7fffffffffffff:dist[n-1];
}

int main(){
    long a=bellman_ford(0)*-1;
    if(a==0x7fffffffffffff*-1)cout<<"inf"<<endl;
    else cout<<a<<endl;
    return 0;
}

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

int main(){
   int a,b;
   cin >> a >> b;
   
   if (a==b){
       cout << "a == b"<<endl;
   }
   else if (a>b){
       cout << "a > b"<<endl;
   }
   else{
       cout << "a < b"<<endl;
   }
   
   return 0;
}




Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a) for(int i=(a);;++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, const char * argv[]) {
    int a,b,ans=0;
    string op;
    IFOR(i, 0){
        cin >> a >> op >> b;
        if(op=="?") break;
        if(op=="+") ans=a+b;
        else if (op=="-") ans=a-b;
        else if (op=="*") ans=a*b;
        else if (op=="/") ans=a/b;
        cout << ans << endl;
        
    }
    
}





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

int main()
{
    int t,i;
    cin>>t;
    map<string,int>m;
    for(i=0;i<t;i++)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    int maxi=0;
    for(auto it=m.begin();it!=m.end();it++)
    {
        maxi=max(maxi,it->second);
    }
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->second == maxi)
            cout<<it->first<<endl;
    }
   return 0;
}


Measured memory_bytes: 25216
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {

	int pm = 114514, jm = 114514;

	for (int i = 0; i < 3; i++) {
		int p;
		scanf("%d", &p);
		pm = min(pm, p);
	}
	for (int i = 0; i < 2; i++) {
		int j;
		scanf("%d", &j);
		jm = min(jm, j);
	}

	printf("%d\n", pm + jm - 50);

	return 0;
}

Measured memory_bytes: 2728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var N = inputArray[0];
			var M = inputArray[1];

			var numArray = retreiveLongArray();

			//2で割れる回数が同じであることを確認する。
			var divTwoCount = divideTwoCount(numArray[0]);
			var divTwoCountflag = numArray.Select(x => divTwoCount == divideTwoCount(x)).All(x =>x);

			//2で割れる数が同じでない場合は、半公倍数は存在しない
			if (!divTwoCountflag) {
				Console.WriteLine(0);
				return;
			}

			var divideNum = (long)Math.Pow(2, divTwoCount);
			//計算量を抑えるために、すべての数を2でできるだけ割っておく

			var numArray2 = numArray.Select(x => x / divideNum).ToArray();

			//最小公倍数を求める
			long lcm = 1;
			for (int i = 0; i < N; i++) {
				lcm = getLcm(lcm, numArray2[i]);
			}
			var M2 = M / (divideNum / 2);
			var ans = ((M2/lcm)+1)/2;

			//答えの出力
			Console.WriteLine(ans);

		}

		/// <summary>
		/// 2で割れる回数を求める
		/// </summary>
		/// <param name="n"></param>
		/// <returns></returns>
		private static long divideTwoCount(long n) {
			var count = 0;
			while (true) {
				if (n%2 ==1) {
					return count;
				}
				n = n / 2;
				count++;
			}
		}


		/// <summary>
		/// 最小公倍数を返す
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		private static long getLcm(long a, long b) {
			return (a * b / getGcd(a, b));
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		static long getGcd(long a, long b) {
			if (a < b) {
				return getGcd(b, a);
			}
			if (b > 0) {
				return getGcd(b, a % b);
			}
			else {
				return a;
			}
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

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

int main() {
  int a,b,ans=0;
  cin >> a >> b;
  for(int i = a;i<b+1;i++){
   if(i/10000==i%10&&(i/1000-(i/10000)*10)==(i%100-i%10)/10)ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3640
using System;

namespace AOJ.ITP
{
    public class Ring
    {
        public static void Main()
        {
            string ring = Console.ReadLine();
            string want = Console.ReadLine();

            string check = ring + ring;
            if (check.IndexOf(want) >= 0) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }
        }
    }
}

Measured memory_bytes: 6200
N = int(input())
a = [0] + list(map(int, input().split()))
b = []
for i in range(1, N+1)[::-1]:
    s = sum(a[j] for j in range(i*2, N+1, i))
    if s % 2 == 1:
        a[i] = 1 - a[i]
    if a[i]:
        b.append(i)
print(len(b))
if len(b) > 0:
    print(*b)


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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seqS = new int[n];
      String[] line = br.readLine().split(" ");
      int cnt=0;
      for (String s : line)
        seqS[cnt++] = Integer.parseInt(s);

      int q = Integer.parseInt(br.readLine());
      line = br.readLine().split(" ");
      
      cnt=0;
      for (String ref : line) {
        if( isExistSeachByBinary(seqS, Integer.parseInt(ref)) )
          cnt++;
      }

      System.out.println(cnt);
    }
  }

  static boolean isExistSeachByBinary(int[] tar, int ref) {
    int left = 0;
    int right= tar.length;
    int mid;
    while( left < right ) {
      mid  = (left + right) / 2;
      if( tar[mid] == ref ) return true;
      else if( tar[mid] > ref ) right = mid;
      else left = mid + 1;
    }

    return false;
  }
}


Measured memory_bytes: 52320
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
int main(void){
    int count=0;
    string str;

    cin >> str;

    for(int i=0;i<str.size();i++){
        if(str[i]=='1'){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
 
#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
 
// constexpr int MOD = 1e9+7;

vector<int> factors(int n){
    vector<int> ret;
    for(int i = 1; i*i <= n; i ++) if(n % i == 0) ret.push_back(i), ret.push_back(n/i);
    return ret;
}
 
int main(void){
    Cin(int, n, k);
    Cins(int, n, a);
    
    int sum = 0;
    For(i, n) sum += a[i];
    
    auto f = factors(sum);
    DeSort(f);
    
    // Couts(f);
 
    auto c = [&](int p){
        vc<int> b(n);
        For(i, n) b[i] = a[i] % p;
        Sort(b);
        
        vc<int> csl(n+1), csr(n+1);
        For(i, n) csl[i+1] = csl[i] + b[i];
        for(int i = n-1; i >= 0; i --) csr[i] = csr[i+1] + (p - b[i]);
        
        /* Cout(p);
        Couts(b);
        Couts(csl);
        Couts(csr);
        */
        
        For(i, n+1){
            if(csl[i] == csr[i]) return csl[i] <= k;
        }
        return false;
    };
    
    
    for(auto x : f){
        if(c(x)){
            Cout(x);
            return 0;
        }
    }
}



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

using namespace std;

int dp[4010][4010];

int main(void) {
  string s, t;
  while (cin >> s >> t) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < s.size(); i++) {
      for (int j = 0; j < t.size(); j++) {
        if (s[i] != t[j]) continue;
        dp[i + 1][j + 1] = dp[i][j] + 1;
      }
    }

    int ans = 0;
    for (int i = 1; i <= s.size(); i++) {
      for (int j = 1; j <= t.size(); j++) {
        ans = max(ans, dp[i][j]);
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 65848
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	rs := []rune(s)
	cnt := 0
	r := 0
	for _, v := range rs {
		if string(v) == "A" || string(v) == "C" ||
			string(v) == "G" || string(v) == "T" {
			cnt++
		} else {
			cnt = 0
		}
		if r < cnt {
			r = cnt
		}
	}
	fmt.Println(r)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
  return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(void)
{
  char s[5];
  bool judge = false;

  scanf("%s", s);

  rep(i, 4)
  {
    if (s[i] == s[i + 1])
      judge = true;
  }
  printf(judge ? "Bad\n" : "Good\n");
  return 0;
}


Measured memory_bytes: 128
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

ll fun(ll n)
{
	ll odd_sum=0,even_sum=0;
	while(n)
	{
		ll temp=n%10;
		n/=10;
		if(temp%2)
			odd_sum+=temp;
		else
			even_sum+=temp;
	}
	return abs(odd_sum-even_sum);
}
int main()
{
	fast();
	ll ans=0,i,j,n;
	cin>>n;
	vll a(n);
	rep(i,n)
		cin>>a[i];
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			ans+=a[i]*a[j];
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int n;
vector<P> p(50);

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep (i, n) cin >> p[i].first >> p[i].second;
    double ans = sqrt((p[1].first - p[0].first) * (p[1].first - p[0].first) + (p[1].second - p[0].second) * (p[1].second - p[0].second)) / 2.0;
    rep (i, n - 2) {
        repp (j, i + 1, n - 1) {
            repp (k, j + 1, n) {
                double a[3], s, S, r;
                a[0] = sqrt((p[j].first - p[i].first) * (p[j].first - p[i].first) + (p[j].second - p[i].second) * (p[j].second - p[i].second));
                a[1] = sqrt((p[k].first - p[j].first) * (p[k].first - p[j].first) + (p[k].second - p[j].second) * (p[k].second - p[j].second));
                a[2] = sqrt((p[i].first - p[k].first) * (p[i].first - p[k].first) + (p[i].second - p[k].second) * (p[i].second - p[k].second));
                s = (a[0] + a[1] + a[2]) / 2.0;
                S = s * (s - a[0]) * (s - a[1]) * (s - a[2]);
                sort(a, a + 3);
                if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2]) r = a[2] / 2.0;
                else r = a[0] * a[1] * a[2] / (4.0 * sqrt(S));
                // r = min(max(max(a / 2.0, b / 2.0), c / 2.0), a * b * c / (sqrt(S) * 4.0));
                // if (r >= 6.73) eprintf("%lf %lf %lf %lf %lf %lf\n", a, b, c, s, S, r);
                chmax(ans, r);
            }
        }
    }
    printf("%.16lf\n", ans);
    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++)
#define ALL(x) x.begin(),x.end()

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  vector<vector<int>::iterator> via(n),vic(n);
  rep(i,n) via[i]=lower_bound(ALL(a),b[i]);
  rep(i,n) vic[i]=upper_bound(ALL(c),b[i]);

  long long da,dc,ans=0;
  rep(i,n){
    da=distance(a.begin(),via[i]);
    dc=distance(vic[i],c.end());
    ans+=da*dc;
  }
  cout<<ans<<endl;  
}

Measured memory_bytes: 5820
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int r,c,k;
    cin >> r >> c >> k;
    vector dp(4, vector(r+1, vector(c+1, 0LL)));
    vector rc(r+1, vector(c+1,0LL));
    for (int i=0; i<k; i++) {
        int r,c,v;
        cin >> r >> c >> v;
        rc[r][c] = v;
    }

    for (int i=1; i<=r; i++) {
        for (int j=1; j<=c; j++) {
            for (int k=0; k<4; k++) dp[0][i][j] = max(dp[0][i][j], dp[k][i-1][j]);
            for (int k=0; k<4; k++) dp[k][i][j] = max(dp[k][i][j], dp[k][i][j-1]);

            for (int k=0; k<4; k++) dp[1][i][j] = max(dp[1][i][j], dp[k][i-1][j] + rc[i][j]);
            for (int k=0; k<3; k++) dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j-1] + rc[i][j]);
        }
    }

    cout << max({dp[0][r][c], dp[1][r][c], dp[2][r][c], dp[3][r][c]}) << endl;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main(){
	
	string str;
	cin >> str;
	vector<ll> S(str.size() + 1);
	REP(i,str.size()){
		if(str[i] == 'A')S[i+1] = 2;
		else S[i+1] = 1;
		S[i+1] += S[i];
	}
	cin >> str;
	vector<ll> T(str.size() + 1);
	REP(i,str.size()) {
		if(str[i] == 'A')T[i+1] = 2;
		else T[i+1] = 1;
		T[i+1] += T[i];
	}
	
	int q;cin >> q;
	REP(i,q){
		int a,b,c,d;cin >> a >> b >> c >> d;
		int A = S[b] - S[a-1];
		int B = T[d] - T[c-1];
		if(abs(A - B) % 3 == 0){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, T;
    cin >> N >> T;
    string S;
    cin >> S;
    char c;
    if(S[T-1] == 'A') {
        c = 'a';
    } else if(S[T-1] == 'B') {
        c = 'b';
    } else {
        c = 'c';
    }
    S[T-1] = c;
    cout << S << endl;
}

Measured memory_bytes: 256
n = int(raw_input())
    
d = [99999 for i in range(n)]
G = [0 for i in range(n)]
v = [[0 for i in range(n)] for j in range(n)]
    
def BFS(s):
  for e in range(n):
    if v[s][e] == 1:
      if d[e] > d[s] + 1:
        d[e] = d[s]+1
        BFS(e)
    
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    v[G[0]-1][G[2+j]-1] = 1
    
d[0] = 0
for s in range(n):
  BFS(s)
for s in range(n):
  if d[s] == 99999:
    d[s] = -1
for s in range(n):
  print'%d %d' %(s+1, d[s])

Measured memory_bytes: 6492
if __name__ == '__main__':
	N = int(input())
	P = list(map(int, input().split()))

	cnt = 0
	for i in range(N - 2):
		if P[i] < P[i+1] < P[i+2] or P[i] > P[i+1] > P[i+2] :
			cnt += 1
		else:
			pass
	print(cnt)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let s: String = read();
    let mut cnt = 0;
    for i in 0..n - 2 {
        if &s[i..i + 3] == "ABC" {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  long long n,m,i,s,j,a=1e18;
  scanf("%lld %lld",&n,&m);
  if(n==m){
    printf("%lld\n",n+1);
    return 0;
  }
  for(i=2;i*i<=n;i++){
    s=0;
    for(j=n;j;j/=i)s+=j%i;
    if(s==m)goto END;
  }//printf("a\n");
  if((i-1)*(i-1)==n)i--;
  for(j=i-1;j;j--){
    s=m-j;
    if(m<j||(n-s)%j)continue;
    i=(n-s)/j;
    if(s<i)goto END;
  }
  printf("-1\n");
  return 0;
 END:;
  printf("%lld\n",i);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dp[MAXn];
vector<ll> e[MAXn];
void dfs(ll x){
  if (dp[x] == -1) dp[x] = 0;
  for (auto i:e[x]) {
    if (dp[i] == -1) dfs(i);
    dp[x] = max(dp[x],dp[i]+1);
  }
}
int main(){
  IOS();
  ll n,m;
  cin >> n >> m;
  REP (i,m) {
    ll u,v;
    cin >> u >> v;
    u--,v--;
    e[u].eb(v);
  }

  RST(dp,-1);
  REP (i,n) if (dp[i] == -1) dfs(i);
  ll ans = 0;
  REP (i,n) ans = max(ans,dp[i]);
  cout << ans << endl;
}


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

int main(){
    int n,m,q;
    cin>>n>>m>>q;
    vector<vector<int> > a(n,vector<int>(n+1,0));
    for (int i = 0; i < m; ++i) {
        int l,r;
        cin>>l>>r;
        --l;--r;
        for (int j = l; j <= r; ++j) {
            ++a[l][j];
        }
    }
    for (int i = 0; i < q; ++i) {
        int l,r;
        cin>>l>>r;
        --l;--r;
        int ans=0;
        for (int j = l; j <= r; ++j) {
            ans+=a[j][j]-a[j][r+1];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int vis[100005];
int v,e,i,x,y,ans=0;
vector <int> adj[100005];
void dfs_(int node)
{
	vis[node]=true;
	for(int i=0;i<adj[node].size();++i)
	{
		if(!vis[adj[node][i]])
		 dfs_(adj[node][i]);
		dp[node]=max(dp[node],1+dp[adj[node][i]]);
	}
}
int main()
{
	cin>>v>>e;
	for(i=0;i<e;++i)
	{
	    cin>>x>>y;
		adj[x].push_back(y);	
	}
	for(i=1;i<=v;++i)
	{
		if(!vis[i])
		 dfs_(i);
	}
	for(i=1;i<=v;++i)
	 ans=max(ans,dp[i]);
cout<<ans;	
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int k;
    cin >> k;
    cout << a[k-1] << endl;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;

    cin >> a;
    cin >> b;

    a--;
    b--;

    Out(a * b);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    vector<ll> a(110, 1);
    for(ll i = 2; i <= n; i++){
        ll count = 2;
        ll j = i;
        bool ok = true;
        while(ok==true){
            //cout << i << endl;
            //cout << j <<  " " << count << endl;
            if(j%count==0){
                j = j/count;
                a[count]++;
            }
            else if(j%count!=0)count++;
            if(j<count) ok = false;
        }
        //cout <<"aa" << endl;
    }
    ll ans = 0;
    //for(ll i = 0; i <= 20; i++)
      //  cout << i << " " << a[i] << endl;
    sort(a.begin(), a.end(), greater<ll>());
    if(a[0]>=75) ans=1;
    for(ll i = 0; i <= n; i++){
        if(a[i]<25) break;
        for(ll j = 0; j <= n; j++){
            if(a[j]<3) break;
            if(i!=j) ans++;
        }
    }
    for(ll i = 0; i <= n; i++){
        if(a[i]<15) break;
        for(ll j = 0; j <= n; j++){
            if(a[j]<5) break;
            if(i!=j){
                ans++;
            }
        }
        //cout << ans << endl;
    }
    for(ll i = 0; i <= n; i++){
        if(a[i]<5) break;
        for(ll j = i+1; j <= n; j++){
            if(a[j]<5) break;
            for(ll k = 0; k <= n; k++){
                if(a[k]<3) break;
                if(i!=j && j!=k && k!=i){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	
	int a,b,c,d;
	
	cin>>a>>b>>c>>d;
	
	if(a*b>c*d){
	cout<<a*b<<endl;
	}else if(a*b<c*d){
	cout<<c*d<<endl;
	}else{
	cout<<c*d<<endl;
	}




return 0;

}



Measured memory_bytes: 256
n, m = map(int, input().split())

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

l = list(zip(a,b))
l.sort()

c = 0
m_rest = m
for i in range(n):
    d = l[i]
    if m_rest == 0:
        break
    if d[1] <= m_rest:
        c += d[0]*d[1]
        m_rest -= d[1]
    else:
        c += d[0]*m_rest
        m_rest = 0

print(c)

Measured memory_bytes: 18520
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>

using namespace std;
typedef long long ll;

ll A, B;

int main() {
	cin >> A >> B;
	if (A <= 5) {
		cout << 0 << endl;
	}
	else if (A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N=input()
inf=float("inf")
dp=[[inf]*(len(N)+1) for i in range(2)]
dp[0][0]=0
for i in range(len(N)):
   tmp=int(N[-1-i])
   dp[0][i+1]=min(dp[0][i],dp[1][i])+tmp
   dp[1][i+1]=min(dp[0][i]+11,dp[1][i]+9)-tmp
print(min(dp[0][-1],dp[1][-1]))

Measured memory_bytes: 89124
class RangeUpdateQuery
  attr_reader :n, :dat, :lazy

  # @param [Integer] len 区間の長さ
  def initialize(len, init: -1)
    @n = 1

    @n *= 2 while @n < len
    @dat = Array.new(2 * @n - 1, init)
    @lazy = Array.new(2 * @n - 1)
  end

  # @param [Integer] l 更新範囲の左端
  # @param [Integer] r 更新範囲の右端
  # @param [Integer] x 更新する値
  def update(l, r, x)
    fill(l, r, x, 0, 0, n - 1)
  end

  # @param [Integer] idx 取得したい値の箇所
  def find(idx)
    sum(idx, idx, 0, 0, n - 1)
  end

  private

  # @param [Integer] a 探索範囲の左端
  # @param [Integer] b 探索範囲の右端
  # @param [Integer] x 更新する値
  # @param [Integer] idx 現在位置
  # @param [Integer] l 現在の探索範囲の左端
  # @param [Integer] r 現在の探索範囲の右端
  def fill(a, b, x, idx, l, r)
    return if r < a || b < l

    evaluate(idx, l, r)

    if a <= l && r <= b
      @lazy[idx] = x
    else
      fill(a, b, x, idx * 2 + 1, l, (l + r) / 2)
      fill(a, b, x, idx * 2 + 2, (l + r) / 2 + 1, r)
    end
  end

  def evaluate(idx, l, r)
    return if lazy[idx].nil?

    @dat[idx] = lazy[idx]

    if r - l > 0
      @lazy[2 * idx + 1] = lazy[idx]
      @lazy[2 * idx + 2] = lazy[idx]
    end

    @lazy[idx] = nil
  end

  def sum(a, b, idx, l, r)
    return 0 if r < a || b < l

    evaluate(idx, l, r)

    if a <= l && r <= b
      dat[idx]
    else
      vl = sum(a, b, idx * 2 + 1, l, (l + r) / 2)
      vr = sum(a, b, idx * 2 + 2, (l + r) / 2 + 1, r)

      vl + vr
    end
  end
end

N, Q = gets.split.map(&:to_i)
ruq = RangeUpdateQuery.new(N, init: 2 ** 31 - 1)

Q.times do
  query = gets.split.map(&:to_i)

  if query.first == 0
    _, s, t, n = *query
    ruq.update(s, t, n)
  else
    _, i = *query
    puts ruq.find(i)
  end
end



Measured memory_bytes: 13264
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

struct Connection {
	vector<int>friends;
	vector<int>block;
	vector<int>friendable;
	Connection() {};
};

int main() {

	double L;
	cin >> L;
	double ans = (L * L * L) / 27.0;
	cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
/*cout<<setprecision(5)<<ret<<endl;で、数字部分を計5桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(5)<<ret<<endlで、小数部のみ5桁表示かつゼロ埋め有*/
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
/* [Shift+Command+b]（コンパイル）ー＞[Ctrl+Shift+`]（ターミナル起動）ー＞[./a.out] */

//////////////////
//  A
int main(void){
    int n;cin>>n;
    n%=1000;
    if(n==0) cout<<0<<endl;
    else cout<<1000-n<<endl;
    return 0;
}
//////////////////
//  B
/*int main(void){

    return 0;
}*/
//////////////////
//  C 
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/


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

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

	ll r = 0, g = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}

	ll all = r * g * b;
	ll sub = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			int k = 2 * j - i;
			if (k < n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) sub++;
		}
	}
	cout << all - sub << endl;
}

Measured memory_bytes: 3568
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var count = 1;
        for (int i = 0; i < n; i++)
            if (a[i] == count) count++;
        Console.WriteLine(count == 1 ? -1 : n - count + 1);
    }
}


Measured memory_bytes: 31452
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,r;
    cin>>n>>r;
    if(n >= 10){
        cout<<r<<endl;
    }else{
        int ans = r + (100 * (10 - n));
        cout<<ans<<endl;
    }
    
    return 0;
    
}



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

int main() {
  int a,b;
  cin >> a >> b;
  bool A=false;
  if(b<10){
    int c=10*a+b;
    int d=sqrt(c);
    if(d==sqrt(c)){
      A=true;
    }
  }
  else if(b<100){
    int c=100*a+b;
    int d=sqrt(c);
    if(d==sqrt(c)){
      A=true;
    }
  }
  else{
    int c=1000*a+b;
    int d=sqrt(c);
    if(d==sqrt(c)){
      A=true;
    }
  }
  if(A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
 
int main(){

  int c,d;
  char a[4],b[4];
  (void) scanf("%s %s",a,b);
  
  strcat(a,b);
  
  c=atoi(a);
  
  d=sqrt(c);
  
  if (d*d == c)
  {
  printf("Yes");
    return 0;
  }
  
  printf("No");
  
  

 
 return 0; 
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    string s;
    ll k;
    cin>>s>>k;

    int n=s.size();
    ll ans=0;
    if(k==1){
        rep(i,n-1){
            if(s[i]==s[i+1]) ans++;
        }
        cout<<ans<<endl;
        return 0;
    }

    if(s[0]!=s[n-1]){
        ll tmp=1;
        rep(i,n-1){
            if(s[i]==s[i+1]) tmp++;
            else{
                ans+=tmp/2;
                tmp=1;
            }
        }
        ans+=tmp/2;
        cout<<ans*k<<endl;
        return 0;
    }

    bool ok=true;
    rep(i,n-1){
        if(s[i]!=s[i+1]) ok=false;
    }
    if(ok){
        cout<<n*k/2<<endl;
        return 0;
    }

    ll fr=1,ba=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]) break;
        fr++;
    }
    for(int i=n-1;i>=1;i--){
        if(s[i]!=s[i-1]) break;
        ba++;
    }

    //cout<<fr<<" "<<ba<<endl;
    ans+=((fr+ba)/2)*(k-1);
    ans+=fr/2;
    ans+=ba/2;
    //cout<<ans<<endl;

    ll tmp=1;
    for(int i=fr;i<n-ba;i++){
        if(s[i]==s[i+1]) tmp++;
        else{
            ans+=(tmp/2)*k;
            tmp=1;
        }
    }
    ans+=(tmp/2)*k;
    cout<<ans<<endl;
}

Measured memory_bytes: 3608