akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#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 rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    string a,b; cin >> a >> b;
    string s = a+b;
    ll n = stoll(s);
    if((ll)sqrt(n)*(ll)sqrt(n)==n) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

char s[] = "FESTIVAL";
vector<int> vv;
ll nw[100];

void print() {
//	cerr << vv.size() << "\n";
	for (int i = 0; i < (int)vv.size(); ++i)
		cout << s[vv[i]];
}

int main() {
	ll k;
	cin >> k;
	k -= 1;
	ll now = 1;
	for (int i = 0; i < 7; ++i)  {
		nw[i] = now;
		ll cc = 0;
		for (int j = 0; j < 400; ++j) {
			if (k < now) {
				for (int l = i - 1; l >= 0; --l) {
					while (k >= nw[l]) {
						k -= nw[l];
						vv.push_back(l);
					}
				}
				for (int l = 0; l < 8; ++l)
					vv.push_back(l);
				print();
				return 0;
			}
			else {
				k -= now;
				vv.push_back(i);
				++cc;
			}
		}
		now *= cc;
	}
	return 0;
}



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

int main(void){
	char s[4];
	cin>>s;

	int a=(s[0]-'0')*10+(s[1]-'0'), b=(s[2]-'0')*10+(s[3]-'0');
	bool flag1, flag2;
	flag1 = a<13 && a>0;
	flag2 = b<13 && b>0;
	if(flag1 && flag2)cout<<"AMBIGUOUS"<<endl;
	else if(~flag1 && flag2)cout<<"YYMM"<<endl;
	else if(flag1 && ~flag2)cout<<"MMYY"<<endl;
	else cout<<"NA"<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
b_list = list(map(int, input().split()))
ans_list = []
ans_list.append(b_list[0])
for i in range(n-2):
    v = b_list[i]
    vn = b_list[i+1]
    ans_list.append(min(v, vn))

ans_list.append(b_list[-1])

print(sum(ans_list))


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main() {
	//頂点数、辺数を受け取る
	int N,M;
	cin>>N>>M;
	vector<tint> E;
	//最短距離行列
	int d[SIZE][SIZE]={};
	//行列の初期化
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j)
				d[i][j]=0;
			else
				d[i][j]=INF;
		}
	}
	//辺の情報を受け取る
	//ノード番号は0-indexedに直す
	for(int i=0;i<M;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		d[a][b]=c;
		d[b][a]=c;
		E.pb(mt(a,b,c));
	}
	//ワーシャルフロイド
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	int use=0;
	for(int i=0;i<M;i++){
		int a,b,c;
		tie(a,b,c)=E[i];
		bool flag=0;
		for(int j=0;j<N;j++){
			if(d[j][a]+c==d[j][b]){
				flag=1;
				break;
			}
		}
		if(flag)
			use++;
	}
	cout<<M-use<<endl;
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define vi vector<int>
#define mod 10000000
using namespace std;
ll dp[100001];
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  int a,b,c;
  cin>>a>>b>>c;
  int x=a;
  int z=c;
  a=b;
  b=x;
  c=a;
  a=z;
  cout<<a<<" "<<b<<" "<<c;
		return 0;
}



Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var s = t.ConvertIntList(t.ReadInput());
            for (var i = 0; i < s.Count; i++)
            {
                var min = s[i];
                var index = -1;
                for (var j = i; j < s.Count - 1; j++)
                {
                    if (min > s[j + 1])
                    {
                        min = s[j + 1];
                        index = j + 1;
                    }
                }

                if (index != -1)
                {
                    var temp = s[i];
                    s[i] = s[index];
                    s[index] = temp;
                }
            }

            Console.WriteLine(string.Join(" ", s));

        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }


        public List<int> ConvertIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }
}
}


Measured memory_bytes: 18040
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int MOD = 1e9 + 7;

class Combination {
 public:
  constexpr Combination() {
    Build();
  }
  static constexpr int MOD = 1000000007;
  static constexpr int n_ = 2020;
  struct LookupTable {
    int64 factorial_[n_];
    int64 inverse_[n_];
    int64 finverse_[n_];
  };
  LookupTable lt {};
  constexpr int64 Get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return lt.factorial_[n] * (lt.finverse_[k] * lt.finverse_[n - k] % MOD) % MOD;
  }
 private:
  constexpr void Build() noexcept {
    lt.factorial_[0] = 1; lt.factorial_[1] = 1;
    lt.finverse_[0] = 1; lt.finverse_[1] = 1;
    lt.inverse_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      lt.factorial_[i] = lt.factorial_[i - 1] * i % MOD;
      lt.inverse_[i] = MOD - lt.inverse_[MOD % i] * (MOD / i) % MOD;
      lt.finverse_[i] = lt.finverse_[i - 1] * lt.inverse_[i] % MOD;
    }
  }
};

Combination kyomukyomupurin;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k; cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    int64 ans = 0;
    (ans += kyomukyomupurin.Get(n - k + 1, i) * kyomukyomupurin.Get(k - 1, i - 1)) %= MOD;
    cout << ans << '\n';
  }

  return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
void solve(){
    string s;
    cin >> s;
    int ans=0;
    rep(i,1,s.size()) if(s[i]!=s[i-1]) ++ans;
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

int main(){
  string n = "";
  cin >> n;

  replace(n.begin(), n.end(), '1', 't');
  replace(n.begin(), n.end(), '9', '1');
  replace(n.begin(), n.end(), 't', '9');
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String string=sc.next();
    for(char i='a'; i<='z'; i++){
      if(string.indexOf(i)<0){
        System.out.println(i);
        return;
      }
    }
    System.out.println("None");
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N, a, cnt=0;
	cin>>N;
	for(int i=0; i<N; i++){
		cin>>a;
		if(a&1)cnt++;
	}
	if(cnt&1)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<string>
#include<set>
#include<utility>
#include<vector>

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

const int INF = 1001001001;

void solve(){
  int h, n; cin >> h >> n;
  vector<int> dp(h+1, INF);
  dp[0] = 0;
  rep(i, n) {
    int a, b; cin >> a >> b;
    rep(j, h+1) {
      dp[j]=min(dp[j], dp[max(0, j-a)]+b);
    }
  }

  cout << dp[h] << endl;
}

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


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

int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll> a(n);
    ll i,j;
    ll sum=0;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        sum+=a.at(i);
        }
    sort(a.begin(),a.end());
    ll nin=0;
    if(x<a.at(0)){
        cout << 0 << endl;
        return 0;
    }
    if(x<sum){
        for(i=0;i<n;i++){
            if(x==a.at(i)){
                nin=i+1;
                break;
            }
            else if(x<a.at(i)){
                nin=i;
                break;
            }
            x-=a.at(i);
        }
    }
    else if(x==sum) nin=n;
    else nin=n-1;
    cout << nin << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <bits/stdc++.h>

using namespace std;

long long n, m;

int main () {
    cin >> n >> m;
    if ( n < m ) {
        while (m--) {
            cout << n;
        }
    }
    else {
        while(n--) {
            cout << m;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
int main()	{
    int a,b;
    cin>>a>>b;
    if(a<b){
    rep(i,b){ printf("%d",a);}}
    else
    {
        rep(i,a){printf("%d",b);}
    }
    
}

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e5 + 7;
const ll INF = LONG_LONG_MAX;


#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
void solve() {
	
	int a,b,h,m;
	cin >> a >> b >> h >> m;

	float HA = 0.5 * (h * 60 + m);  
    float MA = 6 * m;
    float angle = abs(HA -MA);
    angle = min(360 - angle, angle);
    
	//angle = min(abs(angle), 360 - (angle));
	//D1(angle);
	//if(angle < 0) angle += 360;
	cout << fixed << setprecision(20) << sqrt(a*a + b*b - 2*a*b*cos(PI/180 * angle)) << "\n";
	
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 4184
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	if(n >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3616
N = int(input())
A = list(map(int,input().split()))
import collections
X = []
Y = []
for i in range(0,len(A)):
    X.append(i+1+A[i])
    Y.append(i+1-A[i])
x = collections.Counter(X)
n = 0
for j in range(0,len(Y)):
    n = n + x[Y[j]]
print(n)


Measured memory_bytes: 50728
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n, m, v, p;
vector<ll> a;
bool check(ll k){
    ll temp=a[k]+m;
    ll vote=k+p;
    ll maxv=(v-vote)*m;//これから投票する数
    //cout<<maxv<<" "<<k<<"\n";
    for(int i=k+1;i<n-p+1;i++){
        /*
        if(v<=vote){
            return true;
        }
        */
       if(temp-a[i]<0) return false;
        maxv-=min(m,temp-a[i]);
        //vote++;
        if(i==n-p&&maxv>0){
            return false;
        }
    }
    if(maxv<=0)return true;
    if(v-vote<=0)return true;
    return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m>>v>>p;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(ALL(a));
    ll l=-1;
    ll r=n;
    ll mid=(r+l)/2;
     while(r-l>1){
         mid=(r+l)/2;
         //cout<<mid<<" "<<l<<" "<<r<<"\n";
        if(check(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
     }
     //cout<<l<<" "<<r<<"\n";
     cout<<n-r<<"\n";
}



Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <cstring>
#include <map>
#include <unordered_map>
#include <tuple>

using namespace std;

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define umap unordered_map
#define uset unordered_set
#define cina(s, n, a) for(int quer = s; quer < n; quer++) cin >> a[quer]
#define couta(s, n, a) for(int quer = s; quer < n; quer++) cout << a[quer] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES\n" : "NO\n")
#define mod(a, b) (abs(b) + (a % abs(b))) % abs(b)
#define setp(x) fixed << setprecision(x)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
int a[10][10];
int n;
void solve(){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> a[i][j];
    }
    cin >> n;
    map <int, int> m, tmp;
    while(n--){
        int x;
        cin >> x;
        m[x]++;
    }
    bool ok = false;
    tmp = m;
    for(int i = 0; i < 3; i++){
        bool f = false;
        for(int j = 0; j < 3; j++){
            if(tmp[a[i][j]] <= 0){
                f = true;
                break;
            }
            tmp[a[i][j]] -= 1;
        }
        if(!f) ok = true;
    }
    tmp = m;
    for(int i = 0; i < 3; i++){
        bool f = false;
        for(int j = 0; j < 3; j++){
            if(tmp[a[j][i]] <= 0){
                f = true;
                break;
            }
            tmp[a[j][i]] -= 1;
        }
        if(!f) ok = true;
    }
    bool f = false;
    tmp = m;
    for(int i = 0; i < 3; i++){
        if(tmp[a[i][i]] <= 0){
            f = true;
            break;
        }
        tmp[a[i][i]] -= 1;
    }
    if(!f) ok = true;
    tmp = m;
    f = false;
    for(int i = 0; i < 3; i++){
        if(tmp[a[i][3 - i - 1]] <= 0){
            f = true;
            break;
        }
        tmp[a[i][n - i - 1]] -= 1;
    }
    if(!f) ok = true;
    cout << (ok ? "Yes" : "No");
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}


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

int miniChar(string S1, string S2) 
{ 	int n = S1.size(), m = S2.size(); 

	int ans = INT_MAX; 
	for (int i = 0; i < m - n + 1; i++) { 		int minChar = 0; 
		for (int j = 0; j < n; j++) { 
			if (S1[j] != S2[i + j]) { 
				minChar++; 
			} 
		} 
		ans = min(minChar, ans); 
	} 
	return ans; 
} 

int main(){
	string s,t;
	cin >> s >> t;
	cout << miniChar(t, s); 
	return 0; 
} 


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, K;
	cin >> N >> K;
	
	vector<int> P(N), C(N);
	REP(i, N) scanf("%d", &P[i]), --P[i];
	REP(i, N) scanf("%d", &C[i]);
	
	vector<bool> done(N);
	ll ans = -longINF;
	
	REP(s, N) {
		if (done[s]) continue;
		
		vector<int> cycle;
		auto dfs = [&](auto dfs, int x) {
			if (done[x]) return;
			done[x] = true;
			cycle.emplace_back(x);
			dfs(dfs, P[x]);
		};
		dfs(dfs, s);
		
		int sz = cycle.size();
		
		ll loopsum = 0;
		REP(i, sz) loopsum += C[P[cycle[i]]];
		
		REP(i, sz) {
			ll cur = 0;
			int p = cycle[i];
			
			REP(j, sz + 1) {
				if (j > 0) {
					if (j > K) continue;
					if (loopsum > 0) chmax(ans, cur + (K - j) / sz * loopsum);
					else chmax(ans, cur);
				}
				p = P[p];
				cur += C[p];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4092
#include<string>
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
	//freopen("in","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string a,b;
	cin >> a;
	b = a;
	for(int i = 0;i < a.size();i++){
		a[i]='x';
	}	
	cout << a << endl;;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = sorted(LI())

    t = [9,2,5,5,4,5,6,3,7,6]
    d = {}
    for c in a:
        d[t[c]] = c

    dp = [0] * (n+10)
    for i in range(n):
        if i > 0 and dp[i] < 1:
            continue
        di = dp[i] * 10
        for k,v in d.items():
            t = di + v
            if dp[i+k] < t:
                dp[i+k] = t

    return dp[n]


print(main())



Measured memory_bytes: 16728
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

struct edge{
  int to,l;
};
vector<vector<edge>> g(100005);
bool memo[100005];
bool ans[100005];

void dfs(int u,int leng){
  memo[u]=1;
  if(leng%2==0) ans[u]=1;

  rep(i,g[u].size()){
    int v=g[u][i].to;
    if(memo[v]) continue;
    dfs(v,leng+g[u][i].l);
  }
}

int main(){
  int n; cin>>n;
  rep(i,n-1){
    int u,v,w; cin>>u>>v>>w;
    u--;v--;
    g[u].push_back({v,w});
    g[v].push_back({u,w});
  }
  dfs(0,0);
  rep(i,n){
    cout<<(ans[i]?"0":"1")<<endl;
  }
}


Measured memory_bytes: 8576
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;


int main(){
	ll X,Y;
	cin >> X >> Y;
	ll a=2;
	ll ans=1;
	while(X*a<=Y){
		a=a*2;
		ans+=1;
	}
	cout << ans;
  return 0;
}


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

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

    rep(i, s.size()) {
        if (i % 2 == 0) {
            cout << s.at(i);
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, K, s;
ll sum, ans, a;

int main()
{
    cin >> N >> K;
    vector<ll> T, S;
    T.push_back(0);S.push_back(0);
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        T.push_back(T.back() + a);
        S.push_back(S.back() + max(0LL, a));
    }

    for (int i = K; i <= N; i++)
    {
        ans = max((S[N] - S[i]) + S[i - K] + max(0LL, T[i] - T[i - K]), ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const double eps = 1e-8;
const int mod = 998244353;

int a[4];

int main(){
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  priority_queue<ll> q;
  q.push(0);
  ll cnt=0;
  rep(i, N){
    ll h;
    cin >> h;
    if(h>=q.top())cnt++;
    q.push(h);
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 256
// abc131b.cpp : Bite Eating
#include <bits/stdc++.h>
using namespace std;
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ote(x) cout<<(x)<<endl

#define INF 1000000000+1

int main(){
  int N,L; cin>>N>>L;
  int s_taste = 0;
  int del_taste = 0;
  int min_diff = INF;
  up(i,1,N+1,1){
    int taste = L + i - 1;
    s_taste += taste;
    if(min_diff>abs(taste)){
      min_diff = abs(taste);
      del_taste = taste;
    }
  }
  ote(s_taste-del_taste);
}

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

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int k=scan.nextInt();
int[] a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  


System.out.println(a[k-1]);


}
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(1000000)

def func(x):
    return x - 1
def main():
    N, K = map(int, input().split())
    P = list(map(func,map(int, input().split())))
    C = list(map(int, input().split()))
    ans = -float('inf')
    for si in range(N):
        x = si
        tot = 0
        S = []
        while True:
            x = P[x]
            S.append(C[x])
            tot += C[x]
            if x == si:
                break
        l = len(S)
        t = 0
        for i in range(l):
            t += S[i]
            if i + 1 > K:
                break
            now = t
            if tot > 0:
                e = (K-(i+1)) // l
                now += tot*e
            ans = max(ans, now)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 84368
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans = 9999;
    for (int i = 1; i < n; i++) {
        int j = n - i;
        int tmp = 0;
        int tmpi = i;
        int tmpj = j;
        while (tmpi != 0) {
            tmp += tmpi % 10;
            tmpi /= 10;
        }
        while (tmpj != 0) {
            tmp += tmpj % 10;
            tmpj /= 10;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


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

dist = [-1] * N
dist[0] = 0
prev = [0] * N
q = deque([0])
while q:
    v = q.popleft()
    for nv in G[v]:
        if dist[nv] == -1:
            q.append(nv)
            dist[nv] = dist[v] + 1
            prev[nv] = v
    
print('Yes')
for v in prev[1:]:
    print(v+1)

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,a,b; 
vll h;

bool isOk(ll mid){
  ll cnt=0;
  rep(i,n){
    ll k=h[i]-b*mid;
    if(k<0) continue;
    cnt+=(k+(a-b-1))/(a-b);
  }
  if(mid<cnt) return false;
  else return true;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>a>>b;
  h.resize(n);
  rep(i,n) cin>>h[i];
  
  ll ok=1e9+1, ng=0;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(isOk(mid)) ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  rep(i,N){
    cin >> X[i];
  }
  ll sum = 0;
  rep(i,N-1){
    if((X[i+1] - X[i])*A > B){//歩くコストの方が大きい時
        sum += B;
    }
    else sum += (X[i+1] - X[i])*A;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;
#include <math.h>

int main(){
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if((4 * a * b < (c - a - b) * (c - a - b)) && (c > a - b)) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
//
//  main.cpp
//  cpp
//
//  Created by Hao He on 8/13/17.
//  Copyright © 2017 Hao He. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <map>
#include <unordered_map>

using namespace std;
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define mp make_pair
#define maxn 1001
const int mod = 1000000000 + 7;
const int inf = 100000000;

int n, m, k;
vector<int> e[maxn];
int dp[maxn][5001], x[maxn], y[maxn];
int tmp[5001];

bool possible;
#define DP(i, j) ((j)>= 0? dp[i][j]: inf)
void dfs(int u){
    dp[u][0] = 0;
    rep(j,x[u]){
        dp[u][j+1] = inf;
    }
    for(int v: e[u]){
        dfs(v);
        for(int j=x[u]; j>=0; --j){
            dp[u][j] = min(DP(u, j - x[v]) + y[v], DP(u, j - y[v]) + x[v]);
        }
    }
    y[u] = inf;
    rep(j, x[u]+1){
        y[u] = min(y[u], dp[u][j]);
    }
    possible &= y[u] < inf;
    //cout << u << " " << x[u] << " " << y[u] << endl;
}

void solve(){
    cin >> n;
    rep(i,n-1){
        int p;
        cin >> p;
        e[p].push_back(i+2);
    }
    rep(i,n){
        cin >> x[i+1];
    }
    possible = 1;
    dfs(1);
    puts(possible?"POSSIBLE":"IMPOSSIBLE");
}

int main(int argc, const char * argv[]) {
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*
 8
 1 1 1 3 4 5 5
 4 1 6 2 2 1 3 3
 
*/


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ffor(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define rfor(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) ffor(i, 0, j, 1)
#define rrep(i, j) rfor(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
//#define f first
//#define s second
#define inf (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define trace1(x)                     cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)        cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
const double pi=acos(-1.0);
typedef pair<long long int,long long int> pii;
typedef long long ll;
typedef vector<long long int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<long long int,long long int> mpii;
typedef set<long long int> sei;
typedef multiset<long long int> msei;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m,k;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    ll dp[n+1][k+1];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    ll sum[k+1]={0};
    ll tsum[k+1]={0};
    for(i=1;i<=n;i++)
    dp[i][0]=1;
    for(i=0;i<=k;i++)
    sum[i]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(j-1>=a[i])
            {
                dp[i][j]=(sum[j]-sum[j-a[i]-1])%MOD;
                if(dp[i][j]<0)
                dp[i][j]+=MOD;
            }
            else
            {
                dp[i][j]=sum[j];
            }
        }
        sum[0]=1;
        for(j=1;j<=k;j++)
        {
            sum[j]=(dp[i][j]+sum[j-1])%MOD;
        }
    }
    cout<<dp[n][k];
    return 0;
}

Measured memory_bytes: 80768
#include <iostream>
#include <vector>
using namespace std;
vector <int> adj[100001];
bool visited[100001];
void dfs(int cur){
    visited[cur]=1;
    for(int i=0; i<adj[cur].size();i++){
        if(!visited[adj[cur][i]]){
            dfs(adj[cur][i]);
        }
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    int x[m],y[m],z[m];
    for(int i=0; i<m; i++){
        cin>>x[i]>>y[i]>>z[i];
        adj[x[i]].push_back(y[i]);
        adj[y[i]].push_back(x[i]);
    }
    int c=0;
    for(int i=1; i<=n; i++){
        if(!visited[i]){
            dfs(i);
            c++;
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 10112
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[55];
int t=0;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	for (int i=0;i<n;i++) if (a[i]!=i+1) t++;
	if (t==0 || t==2) cout <<"YES";
	else cout <<"NO";
	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

ll pow2(ll a, ll b) {
    if (b == 0) return 1;
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int top(int i) {
    return i / (pow2(10, log10(i)));
}

int back(int i) {
    return i % 10;
}

int main() {
    vector<vector<int>> counter(10, vector<int>(10, 0));

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        int t = top(i);
        int b = back(i);
        counter[t][b]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int t = top(i);
        int b = back(i);
        ll count = counter[b][t];
        ans += count;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <atcoder/fenwicktree>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    fenwick_tree<long long> fw(n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        fw.add(i, a);
    }

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int p, x;
            scanf("%d %d", &p, &x);
            fw.add(p, x);
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%lld\n", fw.sum(l, r));
        }
    }
}


Measured memory_bytes: 8252
N = int(input())
s = input()

# idx=0にN番目の動物、idx=N+1に1番目の動物
ansS = [""] * (N+2)
ansW = [""] * (N+2)
ansS[1] = ansS[N+1] = "S" # 1番目がSの場合
ansW[1] = ansW[N+1] = "W" # 1番目がWの場合
# N番目がSと仮定する
ansS[0] = ansS[N] = "S" 
ansW[0] = ansW[N] = "S" 
for i in range(N):
    
    if s[i] == "o": 
        ansS[i+2] = "S" if ((ansS[i+1] == "S" and ansS[i] == "S") or (ansS[i+1] == "W" and ansS[i] == "W")) else "W"
        ansW[i+2] = "S" if ((ansW[i+1] == "S" and ansW[i] == "S") or (ansW[i+1] == "W" and ansW[i] == "W")) else "W"
    else:
        ansS[i+2] = "S" if ((ansS[i+1] == "S" and ansS[i] == "W") or (ansS[i+1] == "W" and ansS[i] == "S")) else "W"
        ansW[i+2] = "S" if ((ansW[i+1] == "S" and ansW[i] == "W") or (ansW[i+1] == "W" and ansW[i] == "S")) else "W"

if ansS[0] == ansS[N] and ansS[1] == ansS[N+1]:
    print("".join(ansS[1:N+1]))
    exit()

if ansW[0] == ansW[N] and ansW[1] == ansW[N+1]:
    print("".join(ansW[1:N+1]))
    exit()


# idx=0にN番目の動物、idx=N+1に1番目の動物
ansS = [""] * (N+2)
ansW = [""] * (N+2)
ansS[1] = ansS[N+1] = "S" # 1番目がSの場合
ansW[1] = ansW[N+1] = "W" # 1番目がWの場合
# N番目がSと仮定する
ansS[0] = ansS[N] = "W" 
ansW[0] = ansW[N] = "W" 

for i in range(N):
    
    if s[i] == "o": 
        ansS[i+2] = "S" if ((ansS[i+1] == "S" and ansS[i] == "S") or (ansS[i+1] == "W" and ansS[i] == "W")) else "W"
        ansW[i+2] = "S" if ((ansW[i+1] == "S" and ansW[i] == "S") or (ansW[i+1] == "W" and ansW[i] == "W")) else "W"
    else:
        ansS[i+2] = "S" if ((ansS[i+1] == "S" and ansS[i] == "W") or (ansS[i+1] == "W" and ansS[i] == "S")) else "W"
        ansW[i+2] = "S" if ((ansW[i+1] == "S" and ansW[i] == "W") or (ansW[i+1] == "W" and ansW[i] == "S")) else "W"

if ansS[0] == ansS[N] and ansS[1] == ansS[N+1]:
    print("".join(ansS[1:N+1]))
    exit()

if ansW[0] == ansW[N] and ansW[1] == ansW[N+1]:
    print("".join(ansW[1:N+1]))
    exit()

print(-1)

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

using namespace std;

typedef long long ll;

const int nax = 405;
const ll INF = 1e18L + 5; // 10^18+5
ll dp[nax][nax];
ll prefix[nax];
ll a[nax];
// dp[i][j] - the minimum total cost of combining interval [i,j] into one vertex

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 1; i <= n; i++) {
        prefix[i] = prefix[i-1] + a[i-1];
    }

    for(int L = n - 1; L >= 0; --L) {
        for(int R = L; R < n; ++R) {
            if (L == R)
                dp[L][R] = 0;

            else {
                dp[L][R] = INF;
                ll s = prefix[R+1] - prefix[L];
                for(int i = L; i <= R - 1; ++i) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + s);
                }
            }
        }
    }

//    for (int i = 0; i < n; i++) {
//        for (int j = 0; j < n; j++) {
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }

    printf("%lld\n", dp[0][n-1]);
}


Measured memory_bytes: 1536
fn main() {
    let (a, b, n): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let mut ans = 0;
    for f in a..b + 1 {
        if n % f == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

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

// =========



Measured memory_bytes: 5024