akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s,t; cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<vector<int>> ids(30);
    for(int i=0;i<n;i++){
        ids[s[i]-'a'].push_back(i);
    }

    for(int i=0;i<m;i++){
        if(ids[t[i]-'a'].size()==0){
            cout << -1 << endl;
            return 0;
        }
    }

    /* for(char i='a';i<='z';i++){ */
    /*     cout << i << " " << ids[i-'a'] << endl; */
    /* } */


    ll cnt=0;
    int last = -1;
    rep(i,m){
        int c = t[i] - 'a';
        int idx = upper_bound(all(ids[c]),last) - ids[c].begin();
        if(idx == ids[c].size()){ // not found
            //cerr <<" new line " << endl;
            cnt++;
            last = -1;
            idx = upper_bound(all(ids[c]),last) - ids[c].begin();
        }
        /* cerr << t[i] << " " << idx << endl; */
        last = ids[c][idx];
    }

    /* cerr << "cnt " << cnt << endl; */
    /* cerr << "last " << last << endl; */
    ll ans = cnt * (ll)n + last + 1;
    cout << ans << endl;
}


Measured memory_bytes: 1216
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

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

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

Measured memory_bytes: 4580
#include <stdio.h>
#include <string.h>
  
void conv_str(char *str)
{
    int i;
      
    i = 0;
    while (str[i] != '\0'){
        if (str[i] == ' ' || str[i] == '.'){
            str[i] += 0;
        }
        else if (str[i] != 'z'){
            str[i] += 1;
        }
        else {
            str[i] = 'a';
        }
        i++;
    }
}
  
int main(void)
{
    char str[100];
    int next_flag;
    int i, j;
      
    while (scanf("%[a-z .]", str) != EOF){
        getchar();
          
        next_flag = 0;
        for (i = 0; i < 26; i++){
            for (j = 0; j < strlen(str) - 2; j++){
                if (strncmp(&str[j], "this", 4) == 0 || strncmp(&str[j], "that", 4) == 0 || strncmp(&str[j], "the", 3) == 0){
                    printf("%s\n", str);
                    next_flag = 1;
                    break;
                }
            }
            if (next_flag == 1){
                break;
            }
            conv_str(str);
        }
        memset(str, '\0', sizeof(str));
    }
      
    return (0);
}

Measured memory_bytes: 524
#include<stdio.h>

int main(void)
{
    double pie, r, S, N;

    pie = 3.141592653589;
    scanf("%lf", &r);

    S = r * r * pie;

    N = r * 2 * pie;

    printf("%lf %lf\n", S, N);

    return 0;
}


Measured memory_bytes: 2040
// B - Collatz Problem
#include <bits/stdc++.h>
using namespace std;

int main(){
	int s; cin>>s;
	set<int> S;
	while(1){
		S.insert(s);
		s = s%2? 3*s+1: s/2;
		if(S.count(s)) break;
	}
	cout<< S.size()+1 <<endl;
}

Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
s = [input().split() for i in range(n)]
for i in range(len(s)):
    s[i].append(i+1)
    s[i][1] = int(s[i][1])
s = sorted(s,key=lambda x:(x[0],-x[1]))

for i in range(n):
    print(s[i][2])

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

int main(void) {
  int L;
  cin >> L;

  double answer = (double) L * L * L / 27.0;
  cout << fixed << setprecision(12);
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 384
s=input()

x=dict()
for i in range(len(s)):
    S=s[i]
    if S in x:
        x[S]+=1
    else:
        x[S]=1
M=0
cnt=0
for idx in x:
    M=max(M,x[idx])
    cnt+=1
if cnt==1:
    print(0)
    exit()
#y=sorted(x.items(),key=lambda x:x[1],reverse=True)
ans=10**10
#print(y)
for idy in x:
    t=s
    tmp=t
    count1=0
    count2=0
    cnt=0
    #print(idy)
    while(1):
        p=tmp
        tmp=""
        flag=True
        #print(p)
        for i in range(len(p)-1):
            if p[i]==idy or p[i+1]==idy:
                tmp=tmp+idy
                #count1+=1
                #print(tmp)
            else:
                tmp=tmp+p[i]
                #count2+=1
                flag=False
                #print(tmp)
        #print(tmp)
        cnt+=1
        if flag:
            break
    #cnt=count1+count2

    ans=min(cnt,ans)
print(ans)

Measured memory_bytes: 41452
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val y = LongArray(n)
    for(i in 1..y.lastIndex) {
        y[i] = 2*a[i-1]-y[i-1]
    }
    y[0] = (2*a[n-1]-y[n-1])/2
    for(i in 1..y.lastIndex) {
        y[i] = 2*a[i-1]-y[i-1]
    }
    println(y.joinToString(" "))
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  int n;
  int ans;
  cin >> n;
  vector<int> a(n);
  vector<int> idx;
  int max=0;
  int max_sub=0;
  int max_num=0;
  REP(i,n) {
    int tmp;
    cin >> tmp;
    a[i]=tmp;
    if (max < tmp) {
      max_sub=max;
      max=tmp;
    } else if (max_sub<tmp) {
      max_sub=tmp;
    }
  }
  REP(i,n) {
    if(a[i]==max){
      cout << max_sub << endl;
    } else {
      cout << max << endl;
    }
  }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
  
struct segtree{
  vector<int> t,u;
  int n;
  
  void init(int _n){
    n=1;
    while(n<_n)n*=2;
    t.clear();
    u.clear();
    t.resize(2*n);
    u.resize(2*n);
    for(int i=0;i<2*n;i++)
      t[i]=u[i]=0;
  }
  
  void delay(int k,int l,int r){
    if(r-l==1)return;
    
    t[k*2+1]+=u[k];
    u[k*2+1]+=u[k];
    
    t[k*2+2]+=u[k];
    u[k*2+2]+=u[k];
    
    u[k]=0;
  }
  
  void add(int a,int b,int x,int k,int l,int r){
    if(b<=l || r<=a)return;
    delay(k,l,r);
    if(a<=l && r<=b){
      t[k]+=x;
      u[k]+=x;
    }else{
      int m=(l+r)/2;
      add(a,b,x,k*2+1,l,m);
      add(a,b,x,k*2+2,m,r);
      t[k]=min(t[k*2+1],t[k*2+2]);
    }
  }
  
  int query(int a,int b,int k,int l,int r){
    if(b<=l || r<=a)return INF;
    delay(k,l,r);
    if(a<=l && r<=b){
      return t[k];
    }else{
      int m=(l+r)/2;
      int lc=query(a,b,k*2+1,l,m);
      int rc=query(a,b,k*2+2,m,r);
      return min(lc,rc);
    }
  }
  
  void add(int a,int b,int x) {
    add(a,b,x,0,0,n);
  }
  
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};
  
segtree T;
int N,Q;
char str[300005];
set< int > U;
  
int main(){
  scanf("%d %d",&N,&Q);
  scanf("%s",str);
  T.init(N+2);
  
  
  for(int i=0;i<N;i++){
    if(str[i]=='('){
      T.add(i,N,1);
    }else{
      T.add(i,N,-1);
      U.insert(i);
    }
  }
  
  
  set<int> :: iterator it;
  int p,a;
  while(Q--){
  
  
    scanf("%d",&p);
    p--;
    if(str[p]=='('){
      U.insert(p);
      str[p]=')';
      T.add(p,N,-2);
  
      it=U.begin();
      a= *it;
      printf("%d\n",a+1);
      U.erase(it);
      str[a]='(';
      T.add(a,N,2);
    }else if(str[p]==')'){
      it=U.find(p);
      U.erase(it);
      str[p]='(';
      T.add(p,N,2);
  
  
  
        
      int l=0,r=N-1,m,k;
      while(l<r){
        m=(l+r)/2;
        k=T.query(m,N);
          
        if(k<2){
          l=m+1;
        }else{
          r=m;
        }
      }
      printf("%d\n",l+1);
      str[l]=')';
      T.add(l,N,-2);
      U.insert(l);
    }
  }
  return 0;
}

Measured memory_bytes: 18412
mod = 10**9 + 7
h, w, a, b = map(int, input().split())

fact = [1] * (h + w + 1)
invf = [1] * (h + w + 1)
invn = [1] * (h + w + 1)
for i in range(2, h + w + 1):
  fact[i] = fact[i-1] * i % mod
  invn[i] = (-invn[mod % i]) * (mod // i) % mod
  invf[i] = invf[i-1] * invn[i] % mod

count = 0
for i in range(min(h-a, w-b)):
  count += fact[h+b-a-1] * invf[h-a-i-1] * invf[b+i] * fact[w+a-b-1] * invf[a+i] * invf[w-b-i-1]
  count %= mod
print(count)

Measured memory_bytes: 26740
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int dx[] = {-1,0,1},dy[] = {1,1,1};
int main(){
	int x,y;
	while(cin >> x >> y,x,y){
		int field[20][20] = {{0}};
		int dp[20][20] = {{0}};
		for(int i = 0; i < 20; i++)for(int j = 0; j < 20; j++)field[i][j] = 1;
		for(int i = 1; i <= y; i++){
			for(int j = 1; j <= x; j++){
				cin >> field[i][j];
			}
		}
		for(int i = 1; i <= x; i++){
			if(field[1][i] == 0)dp[1][i] = 1;
		}
		int sum = 0;
		for(int i = 1; i <= y; i++){
			for(int j = 1; j <= x; j++){
				if(field[i][j] == 0){
					for(int k = 0; k < 3; k++){
						int px = j + dx[k],py = i + dy[k];
						if((field[py][px] == 2 && k == 1) || field[py][px] == 0){
							dp[py][px] += dp[i][j];
						}
					}
				}
				else if(field[i][j] == 2){
					if(i == y-1)sum += dp[i][j];
					else{
						if(field[i+2][j] != 1)dp[i+2][j] += dp[i][j];
					}
				}
			}
		}
		for(int i = 1; i <= x; i++){
			sum += dp[y][i];
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int INF = 1e6 + 10, A = 5e3 + 10;
int main() {
    fast_cin();
    int n,k;
    cin>>n;
    cin>>k;
    vector<int>h(n);
    for(int i=0;i<n;i++) {
            cin>>h[i];
    }
    vector<int>dp(n,2147483647);
    dp[0]=0;
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<=k+i;j++) {
            if(j<n) {
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[n-1];
      
}



Measured memory_bytes: 1024
H, W = gets.split.map(&:to_i)

#1マスの場合はOK
if H==1 && W==1
  puts "Yes"
  exit
end

s = Array.new(H)

for i in 0..H-1 do
  s[i] = gets.chomp
end

#2マスの場合，片方だけ黒だとダメ
if H==1 && W==2
  if s[0][0] == "#" && s[0][1] == "." || s[0][0] == "." && s[0][1] == "#"
    puts "No"
    exit
  else
    puts "Yes"
    exit
  end
end

if H==2 && W==1
  if s[0] == "#" && s[1] == "." || s[0] == "." && s[1] == "#"
   puts "No"
   exit
 else
   puts "Yes"
   exit
 end
end

D = [[-1,0],[0,1],[1,0],[0,-1]]

for x in 0..H-1 do
  for y in 0..W-1 do
     next if s[x][y] == "."
     flg = false # falseなら２マス以上黒が連なっていない

     D.each {|dx, dy|
          next if x + dx < 0 || x + dx > H-1 || y + dy < 0 || y + dy > W-1

          flg = true if s[x+dx][y+dy] == "#"
     }

     if flg == false
       puts "No"
       exit
     end
  end
end

puts "Yes"


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

const int MAX = 100 / 0.08;
int main() {
    int a, b;
    cin >> a >> b;
    
    auto fn = [&](int n){
        return (int)(n * 0.08) == a && (int)(n * 0.1) == b;
    };
    
    int ans = -1;
    for (int i = 1; i <= MAX; i++) {
        if (fn(i)) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define MAX 10000000
char primes[MAX+1];
int main(){
  int i,j,n,nx,mx;
  for(i=2,nx=sqrt(MAX)+1;i<nx;i++){
    if(!primes[i]){
      for(j=i*2;j<MAX+2;j+=i) primes[j]=1;
    }
  }
  do{
    scanf("%d",&n);
    if(!n) break;
    while(n>=13){
      if(!primes[n]&&!primes[n-2]&&!primes[n-6]&&!primes[n-8]){
	printf("%d\n",n);
	break;
      }
      for(i=n-1;i>=13;i--){
	if(!primes[i]) break;
      }
      n=i;
    }
  }while(1);
  return 0;
}

Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl

#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

int main(){

   int n,r;
   cin>>n>>r;
   int i;
   if(n>=10) cout<<r<<endl;
   else{
    cout<<r+100*(10-n)<<endl;
   }

    

}

Measured memory_bytes: 256
/*
Author: Do Viet Tung
ID: s1232004
- Run/ Compile:
g++ -std=c++11 -o test p2.cpp
./test
*/

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

using namespace std;

struct subset_t{
	int rank;
	int parent;
};


int find(subset_t subsets[], int i){
	if(subsets[i].parent != i)
		subsets[i].parent = find(subsets, subsets[i].parent);
	return subsets[i].parent;
}

void Union(subset_t subsets[], int i, int j){
	int root_of_i = find(subsets, i);
	int root_of_j = find(subsets, j);

	if(subsets[root_of_i].rank < subsets[root_of_j].rank)
		subsets[root_of_i].parent = root_of_j;
	else if(subsets[root_of_i].rank > subsets[root_of_j].rank)
		subsets[root_of_j].parent = root_of_i;
	else{
		subsets[root_of_i].parent = root_of_j;
		subsets[root_of_j].rank++;
	}
}

struct edge_t{
	int src;
	int dest;
	int weight;
	edge_t(){}
	edge_t(int src, int dest, int weight): src(src), dest(dest), weight(weight) {}
	bool operator<(const edge_t &other) const{
		return weight < other.weight; // IT MUST BE STRICT WEAK ORDERING (THERE IS NO X <= Y, MUST BE X < Y or Y < X)
	}
};

struct graph_t{
	int V;
	int E;
	vector<edge_t> edges;
	graph_t(int V, int E, vector<edge_t> edges): V(V), E(E), edges(edges) {}

	vector<edge_t> kruskal(){
		// create the subset for union-find
		subset_t subsets[V];
		for(int i = 0; i < V; ++i){
			subsets[i] = {0, i};
		}
		// sort a copy of the edges in the non-decreasing order
		sort(edges.begin(), edges.end());

		// add an edge to the minimum spanning tree, if it forms a cycle, then don't
		vector<edge_t> mst;
		for(auto i = 0; i < E; ++i){
			int root_of_src = find(subsets, edges[i].src);
			int root_of_dest = find(subsets, edges[i].dest);
			if(root_of_src != root_of_dest){
				mst.push_back(edges[i]);
				Union(subsets, root_of_src, root_of_dest);
			}
		}

		return mst;
	}		
};


int main(){
	int V, E;
	cin >> V >> E;
	vector<edge_t> edges;
	for(int i = 0; i < E; ++i){
		int src, dest;
		int weight;
		cin >> src >> dest >> weight;
		edges.push_back({src, dest ,weight});
 	}
	graph_t g(V, E, edges);


	vector<edge_t> mst = g.kruskal();
	int edge_sum = 0;
	for(auto edge: mst){
		edge_sum += edge.weight;
	}
	cout << edge_sum << endl;
}


Measured memory_bytes: 6508
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var s = ReadLine();
            WriteLine($"{s.First()}{(s.Length - 2)}{ s.Last()}");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 26220
#include<iostream>
#include<algorithm>
 
using namespace std;
 
bool prime[10000001];
 
int main() {
    for (int i = 3; i * i <= 10000000; i += 2) {
        if (!prime[i]) {
            for (int j = i * 2; j <= 10000000; j += i) {
                prime[j] = true;
            }
        }
    }
    int n;
    while (cin >> n, n) {
        for (;;n--) {
            if (!prime[n] && !prime[n - 2] && !prime[n - 6] && !prime[n - 8] && n % 2 != 0) {
                cout << n << endl;
                break;
            }
        }
    }
    return 0;
}
 

Measured memory_bytes: 10924
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    string g[7]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
    for(int i=0;i<7;i++)
    {
        if(g[i]==s)
        {
            cout<<i+1;
        }

    }
    return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<long> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n-k;i++){
    if(v[i]<v[i+k]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 4840
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

answer = 0
for d in range(10,D+1):
    a,b = divmod(d,10)
    if a >= 2 and b >= 2 and 1<=a*b<=M:
        answer += 1

print(answer)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

struct edge{int to,cost;};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vector<vector<edge>> g(n);
    vector<int> color(n,-1);
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].PB(edge{v,w});
        g[v].PB(edge{u,w});
    }
    

    //とりあえず始点は0にしておく，
    //bfsして，距離が偶数なら親と同じ色
    //距離が奇数なら親と違う色？
    color[0]=0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto nv:g[v]){
            if(color[nv.to]!=-1) continue;
            if(nv.cost%2==0){
                color[nv.to]=color[v];
                que.push(nv.to);
            }else{
                //cout<<nv.to<<nv.cost<<"called"<<endl;
                color[nv.to]=color[v]^1;que.push(nv.to);
            }
        }
    }
    rep(i,n) cout<<color[i]<<endl;
}

Measured memory_bytes: 11324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

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

void solve1()
{
    int r, g, b, n; cin >> r >> g >> b >> n;

    int ans = 0;
    for(int i = n; i >= 0; i--) {
        for(int j = n; j >= 0; j--) {
            if((n - r*i - g*j) % b == 0) {
                int k = (n - r*i - g*j) / b;
            if (k >= 0 && k * b <= n)
            {
                ans ++;
            }
            }
        }
    }

    cout << ans << endl;

}

/* a*x + b*y + c*(all - x - y) = n */

int main()
{
    solve1();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;



int main(){
    int n;
    cin >> n;
    int p[n];
    int check=0;
    rep(i,n){
        int x;
        cin >> x;
        p[i] = x-1;
    }
    rep(i,n){
        if(p[i] != i){
            check++;
        }
    }
    if(check==2 || check == 0){
        cout << "YES" <<endl;
    }
    else{
        cout << "NO" <<endl;
    }
    
    
    
    
    return 0;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "atcoder/dsu"
typedef long long int ll;
using namespace std;
using namespace atcoder;
int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    int t[h][w];
    rep(i,h)rep(j,w){
        int x;cin>>x;
        t[i][j]=(x%2)? 1:0;
    }
    int res=0;
    queue<pair<int,int>> from,to;
    rep(i,h-1)rep(j,w){
        if(t[i][j]%2==1){
            t[i+1][j]++;
            from.push({i,j});
            to.push({i+1,j});
            res++;
        }
    }
    rep(i,w-1){
        if(t[h-1][i]%2==1){
            t[h-1][i+1]++;
            from.push({h-1,i});
            to.push({h-1,i+1});
            res++;
        }
    }
    cout<<res<<endl;
    rep(i,res){
        auto F=from.front(),T=to.front();
        from.pop();to.pop();
        cout<<F.first+1<<" "<<F.second+1<<" "<<T.first+1<<" "<<T.second+1<<endl;
    }
}

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

using namespace std;
using ll=long long;

ll dp[20003][256];

ll dfs(int i,int y,vector<int>&c,vector<int>&x){
    if(i>=x.size())return 0;
    if(y<0)y=0;
    if(y>255)y=255;
    if(dp[i][y]!=-1)return dp[i][y];
    ll res=999999999999;
    for(int j=0;j<c.size();++j){
        res=min(res,dfs(i+1,y+c[j],c,x));
    }
    return dp[i][y]=res+(y-x[i])*(y-x[i]);
}

int main(){
    int n,m;
    while(cin>>n>>m,n){
        for(int i=0;i<20003;++i){
            for(int j=0;j<256;++j)dp[i][j]=-1;
        }
        vector<int>c(m),x(n+1);
        for(int i=0;i<m;++i){
            cin>>c[i];
        }
        x[0]=128;
        for(int i=1;i<n+1;++i){
            cin>>x[i];
        }
        cout<<dfs(0,128,c,x)<<endl;
    }
    return 0;
}

Measured memory_bytes: 44696
#include<stdio.h>
int h[300005], w[300005];
int heap[300005], l;
int cnth[300005], cntw[300005];
int comp_h(int a, int b, int z)
{
	if (z == 0)
	{
		if (h[heap[a]] > h[heap[b]])
			return 1;
		else if (h[heap[a]] < h[heap[b]])
			return -1;
		else if (w[heap[a]] > w[heap[b]])
			return 1;
		else
			return -1;
	}
	else if (z == 1)
	{
		if (cnth[heap[a]] < cnth[heap[b]])
			return 1;
		else
			return -1;
	}
	else
	{
		if (cntw[heap[a]] < cntw[heap[b]])
			return 1;
		else
			return -1;
	}
}
void swap_h(int a, int b)
{
	int f = heap[a];
	heap[a] = heap[b];
	heap[b] = f;
	return;
}
void f1(int ne, int z)
{
	heap[l] = ne;
	int p = l;
	l++;
	while (p > 0)
	{
		if (comp_h((p - 1) / 2, p, z) > 0)
			swap_h((p - 1) / 2, p);
		p = (p - 1) / 2;
	}
	return;
}
int f2(int z)
{
	l--;
	swap_h(0, l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2, z) > 0)
			{
				if (comp_h(p, 2 * p + 2, z) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1, z) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1, z) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return heap[l];
}
int main()
{
	int H, W, M;
	scanf("%d %d %d", &H, &W, &M);
	int i, j;
	for (i = 0; i < M; i++)
		scanf("%d %d", &h[i], &w[i]);
	l = 0;
	for (i = 0; i < M; i++)
		f1(i, 0);
	int c[300005];
	for (i = 0; i < M; i++)
		c[i] = f2(0);
	for (i = 0; i < H; i++)
		cnth[i] = 0;
	for (i = 0; i < W; i++)
		cntw[i] = 0;
	for (i = 0; i < M; i++)
	{
		cnth[h[i]]++;
		cntw[w[i]]++;
	}
	int hh[300005], ww[300005];
	l = 0;
	for (i = 0; i <= H; i++)
		f1(i, 1);
	for (i = 0; i <= H; i++)
		hh[i] = f2(1);
	l = 0;
	for (i = 0; i <= W; i++)
		f1(i, 2);
	for (i = 0; i <= W; i++)
		ww[i] = f2(2);
	int min, mid, max;
	c[M] = M;
	h[M] = w[M] = -1;
	for (i = 0; cnth[hh[i]] == cnth[hh[0]]; i++)
	{
		for (j = 0; cntw[ww[j]] == cntw[ww[0]]; j++)
		{
			min = -1;
			max = M;
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (h[c[mid]] < hh[i])
					min = mid;
				else if (h[c[mid]] > hh[i])
					max = mid;
				else if (w[c[mid]] < ww[j])
					min = mid;
				else
					max = mid;
			}
			if (h[c[max]] != hh[i] || w[c[max]] != ww[j])
			{
				printf("%d\n", cnth[hh[0]] + cntw[ww[0]]);
				return 0;
			}
		}
	}
	printf("%d\n", cnth[hh[0]] + cntw[ww[0]] - 1);
	return 0;
}

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

using namespace std;

typedef long long LL;

#define MAX_T 1005

int T;
int N[MAX_T], D[MAX_T];

void input()
{
  cin >> T;
  for (size_t i = 0; i < T; i++) {
    cin >> N[i] >> D[i];
  }
}

void solve()
{
  for (size_t testcase = 0; testcase < T; testcase++) {
    int _D = 127 ^ D[testcase];
    int ret = 127 * (N[testcase]-1);
    if(N[testcase]%2 == 0){
      ret += _D;
    }
    else{
      ret += D[testcase];
    }
    cout << ret << endl;
  }
}

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


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  ll N;
  cin >> N;
  map<string, ll> m;
  REP(i, N) {
    string s;
    cin >> s;
    m[s]++;
  }
  PRINT("AC x " << m["AC"]);
  PRINT("WA x " << m["WA"]);
  PRINT("TLE x " << m["TLE"]);
  PRINT("RE x " << m["RE"]);
  return 0;
} 


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    
    cout << n * (n+1) / 2 << endl;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
w = [0] * (N+1)
v = [0] * (N+1)
for i in range(1, N + 1):
    w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]

if w[1] == 1:
    dp[1][1] = v[1]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        if j >= w[i]:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i])
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[N][W])

Measured memory_bytes: 146984
def partition(arr, p, r):
    x = int(arr[r][1])
    i = p
    for j in range(p, r):
        if int(arr[j][1]) <= x:
            arr[i], arr[j] = arr[j], arr[i]
            i += 1
    arr[i], arr[r] = arr[r], arr[i]
    return i


def quicksort(arr, p, r):
    if p < r:
        q = partition(arr, p, r)
        quicksort(arr, p, q - 1)
        quicksort(arr, q + 1, r)


n = int(input())
arr = [input().split() for _ in range(n)]
arr_s = sorted(arr, key=lambda x:x[1])
quicksort(arr, 0, n - 1)


print("Stable" if arr == arr_s else "Not stable")
for ele in arr:
    print(*ele)




Measured memory_bytes: 29992
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m;
		int t[], h[];
		int t2[], h2[];
		int sumT, sumH;
		int diff;
		int ansT, ansH;

		while (true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}
			t = new int[n];
			h = new int[m];
			sumT = sumH = 0;
			for (int i = 0; i < n; i++) {
				t[i] = sc.nextInt();
				sumT += t[i];
			}
			for (int i = 0; i < m; i++) {
				h[i] = sc.nextInt();
				sumH += h[i];
			}
			Arrays.sort(t);
			Arrays.sort(h);
			diff = sumT - sumH;

			ansT = ansH = 1000;
			if (diff % 2 == 1 || (sumT + sumH) % 2 == 1) {
				System.out.println("-1");
			} else {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < m; j++) {
						if (diff / 2 == t[i] - h[j] && t[i] + h[j] < ansT + ansH) {
							ansT = t[i];
							ansH = h[j];
						}
					}
				}
				if (ansT == 1000) {
					System.out.println("-1");
				} else {
					System.out.println(ansT + " " + ansH);
				}
			}
		}
	}
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;

int main(){
    
    int L;cin>>L;
    int N,cnt=-1;
    for(int i=1;;i++){
        if((1<<i)>L){
            N=i;
            break;
        }
    }
    for(int i=0;i<N;i++){
        if(L&(1<<i)) cnt++;
    }
    cout<<N<<" "<<2*(N-1)+cnt<<endl;
    
    for(int i=1;i<N;i++){
        cout<<i<<" "<<i+1<<" "<<0<<endl;
        cout<<i<<" "<<i+1<<" "<<(1<<(N-i-1))<<endl;
    }
    
    int now=(1<<(N-1));
    for(int i=N-2;i>=0;i--){
        if(L&(1<<i)){
            cout<<1<<" "<<N-i<<" "<<now<<endl;
            now+=(1<<i);
        }
    }
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, S[100000], T[50000], n, q, left, right, mid, cnt=0, flag=0;
  scanf("%d", &n);
  if(n > 0 && n <= 100000){
    for(i = 0; i < n; i++){
      scanf("%d", &S[i]);
      if(i > 0){
	if(S[i-1] > S[i] || S[i] > 1000000000) flag = 1;
      }
    }

    if(flag != 1){
      scanf("%d", &q);
      if(q > 0 && q <= 50000){
	for(i = 0; i < q; i++){
	  scanf("%d", &T[i]);
	  if(T[i] > 1000000000) flag = 1;
	}
	if(flag != 1){
	  for(j = 0; j < q; j++){
	    left = 0;
	    right = n;
	    while(left < right){
	      mid = (left + right) / 2;
	      if(S[mid] == T[j]){
		cnt++;
		break;
	      }else if(T[j] < S[mid]){
		right = mid;
	      }else{
		left = mid + 1;
	      }
	    }
	  }
      
	  printf("%d\n", cnt);
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2324
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,K,ans,r;
LL a, b;
string s;

int main() {

	cin >> N;
	ans = N / 11;
	ans *= 2;
	if (N % 11 == 0) {
		cout << ans << endl;
		return 0;
	}
	if (N % 11 <= 6) {
		ans++;
	}
	else {
		ans += 2;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int a = n / 500;
    int res = 1000 * a;
    n %= 500;
    n /= 5;
    res += 5 * n;
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class A {
	int a, b;
public:
	A()
	{
		cin >> a >> b;
	}
	void solve()
	{
		if (!(a % 3) || !(b % 3) || !((a + b) % 3))
			cout << "Possible" << endl;
		else
			cout << "Impossible" << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

signed main()
{ // #define int long long をしてるのでscanfを使うと意味不明な値が入力され死にます
    string S; cin >> S;

    int depth = 0;
    int ans = 0;

    rep(i, S.size()) {
        if (S[i] == 'S') {
            depth++;
        } else {
            depth--;
            if (depth >= 0) {
                ans += 2;
            } else {
                depth = 0;
            }
        }
    }

    cout << S.size() - ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int i,j,n,a[10000],q,key,sum = 0;

  scanf("%d",&n);

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

  for(j = 0;j < q;j++){
    scanf("%d",&key);

    for(i = 0;i < n;i++){
      if(key == a[i]){
	sum++;
	break;
      }
    }
  }

  printf("%d\n",sum);
  
  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>

int main(){
  int i,n,x,a[100],sum=0,count=1;
  scanf("%d %d",&n,&x);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  
  for(i=0;i<n;i++){
    sum+=a[i];
    if(sum<=x)count++;
    else break;
  }
  printf("%d\n",count);
  return 0;
  
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<stack>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<cstring>
#include<deque>

//----------------------------------------
#define mrepp(i,n,x) for(int i = n-1; i >= x; i--)
#define mrep(i,n) mrepp(i,n,0)
#define repp(i,x,n) for(int i =x; i < n; i++)
#define rep(i,n) repp(i,0,n)

using namespace std;
//----------------------------------------


int main(void){
	for(int N; cin >> N && N;){
		int t[100];
		rep(i,N)
			cin >> t[i];
		sort(t,t+N);
		
		int to = 0;
		repp(i,1,N-1){
			to += t[i];
		}
		
		cout << to/(N-2) << endl;
	}
	
	return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

lint pow(lint x, lint k) {
	lint ret = 1;
	while (k) {
		if (k & 1) ret *= x;
		x *= x;
		k >>= 1;
	}
	return ret;
}

int main() {
	lint N, A;
	cin >> N >> A;
	
	lint ans = N;
	for_(x,1,60) {
		lint mx = sqrt(N) + 2;
		for_(t,1,mx) {
			if (pow(t, x+1) >= N) {
				for_(k,0,x+1) {
					if (pow(t, x-k+1) * pow(t-1, k) >= N) {
						ans = min(ans, A*x + t * (x-k+1) + (t-1) * k);
					}
				}
				break;
			}
		} 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
int main(void){
    char s[11];
    int i,count,ans;
    ans = 0;
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T' ){
            count++;
            if(ans<count){
                ans = count;
            }
        }else{
            count = 0;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
// AtCoder ABC109: A - ABC333
// 2019.9.12 bal4u

#include <stdio.h>

void chmax(int *r, int a) { if (*r < a) *r = a; }

int main()
{
	int A, B, C, ans;
	
	ans = 0;
	scanf("%d%d%d", &A, &B, &C);
	chmax(&ans, A*10 + B + C);
	chmax(&ans, B*10 + A + C);
	chmax(&ans, C*10 + A + B);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main(){
  ll N,Q; cin>>N>>Q;
  vi a(N),x(Q); REP(i,N) cin>>a[i]; REP(i,Q) cin>>x[i];
  vi sum(N+1); sum[0]=0; REP(i,N) sum[i+1]=sum[i]+a[i];
  REP(j,Q) {
    ll cnt=0;
    REP(i,N) cnt+=distance(sum.begin()+i,LB(ALL(sum),sum[i]+x[j]+1))-1;
    cout<<cnt<<endl;
  }
}

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

void output_vector(vector<int> &A) {
  int vector_size = A.size();
  
  for (int i = 0; i < vector_size-1; i++) {
    cout << A.at(i) << " ";
  }
  cout << A.at(vector_size-1) << endl;
}

int main() {
  int N, v, j;
  cin >> N;
  vector<int> A(N);

  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  int num_change = 0;
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    if (minj != i) {
      int tmpA = A.at(i);
      A.at(i) = A.at(minj);
      A.at(minj) = tmpA;
      num_change++;
    }
  }
  
  output_vector(A);
  cout << num_change << endl;
  
}


Measured memory_bytes: 3116
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n;
    cin>>n;
    string S;
    cin>>S;
    int res=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			for(int j=0;j<i;j++)
				if(S[j]==c)
					left=true;
			for(int j=i;j<n;j++)
				if(S[j]==c)
					right=true;
			if(left&&right)
				cnt++;
		}
		res = max(res,cnt);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
N=int(input())
S=input()
a=0
n=int(N/2)
if N%2==0:
    for i in range(n):
        if S[i]!=S[i+n]:
            a=1
    if a==1:
        print('No')
    else:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
def solve():
  n,k = (int(i) for i in input().split())
  r,s,p = (int(i) for i in input().split())
  t = input()
  score = 0
  times = 0
  possible = [False]*n
  for i in range(n):
    if i >= k:
      if t[i-k] == t[i] and possible[i-k]== False:
        possible[i] = True
        continue

    if t[i] == "r":
        score += p
    elif t[i] == "s":
        score += r
    elif t[i] == "p":
        score += s
  print(score)
solve()

Measured memory_bytes: 4084
n, m = map(int, input().split())
A = [list(map(int, input().split()))[::-1] for _ in range(n)]
ans = n
for _ in range(m):
  C = [0]*m
  for i in A:
    C[i[-1]-1] += 1
  t = max(C)
  ans = min(ans, t)
  l = C.index(t)+1
  for i in A:
    i.remove(l)
print(ans)

Measured memory_bytes: 4212
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine().Trim(); }
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static void Display(int[] xs) {
//        for (int i = 0; i < xs.Length; i++) {
//            if (i > 0) Console.Write(' ');
//            Console.Write(xs[i]);
//        }
//        Console.WriteLine();


//        string[] ss = new string[xs.Length];
//        for (int i = 0; i < xs.Length; i++) {
//            ss[i] = xs[i].ToString();
//        }

//        Console.WriteLine(string.Join(" ", ss));

        // string[] ss = xs.Select(e => e.ToString()).ToArray();
        Console.WriteLine(string.Join(" ", (string[])xs.Select(e => e.ToString()).ToArray()));
    }

    static void Main() {
        int n = ReadInt();
        int[] xs = ReadInts();
        if (n != xs.Length) throw new Exception();

        Display(xs);
        for (int i = 1; i < xs.Length; i++) {
            int key = xs[i];
            // insert xs[i] into the sorted sequence xs[0..j-1]
            int j = i - 1;
            while (j >= 0 && xs[j] > key) {
                xs[j+1] = xs[j];
                j--;
            }
            xs[j+1] = key;

            // output
            Display(xs);
        }
    }
}

Measured memory_bytes: 6080