akhauriyash/Code-Regression huggingface dataset:
n,a,b,c = map(int,input().split())
s = []
for _ in range(n):
    s.append(input())
if a + b + c == 0:
    print('No')
elif a + b + c == 1:
    ans = ''
    for i in range(n):
        if s[i] == 'AB':
            if a == 1 and b == 0:
                a = 0
                b = 1
                ans += 'B'
            elif a == 0 and b == 1:
                a = 1
                b = 0
                ans += 'A'
            else:
                print('No')
                exit()
        elif s[i] == 'BC':
            if b == 1 and c == 0:
                b = 0
                c = 1
                ans += 'C'
            elif b == 0 and c == 1:
                b = 1
                c = 0
                ans += 'B'
            else:
                print('No')
                exit()
        else:
            if a == 1 and c == 0:
                a = 0
                c = 1
                ans += 'C'
            elif a == 0 and c == 1:
                a = 1
                c = 0
                ans += 'A'
            else:
                print('No')
                exit()
    print('Yes')
    for i in range(n):
        print(ans[i])
else:
    ans = ''
    s2 = 'AC'
    for i in range(n):
        s1 = s[i]
        if i != n-1:
            s2 = s[i+1]
        if s1 == 'AB':
            if a >= 1 and b == 0:
                a -= 1
                b = 1
                ans += 'B'
            elif a == 0 and b >= 1:
                a = 1
                b -= 1
                ans += 'A'
            elif a >= 1 and b >= 1:
                if s2 == 'BC':
                    b += 1
                    a -= 1
                    ans += 'B'
                else:
                    a += 1
                    b -= 1
                    ans += 'A'
            else:
                print('No')
                exit()
        elif s1 == 'BC':
            if b >= 1 and c == 0:
                b -= 1
                c = 1
                ans += 'C'
            elif b == 0 and c >= 1:
                b = 1
                c -= 1
                ans += 'B'
            elif b >= 1 and c >= 1:
                if s2 == 'AC':
                    c += 1
                    b -= 1
                    ans += 'C'
                else:
                    b += 1
                    c -= 1
                    ans += 'B'
            else:
                print('No')
                exit()
        else:
            if a >= 1 and c == 0:
                a -= 1
                c = 1
                ans += 'C'
            elif a == 0 and c >= 1:
                a = 1
                c -= 1
                ans += 'A'
            elif a >= 1 and c >= 1:
                if s2 == 'AB':
                    a += 1
                    c -= 1
                    ans += 'A'
                else:
                    a -= 1
                    c += 1
                    ans += 'C'
            else:
                print('No')
                exit()
        s1 = s2
    print('Yes')
    for i in range(n):
        print(ans[i])


Measured memory_bytes: 16408
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <random>
#include <chrono>

using namespace std;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define per(i, a, n) for (int i = n - 1; i >= a; --i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef int64_t i64;
typedef uint64_t ui64;
typedef pair<int, int> pi;

struct custom_hash {
    static ui64 splitmix64(ui64 x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ui64 x) const {
        static const ui64 FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T, class U>
inline ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <class T, class U>
inline istream& operator>>(istream& os, pair<T, U>& p) {
    os >> p.first >> p.second;
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
    if (v.empty())
        return os;
    if (v.begin() != v.end())
        os << v.front();
    for (auto it = ++v.begin(); it != v.end(); ++it)
        os << ' ' << *it;
    return os;
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
    for (auto& i : v)
        is >> i;
    return is;
}

template <class T, size_t N>
inline istream& operator>>(istream& is, array<T, N>& a) {
    for (auto& i : a)
        is >> i;
    return is;
}

inline void Solve(istream& is, ostream& os) {
    const int mod = 1'000'000'007;
    int n;
    is >> n;
    vi counts(100'000, 0);
    rep(_, 0, n) {
        int next;
        is >> next;
        ++counts[next];
    }
    if ((n % 2) && counts.front() != 1) {
        os << 0 << "\n";
        return;
    }
    uint64_t result = 1;
    for (size_t i = 1 + (n % 2); i < n; i += 2) {
        if (counts[i] != 2) {
            os << 0 << "\n";
            return;
        }
        result *= 2;
        result %= mod;
    }
    os << result << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << setprecision(20) << fixed;
    Solve(cin, cout);
    return 0;
}


Measured memory_bytes: 768
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int h,w; cin>>h>>w;
    string ans="Yes";
    vector<vector<char>> m(h+2,vector<char>(w+2,'.'));
    vector<vector<int>> d={{1,0},{-1,0},{0,1},{0,-1}};
    rep(i,h)rep(j,w){
        cin>>m[i+1][j+1];
    }
    rep(i,h)rep(j,w){
        if(m[i+1][j+1]=='.') continue;
        int cnt=0,dx,dy;
        for(auto c:d){
            dx=c[0]; dy=c[1];
            if(m[i+1+dx][j+1+dy]=='.') cnt++;
        }
        if(cnt==4){
            ans="No";
        }
    }
    cout<<ans<<endl;
}

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

int main(){
    int x,t;
    cin >> x >> t;
    cout << max(0,x-t) << endl;

    
    return 0;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int x = 1;
    for(int i = 1; i <= m; i++)
        x *= 2;

    cout << (1900 * m + 100 * (n - m)) * x << '\n';
    return 0;
}


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

using namespace std;

#define int long long
constexpr int MOD = 1'000'000'007;

signed main(){
	int N, T;
	int ans = 1;
	vector<int> D;
	
	cin>>N>>T;
	
	D.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>D[i];
	}
	
	sort(D.begin(), D.end());
	
	for(int i = 0, j = 0; i < N; i++){
		for(; j < i; j++){
			if(D[i] - D[j] <= T) {
				break;
			}
		}
		ans *= (MOD + i + 1 - j) % MOD;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
}


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

int main(){
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static void input()
    {
    }
    static void solve()
    {
        input();
        int r = int.Parse(ReadLine());
        WriteLine(3 * r * r);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string str;
    cin>>str;
    int n = (int)str.size();
    vector<bool> v(26);
    for(int i=0;i<n;++i)v[str[i] - 'a'] = true;
    for(int i=0;i<26;++i)if(!v[i]){
        cout << str + (char)('a' + i) << endl;
        return 0;
    }
    for(int i=n-1;i>=0;i--){
        for(int j=str[i] - 'a';j<26;++j)if(!v[j]){
            cout << str.substr(0,i) + (char)('a' + j) << endl;
            return 0;
        }
        v[str[i] - 'a'] = false;
    }
    cout << -1 << endl;
    return 0;
}



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

typedef unsigned long long LL;

std::string str;
LL K;

int main() {
    std::cin >> str >> K;
    for (int i = 0; i < str.size(); ++i) {
        if (K == i + 1 || str[i] != '1') {
            std::cout << str[i];
            break;
        }
    }
    return 0;
}

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

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
//

// mod add
void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

// 0: dammy, 1: 'A', 2: 'G', 3: 'C', 4: 'T'
// "AGC, GAC, ACG", "A*GC", "AG*C" を含まない (012, 102, 021 を禁止)
long long solve(int N) {
    auto dp = make_vec<long long>(N+1, 5, 5, 5); // dp[i文字][3文字前][2文字前][1文字前]
    dp[0][0][0][0] = 1;
    for (int n = 0; n < N; ++n) {
        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
                for (int k = 0; k < 5; ++k) {
                    for (int l = 1; l < 5; ++l) {
                        if (i == 1 && j == 2 && l == 3) continue;
                        if (i == 1 && k == 2 && l == 3) continue;
                        if (j == 1 && k == 2 && l == 3) continue;
                        if (j == 2 && k == 1 && l == 3) continue;
                        if (j == 1 && k == 3 && l == 2) continue;
                        add(dp[n+1][j][k][l], dp[n][i][j][k]);
                    }
                }
            }
        }
    }
    long long res = 0;
    for (int i = 1; i < 5; ++i)
        for (int j = 1; j < 5; ++j)
            for (int k = 1; k < 5; ++k)
                add(res, dp[N][i][j][k]);
    return res;
}

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; cin >> N;
    cout << solve(N) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    int a[M], b[M];
    P l[M];
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        l[i] = P(b[i], a[i]);
    }

    sort(l, l+M);

    int now = -1;
    int ans = 0;
    for(int i=0; i<M; i++){
        int s = l[i].second;
        int e = l[i].first;
        if((now < s) || (now>(e-1))) {
            now = e-1;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

namespace ConsoleApplication85
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[3];
            a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = Math.Abs(a[1] - a[0]);
            int c = Math.Abs(a[2] - a[0]);
            if (b > c)
                Console.WriteLine("B");
            else Console.WriteLine("A");
        }
    }
}


Measured memory_bytes: 13396
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  } 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (ll i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(ll n, ll k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }

int main() { 
    COMinit();
    ll n,m;
    std::cin >> n>>m;

    // 0または1または2または3...で上下一致する、の補集合が答え
    // =Σ (-1)^|s|*Xs
    
    // 上　Sに∅は含まない、、、
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        // 少なくともi個一致しているものがある組み合わせの数
        ans += COM(m,n)*fac[n]%MOD* //Aの固定   
               COM(n,i)%MOD* //どこが一致するか
               COM(m-i,n-i)%MOD*fac[n-i]%MOD* //Bの自由度
               modpow(-1+MOD,i)%MOD; //包除原理
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 15528
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int> > edges(n);
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<vector<bool> > used(2, vector<bool>(n, false));
    queue<pair<int, int> > q;
    used[0][0] = true;
    q.push(make_pair(0, 0));
    while(!q.empty()){
        int k = q.front().first;
        int a = q.front().second;
        q.pop();
        for(int b : edges[a]){
            if(!used[k^1][b]){
                used[k^1][b] = true;
                q.push(make_pair(k^1, b));
            }
        }
    }

    vector<int> v(2, 0);
    for(int i=0; i<2; ++i){
        for(int j=0; j<n; ++j){
            if(used[i][j])
                ++ v[i];
        }
    }
    long long ans;
    if(v[0] == n)
        ans = n * (n - 1LL) / 2 - m;
    else
        ans = v[0] * (long long)v[1] - m;
    cout << ans << endl;

    return 0;
}


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main(){
	ll a,b;
	cin>>a>>b;
	if(b>=0&&a<=0){
		cout << "Zero"<<endl;
	}
	else{
		if(a>0&&b>0){
			cout << "Positive"<<endl;
		}
		else{
			if((b-a)%2==0){
				cout << "Negative"<<endl;
			}
			else{
				cout << "Positive"<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)


using namespace std;

int main(){

int N;
cin>>N;

long long A[N];
rep(i,N){
    cin>>A[i];
}

vector<long long >v;

int ans=1;
v.emplace_back(A[0]);
long long max=A[0];
long long min=A[0];
for(int i=1;i<N;i++){
    if(A[i]<=min){
        v.emplace(v.begin(),A[i]);
        ans++;
    }
    else if(A[i]>max){
        v[ans-1]=A[i]; 
    }
    else{
        long long  it=lower_bound(v.begin(),v.end(),A[i])-v.begin();//A[i]以上の要素
        v[--it]=A[i];
    }
    max=v[ans-1];
        min=v[0];
}
//rep(i,ans)cout<<v[i]<<" ";
cout<<ans<<endl;
    
 return 0;
}
/*
5
2
1
4
5
3

2


4
0
0
0
0

4



*/

Measured memory_bytes: 2168
#include<cstdio>

int main(){
    int n,x;
    for(int i = 0;; i++){
        scanf("%d %d",&n,&x);
        if(n == 0 && x == 0){
            break;
        }
        int s = 0;
        int j,k,l;
        for(j = n; j >= 3; j--){
            for(k = j - 1; k >= 2; k--){
                for(l = k - 1; l >= 1; l--){
                    if(j + k + l == x){
                        s++;
                    }
                }
            }
        }
        printf("%d\n",s);
    }
    return 0;
}


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

using namespace std;

vector<int> pot = {0,10,20,30,40,50,60,70,80,90,100,110,120,130};

int main(){

	vector<pair<int,int>> v(5);

	for(int i=0;i<5;++i){
		cin >> v[i].second;
		v[i].first = pot[upper_bound(pot.begin(),pot.end(),v[i].second)-pot.begin()] - v[i].second;
		if(v[i].first == 10) v[i].first = 0;
	}

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

	int ans = 0;
	int last = ans;

	for(int i=0;i<4;++i){
		//cout << v[i].first << ' ' << v[i].second << ' ' << ans << '\n';
		ans+=v[i].first + v[i].second;
	}

	ans+=v[4].second;

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[][] ar = new int[n][n];
		for (int i=0;i<n;i++) {
			int me = scan.nextInt();
			int nv = scan.nextInt();
			for (int j=0;j<nv;j++) {
				int to = scan.nextInt();
				ar[me-1][to-1]=1;
				//ar[to-1][me-1]=1;
			}
		}
		
		for (int i=0;i<n;i++) {
			StringBuilder sb = new StringBuilder();
			for (int j=0;j<n;j++) {
				sb.append(ar[i][j]).append(" ");
			}
			System.out.println(sb.substring(0, sb.length()-1));
		}
	}
}

Measured memory_bytes: 30044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  
  int k,s;
  cin >>k>>s;
  int ans = 0;
  rep(p,k+1){
    rep(q,k+1){
      int r = s-p-q;
      if(r>=0 && r<=k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=2005;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,a[N];
int main()
{
	n=read();
	for(int i=1; i<=n; i++) a[i]=read();
	sort(a+1, a+n+1);
	ll ans=0;
	for(int i=n; i>=1; i--){
		for(int j=i-1; j>=1; j--){
			int k=lower_bound(a+1, a+j, a[i]-a[j]+1)-a;
			ans+=j-k;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int h[N];
  for(int i = 0; i < N; i++) cin >> h[i];

  int ans = 0;
  int cnt = 0;
  for(int i = 0; i < N - 1; i++){
    if(h[i] >= h[i+1]) cnt++;
    else cnt = 0;

    ans = max(ans, cnt);
  }

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

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl p(n);
    rep(i,n){
        ll t; cin >> t; t--;
        p[t] = i+1;
    }
    vl a(n),b(n);
    ll num = 2;
    a[0] = 1;
    REP(i,1,n){
        if(p[i] < p[i-1]) a[i] = num;
        else{
            num += p[i] - p[i-1];
            a[i] = num;
        }
        num++;
    }
    for(auto i : a) cout << i << " ";
    cout << endl;
    b[n-1] = 1;
    ll sum = b[n-1] + a[n-1];
    for(ll i=n-2; i>=0; i--){
        b[i] = sum + p[i] - p[i+1] - a[i];
        sum = b[i] + a[i];
    }
    for(auto i : b) cout << i << " ";
    cout << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
string s;
map<string,int> ma;
int main()
{
	int i,j,k,n,m,x;
	scanf("%d",&n);
	cin>>s;
	ma[s]=1;
	char ch=s[s.size()-1];
	for(i=1;i<n;i++)
	{
		cin>>s;
		if(ma.count(s)||s[0]!=ch)
		{
			printf("No");
			return 0;
		}
		ch=s[s.size()-1];
		ma[s]=1;
	}
	printf("Yes");
}


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(){
    int n,x,t;cin>>n>>x>>t;
    int y=(n-1)/x;
    cout<<(y+1)*t<<endl;
    return 0;
}

Measured memory_bytes: 3620
L, R = map(int, input().split())

A = []
Lm = L % 2019
Rm = R % 2019
for _ in range(min(R - L + 1, 2019 * 2)):
    A.append(Lm)
    Lm = (Lm + 1) % 2019

A.sort()
ans = 2018
for i in range(len(A)):
    for j in range(i + 1, len(A)):
        ans = min(ans, (A[i] * A[j]) % 2019)
        if ans == 0:
            break

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  vector<ll> sum(n);
  sum[0]=a[0];
  for(i=1;i<n;i++)sum[i]=sum[i-1]+a[i];//累積和           
  int ans=a.size();
  rep(i,n-1){//iが生き残るか                              
    ll size=sum[i];
    while(size<sum[n-1]){
      int sup=upper_bound(all(a),size*2)-a.begin();
      sup--;//現状吸収できる最大                          
      if(size>=sum[sup])break;
      size=sum[sup];
    }
    if(size<sum[n-1])ans--;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
void tc(){
    string s;
    cin >> s;
    map<char, int> used;
    for(auto x : s){
        used[x]++;
    }
    if(SZ(used) < 26){
        for(char x = 'a'; x <= 'z'; x++){
            if(!used.count(x) && s + x > s){
                cout << s + x;
                return;
            } 
        }
    }else{
        string res;
        int n = SZ(s);
        int mxsuff = n - 1;
        for(int i = n - 2; i >= 0; i--){
            if(s[i] >  s[i + 1]){
                mxsuff = i;
            }else break;
        }
        if(mxsuff == 0){
            cout << -1;
        }else{
            char mn = 'z';
            for(int i = mxsuff; i < n; i++){
                if(s[i] > s[mxsuff - 1]){
                    mn = min(mn, s[i]);
                }
            }
            cout << s.substr(0, mxsuff - 1) + mn;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    int n;
    ll L;
    cin>>n>>L;
    V<ll> a(n);
    cinf(n,a);
    bool ok=0;
    int last;
    rep(i,n-1){
        if(a[i]+a[i+1]>=L){
            ok=1;
            last=i+1;
            break;
        }
    }
    if(ok){
        cout<<"Possible"<<'\n';
        int m=1;
        while(m<last){
            printf("%d\n",m);
            m++;
        }
        m=n-1;
        while(m>last){
            printf("%d\n",m);
            m--;
        }
        
        printf("%d\n",last);
    }else printf("Impossible\n");
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int K = 100005;
const int N = 101;

long long dp[N][K] , g[N][K] , a[N];
int n , k;
int mod = 1000000007;


int32_t main(){
	scanf("%d%d" , &n , &k);
	for(int i = 1 ; i <= n;i++) scanf("%lld" , &a[i]);
	dp[0][0] = 1;
	for(int i = 1 ; i <= n ;i ++){
		for(int j = 0 ; j <= k; j ++){
			if(j ==0) dp[i][j] = 1;
			else{
			if(i == 1){
				if(j <= a[i]) dp[i][j] = 1; 
			}
			else{
				int R = j , L = j - a[i] - 1;
				dp[i][j] = g[i-1][R];
				if(L >= 0) dp[i][j] -= g[i-1][L];
				if(dp[i][j] < mod) dp[i][j] += mod;
				dp[i][j] %= mod;
			}
			}
		}
		for(int j = 0 ; j <= k ; j++){
			if(j) g[i][j] = (g[i][j-1] + dp[i][j])%mod;
			else g[i][j] = dp[i][j];
		}
	}
	printf("%lld\n" , dp[n][k]);
}

Measured memory_bytes: 157312
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int n,m;
Vi v[100000];
int sz[100000];
int main() {
	int ans=0;
	int n,m;
	scanf("%d%d",&n,&m);
	fup(i,0,n-1,1)
	{
		int x;
		scanf("%d",&x);
		v[x%m].pb(x);
		sz[x%m]++;
	}
	fup(i,0,m-1,1)sort(ALL(v[i]));
	fup(i,0,m/2,1)
	{
		if(i==0)ans+=sz[i]/2;
		else if(m%2==0 && i==m/2)ans+=sz[i]/2;
		else
		{
			int j=i,k=m-j;
			if(sz[j]<sz[k])swap(j,k);
			int t=0;
			fup(ii,1,sz[j]-1,1)
			{
				if(v[j][ii]==v[j][ii-1])
					t++,ii++;
			}
			t=min(t,(sz[j]-sz[k])/2);
			ans+=t;
			sz[j]-=2*t;
			ans+=min(sz[j],sz[k]);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

long N,M;
priority_queue<long> A;
long coupon[100001];

int main(){
    cin>>N>>M;
    long ans=0;
    rep(i,N){
        long x;
        cin>>x;
        A.push(x);
        ans+=x;
    }

    rep(i,M){
        long t=A.top();
        A.pop();
        A.push(t/2);
        ans-=t;
        ans+=t/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include<stdio.h>

int main(void)
{
  int n;
  scanf("%d",&n);
  
  char s[110];
  int i,judge=1;
  for(i=0;i<n;i++){
    scanf("%c",&s[i]);
    if(s[i]=='Y')
      judge = 0;
  }

  if(judge==1)
    printf("Three\n");
  else
    printf("Four\n");

  return 0;
}


Measured memory_bytes: 1660
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int a, b, c, d;

int main() {
  init_ios();
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0) {
    c -= b;
    if (c <= 0)
      break;
    a -= d;
  }
  if (a <= 0)
    cout<<"No\n";
  else
    cout<<"Yes\n";
}

Measured memory_bytes: 3652
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
d = []
for _ in range(int(input())):
    d.append(int(input()))
for i in range(3):
    t = 0
    t2 = 0
    for j in range(3):
        if a[i][j] in d:
            t += 1
        if a[j][i] in d:
            t2 += 1
        if t == 3 or t2 == 3:
            print("Yes")
            exit()
t = 0
t2 = 0
for i in range(3):
    for j in range(3):
        if i == j and a[i][j] in d:
            t += 1
        if i + j == 2  and a[i][j] in d:
            t2 += 1
if t == 3 or t2 == 3:
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int i;
  long ans = 0;
  for(i=0;i<n;i++){
    cin >> a[i];
    ans += a[i]-1;
  }
  cout << ans;
}

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

long dp[110][100010], mod=1000000007;
int main() {
	int N, K, a[110]; cin >> N >> K;
	for(int i=1; i<=N; ++i) cin >> a[i];
	dp[0][0]=1;
	for(int i=1; i<=N; ++i){
	    long ad=0;
	    for(int j=0; j<=K; ++j){
	        ad=(ad+dp[i-1][j])%mod;
	        dp[i][j]=ad;
	        if(j>=a[i]) ad=(ad+mod-dp[i-1][j-a[i]]);
	    }
	}
	cout << dp[N][K] << endl;
	return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    vector<int> B(N,0);
    vector<int> C(N-1,0);
    for(int i=0;i<N;++i) cin >> A[i];
    for(int i=0;i<N;++i) cin >> B[i];
    for(int i=0;i<N-1;++i) cin >> C[i];

    int ans=0;

    for(int i=0;i<N-1;++i){
        ans += B[A[i]-1];
        if(A[i+1]-A[i]==1) ans += C[A[i]-1];
    }
    ans += B[A[N-1]-1];
    cout << ans << endl;
}



Measured memory_bytes: 256
<?php

while(($in = trim(fgets(STDIN)))!='0 0'){
	$dp=array(array());
	sscanf($in,"%d %d",$n,$s);
	for($i=0;$i<=10;$i++){
		for($j=0;$j<=1000;$j++){
		$dp[$i][$j]=0;
	}
 }
 $dp[0][0]=1;
	for($i=0;$i<=100;$i++){
		for($j=9;$j>=0;$j--){
			for($m=0;$m+$i<=$s;$m++){
				$dp[$j+1][$m+$i]+=$dp[$j][$m];
			}
		}
	}
	print($dp[$n][$s]."\n");
}

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

using namespace std;
typedef long long ll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

#define MOD 998244353

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;

    ll A[Q];
    for(int i=0; i<Q; i++) cin >> A[i];

    ll P[N];
    for(int i=0; i<N; i++) P[i] = K - Q;
    for(int i=0; i<Q; i++) P[A[i]-1]++;

    for(int i=0; i<N; i++) {
        if(P[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

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

long long rec(int n, long long x) {
    if (n == 0) return 1;
  
    long long len = (1LL<<(n+1)) - 3;
  
    long long num = (1LL<<n) - 1;
  
    if (x == 1) {
      return 0;
    }
    else if (x <= len + 1){
      return rec(n-1, x-1);
    }
    else if (x == len + 2) {
      return num + 1;
    }
    else if (x <= (len + 1) * 2){
      return num + 1 + rec(n-1, x-len-2);
    }
    else {
      return num * 2 + 1;
    }
}

int main() {
    int N; long long X;
    cin >> N >> X;
    cout << rec(N, X) << endl;
}


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

int N;
int a=0;
int main(){
	cin>>N;
	for(int i=1; i<=9; i++) {
		for(int j=1; j<=9; j++) {
			if(i*j==N) {
				a++;
			}
		}
	}
	if(a>0) {
		cout<<"Yes"<<endl;
	} else if(a<=0) { 
	 cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  vector<char>vec(3);
  for(ll i=0;i<3;i++){
    cin>>vec.at(i);
    if(vec.at(i)=='1'){
      vec.at(i)='9';
    }
    else{
      vec.at(i)='1';
    }
  }
  for(ll i=0;i<3;i++){
    cout<<vec.at(i);
  }
  cout<<endl;
  return 0;
}
  
  
    
    
  


Measured memory_bytes: 3584
def main():
    n = int(input())
    d = dict()
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            d[(i, j)] = 0
    for i in range(1, n+1):
        ii = str(i)
        start = int(ii[0])
        end = int(ii[-1])
        if start == 0:
            continue
        if end == 0:
            continue
        d[(start, end)] += 1
    for i in range(1, 10):
        for j in range(1, 10):
            if i != j:
                ans += d[(i, j)]*d[(j, i)]
    for i in range(1, 10):
        ans += d[(i, i)]*d[(i, i)]
    print(ans)


main()


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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,a[101],sum1=0,sum2=0,i,m=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(i=n;i>=1;i--)
        if(m==0)
        {
            sum1+=a[i];
            m=1;
        }

        else
        {
            sum2+=a[i];
            m=0;
        }


    cout<<abs(sum1-sum2)<<endl;

}



Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  auto S = scan;

  string solve() {
    return S[2] == S[3] && S[4] == S[5] ? "Yes" : "No";
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
typedef pair<int,int> P;

int main(){
	string s;
	cin >> s;
	int K;
	cin >> K;
	for(int i=0;i<s.size();i++){
		if(s[i]=='a')
			continue;
		else if('z'-s[i]<K){
			K-='z'-s[i]+1;
			s[i]='a';
		}
	}
	s[s.size()-1]=(s[s.size()-1]-'a'+K)%26+'a';
	cout << s << endl;
	return 0;
}

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


int main(){
    ll A,B;
    cin >> A >> B;
    map<ll,int> res;
    ll AB=__gcd(A,B);
    ll num = AB;
    ll ans;
    for(int i=2;pow((ll)i,2)<AB;i++){
        while(num%i==0){
            res[i]++;
            num/=i;
        }
    }
    if(num!=1) res[num]++;

    ans = res.size()+1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Main m = new Main();
        m.run();
    }

    private void run() {
        int a = sc.nextInt();
        int b = sc.nextInt();

        for (int i = 0; i < 1250; i++) {
            int p1 = (int) Math.floor(i * 0.08);
            int p2 = (int) Math.floor(i * 0.1);
            if (p1 == a && p2 == b) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 25044
n = int(input())
a = [int(input()) for i in range(n)]
mod = 998244353
sm = sum(a)
dp = [[0 for i in range(sm+1)] for j in range(n+1)]
dp2 = [[0 for i in range(sm+1)] for j in range(n+1)]
dp[0][0] = 1
dp2[0][0] = 1
for i in range(1,n+1):
  x = a[i-1]
  dp2[i] = dp2[i-1][:]
  for j in range(sm+1):
    dp[i][j] = dp[i-1][j]*2
    if j >= x:
      dp[i][j] += dp[i-1][j-x]
      dp2[i][j] += dp2[i-1][j-x]
    dp[i][j] %= mod
    dp2[i][j] %= mod
ans = pow(3,n,mod)-sum(dp[-1][(sm+1)//2:])*3
if sm%2:
  print(ans%mod)
else:
  print((ans+dp2[-1][sm//2]*(mod+1)//2*6)%mod)

Measured memory_bytes: 693304
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main() {
    string s,t;
    cin >> s >> t;
    vector<int> start(26, -1);
    vector<int> goal(26, -1);
    rep(i, s.size()) {
        int a = s[i] - 'a';
        int b = t[i] - 'a';

        if (start[a] != -1 || goal[b] != -1) {
            if (start[a] != b || goal[b] != a) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            start[a] = b;
            goal[b] = a;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 776
import math
a,b = list(map(int, input().split()))
def zeinuki(tax, ratio):
    _min=math.ceil(tax/ratio)
    _max=math.ceil((tax+1)/ratio)-1
    return _min, _max

c08=zeinuki(a, 0.08)
c10=zeinuki(b, 0.1)
if c10[0]>c08[1] or c08[0]>c10[1]:
    print(-1)
else:
    print(max(c08[0], c10[0]))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    long long mod = 1e9 + 7;
    vector<long long>v;
    long long ans = 1;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        long long x;
        cin >> x;
        v.push_back(x);
        ans = (ans * x) % mod;
        if(x >= 0){
            cnt++;
        }
    }
    if(n == k){
        cout << (ans + mod) % mod;
        return 0;
    }
    if(cnt == 0 && k % 2 == 1){
        sort(v.rbegin(), v.rend());
        long long cur = 1;
        for(int i = 0; i < k; i++){
            cur = (cur * v[i]) % mod;
        }
        cout << (cur + mod) % mod;
        return 0;
    }
    else{
        vector<pair<long long, int> >v2;
        vector<long long>a, b;
        for(int i = 0; i < n; i++){
            if(v[i] >= 0){
                v2.push_back(make_pair(v[i], 1));
                a.push_back(v[i]);
            }
            else{
                v2.push_back(make_pair(-v[i], -1));
                b.push_back(-v[i]);
            }
        }
        sort(v2.rbegin(), v2.rend());
        sort(a.rbegin(), a.rend());
        sort(b.rbegin(), b.rend());
        ans = 1;
        int c1 = 0, c2 = 0;
        for(int i = 0; i < k; i++){
            ans = (ans * v2[i].first) % mod;
            if(v2[i].second == 1){
                c1++;
            }
            else{
                c2++;
            }
        }
        if(c2 % 2 == 0){
            cout << (ans + mod) % mod;
            return 0;
        }
        else{
            ans = 1;
            if(c1 == a.size()){
                for(int i = 0; i < c1 - 1; i++){
                    ans = (ans * a[i]) % mod;
                }
                for(int i = 0; i < c2 + 1; i++){
                    ans = (ans * b[i]) % mod;
                }
                cout << (ans + mod) % mod;
                return 0;
            }
            else if(c1 == 0 || c2 == b.size()){
                for(int i = 0; i < c1 + 1; i++){
                    ans = (ans * a[i]) % mod;
                }
                for(int i = 0; i < c2 - 1; i++){
                    ans = (ans * b[i]) % mod;
                }
                cout << (ans + mod) % mod;
                return 0;
            }
            else{
                if(a[c1] * a[c1 - 1] >= b[c2] * b[c2 - 1]){
                    for(int i = 0; i < c1 + 1; i++){
                        ans = (ans * a[i]) % mod;
                    }
                    for(int i = 0; i < c2 - 1; i++){
                        ans = (ans * b[i]) % mod;
                    }
                    cout << (ans + mod) % mod;
                    return 0;
                }
                else{
                    for(int i = 0; i < c1 - 1; i++){
                        ans = (ans * a[i]) % mod;
                    }
                    for(int i = 0; i < c2 + 1; i++){
                        ans = (ans * b[i]) % mod;
                    }
                    cout << (ans + mod) % mod;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 11616
#include <iostream>
#include <utility>

struct card{
	char suit, value;
};

void bubbleSort(struct card A[], int N){
	for(int i = 0; i < N; i++){
		for(int j = N-1; j >= i; j--){
			if(A[j].value < A[j-1].value) std::swap(A[j], A[j-1]);
		}
	}
}

void selectionSort(struct card A[], int N){
	for(int i = 0; i < N; i++){
		int minj = i;
		for(int j = i; j < N; j++){
			if(A[minj].value > A[j].value) minj = j;
		}
		std::swap(A[minj], A[i]);
	}
}

int main(){
	int N;
	std::cin >> N;
	card A[N], B[N];
	for(int i = 0; i < N; i++){
		std::cin >> A[i].suit >> A[i].value;
		B[i].suit = A[i].suit;
		B[i].value = A[i].value;
	}
	bubbleSort(A, N);
	for(int i = 0; i < N; i++){
		if(i) std::cout << " ";
		std::cout << A[i].suit << A[i].value;
	}
	std::cout << std::endl;
	std::cout << "Stable" << std::endl;
	selectionSort(B, N);
	for(int i = 0; i < N; i++){
		if(i) std::cout << " ";
		std::cout << B[i].suit << B[i].value;
	}
	std::cout << std::endl;
	int f = 1;
	for(int i = 0; i < N; i++){
		if(A[i].suit != B[i].suit){
			std::cout << "Not stable" << std::endl;
			f = 0;
			break;
		}
	}
	if(f) std::cout << "Stable" << std::endl;
	return 0;

}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll b[11];
ll A[3][3];
string ans = "No";
int main(){
	REP(i,0,3){
		REP(j,0,3){
			cin >> A[i][j];
		}
	}
	ll N;
	cin >> N;
	REP(i,0,N){
		cin >> b[i];
	}
	REP(k,0,N) {
		REP(i, 0, 3) {
			REP(j, 0, 3) {
				if(A[i][j] == b[k]){
					A[i][j] = 0;
				}
			}
		}
	}
	REP(i,0,3){
		if(!(A[0][i] || A[1][i] || A[2][i])){
			ans = "Yes";
		}
		if(!(A[i][0] || A[i][1] || A[i][2])){
			ans = "Yes";
		}
	}
	if(!(A[0][0] || A[1][1] || A[2][2])){
		ans = "Yes";
	}
	if(!(A[2][0] || A[1][1] || A[0][2])){
		ans = "Yes";
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 256