akhauriyash/Code-Regression huggingface dataset:
const MOD: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut v: Vec<(usize, bool)> = Vec::new();
    for _ in 0..n {
        v.push((sc.read(), true));
    }
    for _ in 0..n {
        v.push((sc.read(), false));
    }
    v.sort();

    let mut ans = 1;
    let mut a_stack = 0;
    let mut b_stack = 0;
    for &(_, is_a) in &v {
        if is_a {
            if b_stack > 0 {
                ans = (ans * b_stack) % MOD;
                b_stack -= 1;
            } else {
                a_stack += 1;
            }
        } else {
            if a_stack > 0 {
                ans = (ans * a_stack) % MOD;
                a_stack -= 1;
            } else {
                b_stack += 1;
            }
        }
    }

    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

int main(){
	int n;
	cin>>n;
	long long a[n],b,c,d;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i==0){
			b=a[i];
			c=a[i];
			d=a[i];
		}
		else if(b>a[i]){
			b=a[i];
		}
		else if(c<a[i]){
			c=a[i];
		}
		if(i>0){
			d+=a[i];
		}
	}
	cout<<b<<" "<<c<<" "<<d<<endl;
	return 0;
}



Measured memory_bytes: 3156
/*           pmaik
    ░▒▓█►─═ Maneesh ═─◄█▓▒░


          ( •̪●)
        ███████]▄▄▄▄▄▄▄▄▃  ▃  ▃ 
    ▂▄▅█████████▅▄▃▂
   [███████████████████]
  ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤......  */

#include<bits/stdc++.h>
using namespace std;
#define inf() ifstream cin("in00.txt")
#define onf() ofstream cout("out00.txt")
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<ll,ll>
#define fi first
#define se second
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

 
int main()
{
    fastio;
    int x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
        int a,b;
        scanf("%d%d",&a,&b);
        if(a%2==0 && b%2==0 || a%2==1 && b%2==1)printf("%d\n",(int)(a+b)/2);
        else printf("%d\n",(int)(a+b)/2+1);
        return 0;
}


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

class Union_Find{
private:
  vector<int64_t> par;
  vector<int64_t> rank;
  vector<int64_t> num;

  int64_t find(int64_t x){
    if(par.at(x)==x){
      return x;
    }else{
      return par.at(x)=find(par.at(x));
    }
  }

public:
  Union_Find(int64_t n){
    par.resize(n);
    rank.resize(n,0);
    num.resize(n,1);
    for(int64_t i=0;i<n;i++){
      par.at(i)=i;
    }
  }

  void unite(int64_t x,int64_t y){
    x=find(x);
    y=find(y);
    if(x==y){
      return;
    }
    if(rank.at(x)<rank.at(y)){
      par.at(x)=y;
      num.at(y)+=num.at(x);
    }else if(rank.at(x)>rank.at(y)){
      par.at(y)=x;
      num.at(x)+=num.at(y);
    }else{
      par.at(x)=y;
      rank.at(y)++;
      num.at(y)+=num.at(x);
    }
  }

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

  int64_t size(int64_t x){
    return num.at(find(x));
  }

};

int main(){
  int N,M;
  cin >> N >> M;
  Union_Find uni(N+1);
  int A,B;
  for(int i=0;i<M;i++){
    cin >> A >> B;
    uni.unite(A,B);
  }
  int64_t ans=0;
  for(int i=2;i<=N;i++){
    if(!uni.same(1,i)){
      ans++;
      uni.unite(1,i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5640
# -*- coding: utf-8 -*-

X, Y, Z, K = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

ABC = []

for x in range(X):
    for y in range(Y):
        if (x + 1) * (y + 1) > K:
            break
        for z in range(Z):
            if (x + 1) * (y + 1) * (z + 1) > K:
                break
            ABC.append(A[x] + B[y] + C[z])

ABC = sorted(ABC, reverse=True)

ABC = ABC[:K]
ABC = [str(abc) for abc in ABC]

print("\n".join(ABC))


Measured memory_bytes: 9544
#include <stdio.h>

int main(){
  int r,c,a[101][101],i,j,sum=0;
  scanf("%d %d",&r,&c);
  for(i=0; i<101; i++){
    for(j=0; j<101; j++){
      a[i][j]=0;
    }
  }
  for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      a[r][j]+=a[i][j];
      a[i][c]+=a[i][j];
    }
  }//-----            
for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      a[r][c]+=a[r][j];
      a[r][c]+=a[i][c];
    }
  }
  a[r][c]/=(r+c);
  for(i=0; i<=r; i++){
    for(j=0; j<=c; j++){
      if(j==c)printf("%d\n",a[i][j]);
      else printf("%d ",a[i][j]);
    }
  }
  return 0;
}


Measured memory_bytes: 2044
n = int(input())
s = input()

"""
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
"""
# gagsg
r = s.count('R')
g = s.count('G')
b = s.count('B')

"""
for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'G':
        g += 1
    else:
        b += 1
"""
ans = r*g*b

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2 * j - i
        if k < n:
            if s[i] == s[j]:
                continue
            if s[j] == s[k]:
                continue
            if s[k] == s[i]:
                continue
            ans -= 1
print(ans)


Measured memory_bytes: 67444
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    System.out.println(IntStream.range(0, N).filter(i -> sc.nextInt() >= K).count());
  }
}

Measured memory_bytes: 49480
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll K;
  cin >> K;
  string S;
  cin >> S;
  ll N = S.size();
  if(N <= K) cout << S << endl;
  else{
    cout << S.substr(0, K) << "..." << endl;
  }
}

Measured memory_bytes: 3616
using System;
using System.Linq;

namespace ABC161
{
    class B
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var n = a[0]; var m = a[1];
            var A = Console.ReadLine().Split().Select(double.Parse).ToArray();

            double sum = A.Sum();
            double count = 0;
            for (int i = 0; i < n; i++)
            {
                if (sum * (1 / (4 * m)) <= A[i]) count++;
            }

            if (m <= count) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n, r;
    cin >> n >> r;

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

    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  int ans = 0;
  rep(i,n+1){
    int j = 0;
    int cnt = 0;
    while(j < n){
      j++;
      if(j%2 == 0) continue;
      if(i%j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define INF 100000000;
bool comp[10];
int d, g, p[10], c[10], ans=INF;

void dfs(int i, bool s){
  comp[i]=s;
  if(i<d-1){dfs(i+1,1); dfs(i+1,0); return;}
  int sc=0, num=0, ii=d-1, add;
  REP(j,d){sc+=comp[j]*c[j]; num+=comp[j]*p[j];}
  if(sc<g){
    while(comp[ii]) ii--;
    add = (g-sc)/((ii+1)*100);
    if(add<p[ii]) num+=max(1,add);
    else num=INF;
  }    
  ans=min(ans,num);
}

int main(){
  REP(i,10) {comp[i]=0; p[i]=0; c[i]=0;}
  cin >> d >> g;
  REP(i,d) cin >> p[i] >> c[i];
  REP(i,d) c[i]=(i+1)*100*p[i]+c[i];
  dfs(0,1); dfs(0,0);
  cout << ans << endl;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), T = input();
    int ans = inf;
    range(i, 0, N) {
        int c = input(), t = input();
        if (t > T) continue;
        chmin(ans, c);
    }

    if (ans == inf) cout << "TLE" << endl;
    else cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
  int i;
  char op[100];
  int num[100];
  for(i=0;i<100;i++){
    num[i]=0;
  }
  i=0;
  while(scanf("%s",op)!=EOF){	//scanf?????????????????§
    if(op[0]=='+'){
      num[i-2]=num[i-1]+num[i-2];
      i--;
    }else if(op[0]=='-'){
      num[i-2]=num[i-2]-num[i-1];
      i--;
    }else if(op[0]=='*'){
      num[i-2]=num[i-1]*num[i-2];
      i--;
    }else{
      num[i]=atoi(op);
      i++;
    }
  }
  printf("%d\n",num[i-1]);

  return 0;
}

Measured memory_bytes: 1860
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var rhombic = new List<int[]>();

			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				rhombic.Add(s.Split(',').Select(i => int.Parse(i)).ToArray());
			}
			
			int[,] dp = new int[128,128];
			dp[0, 0] = rhombic[0][0];
			for (int i = 1; i < rhombic.Count; i++)
			{
				for (int j = 0; j < rhombic[i].Count(); j++)
				{
					dp[i, j] = Math.Max(dp[i - 1, j], (i <= (rhombic.Count / 2) ? (j > 0 ? dp[i - 1, j - 1] : 0) : dp[i - 1, j + 1])) + rhombic[i][j];
				}
			}
			Console.WriteLine(dp[rhombic.Count - 1, 0]);
		}
	}
}

Measured memory_bytes: 10304
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>

using namespace std;

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

typedef vector<int> vi;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		double xa, ya, ra, xb, yb, rb;
		scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb);

		double dist = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
		if(dist > ra+rb)
			puts("0");
		else if(dist+ra < rb)
			puts("-2");
		else if(dist+rb < ra)
			puts("2");
		else
			puts("1");
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<ll>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
int x, n; cin>>x>>n ;
vector<int> A(n) ;rep(i,n) cin>>A[i] ;
ll ans=1000 ;
ll kotae =-1 ;

rep2(i,-100,200){
 bool a=true ;
 rep(j,n){
   if(i==A[j]) a=false ;
 }
if(a==false) continue ;
if(ans>abs(x-i)){
ans= abs(x-i) ;
kotae=i ;
}
}
cout<< kotae <<endl ;
  return 0;
  }

Measured memory_bytes: 3624
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int>b(m);
    rep(i,m)cin>>b[i];
    vector<vector<int> > a(n,vector<int>(m));
    rep(i,n){
        rep(j,m){
            cin>>a[i][j];
        }
    }    
    int ans=0;
    rep(i,n){
        int  x=0;
        rep(j,m){
            x+=a[i][j]*b[j];
        }
        if(x+c>0)ans++;
    }
cout<<ans;
return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve(){
    string s;
    cin>>s;
    int c=0;
    rep(i,0,s.size()){
        int d=0;
        while(s[i]=='R'){
            d++;
            i++;
        }
        if(d>c){
            c=d;
        }
    }
    cout<<c<<endl;
}
int32_t main(){
    c_p_c();
    int t;
    t=1;
    //cin>>t;
    while(t--){
       solve(); 
    }
	return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    int s_size = S.size();
    int t_size = T.size();
    int size = s_size - t_size;
    int n = T.size();
    int count;
    for(int i = 0; i <= size; i++){
        count = 0;
        for(int j = 0; j < t_size; j++){
            if(S[i+j] != T[j]) count++;
        }
        n = min(n, count);
    }
    cout << n << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  char a[10];
  scanf("%s",a);
  if(a[0]=='A' &&a[1]=='A' &&a[2]=='A')
    printf("No");
  else if(a[0]=='B' &&a[1]=='B' &&a[2]=='B') 
    printf("No");
  else
    printf("Yes");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


//INT_MAX	2,147,483,647 = 2*1.0e9

const int NMAX = 100050;
const int MOD = 1000000007;

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

  vector<bool> broken(N+2, false);
  rep(i, M){
    int a; cin >> a;
    broken[a] = true;
  }

  vector<int> dp(N+1, 0);
  dp[0] = 1;

  for(int i = 1; i < N+1; i++){
    if(broken[i]){
      dp[i] == 0;
      continue;
    }
    if(i == 1){
      dp[i] = dp[i-1];
      dp[i] %= MOD;
    } else {
      dp[i] = dp[i-1] + dp[i-2];
      dp[i] %= MOD;
    }
  }

  cout << dp[N] << endl;

  return 0;
}



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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 x, n;
    cin >> x >> n;
    set<i64> ps;
    for (i64 i = 0; i < n; i++) {
        i64 p;
        cin >> p;
        ps.insert(p);
    }

    i64 ans = INF, dist = INF;
    for (i64 i = 0; i <= 101; i++) {
        if (ps.find(i) != ps.end()) continue;
        if (abs(x - i) >= dist) continue;
        ans = i;
        dist = abs(x - i);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3652
N, M = map(int, input().split())
S = input()

ans = []
flg = 1
i = N
while i != 0:
    for j in range(min(M, i), 0, -1):
        if S[i-j] == '0':
            ans.append(j)
            i -= j
            break
    else:
        flg = -1
        i = 0
    # print(i)

if flg == -1:
    print(flg)
else:
    ans.reverse()
    print(*ans)


Measured memory_bytes: 6384
import itertools
_n = int(input())
n = range(1, _n + 1)
p = "-".join(list(map(str, input().split())))
q = "-".join(list(map(str, input().split())))
a = 0
b = 0
for i, x in enumerate(itertools.permutations(n)):
    _x = "-".join(list(map(str, x)))
    if p == _x:
        a = i + 1
    if q == _x:
        b = i + 1
    if a * b != 0:
        break
print(abs(a - b))    


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

typedef long long ll;

using namespace std;

int main()
{
  ll m;
  cin >> m;

  ll n = 1000001;
  vector<int> p;
  vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
      if (is_prime[i] && (long long)i * i <= n) {
          for (int j = i * i; j <= n; j += i)
              is_prime[j] = false;
      }
  }

  for(int i = 2; i < 1000001; i++)
    if(is_prime[i])
      p.push_back(i);

  ll z = 0;
  int ctr = 0;
  while(m != 1 && ctr < p.size())
  {
    ll prime = p[ctr];
    ll po = prime;
    while(m % po == 0)
    {
      z++;
      m = m / po;
      po = po * prime;
    }

    ctr++;
  }

  if(m > 1000000)
    z++;

  cout << z << endl;
}


Measured memory_bytes: 4052
using System;
using System.Linq;

namespace AtCoder.DP
{
    class EDPC_M
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = nk[0];
            var k = nk[1];

            const long mod = 1000000007;
             
            var dp = new long[n + 1, k + 1];

            var acc = 0;
            for (int i = 1; i <= n; i++)
            {
                acc += a[i - 1];
                dp[i, 0] = 1;
                for (int j = 1; j <= Math.Min(acc, k); j++)
                {
                    dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                    if (j > a[i - 1])
                        dp[i, j] -= dp[i - 1, j - 1 - a[i - 1]];
                    dp[i, j] %= mod;
                }
            }
            Console.WriteLine(dp[n, k] < 0 ? dp[n, k] + mod : dp[n, k]);
        }
    }
}


Measured memory_bytes: 105904
#include <iostream>
using namespace std;
typedef long long ll;
int n;
ll arr[200001];
ll prefSum[200001];
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    ll sum = 0;
    for(int i =0 ; i < n; i ++){
        cin >> arr[i];
        sum += arr[i];
        prefSum[i] = sum;
    }
    ll mnn = (1LL << 60LL);
    ll A = 0, B;
    for(int i = 0; i + 1 < n; i ++){
        A += arr[i];
        B = prefSum[n - 1] - A;
        mnn = min(mnn, abs(A - B));
    }
    cout << mnn << endl;
    return 0;
}


Measured memory_bytes: 3328
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  int n, k;
  int x;
  while(cin>>n>>k){
    if(n==0&&k==0)break;

    vector<int> s(n + 1, 0);
    rep(i, n){
      cin >> x;
      s[i + 1] = s[i] + x;
    }
    int ma = 0;
    for (int i = 0; i + k < n + 1; i++)ma = max(ma, s[i + k] - s[i]);
    cout << ma << endl;

  }

  return 0;
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a = 10;
    int k;
    cin>> k;

    if(k == 1){
        cout<< 1 << endl;
        return 0;
    }

    if(k % 2 == 0 || k % 5 == 0){
        cout<< -1 << endl;
        return 0;
    }

    k *= 9;
    for(int i = 0; i <= 10*k; i++){
        if((7*(a - 1 + k)) % k ==0){
            cout<< i+1 << endl;
            return 0;
        }
        a = (a*10) % k;
    }
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node {int key;  struct node *right,*left,*pr;} node;
node *root,*NIL;

node * find(node *u,int k){
  while(u != NIL && k != u->key)//uがNILまたはkeyが見つかったら抜ける。//
  { if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  node *y = NIL,*x = root,*z;
  z = (node *)malloc(sizeof(node));
  z->key = k; z->left = z->right = NIL;
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->pr = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}
//中間順巡回//
void inP(node *u){
  if(u == NIL) return;
  inP(u->left);
  printf(" %d",u->key);
  inP(u->right);
}
//先行準巡回//
void preP(node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preP(u->left);
  preP(u->right);
}

int main(){
  int n,i,key;
  node *t;
  char cmd[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",cmd);

    if(cmd[0] == 'f'){
      scanf("%d",&key);
      t = find(root,key);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }else if(cmd[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }else if(cmd[0] == 'p'){
      inP(root);
      printf("\n");
      preP(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20540
#include <stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  int *a = malloc(sizeof(int) * N);
  for(int i = 0; i < N; i++){
    scanf("%d", &a[i]);
  }
  
  int max = 0;
  int max_n = 0;
  for(int i = 0; i < N; i++){
    if(max < a[i]){
      max_n = i;
      max = a[i];
    }
  }
  
  int *judge = malloc(sizeof(int) * N);
  for(int i = 0; i < N; i++){
    judge[i] = a[i];
  }
  
  while(judge[max_n] != 0){
  int count = 0;
  for(int i = 0; i < N; i++){
    if(judge[i] == 0) continue;
    if(judge[i] % 2 == 1) count++;
    judge[i] = judge[i] / 2;
  }
  if(count % 2 == 1){
    printf("No");
    return 0;
  }
  }
  /*
  for(int i = 0; i < N; i++){
    printf("%d ", judge[i]);
  }
  printf("\n");
  */
  printf("Yes");
  return 0;
}

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

int main(){
  int A,B,C;
  cin>>A>>B;
  C=A+B;
  if(A%3==0||B%3==0||C%3==0){
    cout<<"Possible"<<"\n";
  }else{
    cout<<"Impossible";
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

bool is_prime(int n) {
    if (n == 1) return false;

    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

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

    for (int i = x; i < 100010; i++)
    {
        if (is_prime(i)) {
            cout << i << "\n";
            return 0;
        }
    }
    
}

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

using namespace std;

long long int cnt[100001];

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

	int n;
	long long int sum = 0;
	
	cin >> n;

	for(int i=1;i<=n;i++)
	{
		int t;
		cin >> t;
		sum += t;
		cnt[t]++;
	}

	int q,b,c;

	cin >> q;

	for(int i=0;i<q;i++)
	{
		cin >> b >> c;
		long long int num = cnt[b];
		sum -= (b*num);
		sum += (c*num);
		cnt[c] += num;
		cnt[b] = 0;
		cout << sum << '\n';
	}

	return 0;
}	

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

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

int a, b;

int main(){
    cin >> a >> b;
    if((a + b) % 2 == 0)  cout << (a + b) / 2 << endl;
    else cout << (a + b) / 2 + 1 << endl;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = gets.split.map(&:to_i)
a = Math.sqrt((x1-x2)**2+(y1-y2)**2)
if x1 == x2 then
    if y1 > y2 then
        x3 = x1+a
        x4 = x3
        y3 = y2
        y4 = y1
    else
        x3 = x1-a
        x4 = x3
        y3 = y2
        y4 = y1
    end
elsif y1 == y2 then
    if x1 < x2 then
        x3 = x2
        x4 = x1
        y3 = y2 + a
        y4 = y3
    else
        x3 = x2
        x4 = x1
        y3 = y2 - a
        y4 = y3
    end
elsif x1 < x2 then
    x3 = x2 - (y2-y1)
    x4 = x1 - (y2-y1)
    y3 = y2 + (x2-x1)
    y4 = y1 + (x2-x1)
else
    x3 = x2 + (y1-y2)
    x4 = x1 + (y1-y2)
    y3 = y2 + (x2-x1)
    y4 = y1 + (x2-x1)
end
puts "#{x3.to_i} #{y3.to_i} #{x4.to_i} #{y4.to_i}"

Measured memory_bytes: 1788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int N, M, K, A;
    std::cin >> N >> M;
    std::vector<int> dishes(M, 0);

    for (int i = 0; i < N; i++)
    {
        std::cin >> K;
        for (int j = 0; j < K; j++)
        {
            std::cin >> A;
            dishes[--A]++;
        }
    }
    int answer = 0;
    for (int i = 0; i < M; i++)
    {
        if (dishes[i] == N) { answer++; }
    }

    std::cout << answer << std::endl;
    return 0;
}

Measured memory_bytes: 256
x = int(input())
ans = 0
if 400 <= x < 600:
  ans = 8
elif 600 <= x < 800:
  ans = 7
elif 800 <= x < 1000:
  ans = 6
elif 1000 <= x < 1200:
  ans = 5
elif 1200 <= x < 1400:
  ans = 4
elif 1400 <= x < 1600:
  ans = 3
elif 1600 <= x < 1800:
  ans = 2
elif 1800 <= x < 2000:
  ans = 1
print(ans)

Measured memory_bytes: 9152
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi
from operator import mul
from functools import reduce
import math
from itertools import accumulate

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def prime(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return is_prime

def main():
    q = int(input())
    is_prime = prime(10**5)

    def p(total, x):
        return total + (1 if is_prime[x] and is_prime[(x+1)//2] else 0)

    cumsum = list(accumulate(range(10**5), p))
    for l, r in readlines(q):
        print(cumsum[r] - cumsum[l-1])


main()


Measured memory_bytes: 8180
#include <iostream>
#define ll long long
using namespace std;

ll cal10[64];

ll big10(ll key, ll mod){
    ll res=1;
    for(int i=0; i<64; ++i){
        if(key&((ll) 1<<i)){
            res=(res*cal10[i])%mod;
        }
    }
    return res;
}

int main() {
    ll L, A, B, M;
	cin >> L >> A >> B >> M;
	ll b10[19];
	b10[0]=1;
	for(int i=1; i<19; ++i) b10[i]=b10[i-1]*10;
	ll rnow=L, dig=0, ans=0;
	cal10[0]=10%M;
	for(int i=1; i<64; ++i) cal10[i]=(cal10[i-1]*cal10[i-1])%M;
	for(int p=18; p>0; --p){
	    ll left=-1, right=rnow;
	    while(left+1<right){
	        ll mid=(left+right)/2;
	        if(A+B*mid<b10[p-1]) left=mid;
	        else right=mid;
	    }
	    ll cnt=rnow-right;
	    if(cnt==0) continue;
	    ll dp[3][3], ep[3][3];
	    dp[0][0]=(b10[p]+1)%M;
	    dp[0][1]=dp[0][2]=M-b10[p]%M;
	    dp[1][0]=1;
	    dp[1][1]=dp[1][2]=dp[2][0]=dp[2][1]=0;
	    dp[2][2]=b10[p]%M;
	    for(int i=0; i<3; ++i){
	        for(int j=0; j<3; ++j){
	            if(i==j) ep[i][j]=1;
	            else ep[i][j]=0;
	        }
	    }
	    for(int s=0; s<64; ++s){
	        ll fp[3][3];
	        if((cnt-1)&((ll) 1<<s)){
	            for(int j=0; j<3; ++j){
	                for(int k=0; k<3; ++k){
	                    fp[j][k]=0;
	                    for(int q=0; q<3; ++q){
	                        fp[j][k]=(fp[j][k]+(dp[j][q]*ep[q][k])%M)%M;
	                    }
	                }
	            }
	            for(int i=0; i<9; ++i) ep[i/3][i%3]=fp[i/3][i%3];
	        }
	        for(int j=0; j<3; ++j){
	            for(int k=0; k<3; ++k){
	                fp[j][k]=0;
	                for(int q=0; q<3; ++q){
	                    fp[j][k]=(fp[j][k]+(dp[j][q]*dp[q][k])%M)%M;
	                }
	            }
	        }
	        for(int i=0; i<9; ++i) dp[i/3][i%3]=fp[i/3][i%3];
	    }
	    ll ad=(ep[0][0]*(((A%M)+((B%M)*((rnow-1)%M))%M)))%M;
	    ad=(ad+(ep[0][2]*(B%M))%M)%M;
	    ad=(ad*big10(dig, M))%M;
	    ans=(ans+ad)%M;
	    dig += cnt*p;
	    rnow=right;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 255050

ll n,m,k;

vec G[N];
int who[N];
ll a[N],b[N];

main(){
    n=in();
    rep(i,n){
        a[i]=in();b[i]=in();
    }
    vec p;
    rep(i,n)p.pb(i);
    sort(ALL(p),[&](int x,int y){
        return a[x]+b[x]>a[y]+b[y];
    });
    ll ans=0;
    rep(i,n){
        if(i%2)ans-=b[p[i]];
        else ans+=a[p[i]];
    }
    cout<<ans;
}

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

int main() {
    ll H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    vector<vector<ll>> h(H, vector<ll>(W, 0)), w(H, vector<ll>(W, 0));
    rep(x, W) {
        ll temp = 0, from = 0;
        rep(y, H) {
            if (S[y][x] == '#') {
                for (int i = from; i < y; i++) {
                    h[i][x] = temp;
                }
                temp = 0;
                from = y + 1;
            } else {
                temp++;
            }
        }
        for (int i = from; i < H; i++) {
            h[i][x] = temp;
        }
    }
    rep(y, H) {
        ll temp = 0, from = 0;
        rep(x, W) {
            if (S[y][x] == '#') {
                for (int i = from; i < x; i++) {
                    w[y][i] = temp;
                }
                temp = 0;
                from = x + 1;
            } else {
                temp++;
            }
        }
        for (int i = from; i < W; i++) {
            w[y][i] = temp;
        }
    }
    ll mx = 0;
    rep(x, W) rep(y, H) mx = max(mx, h[y][x] + w[y][x]);
    cout << mx - 1 << endl;
    return 0;
}


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

namespace abc119d
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadIntList();
            var N = s[0];
            var M = s[1];

            var a = 1;
            var z = N;

            for (int i = 0; i < M; i++)
            {
                s = ReadIntList();
                a = (a < s[0]) ? s[0] : a;
                z = (z > s[1]) ? s[1] : z;
            }
            if (a <= z)
                Console.WriteLine(z - a + 1);
            else
                Console.WriteLine(0);
#if DEBUG
            Console.ReadKey();
#endif
        }

        private static bool IsRange(int a, int from, int to) => (from <= a && a <= to);
        private static int ReadInt() => int.Parse(Console.ReadLine());
        private static List<int> ReadIntList() => Console.ReadLine().Split().Select(int.Parse).ToList();
        private static double ReadDouble() => double.Parse(Console.ReadLine());
        private static List<double> ReadDoubleList() => Console.ReadLine().Split().Select(double.Parse).ToList();
        private static long ReadLong() => long.Parse(Console.ReadLine());
        private static List<long> ReadLongList() => Console.ReadLine().Split().Select(long.Parse).ToList();
        private static List<int> Int2Digits(int a) => a.ToString().ToCharArray().Select(_ => int.Parse(_.ToString())).ToList();
        private static int BinarySearch<Type>(IReadOnlyList<Type> s, Type target) // target 以下の最大要素のインデックスを返す
            where Type : IComparable
        {
            var lower = 0;
            var upper = s.Count - 1;
            while (upper - lower > 1)
            {
                var mid = lower + (upper - lower) / 2;
                if (s[mid].CompareTo(target) <= 0)
                {
                    lower = mid;
                }
                else
                {
                    upper = mid;
                }

            }
            return lower;
        }
    }
}


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

#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int c[n],s[n],f[n];
    rep(i,0,n-1){
        cin>>c[i]; //次の駅までの時間
        cin>>s[i]; //始発
        cin>>f[i]; //発車感覚
    }
    rep(i,0,n-1){
        int ans = s[i]+c[i];
        rep(j,i+1,n-1){
            while(ans % f[j] != 0) ans++;
            ans = max(ans,s[j]);
            ans += c[j];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

m,d = lr()
ans = 0
for i in range(4,m+1):
    for j in range(22,d+1):
        d1 = j%10
        d10 = j//10
        if i == d1*d10 and d1>=2 and d10>=2:
            ans+=1
print(ans)

Measured memory_bytes: 77348
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 60;

Int dp[max_n][max_n][max_n*max_n];

int main(void) {
    Int n,k;
    cin>>n>>k;
    dp[0][0][0] = 1;
    
    for(Int i = 0;i < n;i++) {
        for(Int j = 0;j < i+1;j++) {
            for(Int s = 0;s < k/2+1;s++) {
                Int nj;
                nj = j;
                //both connect
                dp[i+1][j][s+nj] += dp[i][j][s];
                dp[i+1][j][s+nj] %= MOD;

                //both rest
                nj = j+1;
                dp[i+1][nj][s+nj] += dp[i][j][s];
                dp[i+1][nj][s+nj] %= MOD;

                //connect one side
                nj = j;
                Int x = j*2;
                dp[i+1][nj][s+nj] += dp[i][j][s]*x%MOD;
                dp[i+1][nj][s+nj] %= MOD;

                if(j >= 1) //connect both
                {
                    Int nj = j-1;
                    Int x = j*j;
                    dp[i+1][nj][s+nj] +=dp[i][j][s]*x%MOD;
                    dp[i+1][nj][s+nj] %= MOD;
                }
            }
        }
    }

    if(k & 1) {
        cout<<0<<endl;
    } else {
        cout<<dp[n][0][k/2]%MOD<<endl;
    }
    return 0;
}




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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


typedef pair<int, int> p;

int main(){
  int n, m;
  cin >> n >> m;

  vector<p> v(n);
  REP (i, n) {
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }

  sort(v.begin(), v.end());

  LL ans = 0;
  int num = 0;
  int i = 0;
  while (num < m) {
    if (v[i].second <= 0) i++;
    else {
      ans += v[i].first;
      v[i].second--;
      num++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
pair<int,int> a[100010];
bool cmp(pair<int,int> &a,pair<int,int> &b){
    if(a.first==b.first){
        return abs(a.first-a.second)<abs(b.first-b.second);
    }
    return a.first<b.first;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x,l;
        cin>>x>>l;
        a[i].first=x+l-1;
        a[i].second=x-l;
    }
    // end start
    sort(a,a+n,cmp);
    /*
    for(int i=0;i<n;i++)
        cout<<a[i].first<<' '<<a[i].second<<'\n';*/
    int cnt=0;
    for(int i=0;i<n;i++){
        int j= i;
        cnt++;
        while(i+1<n&&a[j].first>=a[i+1].second)
            i++;
    }
    cout<<cnt;

}

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d;
  e = a + b;
  f = c + d;
  if (e > f) {
    cout << "Left" << endl;
  }
  else if (e == f){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

using namespace std;
typedef long long LL;
const int nn = 2e5 + 5;

struct data {
	int s;
	int t;
	int x;
};

bool cmp(data a, data b) {
	return a.x < b.x;
}

data arr[nn];
int ans[nn];
map<int, vector<int> > v;

int main() {
	set<int> tmp;
	int N, Q, mulai, selesai, titik;
	scanf("%d %d", & N, & Q);
	int idx = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", & mulai, & selesai, & titik);
		selesai--;
		mulai = max(mulai, titik);
		if (mulai <= selesai) {
			arr[idx].s = mulai - titik;
			arr[idx].t = selesai - titik;
			arr[idx].x = titik;
			idx++;
		}
	}
	memset(ans, -1, sizeof ans);
	sort (arr, arr + idx, cmp);
	for (int i = 0; i < Q; i++) {
		int D;
		scanf("%d", & D);
		v[D].push_back(i);
		tmp.insert(D);
	}
	for (int i = 0; i < idx; i++) {
		set<int>::iterator p = tmp.lower_bound(arr[i].s);
		stack<int> st;
		while (p != tmp.end()) {
			int bil = *p;
			if (bil > arr[i].t) break;
			st.push(bil);
			int l1 = v[bil].size();
			for (int j = 0; j < l1; j++) {
				ans[v[bil][j]] = arr[i].x;
			}
			p++;
		}
		while (!st.empty()) {
			tmp.erase(st.top());
			st.pop();
		}
	}
	for (int i = 0; i < Q; i++) {
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 36224
// https://atcoder.jp/contests/abc144/tasks/abc144_b

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (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 FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int N;
  set<int> s;
  rep(i, 1, 10)
  {
    rep(j, 1, 10)
    {
      s.insert(i * j);
    }
  }

  cin >> N;

  if (s.find(N) != s.end())
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';

  return 0;
}


Measured memory_bytes: 256