akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
  string s;
  int gx, gy;
  cin >> s >> gx >> gy;
  bool flag = true;
  vector<int> x, y;
  int temp = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'F') temp++;
    else{
      if(flag){
	x.push_back(temp);
	temp = 0;
	flag = false;
      }else{
	y.push_back(temp);
	temp = 0;
	flag = true;
      }
    }
  }
  if(flag){
    x.push_back(temp);
  }else{
    y.push_back(temp);
  }
  int posx = 0;
  int posy = 0;
  posx += x[0];
  x.erase(x.begin());
  sort(x.begin(), x.end(), greater<int>());
  sort(y.begin(), y.end(), greater<int>());
  for(int i = 0; i < x.size(); i++){
    temp = x[i];
    if(posx < gx) posx += temp;
    else posx -= temp;
  }
  for(int i = 0; i < y.size(); i++){
    temp = y[i];
    if(posy < gy) posy += temp;
    else posy -= temp;
  }
  if(posx == gx && posy == gy) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, M, X;
    cin >> N >> M >> X;
    int book[15][15];
    REP(i, N)
    {
        REP(j, M + 1)
        {
            cin >> book[i][j];
        }
    }

    int lis[15];
    int ans = INF;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        REP(i, M)
        {
            lis[i] = 0;
        }
        int money = 0;
        REP(i, N)
        {
            if (bit & (1 << i))
            {
                money += book[i][0];
                REP(j, M)
                {
                    lis[j] += book[i][j + 1];
                }
            }
        }
        bool flg = true;
        REP(i, M)
        {
            if (lis[i] < X)
                flg = false;
        }
        if (flg)
        {
            ans = min(money, ans);
        }
    }
    if (ans == INF)
    {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin>>n>>m;
	vector<int>len(m),p(m);
	vector<vector<int>>s(m,vector<int>(n,-1));
	for(int i=0;i<m;i++){
		cin>>len[i];
		for(int j=0;j<len[i];j++){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++)
		cin>>p[i];
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		set<int>on_bit;
		for(int j=0;j<n;j++)
			if(i&(1<<j))
				on_bit.insert(j);
		int flag=1;
		for(int j=0;j<m;j++){
			int bulb=0;
			for(int k=0;k<len[j];k++){
				if(on_bit.count(s[j][k]))
					bulb++;
			}
			if(bulb%2!=p[j]){ 
				flag=0;
				break;
			}
		}
		if(flag)
			ans++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
from functools import lru_cache

n,k = list(map(int, input().split()))

# 2000までの階乗（MOD:10^9+7）とその逆元を計算しておく
MOD = 10**9+7
fact = [1, 1]
fact_inv = [1, 1]

for i in range(2, n+1):
    fact.append(fact[i-1] * i % MOD)
    fact_inv.append(pow(fact[i], MOD-2, MOD))

@lru_cache(maxsize=None)
def combi(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return (fact[n] * fact_inv[k] * fact_inv[n-k]) % MOD

for i in range(1, k+1):
    print((combi(n-k+1, i) * combi(k-1, i-1)) % MOD)

Measured memory_bytes: 10220
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

using namespace std;


int main()  {
    int a;
    cin >> a;
    int n[4];
    for (int i = 0; i < 4; i++) {
        int tmp = a % 10;
        a /= 10;
        n[4 - i - 1] = tmp;
    }
    int res = 0; 
    string final = "";
    for (int i = 0; i < 8; i++) {
        res = n[0];
        final = "";
        final.push_back('0' + n[0]);
        if (i & 4)  {
            res -= n[1];
            final.push_back('-');
            final.push_back('0' + n[1]);
        } else {
            res += n[1];
            final.push_back('+');
            final.push_back('0' + n[1]);
        }
        if (i & 2)  {
            res -= n[2];
            final.push_back('-');
            final.push_back('0' + n[2]);
        } else {
            res += n[2];
            final.push_back('+');
            final.push_back('0' + n[2]);
        }
        if (i & 1)  {
            res -= n[3];
            final.push_back('-');
            final.push_back('0' + n[3]);
        } else  {
            res += n[3];
            final.push_back('+');
            final.push_back('0' + n[3]);
        }
        if (res == 7)    {
            final.push_back('=');
            final.push_back('7');
            cout << final << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> b(N);
    REP(i, 0, N) cin >> b[i];

    vector<int> ans(N);
    REP(i, 0, N) {
        int num = 0;
        for (int j = b.size() - 1; j >= 0; j--) {
            if (b[j] == j + 1) {
                num = j + 1;
                b.erase(b.begin() + j);
                break;
            }
        }
        if (!num) {
            cout << -1 << endl;
            return 0;
        }
        ans[i] = num;
    }

    REP(i, 0, N) cout << ans[ans.size() - 1 - i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll,ll> pll;
vector<ll> A;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    A.resize(n);
    rep(i,n){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    rep(i,n){
        m-=A[i];
        if(m<0)break;
        ans++;
    }
    if(m>0)ans--;
    cout<<ans<<endl;
}

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

int main(){
    string st, ans="Yes";   cin >> st;
    int n=0, s=0, e=0, w=0;

    for(int i=0; i<st.size();i++){
        if(st[i]=='S') s+=1;
        else if(st[i]=='N') n+=1;
        else if(st[i]=='W') w+=1;
        else e+=1;
    }
    if(n<s) swap(n, s);
    if(e<w) swap(e, w);
    if((n!=0 && s==0) || (e!=0 && w==0))  ans = "No";
    cout << ans << endl;
}


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

int main(){
  int cost=0;
  vector<int> vec(3);
  for(int i=0;i<3;i++)
    cin>>vec.at(i);
  sort(vec.begin(),vec.end());
  cout<<abs(vec.at(0)-vec.at(1))+abs(vec.at(1)-vec.at(2))<<endl;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance(vec.begin(), itr);
    if (index != vec.size()) { // 発見できたとき
        return 1;
    } else { // 発見できなかったとき
        return 0;
    }
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

struct node {
    vector<int> childs;
    int count = 0;
};

void dfs(vector<node> &nodes, int label, int addcount) {

    nodes[label].count += addcount;
    for (int child : nodes[label].childs) {
        dfs(nodes, child, nodes[label].count);
    }
}

int main() {

    int A, B;

    cin >> A >> B;

    int c = 0;
    int num = 1;
    while (true) {

        if (num < B) {
            num--;
            num += A;
        } else {
            break;
        }
        c++;
    }

    cout << c << endl;
}

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

int main(void) {
  string S;
  cin >> S;
  int len = S.size();
  int start = (len % 2) ? 1 : 2;
  for (int i = start; i < len; i += 2) {
    int half = (len - i) / 2;
    if (S.substr(0, half) == S.substr(half, half)) {
      cout << len - i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]

a=ord("a")
l=[50]*26

for i in s:
    for j in range(26):
        l[j] = min(l[j],i.count(chr(a+j)))

for i in range(26):
    for kk in range(l[i]):
        print(chr(a+i),end="")


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
bool knapsack(vector<int> weight,int W){
  vector<int> dp(20001,inf);
  dp[0]=0;
  int n=weight.size();
  for(int i=0;i<n;i++){
    weight[i]*=2;
    for(int j=20000;j>=0;j--){
      if(weight[i]<=j){
        dp[j]=min(dp[j],dp[j-weight[i]]+1);
      }
    }
  }
  return dp[W]!=inf;
}
signed main(){
  string s;cin>>s;
  int x,y;cin>>x>>y;
  int n=s.length();
  int ind=inf;
  rep(i,n){
    if(s[i]=='T'){
      ind=i;
      break;
    }
    else x-=1;
  }
  if(ind==inf){
    if(x==0&&y==0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
    return 0;
  }
  bool flag=true;
  int cur=0;
  s+='T';
  vector<int> X,Y;
  //printf("ind==%d, n=%d\n",ind,n);
  for(int i=ind+1;i<=n;i++){
    if(s[i]=='T'){
      flag=!flag;
      if(cur==0)continue;
      if(flag)X.push_back(cur);
      else Y.push_back(cur);
      cur=0;
    }
    else cur++;
  }
  vector<int> hogeX(X);
  vector<int> hogeY(Y);
  int sumX=0;
  int sumY=0;
  int xnum=X.size();
  rep(i,xnum)sumX+=X[i];
  int ynum=Y.size();
  rep(i,ynum)sumY+=Y[i];
  if(sumX<x||sumY<y){
    cout<<"No"<<endl;
    return 0;
  }
  //printf("sumY-y=%d\n",sumY-y);
  if(knapsack(X,sumX-x)){
    if(knapsack(Y,sumY-y)){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T; cin >> S >> T;
  int ans=0;

 
  if(S.at(0) == T.at(0)) ans++;
  if(S.at(1) == T.at(1)) ans++;
  if(S.at(2) == T.at(2)) ans++;

	cout << ans  << endl;

    return 0;
}

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

int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	vector<ll> h(N);
	for (int i = 0; i < N; i++){
		cin >> h[i];
	}
	sort(h.begin(), h.end());

	ll right = (h[N-1]+B-1)/B;
	ll left = 0;
	while ((right-left)/2 != 0){
		ll mid = left+(right-left)/2;
		ll x = mid*B;
		auto it = upper_bound(h.begin(), h.end(), x);
		ll cnt = 0;
		for (int i = (it-h.begin()); i < N; i++){
			ll resth = h[i]-x;
			cnt += (resth+(A-B)-1)/(A-B);
		}

		if (cnt <= mid){
			right = mid;
		} else {
			left = mid;
		}
	}

	cout << right << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e8;
typedef pair<ll,ll> LL;

string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>

char buf[40];
bool inOrigin[256];
char out[10][25];

int count(char *c){
    if (*c=='\0') return 1;

    int ret=0;
    if (!inOrigin[*c]) {
        if (inOrigin[(*c)+1]) return 0;
        inOrigin[(*c)+1]=true;
        ret+=count(c+1);
        inOrigin[(*c)+1]=false;
    }else{
        ret+=count(c+1);
        if (!inOrigin[(*c)+1]) {
            inOrigin[(*c)+1]=true;
            ret+=count(c+1);
            inOrigin[(*c)+1]=false;
        }
    }

    return ret;
}

void outputAll(char* c){
    char cur=*c;
    if (cur=='\0') {
        puts(buf);
        return;
    }

    if (!inOrigin[cur]) {
        if (inOrigin[(*c)+1]) return ;
        inOrigin[cur+1]=true;
        (*c)+=1;
        outputAll(c+1);
        (*c)-=1;
        inOrigin[cur+1]=false;
    }else{
        outputAll(c+1);
        if (!inOrigin[(*c)+1]) {
            inOrigin[(*c)+1]=true;
            (*c)+=1;
            outputAll(c+1);
            (*c)-=1;
            inOrigin[(*c)+1]=false;
        }
    }
}

int outCnt=0;
void outputLess(char* c){
    if (outCnt==5) return;
    char cur=*c;
    if (cur=='\0') {
        strcpy(out[outCnt],buf);
        outCnt++;
        // if (outCnt==5) throw 1;
        return;
    }

    if (!inOrigin[cur]) {
        if (inOrigin[(*c)+1]) return ;
        if (outCnt==5) return;
        inOrigin[cur+1]=true;
        (*c)+=1;
        outputLess(c+1);
        (*c)-=1;
        inOrigin[cur+1]=false;
    }else{
        if (outCnt==5) return;
        outputLess(c+1);
        if (!inOrigin[(*c)+1]) {
            if (outCnt==5) return;
            inOrigin[(*c)+1]=true;
            (*c)+=1;
            outputLess(c+1);
            (*c)-=1;
            inOrigin[(*c)+1]=false;
        }
    }
}

void outputLarger(char* c){
    if (outCnt==5) return;
    char cur=*c;
    if (cur=='\0') {
        strcpy(out[9-outCnt],buf);
        outCnt++;
        // if (outCnt==5) throw 1;
        return;
    }

    if (!inOrigin[cur]) {
        if (inOrigin[(*c)+1]) return ;
        if (outCnt==5) return;
        inOrigin[cur+1]=true;
        (*c)+=1;
        outputLarger(c+1);
        (*c)-=1;
        inOrigin[cur+1]=false;
    }else{
        if (!inOrigin[(*c)+1]) {
            if (outCnt==5) return;
            inOrigin[(*c)+1]=true;
            (*c)+=1;
            outputLarger(c+1);
            (*c)-=1;
            inOrigin[(*c)+1]=false;
        }
        if (outCnt==5) return;
        outputLarger(c+1);
    }
}

int main(){
    inOrigin['a']=true;
    inOrigin['z'+1]=true;
    while(scanf("%s",buf)&&buf[0]!='#'){
        auto temp=count(buf);
        printf("%d\n",temp);
        if (temp<=10) outputAll(buf);
        else{
            outCnt=0;
            outputLess(buf);
            outCnt=0;
            outputLarger(buf);
            for(int i=0;i<10;i++) puts(out[i]);
        }
    }


    return 0;
}


Measured memory_bytes: 2592
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] array = new int[n];

        for(int i = 0;i < array.length;i++) {
        	array[i] = sc.nextInt();
        }
        for(int i = n - 1;i >= 0;i--) {
        	System.out.print(array[i]);
        	if(!(i == 0)){
        		System.out.print(" ");
        	}
        }
        System.out.println();
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

int main() {
	cin >> n;
	
	cout << (1.0 * ce(n, 2) / n) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int h,w,n,b[10001],c=0,h1=1,a;
    cin>>h>>w>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        for(int j=0;j<a;j++)
        {
            b[c+j]=h1;
        }
        h1++;
        c+=a;
    }
    for(int k=0;k<h;k++)
   {

        for(int l=0;l<w;l++)
    {
        if(k%2==0)
        {
            cout<<b[w*k+l];
            cout<<" ";
        }
        else
        {
            cout<<b[w*(k+1)-l-1];
            cout<<" ";
        }

    }
       cout<<endl;
   }

}


Measured memory_bytes: 384
#include <stdio.h>

#define TRUE 1
#define FALSE 0

typedef struct {
  char suit;
  int value;
} Card;

void BubbleSort(Card *,int);
void SelectionSort(Card *,int);
int isStable(Card *,Card *,int);
void print(Card *,int);
void swap(Card *,Card *);

int main(){
  int i,N;
  Card C1[36],C2[36];


  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf(" %c%d",&C1[i].suit,&C1[i].value);
     }

  for(i=0;i<N;i++)C2[i] = C1[i];

  BubbleSort(C1,N);
  SelectionSort(C2,N);

  print(C1,N);
  if( isStable(C1,C1,N) )printf("Stable\n");
  else printf("Not stable\n");

  print(C2,N);
  if( isStable(C1,C2,N) )printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}

void BubbleSort(Card C[],int N){
  int i,j,flag;

  flag = 1;

  while(flag){
    flag = 0;
    for(i=0;i < N;i++){
for(j=N-1;j >= i+1;j--){

        if( C[j].value < C[j-1].value ){
          swap(&C[j],&C[j-1]);

          flag = 1;

        }
      }
    }
  }
}

void SelectionSort(Card C[],int N){
  int i,j,minj;


  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j < N;j++){
      if( C[j].value < C[minj].value){
        minj = j;
      }
    }
        swap(&C[i],&C[minj]);
    }
}



int isStable(Card in[],Card out[],int N){
  int i,j,a,b;

  for(i=0;i<N;i++){

    for(j=i+1;j<N;j++){

      for(a=0;a<N;a++){

        for(b=a+1;b<N;b++){
           if( (in[i].value == in[j].value) && (in[i].value == out[b].value) &&  (in[i].suit == out[b].suit) && (in[j].val\
ue == out[a].value) && (in[j].suit  == out[a].suit)){
            return FALSE;
          }

        }

      }

    }

 }

  return TRUE;
}

void print(Card C[],int N){
  int i;

  for(i=0;i<N;i++){
    if(i>0)printf(" ");

    printf("%c%d",C[i].suit,C[i].value);
  }
  printf("\n");
}

void swap(Card *in,Card *out){
  Card temp;

  temp = *in;
  *in = *out;
  *out = temp;
}



Measured memory_bytes: 2144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	var a, b, x int
	fmt.Scan(&a, &b, &x)
	if a <= x && x <= a+b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    string s;
    cin >> s;
    int a,b,c,d;
    a = s[0]-'0';
    b = s[1]-'0';
    c = s[2]-'0';
    d = s[3]-'0';
    auto k = {-1, 1};
    auto f=[](int k){
        if(k == -1)return "-";
        else return "+";
    };
    for(auto x : k){
        for(auto y : k){
            for(auto z : k){
                if(b*x+c*y+d*z==7-a){
                    cout << to_string(a) << f(x) << to_string(b) << f(y)<< to_string(c) << f(z) << to_string(d) << "=7";
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <bitset>
#include <map>
#include <cstring>
#include <cstdlib>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int a, b;
	cin >> a >> b;
	if(a == 1) a = 100;
	if(b == 1) b = 100;
	if(a == b){
		cout << "Draw" << endl;
		return 0;
	}
	if(a < b){
		cout << "Bob" << endl;
	}else{
		cout << "Alice" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
vector<string> split(string& input, char delimiter)
{
  istringstream stream(input);

  string field;
  vector<string> result;
  while (getline(stream, field, delimiter)) {
      if(field != "")
          result.push_back(field);
  }
  return result;
}

int main(void){

  string input;
  cin >> input;
  vector <string> vec = split (input,',');
  REP(i,vec.size()){
      cout << vec[i];
      if(i != vec.size()-1)
          cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string S;
	cin >> S;
	int ans = 0;
	for(int i = 1; i < S.size(); i++)
		if(S[i - 1] != S[i]) ans++;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>

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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }
  sort(A.begin(), A.end());

  int AI = A.back();
  A.pop_back();

  int target = (AI + 1) / 2;
  auto itr = lower_bound(A.begin(), A.end(), target);
  int AJ = A.back();
  if (itr != A.end()) {
    if (itr == A.begin()) {
      AJ = *itr;
    } else {
      int diff0 = abs(target - *itr);
      int diff1 = abs(target - *(itr - 1));
      if (diff0 < diff1)
        AJ = *itr;
      else
        AJ = *(itr - 1);
    }
  }
  cout << AI << " " << AJ << endl;
  return 0;
}

Measured memory_bytes: 640
# coding: utf-8
import heapq

n, m = map(int, input().split())
l = [ -1 * int(n) for n in input().split()]

heapq.heapify(l)

for i in range(m):
    a = heapq.heappop(l) * (-1)
    a = int(a/2)
    if a != 0:
        heapq.heappush(l, a * (-1))
    if len(l) == 0:
        break
    
    
print(sum(l) * (-1))
    

Measured memory_bytes: 14180
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		long[] a = new long[n];
		for(int i=0;i<n;i++) a[i] = input.nextLong();
		
		long tot = 0;
		HashMap<Long,Long> hmap = new HashMap<Long,Long>();
		
		for(int i=0;i<n;i++){
		    hmap.put(a[i],hmap.getOrDefault(a[i],(long)0)+1);
		}
		
		for(Map.Entry<Long,Long> e:hmap.entrySet()){
		    long v = e.getValue();
		    tot += (v*(v-1))/2;
		}
		
		for(int i=0;i<n;i++){
		    long v = hmap.get(a[i]);
		    long val = tot;
		    val -= (v*(v-1))/2;
		    v--;
		    val += (v*(v-1))/2;
		    
		    System.out.println(val);
		}
	}
}


Measured memory_bytes: 107808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
    a[i]--;
  }
  int ans=0;
  rep(i,0,n){
    if(a[i]==i){
      swap(a[i],a[i+1]);
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#!usr/bin/env python3

import sys


class Die:
    def __init__(self, pips):
        self.pips = pips

    def move_die(self, direction):
        if direction == 'N':
            tmp = self.pips[0]
            self.pips[0] = self.pips[1]
            self.pips[1] = self.pips[5]
            self.pips[5] = self.pips[4]
            self.pips[4] = tmp
            del tmp
        elif direction == 'S':
            tmp = self.pips[0]
            self.pips[0] = self.pips[4]
            self.pips[4] = self.pips[5]
            self.pips[5] = self.pips[1]
            self.pips[1] = tmp
            del tmp
        elif direction == 'E':
            tmp = self.pips[0]
            self.pips[0] = self.pips[3]
            self.pips[3] = self.pips[5]
            self.pips[5] = self.pips[2]
            self.pips[2] = tmp
            del tmp
        elif direction == 'W':
            tmp = self.pips[0]
            self.pips[0] = self.pips[2]
            self.pips[2] = self.pips[5]
            self.pips[5] = self.pips[3]
            self.pips[3] = tmp
            del tmp

    def spin_die_clockwise(self):
        tmp = self.pips[1]
        self.pips[1] = self.pips[2]
        self.pips[2] = self.pips[4]
        self.pips[4] = self.pips[3]
        self.pips[3] = tmp
        del tmp


def init_die():
    pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]
    die = Die(pips)

    return die


def roll_die(die):
    directions = list(sys.stdin.readline().strip('\n'))

    for direction in directions:
        die.move_die(direction)

    return die


def question_rightside(die):
    q = int(sys.stdin.readline().strip('\n'))

    for question in range(q):
        q_pips = [int(pip) for pip in sys.stdin.readline().strip('\n').split()]

        if q_pips[0] == die.pips[1]:
            die.move_die('N')
        elif q_pips[0] == die.pips[2]:
            die.move_die('W')
        elif q_pips[0] == die.pips[3]:
            die.move_die('E')
        elif q_pips[0] == die.pips[4]:
            die.move_die('S')
        elif q_pips[0] == die.pips[5]:
            die.move_die('N')
            die.move_die('N')

        while die.pips[1] != q_pips[1]:
            die.spin_die_clockwise()

        print(die.pips[2])


def are_identical(die1, die2):
    if sorted(die1.pips) != sorted(die2.pips):
        return 'No'
    else:
        for idx, pip in enumerate(die2.pips):
            for spin in range(4):
                if die1.pips == die2.pips:
                    return 'Yes'
                else:
                    die1.spin_die_clockwise()
            if idx in {0, 1, 2}:
                die1.move_die('N')
            if idx in {3}:
                die1.move_die('N')
                die1.move_die('E')
            if idx in {4}:
                die1.move_die('E')
                die1.move_die('E')

        return 'No'


def main():
    die1 = init_die()
    die2 = init_die()
    print(are_identical(die1, die2))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7924
#include<stdio.h>
int main(void){
  int N,M,C,i,j,ans=0,check=0;
  scanf("%d %d %d",&N,&M,&C);
  int B[M];
  for(i=0;i<M;i++){
    scanf("%d",&B[i]);
  }
  int A[N][M];
  for(i=0;i<N;i++){
    for(j=0;j<M;j++){
      scanf("%d",&A[i][j]);
    }
  }
   for(i=0;i<N;i++){
     check=0;
     for(j=0;j<M;j++){
       check=check+A[i][j]*B[j];
     }
     check=check+C;
     if(check>0){
       ans++;
     }
   }
  printf("%d",ans);
  return 0;
}
       

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
class dice{
public:
	int num[6], tmp;
	void moveS(){
		tmp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = tmp;
	}
	void moveN(){
		tmp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = tmp;
	}
	void moveW(){
		tmp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = tmp;
	}
	void moveE(){
		tmp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = tmp;
	}
	void moveR(){
		tmp = num[1];
		num[1] = num[2];
		num[2] = num[4];
		num[4] = num[3];
		num[3] = tmp;
	}
};

int main(){
	dice a;
	dice b; 
	for (int i = 0; i < 6; i++){
		cin >> a.num[i];
	}
	for (int i = 0; i < 6; i++){
		cin >> b.num[i];
	}
		if (a.num[0] == b.num[0] && a.num[1] == b.num[1] && a.num[2] == b.num[2] && a.num[3] == b.num[3] && a.num[4] == b.num[4] &&a.num[5]==b.num[5] ){
			cout << "Yes" << endl;
			return 0;
		}
	for (int j = 0; j < 4; j++){
		b.moveR();

		for (int k = 0; k < 4; k++){
			b.moveN();

			if (a.num[0] == b.num[0] && a.num[1] == b.num[1] && a.num[2] == b.num[2] && a.num[3] == b.num[3] && a.num[4] == b.num[4] && a.num[5] == b.num[5]){
				cout << "Yes" << endl;
				return 0;
			}

		}
	}

	for (int j = 0; j < 4; j++){
		b.moveE();

		for (int k = 0; k < 4; k++){

			b.moveN();

			if (a.num[0] == b.num[0] && a.num[1] == b.num[1] && a.num[2] == b.num[2] && a.num[3] == b.num[3] && a.num[4] == b.num[4] && a.num[5] == b.num[5]){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;

}




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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int N = input[0];
		long ans = 1;
        for(int i = 1; i <= N; i++)
		{
			ans = ans * i % mod;
		}

       
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  string s;
  cin >> s;
  int a=0,z=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){
      a=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i)=='Z'){
      z=i;
      break;
    }
  }
  cout << z-a+1 << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<stack>
#include<cstdio>
using namespace std;
const int MAX=100005;
struct Node{
	int parent,left,right,depth;
	string type;
	Node():parent(-1),left(-1),right(-1){ }
}T[MAX];
int N;
void dfs(int node,int depth){
	if(node>=N||node<0)return ;
	T[node].depth=depth;
	T[node].type="internal node";
	if(T[node].left!=-1)dfs(T[node].left,depth+1);
	else T[node].type="leaf";
	if(T[node].right!=-1)dfs(T[node].right,depth);
}
void print(int num){
	printf("node %d: parent = %d, depth = %d, %s, [",num,T[num].parent,T[num].depth,T[num].type.c_str());
	stack<int> Q;
	int p=T[num].left;
	while(p!=-1){
		Q.push(p);
		p=T[p].right;
	}
	while(!Q.empty()){
		printf("%d",Q.top());
		Q.pop();
		if(!Q.empty())printf(", ");
	}
	putchar(']');
	putchar('\n');
}
int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		int id,k,c,c0=-1;
		cin>>id>>k;
		for(int j=0;j<k;j++){
			cin>>c;
			T[c].parent=id;
			if(c0!=-1)T[c].right=c0;
			c0=c;
		}
		T[id].left=c0;
	}
	int p=0;
	while(T[p].parent!=-1){
		p=T[p].parent;
	}
	dfs(p,0);
	T[p].type="root";
	for(int i=0;i<N;i++){
		print(i);
	}
	return 0;
}


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

typedef long long ll;

ll gcd(ll a, ll b){
	if(b > a) {ll tmp = a; a = b; b = tmp;}
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll mod = 1e9+7;

ll power(ll a, ll b){
	ll tmp = 1LL;
	while( b >= 1){
		if(b % 2){ tmp = (tmp * a) % mod;}
		a = (a * a) % mod;
		b /= 2;
	}
	return tmp % mod;
}

ll modinv(ll x){
	return power(x, mod-2);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	int arr[n];
	map<ll, ll> m;
	for(int i=0; i<n; i++){
		map<ll, ll> tmp;
		cin >> arr[i];
		ll se = arr[i];
		while(arr[i] != 1){
			for(int j=2; j*j<=arr[i]; j++){
				if(arr[i] % j == 0){
					while(arr[i] % j == 0){
						arr[i] /= j;
						tmp[j]++;
					}
				}
			}
			if(arr[i] > 1) tmp[arr[i]]++;
			arr[i] = 1;
		}
		arr[i] = se;
		for(auto x: tmp){
			m[x.first] = max(m[x.first], x.second);
		}
	}
	ll lcm = 1LL;
	for(auto x : m){
		lcm = (lcm * power(x.first, x.second)) % mod;
	}
	//cout << lcm << endl;
	ll ans = 0LL;
	for(int i=0; i<n; i++){
		ans = (ans + ((modinv(arr[i])) * lcm) % mod) % mod;
	}

	cout << ans << endl;

}


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

const int N = 3e3 + 7;

int dp[N][N];

string s, t;

int main() {

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

        for(int i = n; i > 0; i--) {
                for(int j = m; j > 0; j--) {
                        dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
                        if(s[i - 1] == t[j - 1]) dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
                }
        }

        int i = 1, j = 1;

        while(i <= n && j <= m) {
                if(dp[i][j] == dp[i][j + 1]) j++;
                else if(dp[i][j] == dp[i + 1][j]) i++;
                else {
                    cout << s[i - 1];
                    i++;
                    j++;
                }
        }
        cout << endl;
}


Measured memory_bytes: 35456
/*  AC祈願アンコウ
   　／￣＼
   ○    ／￣￣￣＼ヘ
    　 /・　 ・　 ＼>   
    ／￣￣￣＼　　  Ｖ| 
   ｜  ―――  ｜      ｜|
    ＼＿＿＿／　　  ∧|
    　　＼　　　　／
    　　　￣￣￣￣
*/

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

typedef int64_t ll;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) signed((a).size())
#define LEN(a) signed((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")

signed main(){
    string s;
    cin >> s;

    int a = SZ(s);

    int ans = 0;
    REP(i,1<<(a-1)){
        int val=0;
        int tmp = s[0]-'0';
        REP(j,a-1){
            if((i>>j)&1){
                val += tmp;
                tmp = s[j+1]-'0';
            } else {
                tmp = tmp*10 + (s[j+1]-'0');
            }
        }
        val += tmp;
        //printf("val : %lld\n",val);
        ans += val;
    }

    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
d = []
for i in range(n):
    xyz = list(map(int,input().split()))
    dj = []
    for j in range(8):
        s = 0
        for k in range(3):
            if j>>k & 1 == 1:
                s += xyz[k]
            else:
                s -= xyz[k]
        dj.append(s)
    d.append(dj)
ans = 0
for i in range(8):
    a = [x[i] for x in d]
    a.sort(reverse=True)
    ans = max(ans,sum(a[0:m]))
print(ans)

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

int main() {
    int n, x;
    cin >> n >> x;
    int g = 0;
    for(int i = 0; i < n; ++i) {
        int b;
        cin >> b;
        b = abs(b - x);
        g = __gcd(g, b);
    }
    cout << g << endl;
}

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

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

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c,k;cin >> a >> b >> c >> k;

  int i;
  for(i = 0;i < k;i++){
    if(b <= a) b *= 2;
    else break;
  }
  for(;i < k;i++){
    c *= 2;
  }
  if(a < b && b < c) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    SortedSet<Shop> shops = new TreeSet<>();
    for (int i = 0; i < n; i++) {
      long value = sc.nextLong();
      long limit = sc.nextLong();
      shops.add(new Shop(value, limit));
    }
    long cost = 0;
    for (Shop shop : shops) {
      if (m == 0) break;
      if (m >= shop.limit) {
        cost += shop.cost * shop.limit;
        m -= shop.limit;
      } else {
        cost += shop.cost * m;
        m = 0;
      }
    }
    System.out.println(cost);
  }

  static class Shop implements Comparable<Shop> {
    private long cost;
    private long limit;

    public Shop(long cost, long limit) {
      this.cost = cost;
      this.limit = limit;
    }

    @Override
    public int compareTo(Shop shop) {
      if (this.cost == shop.cost) {
        return 1;
      } else {
        return (int) (this.cost - shop.cost);
      }
    }
  }
}

Measured memory_bytes: 98740
import sys
import math

matlist = [0] * 5
for i in range(5):
    matlist[i] = int(sys.stdin.readline())

mn = 11
idx = 0
for i in range(5):
    tmp = matlist[i] % 10
    if tmp == 0:
        tmp = 10
    if mn > tmp:
        idx = i
        mn = tmp

ans = 0
for i in range(5):
    if i != idx:
        ans += math.ceil(matlist[i]/10)*10
    else:
        ans += matlist[i]

print(int(ans))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n)  for(int i=0;i<(n);++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  REP(i, N) {
    cin >> c.at(i) >> t.at(i);
  }
  
  bool TLE = true;
  int min_cost = c.at(0);
  REP(i, N) {
    if (T >= t.at(i)) {
      TLE = false;
      if (min_cost > c.at(i)) {
        min_cost = c.at(i);
      }
    }
  }
  if (TLE) {
    cout << "TLE" << endl;
  }
  else {
    cout << min_cost << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final long MOD = 1_000_000_007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		int count = 0;
		for (int i=4;i<=m;i++) {
			for (int j=22;j<=d;j++) {
				if (j%10 >= 2 && (j/10) * (j%10) == i) {
					count++;
				}
			}
		}
		System.out.println(count);


	}





}

Measured memory_bytes: 22740
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var N, M int
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &M)

	for i := (M / N); i >= 1; i-- {
		if M%i == 0 {
			fmt.Println(i)
			return
		}
	}
}


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

typedef pair<int, int> P;

int main() {
    int n, m;
    cin >> n >> m;
    P jobs[n];
    int ans = 0;
    set<int> st;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        jobs[i] = P(-b, a);
    }
    for (int i = 1; i <= m; i++) {
        st.insert(i);
    }
    sort(jobs, jobs + n);
    for (int i = 0; i < n; i++) {
        auto it = st.lower_bound(jobs[i].second);
        //cout << ' ' << *it << ' ' << jobs[i].second << endl;
        if (it != st.end()) {
            ans -= jobs[i].first;
            st.erase(it);
        }
    }

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


Measured memory_bytes: 5760
#include<stdio.h>
 
int main(void)
 
 
{
 
 
int a,b,c;
 
 
int count=0;
 
 
int i;
 
 
scanf("%d %d %d",&a,&b,&c);
 
 
for(i=a;i<=b;i++)
 
 
{
 
 
if(c%i==0) count++;
 
 
}
 
 
printf("%d\n",count);
 
 
return 0;
 
 
}

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

int main()
{
  int a, b,ans,n=1;
  cin >> a >> b;
  for (int i = 0; true;i++){
    if(n>=b){
      ans = i;
      break;
    }
    n += (a - 1);
  }
  cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

class Combination {
private:
    int64_t mod; // 元, 素数でないとNG
    int64_t max_size; // 最大値, 10^7まで
    vector<int64_t> factorial; // 階乗
    vector<int64_t> inverse; // 逆元
    vector<int64_t> inverse_factorial; // 逆元の階乗

    void init() {
        // 値は1で初期化する
        factorial.assign(max_size, 1);
        inverse.assign(max_size, 1);
        inverse_factorial.assign(max_size, 1);
        for (auto i = 2; i < max_size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod; // 拡張Euclidの互除法の変形版
            // inverse[i] = modinv(i); // Fermatの小定理
            inverse_factorial[i] = inverse_factorial[i - 1] * inverse[i] % mod;
            // cout << i << " " << factorial[i] << " " << inverse[i] << " " << inverse_factorial[i] << endl;
        }
    };
public:;
    Combination(int64_t mod, int64_t max_size) {
        this->mod = mod;
        assert(max_size < 1e7);
        this->max_size = max_size + 1;
        // テーブル生成
        init();
    };
    virtual ~Combination(){};

    int64_t modpow(int64_t a, int64_t n) {
        int64_t ret = 1;
        while(n > 0) {
            if(n & 1) ret = ret * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return ret;
    };
    int64_t modinv(int64_t a) { return modpow(a, mod - 2); };
    int64_t combination(int64_t n, int64_t k) {
        if (n < k) return 0;
        if (n < 0 or k < 0) return 0;
        // cout << factorial[n] << " " << inverse_factorial[k] << " " << inverse_factorial[n - k] << endl;
        return factorial[n] * (inverse_factorial[k] * inverse_factorial[n - k] % mod) % mod;
    };
};

int main(){
    int x, y;
    cin >> x >> y;

    int64_t ans = 0, mod = 1e9+7, n = max(x, y);
    Combination c(mod, n);
    for (auto i = 0; i <= x / 2; i++) {
        int j = (x - 2 * i);
        if(y - (i + 2 * j) != 0) continue;
        ans = (ans + c.combination(i + j, i)) % mod;
    }

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

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define mid(min, max) ((min + max) / 2)

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

	rep(i, s.length()) cout << 'x';

	return 0;
}


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	ll a, b;
	cin >> a >> b;
	if (a * b <= 0){
		cout << "Zero" << endl;
	}
	else if (a > 0){
		cout << "Positive" << endl;
	}
	else{
		cout << ((b - a) % 2 == 0 ? "Negative" : "Positive") << endl;
	}

}


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


	solve();
	system("PAUSE");
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int cntR[n], cntG[n], cntB[n];
  cntR[n-1] = 0; cntG[n-1] = 0; cntB[n-1] = 0;
  if (s[n-1] == 'R') cntR[n-1]++;
  else if (s[n-1] == 'G') cntG[n-1]++;
  else if (s[n-1] == 'B') cntB[n-1]++;

  repI(i, 1, n) {
    cntR[n-1-i] = cntR[n-i];
    cntG[n-1-i] = cntG[n-i];
    cntB[n-1-i] = cntB[n-i];
    if (s[n-1-i] == 'R') cntR[n-1-i]++  ;
    else if (s[n-1-i] == 'G') cntG[n-1-i]++;
    else if (s[n-1-i] == 'B') cntB[n-1-i]++;
  }

  char rgb[3] = {'B', 'G', 'R'};
  ll ans = 0;

  do {
    rep(i, n) {
      repI(j, i+1, n) {
        if (s[i] != rgb[0] || s[j] != rgb[1]) continue;
        if (rgb[2] == 'R') {
          if (j == n - 1) ans += cntR[j];
          else ans += cntR[j+1];
          if (2*j - i < n - 1) {
            if (cntR[2*j-i] != cntR[2*j-i+1]) ans--;
          }
          if (2*j - i == n - 1) {
            if (cntR[2*j-i] == 1) ans--;
          }
        }
        if (rgb[2] == 'G') {
          if (j == n - 1) ans += cntG[j];
          else ans += cntG[j+1];
          if (2*j - i < n - 1) {
            if (cntG[2*j-i] != cntG[2*j-i+1]) ans--;
          }
          if (2*j - i == n - 1) {
            if (cntG[2*j-i] == 1) ans--;
          }
        }

        if (rgb[2] == 'B') {
          if (j == n - 1) ans += cntB[j];
          else ans += cntB[j+1];
          if (2*j - i < n - 1) {
            if (cntB[2*j-i] != cntB[2*j-i+1]) ans--;
          }
          if (2*j - i == n - 1) {
            if (cntB[2*j-i] == 1) ans--;
          }
        }
        // cout << "i,j: " << i << " " << j << " " << ans << endl;
      }
    }
} while(next_permutation(rgb, rgb + 3));

cout << ans << endl;



  /*
  cntR, cntG, cntB are displayed;
  rep(i, n) {
    cout << cntR[i] << " "  << cntG[i] << " " << cntB[i] << endl;
  } */


  return 0;
}


Measured memory_bytes: 3692