akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        string ans="Yes";
        string s;cin>>s;
        if(s=="AAA"||s=="BBB")ans="No";
        cout<<ans<<endl;
    }   
    return 0;   
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<int> v(n);
    forn(n) {
        cin >> v[i];
        --v[i];
    }
    vector<int> tim(n, -1);
    tim[0] = 0;
    int curr = 0;
    while (tim[v[curr]] == -1) {
        tim[v[curr]] = tim[curr] + 1;
        curr = v[curr];
        k--;
        if (k == 0) {
            cout << curr + 1 << endl;
            return;
        }
    }
    int len = tim[curr] - tim[v[curr]] + 1;
    // cout << len << " " << k << endl;
    k %= len;
    while (k--) {
        curr = v[curr];
    }
    cout << curr + 1 << endl;
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <math.h>

using namespace std;

int main() {
string tx;
cin >> tx;
if (tx== "ARC"){
    cout << "ABC";
}
else{
    cout << "ARC";
}
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> A;
    ll num = 0;
    bool flag_a = true;
    rep(i, 0, S.size()) {
        if(flag_a) {
            if(S[i] == '1') num++;
            else {
                A.push_back(num);
                num = 1;
                flag_a = false;
            }
        } else {
            if(S[i] == '1') {
                A.push_back(num);
                num = 1;
                flag_a = true;
            } else {
                num++;
            }
        }
    }
    if(num > 0) A.push_back(num);
    if(A.size() % 2 == 0) A.push_back(0);

    int Add = 2 * K + 1;
    vector<int> sum(A.size() + 1);
    rep(i, 0, A.size()) sum[i + 1] = sum[i] + A[i];

    ll rsl = 0;
    for(int i = 0; i < A.size(); i += 2) {
        int left = i, right = min(i + Add, (int)A.size());
        ll tmp = sum[right] - sum[left];
        chmax(rsl, tmp);
    }

    cout << rsl << endl;
}


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

const ll inf = 1e18;
int N , W;
ll w[105] , v[105];
ll DP[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> W;
    for(int i = 1; i <= W; ++i)DP[i] = -inf;
    for(int i = 1; i <= N; ++i){
        cin >> w[i] >> v[i];
    }
    DP[0] = 0;
    for(int i = 1; i <= N; ++i){
        for(int j = W; j >= 0; --j){
            if(j - w[i] >= 0)
                DP[j] = max(DP[j] , DP[j - w[i]] + v[i]);
        }
    }
    ll ret = 0;
    for(int i = 0; i <= W; ++i)ret = max(ret , DP[i]);
    cout << ret << endl;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const long long mod = 1000000007;
// auto mod int
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    int npos = 0;
    rep(i, n) if (a[i] >= 0) ++npos;
    int nneg = n - npos;
    bool ok = false;
    if (npos > 0) {
        if (k==n) ok = (nneg%2==0);
        else ok = true;
    }
    else ok = (k%2==0);
    mint ans = 1;
    if (ok) {
        vi pos, neg;
        rep(i, n) {
            if (a[i] >= 0) pos.pb(a[i]);
            else neg.pb(a[i]);
        }
        VSORT(neg);
        if (k%2==1) {
            VSORT(pos);
            ans *= pos.back(); pos.pop_back();
            reverse(all(pos));
        }
        else RSORT(pos);
        vll x;
        for (int i=0; i+1<sz(pos); i+=2) x.pb((ll)(pos[i])*pos[i+1]);
        for (int i=0; i+1<sz(neg); i+=2) x.pb((ll)(neg[i])*neg[i+1]);
        RSORT(x);
        rep(i, k/2) ans *= x[i];
    }
    else {
        RSORT(a);
        rep(i, k) ans *= a[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{

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

    cout << (n >= 10 ? r : r + 100 * (10 - n)) << '\n';
    return 0;
}


Measured memory_bytes: 3604
N, K = map(int, input().split())
A_arr = list(map(int, input().split()))

idx = A_arr.index(1)
leftn = idx
rightn = N - idx - 1

c = []

for i in range(max(K - leftn - 1, 0), K):
    c.append(1 + ((leftn - (K-1-i)) + K-1-1) // (K-1) + ((rightn - i) + K-1-1) // (K-1))

print(min(c))

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    vector<int> E[limit];

    rep(i, n) {
        E[i].push_back(i + 1);
    }

    REP(i, 1, 10) {
        int p = (int) pow(6, i);
        if (p > n) break;

        rep(j, n) {
            if (j + p > n) break;
            E[j].push_back(j + p);
        }
    }

    REP(i, 1, 10) {
        int p = (int) pow(9, i);
        if (p > n) break;

        rep(j, n) {
            if (j + p > n) break;
            E[j].push_back(j + p);
        }
    }

    queue<int> que;
    que.push(0);
    int d[n + 1];
    d[0] = 0;
    REP(i, 1, n + 1) d[i] = INF;

    while (!que.empty()) {
        int q = que.front();
        for (auto e : E[q]) {
            if (d[e] == INF) {
                d[e] = d[q] + 1;
                que.push(e);
            } else if (d[e] > d[q] + 1) {
                d[e] = d[q] + 1;
            }
        }
        que.pop();
    }

    cout << d[n] << endl;

    return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  for(int i=0;i<26;i++){
    for(int j=0;j<16;j++){
      if(i*4+j*7==N){cout<<"Yes"<<endl; return 0;}
    }
  }
  cout<<"No"<<endl;
}

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

int main(){
    int A = 0;
    int B = 0;
    int C = 0;
    int X = 0;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(i == 0 && j == 0 && k == 0) continue;
                int sum = 50 * k + 100 * j + 500 * i;
                if(sum == X) ans ++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
 
int gcd( int x, int y )
{
    int t;
    while( 0 < y ) {
        t = y;
        y = x % y;
        x = t;
    }
     
    return x;
}
 
int main( )
{   
    int x, y;
      
    scanf( "%d%d", &x, &y );
      
    int t;
    if( y < x ) {
        t = x;
        x = y;
        y = t;
    }
      
    printf( "%d\n", gcd( x, y ) );
     
    return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
int n,y;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>y;
	for(int i=0;i<=n&&10000*i<=y;i++)
		for(int j=0;i+j<=n&&10000*i+5000*j<=y;j++)
				if((y-10000*i-5000*j)%1000==0&&(y-10000*i-5000*j)/1000==n-i-j)
				{
					cout<<i<<" "<<j<<" "<<(y-10000*i-5000*j)/1000<<endl;
					return 0;
				}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

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

#define ll long long

ll dp[105][100005];
int weight[105];
ll price[105];
int n, w;

void initialize()
{
    for(int i=0;i<=100;i++)
    {
        for(int j=0;j<=100000;j++)
            dp[i][j] = -1;
    }
}

ll knapsack(int i, int j)
{
    if(i<=0 || j<=0) return 0;

    //if(j==weight[1]) return price[1];

    if(dp[i][j]!=-1) return dp[i][j];

    ll ret = knapsack(i-1, j);

    if(weight[i]<=j)
        ret = max(ret, knapsack(i-1, j-weight[i])+price[i]);

    dp[i][j] = ret;

    return ret;
}

int main()
{
    initialize();


    cin>>n>>w;
    for(int i=1;i<=n;i++)
        cin>>weight[i]>>price[i];


    ll retVal = knapsack(n, w);
    cout<<retVal<<endl;


    return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, h;
int a[100000], b[100000];

int main(){
    cin >> n >> h;
    rep(i,n) {
        cin >> a[i] >> b[i];
    }
    sort(a, a+n, greater<int>());
    sort(b, b+n, greater<int>());
    int ans = 0;
    rep(i,n) {
        if (b[i] <= a[0]) {
            break;
        }
        h -= b[i];
        ans++;
        if (h <= 0) {
            break;
        }
    }
    if (h > 0) {
        ans += (h+a[0]-1)/a[0];
    }
    cout << ans << endl;
}
































Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int D=sc.nextInt();
		int[][] za=new int[N][M];
		for(int i=0; i<N; i++) {
			String s=sc.next();
			for(int j=0; j<M; j++) {
				if(s.charAt(j)=='.') {
					za[i][j]=0;
				}
				else{
					za[i][j]=1;
				}
			}
		}
		int ok=0;
		for(int i=0; i<N; i++) {
			for(int j=0; j<M-D+1; j++) {
				for(int k=j; k<D+j; k++) {
					if(za[i][k]==1) {
						break;
					}
					else if(za[i][k]==0 && k==D+j-1) {
						ok++;
					}
				}
			}
		}
		for(int i=0; i<N-D+1; i++) {
			for(int j=0; j<M; j++) {
				for(int k=i; k<D+i; k++) {
					if(za[k][j]==1) {
						break;
					}
					else if(za[k][j]==0 && k==D+i-1) {
						ok++;
					}
				}
			}
		}
		pl(ok);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    unordered_map<string, int> mp;
    cin >> n;
    long long res = 0;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        res += mp[s];
        mp[s]++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <iomanip>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


    double n,m;
    cin >> n >> m;

    vector<vector<int>> to(n, vector<int>(0));


    int a,b;
    rep(i,m){
        cin >> a >> b;
        //cout<< "a "<<a<<"b "<<b << endl;
        --a;--b;

        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    vector<int> miti(n,-1);
    miti[0] = 0;

    //cout << "test" << endl;

    while(!que.empty()){
        int now = que.front();que.pop();

        //cout << "now= " << now << endl;

        for(auto c:to[now]){
           // cout << "NAME= " << c << endl;
            if(miti[c] == -1){
                miti[c] = now;
                que.push(c);
              //  cout<<"q= " << c << endl;
            }
        }
    }

    miti.erase(miti.begin());

    cout << "Yes" << endl;
    for(auto a :miti){
        cout << a+1 << endl;
    }


    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define pb push_back
#define PI acos(-1)
#define mp make_pair
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define F first
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y)
#define maxn 100010
#define S second
#define ll long long int
#define inf 1000002014
#define infl 1000000000000020000ll
#define mod 1000000007
#define clrs(x) memset(x,0,sizeof x)
#define sz(x) (int) x.size()
#define pi pair< int,int >
#define pii pair<pi,int>
#define pu push
#define ld long double
#define trace1(x)  cerr << #x << ": " << x << endl
#define trace2(x, y)  cerr << #x << ": " << x << " | " << #y << ": " << y << endl
using namespace std;
int arr[maxn];
vector< int >v[maxn];
int dp[maxn];
void dfs(int s,int p)
{
    int leaf = 1;
    for(int i=0;i<sz(v[s]);i++)
    {
        if(v[s][i]!=p)
        {
            leaf = 0;
            dfs(v[s][i],s);
        }
    }
    if(!leaf)
    {
        vector< int > sor;
        for(int i=0;i<sz(v[s]);i++)
        {
            if(v[s][i]!=p)
            {
                sor.pb(-dp[v[s][i]]);
            }
        }
        sort(sor.begin(), sor.end());
        int ma = 0;
        for(int i=0;i<sz(sor);i++)
        {
            ma = max(ma,i+1+(sor[i]*-1));
        }
        dp[s] = ma;
    }
}
int main(int argc, char const *argv[])
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    sd(n);
    for (int i = 2; i <= n; ++i)
    {
        sd(arr[i]);
        v[i].pb(arr[i]);
        v[arr[i]].pb(i);
    }
    dfs(1,0);
    printf("%d\n",dp[1]);
    return 0;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
 
int main() { 
  int N, l, InN, num;
  string StN, NN;
  cin >> N;
  StN = to_string(N); 
  l = StN.size(); 
  
  vector<string> VcN(l);
  for(int i = 0;i < l;i++){
  VcN.at(i) = StN.at(i);
  }
  
  num = 0;
  for(int i = 0;i < l;i++){
  NN = VcN.at(i);
  InN = atoi(NN.c_str());
  num = num + InN;
  }
  
  if(N % num == 0){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string S;
  cin>>S;
  int M=S.size();
  int count=0;
  for(int i;i<(M+1)/2;i++){
    if(S.at(i)!=S.at(M-i-1)){
      count++;
    }
    continue;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    int n;
    string s;
    cin>>n>>s;
    vector<bool>vec1(10,false);
    vector<bool>vec2(100,false);
    vector<bool>vec3(1000,false);
    for(int i=0;i<n;i++){
        if(vec1.at((int)s.at(i)-'0')==true){
            continue;
        }
        else{
            vec1.at((int)s.at(i)-'0')=true;
        }
        for(int j=i+1;j<n;j++){
            if(vec2.at(((int)s.at(i)-'0')*10 + ((int)s.at(j)-'0')) == true){
                continue;
            }
            else{
                vec2.at(((int)s.at(i)-'0')*10 + ((int)s.at(j)-'0')) = true;
            }
            for(int k=j+1;k<n;k++){
                if(vec3.at(((int)s.at(i)-'0')*100 + ((int)s.at(j)-'0')*10 + ((int)s.at(k)-'0')) == true){
                    continue;
                }
                else{
                    vec3.at(((int)s.at(i)-'0')*100 + ((int)s.at(j)-'0')*10 + ((int)s.at(k)-'0')) = true;
                }

            }
        }
    }
    int ans=0;
    for(int i=0;i<1000;i++){
        if(vec3.at(i))ans++;
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, a[2010];

// i番目以降の要素を使って、mを作れればtrue、作れなければfalse
bool solve(int i, int m) {
  //cout << i << "," << m << endl;
  if (m == 0) {
    return true;
  }
  if (i >= n) {
    return false;
  }
  bool res = solve(i+1, m) || solve(i+1, m-a[i]);
  return res;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int m ;
    cin >> m;
    //cout << m << "----" <<endl;
    if (solve(0, m)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>

int main(){
    int a, b;
    char c[2];
    scanf("%d %d", &a, &b);
    if (a > b) {
        strcpy(c, ">");
    } else if (a < b) {
        strcpy(c, "<");
    } else {
        strcpy(c, "==");
    }
    printf("a %s b\n", c);
    return 0;
}



Measured memory_bytes: 2052
n = int(input())
L = list(map(int,input().split()))
L.sort()

from itertools import accumulate
li = list(accumulate(L))

cnt = 0
flag = False
for i in range(n-1):
    if li[i]*2 >= L[i+1]:
        flag =True
        cnt +=1
    else:
        flag =False
        cnt = 0
print(cnt+1)


Measured memory_bytes: 14308
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const double INF3 = 900000000000000;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()


int main() {
	ll n, a[200010], b[200010], a2[200010], b2[200010], ans = 0;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	for (int i = 0;i < n;i++)cin >> b[i];
	for (int k = 0;k < 29;k++) {
		ll c = 1 << k, sum = 0;
		for (int i = 0;i < n;i++) {
			a2[i] = a[i] % (c * 2);
			b2[i] = b[i] % (c * 2);
		}
		sort(b2, b2 + n);
		for (int i = 0;i < n;i++) {
			sum += lower_bound(b2, b2 + n, 2 * c - a2[i]) - lower_bound(b2, b2 + n, c - a2[i]);
			sum += lower_bound(b2, b2 + n, 4 * c - a2[i]) - lower_bound(b2, b2 + n, 3 * c - a2[i]);
		}
		if (sum % 2 == 1)ans += c;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int sx,sy,tx,ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx;
	int dy = ty - sy;

	rep(i, dy)cout << 'U';
	rep(i, dx)cout << 'R';

	rep(i, dy)cout << 'D';
	rep(i, dx)cout << 'L';

	cout << 'L';
	rep(i, dy+1)cout << 'U';
	rep(i, dx+1)cout << 'R';
	cout << 'D';

	cout << 'R';
	rep(i, dy + 1)cout << 'D';
	rep(i, dx + 1)cout << 'L';
	cout << 'U';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

ll 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()
{
    
   int a,b,c,d,e,ans=0,N; cin>>N;
   d=sqrt(N);
   rpt(a,1,d+1){
      e=N/a;
      rpt(b,a,e+1){
         if(N-a*b>0){
           ++ans;
           if(a!=b){++ans;}
         }
      }
   }

   cout<<ans<<endl;

}

Measured memory_bytes: 3716
#include <stdio.h>

int cost[101][101];

int main(void){
	int n,k,a,b,c,i,j,z;
	const int def = 1000000000;
	for(;scanf("%d%d",&n,&k),n|k;){
		for(i=1;i<=n;i++)for(j=1;j<=n;j++)cost[i][j]=def;
		z=0;
		for(;k--;){
			scanf("%d",&a);
			if(a){
				scanf("%d%d%d",&a,&b,&c);
				if(cost[a][b]>c){
					cost[a][b] = cost[b][a] = c;
					z = 1;
				}
			}else{
				if(z)
					for(a=1;a<=n;a++)
						for(i=1;i<n;i++)
							for(j=i+1;j<=n;j++){
								c=cost[i][a]+cost[a][j];
								if(cost[i][j]>c)
									cost[i][j] = cost[j][i] = c;
							}
				scanf("%d%d",&a,&b);
				printf("%d\n",cost[a][b]<def?cost[a][b]:-1);
				z = 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	ll a=1,b=1;
	rep(i,n){
		ll x,y;
		cin >> x >> y;
		ll A,B;
		if(a%x==0) A=a/x;
		else A=a/x+1;
		if(b%y==0) B=b/y;
		else B=b/y+1;
		ll m=max(A,B);
		a=m*x;
		b=m*y;
	}
	cout << a+b << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		//k = k * 2;
		for(int i = x - k + 1; i < x + k; i++) {
			System.out.print(i + " ");
		}
		System.out.println();
	
	}

}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){
  int x,y,temp,result;

  scanf("%d%d",&x,&y);

  if(x<y){//x=gig,y=small
    temp=x;
    x=y; 
    y=temp;
  }
  
  result=x%y;

  //printf("result %d\n",result);
  
  while(result!=0){
    x=y; //x=small
    y=result;
    result=x%y;
  }

  printf("%d\n",y);

  return 0;
}



Measured memory_bytes: 2140
import sys
input = sys.stdin.readline

N = int(input())
A = [0] * N
B = [0] * N

for i in range(N):
    A[i], B[i] = map(int, input().split())

ans = 0

for i in reversed(range(N)):
    t = (ans + A[i]) % B[i]
    if t != 0:
        ans += B[i] - t

print(ans)

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

using namespace std;

const int MAXN = 2018;

bool A[MAXN+1][MAXN+1];
bool visited[MAXN+1][MAXN+1];
int ri[MAXN+1][MAXN+1];
int le[MAXN+1][MAXN+1];
int up[MAXN+1][MAXN+1];
int down[MAXN+1][MAXN+1];
int root[MAXN+1][MAXN+1];
int n,m,q;


bool chk(int x,int y){if(x<=0||y<=0||x>n||y>m)return false; return true;}

void dfs(int c,int d)
{
    visited[c][d] = true;

    if(chk(c+1,d)&&A[c+1][d]&&!visited[c+1][d]){
        dfs(c+1,d);
        up[c+1][d] = 1;
    }
    if(chk(c-1,d)&&A[c-1][d]&&!visited[c-1][d]){
        dfs(c-1,d);
        down[c-1][d] = 1;
    }
    if(chk(c,d-1)&&A[c][d-1]&&!visited[c][d-1]){
        dfs(c,d-1);
        ri[c][d-1] = 1;
    }
    if(chk(c,d+1)&&A[c][d+1]&&!visited[c][d+1]){
        dfs(c,d+1);
        le[c][d+1] = 1;
    }


    return;
}

int main()
{

	scanf("%d%d%d",&n,&m,&q);


	for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){

            scanf("%1d",&A[i][j]);
        }



    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            if(A[i][j]&&!visited[i][j]){

                    root[i][j] = true; dfs(i,j);

            }
            else continue;
        }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            root[i][j] +=root[i-1][j]+root[i][j-1]-root[i-1][j-1];



    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            ri[i][j] += ri[i-1][j];
            le[i][j] += le[i-1][j];
            down[i][j] += down[i][j-1];
            up[i][j] += up[i][j-1];
        }

    for(int i=1;i<=q;i++)
    {
        int x1,x2,y1,y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

        int sum = 0;

        sum +=(root[x2][y2]+root[x1-1][y1-1]-root[x2][y1-1]-root[x1-1][y2]);


        sum+=le[x2][y1]-le[x1-1][y1];
        sum+=ri[x2][y2]-ri[x1-1][y2];
        sum+=up[x1][y2]-up[x1][y1-1];
        sum+=down[x2][y2]-down[x2][y1-1];
        printf("%d\n",sum);

    }


	return 0;
}


Measured memory_bytes: 90112
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    double a,b;
    cin >> a >> b;
    cout << a/b;
    return 0;
}


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

int main(){
  int n;
  while(cin>>n,n){
    int a[20],sum=0;
    for(int i=0;i<n;i++)cin>>a[i],sum+=a[i];
    
    S mp[21];
    S::iterator it;
    mp[0].insert(0);
    for(int i=0;i<n;i++)
      for(it=mp[i].begin();it!=mp[i].end();it++)mp[i+1].insert((*it)+a[i]),mp[i+1].insert(*it);

    int ans=1e9;
    for(it=mp[n].begin();it!=mp[n].end();it++)ans=min(ans,abs(sum-2*(*it)));
    cout <<ans<<endl;
  }
  return 0;
}

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

string S;
ll N, L[200000], R[200000];
vector<ll> E[200000];
vector<ll> d;
bool visited[200000];

ll dfs(ll v) {
  if(visited[v]) return 0;
  visited[v] = true;

  ll ret = d[v];
  for(ll u : E[v]) ret += dfs(u);
  return ret;
}

int main(void) {
  cin >> S >> N;
  REP(i, 0, N) cin >> L[i] >> R[i], L[i]--, R[i];

  S = "a" + S + "a";
  REP(i, 0, S.length() - 1) d.push_back((S[i + 1] - S[i] + 26) % 26);

  REP(i, 0, N) {
    E[L[i]].push_back(R[i]);
    E[R[i]].push_back(L[i]);
  }
  REP(i, 0, (d.size()) / 2) {
    E[i].push_back(d.size() - 1 - i);
    E[d.size() - 1 - i].push_back(i);
  }

  bool ans = true;
  REP(i, 0, d.size()) visited[i] = false;
  REP(i, 0, d.size()) {
    ll sum = dfs(i) % 26;
    if(sum != 0) ans = false;
  }
  cout << (ans ? "YES" : "NO") << endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const double PI = acos(-1);

int main(){
	
	double a,b,c;
	cin >>a >>b >>c;
	
	double s = a* b * sin(c*PI/180) /2;
	double z = sqrt(a*a + b*b -2*a*b*cos(c*PI/180));
	printf("%.10f\n%.10f\n%.10f\n", s, z+a+b, s/a*2);
	return 0;
}



Measured memory_bytes: 3432
# AGC 025 A - Digits Sum
N = int(input())

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
if N <= 10:
    print(str(N))
if N > 10:
    for i in range(2,N-1):
        A = i
        B = N - i
        list_a.append(sum_of(A) + sum_of(B))
    print(min(list_a))

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

using namespace std;

typedef long long ll;
typedef long double ld;

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

  string s;
  cin >> s;
  int n = (int) s.size();
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll num = 0;
    for (int j = i; j < n; j++) {
      num = 10 * num + s[j] - '0';
      int fix = j - i + (i != 0) + (j != (n - 1));
      ans += num * (1LL << (n - 1 - fix));
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 2e5+5, M=2e4+5, oo=0x3f3f3f3f;

ll n, t;
pair<ll, ll> p[N];

int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> p[i].second >> p[i].first;
    sort(p, p+n);
    for(int i=0; i<n; i++)
    {
        if(t + p[i].second > p[i].first)
            return cout << "No", 0;
        t+=p[i].second;
    }
    cout << "Yes";
    return 0 ;
}


Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
        int H = 0;
        int M = 0;
        int sum = 0;
 
      if(m1<m2){
        H = h2 - h1;
        M = m2 - m1;
      }else{
        H = h2 - h1 - 1;
        M = m2+60 - m1;
     }
      sum = M + 60*H;
      if((sum - k)>0){
        System.out.println(sum-k);
      }else{
        System.out.println(0);
      }
    }
}

Measured memory_bytes: 35520
#include <bits/stdc++.h>
#define dbg(nazwa) cerr<<#nazwa ": " << (nazwa) << "\t"
#define nl cerr << endl
using namespace std;
using ll = long long;
const int N = 1e5 + 3;
int t[103];
bool dp[N];

// dp[i] = 1 jesli pozycja i jest wygrywajaca

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> t[i];
	}
	
	for(int stone = 0; stone <= k; stone++) {
		for(int i = 1; i <= n; i++) {
			if(stone >= t[i] and !dp[stone-t[i]])
				dp[stone] = 1;
		}
	}
	//for(int i = 1; i <= k; i++) cout << dp[i] << " ";
	cout << (dp[k] ? "First" : "Second");
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
int n,i,j;
  cin >> n;
  for(i=1;i<=9;i++){
  	for(j=1;j<=9;j++){
 		if(i*j==n){
        cout << "Yes" << endl;
          return 0;
        }
  	}
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

using namespace std;
const int INF = INT_MAX;

struct edge
{
	edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
	int to, cap, rev;
};

int V, E;
vector<vector<edge>> G;
vector<int> level;
vector<int> iter;

void add_edge(int from, int to, int cap)
{
	G[from].emplace_back(to, cap, (int)G[to].size());
	G[to].emplace_back(from, 0, (int)G[from].size() - 1);
}

void bfs(int s)
{
	level.assign(V, -1);

	queue<int> que;
	level[s] = 0;
	que.push(s);

	while (!que.empty())
	{
		int v = que.front();
		que.pop();

		for (int i = 0; i < G[v].size(); i++)
		{
			edge &e = G[v][i];
			if (e.cap > 0 and level[e.to] < 0)
			{
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int g, int f)
{
	if (v == g)
		return f;

	for (int &i = iter[v]; i < G[v].size(); i++)
	{
		edge &e = G[v][i];

		if (e.cap > 0 and level[v] < level[e.to])
		{
			int d = dfs(e.to, g, min(f, e.cap));

			if (d > 0)
			{
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int g)
{
	int flow = 0;

	while (true)
	{
		bfs(s);

		if (level[g] < 0)
			return flow;

		iter.assign(V, 0);
		int f;

		while ((f = dfs(s, g, INF)) > 0)
		{
			flow += f;
		}
	}
}

int main()
{
	cin >> V >> E;

	G.resize(V);

	for (int i = 0; i < E; i++)
	{
		int u, v, c;
		cin >> u >> v >> c;
		add_edge(u, v, c);
	}

	cout << max_flow(0, V - 1) << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main(){
    int n, t; cin >> n >> t;
    vector<pair<int,int>> c(n);
    rep(i,n) cin >> c[i].first >> c[i].second;
    int cost_min = INFINITY;
    rep(i,n){
        if(c[i].second <= t)cost_min = min(cost_min, c[i].first);
    }
    if(cost_min > 10000)cout << "TLE" << endl;
    else cout << cost_min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  bool ok = true;
  for (int i = 0; i < N; i++)
  {
    if (A[i] % 2 == 0)
    {
      if (!(A[i] % 3 == 0 or A[i] % 5 == 0))
        ok = false;
    }
  }
  if (ok)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}


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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	int pow2n = 1 << n; 
	multiset<int> ms;
	rep(i, pow2n) {
		int x;
		cin >> x;

		ms.insert(x);
	}

	vector<int> v;
	auto itr = ms.end();
	itr--;
	v.push_back(*itr);

	rep(i, n){
		vector<int> w = v;
		for(int x : w){
			auto itr = ms.lower_bound(x);
			if(itr == ms.begin()){
				puts("No");
				return 0;
			}
			itr--;

			v.push_back(*itr);
			ms.erase(itr);
		}
	}

	puts("Yes");
}


Measured memory_bytes: 14324
s=input()
c=[]
f=[]
for num in range(len(s)):
    if s[num] == 'C':
        c.append(num)
    if s[num] == 'F':
        f.append(num)
        
if 'C' in s and 'F' in s:
	print('Yes') if min(c) < max(f) else print('No')
else:
  print('No')

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

ll power(ll a, ll b){
  return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}

ll comb(ll n, ll k){
  ll x = 1, y = 1;
  for(ll i = 1; i <= k; i++){
    x = x * (n-i+1) % mod;
    y = y *  i % mod;
  }
  return x*power(y, mod-2)%mod;
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = power(2, n);
  ans -= 1;
  ans -= comb(n, a);
  ans -= comb(n, b);
  cout << (ans%mod+mod)%mod << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstring>
using namespace std;
map<char,int>h;
int main()
{
	int n,ans=0,t;
    string s;
    cin>>n>>s;
    for(int i=0; i<s.length(); i++)
    {  t=0;
      for(int j=0; j<=i; j++)
       if(h[s[j]]==0) h[s[j]]++;
       for(int j=i+1; j<s.length(); j++)
       if(h[s[j]]==1) { t++; h[s[j]]=0;}
       ans=max(t,ans);
     }
    cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    // num of luggage
    static int n;
    // num of truck
    static int k;
    // luggage
    static int[] w;

    static int countLuggage(int p) {
        int cnt = 0;
        for (int j = 0; j < k; j++) {
            int sum = 0;
            while (sum + w[cnt] <= p) {
                sum += w[cnt];
                cnt++;
                if (cnt == n) return n;
            }
        }
        return cnt;
    }

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            String[] line = in.readLine().split(" ");
            n = Integer.parseInt(line[0]);
            k = Integer.parseInt(line[1]);
            w = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = Integer.parseInt(in.readLine());
            }

            int left = 0;
            int right = 100000 * 10000;
            int mid = 0;
            while (left < right) {
                mid = (left + right) / 2;
                int nLuggage = countLuggage(mid);
                if (nLuggage >= n) right = mid;
                else left = mid + 1;
            }

            System.out.println(right);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N;

int main(){
    cin >> N;
    FOR(i,1,N+1)
    {
        int a;
        cin >> a;
        if(a%2==0 && (a%3!=0 && a%5!=0))
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define max(a, b) (((a)<(b))?b:a)
#define min(a, b) ((a>b)?b:a)
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pi 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define maxn 500002
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
int f[maxn];
vi fre;
vii ans;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif
    int n;
    cin>>n;
    int maxx= 0;
    int id ;
    rep (i,0,n) {
        cin>>f[i];
        if (abs(maxx)<abs(f[i])){
            maxx=f[i];
            id = i;

        }

    }

    if (maxx>=0) {
        rep (i,0,n) {
            if (f[i]<0)
                ans.push_back(mp(id+1,i+1));
        }

        rep (i,0,n-1) {
            ans.push_back(mp(i+1,i+2));
        }

    }
    if (maxx<=0) {
        rep (i,0,n) {
            if (f[i]>0)
                ans.push_back(mp(id+1,i+1));
        }

        for (int i=n-1;i>0;i--) {
            ans.push_back(mp(i+1,i));
        }

    }


    cout<<ans.size()<<endl;
    rep (i,0,ans.size())
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    return 0;
}








Measured memory_bytes: 256
def levenshteinDistance(s1: str, s2: str):
    n = len(s1)
    m = len(s2)
    dp = [[0] * (n + 1) for i in range(m + 1)]

    for i in range(n + 1):
        dp[0][i] = i

    for i in range(m + 1):
        dp[i][0] = i

    for i in range(1, m + 1):
        for j in range(1, n + 1):
            substitution_cost = 0
            if s1[j-1] != s2[i-1]:
                substitution_cost = 1
            deletion_cost = dp[i-1][j] + 1
            insertion_cost = dp[i][j-1] + 1
            substitution_cost = dp[i-1][j-1] + substitution_cost
            cost = min(deletion_cost, min(insertion_cost, substitution_cost))
            dp[i][j] = cost
    return dp[m][n]

	
s1 = input()
s2 = input()
print(levenshteinDistance(s1, s2))



Measured memory_bytes: 43076
n = gets.to_i
a = n.times.map { gets.to_i }
score = 0
more = a.sort.reverse
less = a.sort
ans = []
i = 0
op_more = 0 # 0のとき左から
op_less = 0 # 0のとき左から
cnt = (n % 2 == 0 ? n : n - 1)
while i < cnt
  if i % 2 == 0
    if op_less == 0
      ans.unshift(less.shift)
    else
      ans.push(less.shift)
    end
    op_less = 1 - op_less
  else
    if op_more == 1
      ans.unshift(more.shift)
    else
      ans.push(more.shift)
    end
    op_more = 1 - op_more
  end
  i += 1
end
if n % 2 == 0
  p ans.each_cons(2).map { |(x, y)| (x - y).abs }.inject(:+)
else
  cands = [ans.dup, ans.dup]
  cands[0].push(more[0])
  cands[1].unshift(more[0])
  p cands.map { |cand| cand.each_cons(2).map { |(x, y)| (x - y).abs }.inject(:+) }.max
end


Measured memory_bytes: 9624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

ll ans = 0;

int main() {
  string s;
  cin >> s;
  vector<ll> v(s.size());
  for (int i = 0; i < s.size(); ++i) {
    v[i] = s[i] - '0';
  }

  auto n = s.size();
  for (int bit = 0; bit < (1 << n-1); ++bit) {
    vector<int> p;
    for (int i = 0; i < n; ++i) {
      if ((bit >> i) & 1) p.push_back(i);
    }
    p.push_back(10000);

    vector<string> str;
    string tmp = "";
    int k = 0;
    // reverse(p.begin(), p.end());
    for (int i = 0; i < n; ++i) {
      tmp += s[i];
      if (p[k] == i){
        str.push_back(tmp);
        tmp.clear();
        k++;
      }
    }
    if (!tmp.empty())
      str.push_back(tmp);
    for (auto it : str) {
      ans += stoll(it);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256