akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		String s[]=new String[N];
		char ans[]=new char[N];
		for(int i=0;i<N;i++){
			s[i]=stdIn.next();
		}
		for(int i=0;i<N;i++){
			if(s[i].equals("AB")){
				if(A>B){
					A--;B++;ans[i]='B';
				}
				else
				if(B>A){
					B--;A++;ans[i]='A';
				}
				else
				if(A==B){
					if(A==1&&C==0&&i!=N-1&&s[i+1].equals("BC")){
						A--;B++;ans[i]='B';
					}
					else{
						B--;A++;ans[i]='A';
					}
				}
			}
			if(s[i].equals("AC")){
				if(A>C){
					A--;C++;ans[i]='C';
				}
				else
				if(C>A){
					C--;A++;ans[i]='A';
				}
				else
				if(A==C){
					if(A==1&&B==0&&i!=N-1&&s[i+1].equals("BC")){
						A--;C++;ans[i]='C';
					}
					else{
						C--;A++;ans[i]='A';
					}
				}
			}
			if(s[i].equals("BC")){
				if(C>B){
					C--;B++;ans[i]='B';
				}
				else
				if(B>C){
					B--;C++;ans[i]='C';
				}
				else
				if(C==B){
					if(C==1&&A==0&&i!=N-1&&s[i+1].equals("AB")){
						C--;B++;ans[i]='B';
					}
					else{
						B--;C++;ans[i]='C';
					}
				}
			}
			if(A<0||B<0||C<0){
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
		for(int i=0;i<N;i++){
			System.out.println(ans[i]);
		}
	}
}


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

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
  if(N%2 == 1) {
		cout << "No" << endl;
	} else {
		bool ans = true;
        rep(i, N/2){
					if(S[i] != S[i+(N/2)]) ans = false;
				}
				if(ans){
					cout << "Yes" << endl;
				} else {
					cout << "No" << endl;
				}
    }
}

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

int main() {	

	ll n; cin >> n;
	map<string,ll> mp;
	for (ll i = 0; i < n; i++) {
		string tmp; cin >> tmp;
		sort(tmp.begin(), tmp.end());
		mp[tmp]++;
	}
	ll ans = 0;
	for (auto u : mp) {
		ans += u.second * (u.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
// ~maqsat~
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n";
#define TEZ ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout);

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> inline void cmin(T &a, U b) { a = min(a, b); }
template <class T, class U> inline void cmax(T &a, U b) { a = max(a, b); }
template <class T, class U, class X, class Y> inline void psmn(T &a, U b, X &p, Y i) { if(b < a)a = b,p = i; }
template <class T, class U, class X, class Y> inline void psmx(T &a, U b, X &p, Y i) { if(b > a)a = b,p = i; }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846

int main() {
	fre(""); TEZ;

	int n;
	cin >> n;
	int a[N], ans[N];
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		ans[a[i]] = i;
	}
	for(int i = 1; i <= n; i++) {
		cout << ans[i] << ' ';
	}

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n],b[n];
  for(int i=0;i<n;i++) cin >> a[i];
  bool ans=true;
  for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]) ans=false;
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=0;k<n;k++){
        b[k]=a[k];
      }
      b[i]=a[j]; b[j]=a[i];
      bool check=true;
      for(int k=0;k<n-1;k++){
        if(b[k]>=b[k+1]) check=false;
      }
      if(check) ans=true;
    }
  }
  cout << (ans?"YES":"NO") << endl;      
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;

int main(){
	string s;
	cin >> s;
	for(int i=0;i<3;i++){
		for(int j=i;j<3;j++){
			if(s[i]>s[j])
				swap(s[i],s[j]);
		}
	}
	if(s == "abc")
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define all(v) v.begin(), v.end()

const int mod = 1e9 + 7;

vector<int> getZarr(string a)
{
	int n = a.size();
	vector<int> z;
	z.resize(a.size());
	
	int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && a[R-L] == a[R]) R++;
            z[i] = R-L; R--;
        } else {
            int k = i-L;
            if (z[k] < R-i+1) z[i] = z[k];
            else {
                L = i;
                while (R < n && a[R-L] == a[R]) R++;
                z[i] = R-L; R--;
            }
        }
    }
	
	return z;
}

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

	int n;
	cin >> n;

	string s;
	string t;

	cin >> s;
	cin >> t;

	t += s;

	vector<int> z = getZarr(t);

	for (int i = n; i < t.size(); i++) {
		if(z[i] == 2 * n - i) {
			cout << 2 * n - z[i] << endl;
			return 0;
		}
	}
	cout << 2 * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
/*struct node {
    int s, e, m, v;
    node *l, *r;
    node(int _s, int _e) {
        s = _s; e = _e; m = (s+e)/2;
        v = 0;
        if (s != e) {
            l = new node(s, m);
            r = new node(m+1, e);
        }
    }
    void up(int x, int nv) {
        if (s == e){
            v = nv; return;
        }
        if (x <= m) l->up(x,nv);
        else r->up(x,nv);

    }
    int rmq1(int x, int y, int v) { //from right,
        if (s==x && e==y) {
            return v;
        }
        if (x>m) return r->rmq(x, y);
        if (y<=m) return l->rmq(x, y);
        return min(l->rmq(x, m), r->rmq(m+1, y));
    }
} *root;
*/
main(){
    int n;
    scanf("%lld",&n);
    int a[n+2];
    int p[n+2]; p[0] = 0, p[n+1] = n+1;
    for (int i =1 ; i <= n; i++) {
        scanf("%lld",&a[i]);
        p[a[i]] = i;
    }
    int l[n+2]; l[0] = 0;
    int r[n+2]; r[n+1] = n+1;
    int ll[n+2], rr[n+2];
    memset(ll,-1,sizeof(ll));
    memset(rr,-1,sizeof(rr));
    ll[0] = 0, rr[n+1] = n+1;
    set<int> s; //stores pos;
    s.insert(0);
    for (int i = n; i >= 1; i--){
        //printf("%lld ",i);
        set<int>::iterator k = s.lower_bound(p[i]);
        if (k != s.begin()){
            k = prev(k);
            l[p[i]] = *(k);
        }
        else l[p[i]] = 0;
        if (k != s.begin()){
            k = prev(k);
            ll[p[i]] = *(k);
        }
        else ll[p[i]] = 0;
        s.insert(p[i]);
        //printf("%lld %lld %lld\n",p[i],l[p[i]],ll[p[i]]);
    }
    s.clear();
    s.insert(n+1);
    for (int i = n; i >= 1; i--){
        //printf("%lld ",i);
        set<int>::iterator k = s.lower_bound(p[i]);
        if (k != s.end()){
            r[p[i]] = *(k);
        }
        else r[p[i]] = n+1;
        if (next(k) != s.end()){
            k = next(k);
            rr[p[i]] = *(k);
        }
        else rr[p[i]] = n+1;
        s.insert(p[i]);
        //printf("%lld %lld %lld\n",p[i],r[p[i]],rr[p[i]]);
    }
    s.clear();
    int ans = 0;
    for (int i = 1; i <= n; i++){
        //printf("%lld %lld %lld -> ",l[i],i,r[i]);
        //printf("%lld %lld\n",ll[l[i]],rr[r[i]]);
        int l1, l2 = i-l[i],r1 = r[i]-i,r2;
        l1 = l[i]-ll[i];
        r2 = rr[i]-r[i];
        //printf("%lld %lld %lld %lld\n",l1,l2,r1,r2);
        //printf("%lld * %lld\n",a[i],(l1*r1 + l2*r2));
        ans += a[i]*(l1*r1 + l2*r2);
    }
    printf("%lld",ans);
}


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

int main(){
    int count=0;
    int A[100],n;
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> A[i];
    }
    int flag = 1;
    while (flag){
     flag = 0;
     for (int j=n-1;j>=1;j--){
        if (A[j] < A[j-1]){
         swap(A[j],A[j-1]);
         count++;
         flag = 1;
        }
        }
    }
    for (int i=0;i<n;i++){
        if (i!=0){cout << " ";};
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll const MAX_N = 1000;

int main() {
    INIT;

    ll N;
    cin >> N;

    ll res = N;

    rep(i, N + 1) {
        ll cc = 0;

        ll t = i;
        while (t > 0) {
            cc += t % 6;
            t /= 6;
        }

        t = N - i;
        while (t > 0) {
            cc += t % 9;
            t /= 9;
        }

        chmin(res, cc);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3564
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=2e5+10;
typedef long long ll;
struct node{ll x,y;};
vector<node> dp[N];
int n,f,v,ch[N][2],w[N][2],t;ll mlen;
void dfs(int u){
    int ls=ch[u][0],rs=ch[u][1],lt=w[u][0],rt=w[u][1];
    if(!ls){dp[u].push_back(node{0,0});return;}
    dfs(ls);
    dfs(rs);
    int j=0;vector<node> L(0),R(0);
    rep(i,0,(int)dp[ls].size()-1){
        for(;j+1<dp[rs].size()&&dp[ls][i].y+dp[rs][j+1].x+lt+rt<=mlen;++j);
        if(j<dp[rs].size()&&dp[ls][i].y+dp[rs][j].x+lt+rt<=mlen) L.push_back(node{dp[ls][i].x+lt,dp[rs][j].y+rt});
    }
    j=0;
    rep(i,0,(int)dp[rs].size()-1){
        for(;j+1<dp[ls].size()&&dp[rs][i].y+dp[ls][j+1].x+lt+rt<=mlen;++j);
        if(j<dp[ls].size()&&dp[rs][i].y+dp[ls][j].x+lt+rt<=mlen) R.push_back(node{dp[rs][i].x+rt,dp[ls][j].y+lt});
    }
    int i=0;j=0;ll lst=1e18;
    while(i<L.size()||j<R.size())
        if(i<L.size()&&(j==R.size()||L[i].x<=R[j].x)){
            if(L[i].y<lst) lst=L[i].y,dp[u].push_back(L[i]);
            ++i;
        }
        else{
            if(R[j].y<lst) lst=R[j].y,dp[u].push_back(R[j]);
            ++j;
        }
    return;
}
bool check(ll x){
    rep(i,0,n) dp[i].clear();
    dfs(1);//cerr<<dp[1].size()<<endl;
    return dp[1].size()!=0;
}
int main(){
    scanf("%d",&n);
    rep(i,2,n) scanf("%d%d",&f,&v),ch[f][t=!!ch[f][0]]=i,w[f][t]=v;
    ll l=0,r=1LL<<40,ans=r;
    while(l<=r){
        ll mid=(l+r)>>1;mlen=mid;
        //cerr<<l<<" "<<r<<" "<<mid<<endl;
        if(check(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 32964
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll minV = 1 << 21, maxV = 0;
	ll a[100];
	rep(i, 0, N) {
		cin >> a[i];
		if (maxV < a[i]) {
			maxV = a[i];
		}
		if (minV > a[i]) {
			minV = a[i];
		}
	}
	cout << maxV - minV << endl;
	return 0;
}

Measured memory_bytes: 256
// Fri Aug 21 19:35:37 IST 2020      
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int N = 1e5+7; 
const int INF = 2e9;
const int64 reallyBig = 1e16+7;

struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 

int tests(){    
    int H,W;
    cin >> H >> W;
    int M;
    cin >> M;
    vector <int> row(H+1),col(W+1);
    set <pair<int,int>> s;
    forn(k,0,M){
        int a,b;
        cin >> a >> b;
        row[a]++;
        col[b]++;
        s.insert({a,b});
    }     
    int row_mex = *max_element(all(row));
    int col_mex = *max_element(all(col));
    int row_len = 0, col_len = 0;
    vector <int> v1,v2;
    forn(i,1,H+1)
        if(row_mex == row[i])
            row_len++,v1.push_back(i);
    forn(i,1,W+1)
        if(col_mex == col[i])
            col_len++,v2.push_back(i);
    int64 check  = (int64)row_len*col_len;
    if(check > M)
        return cout << row_mex+col_mex << '\n',0;
    int ans  = 0;
    for(int &t : v1)
        for(int &p : v2)
            ans =  max(ans,row_mex+col_mex-(int)(s.find({t,p}) != s.end()));
    cout << ans << '\n';
    return 0;
}
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 

Measured memory_bytes: 23744
N=int(input())
res=0
def make_divisors(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)
	return divisors
if N<105:
	print('0')
else:
	for i in range(105,N+1,2):
		if len(make_divisors(i))==8:
			res+=1
	print(res)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vector<pii> > vvpii;

#define pb push_back
#define endl '\n'
#define INF (int)1e9
#define EPS 1e-9
#define gcd __gcd
#define rs resize
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define by(T, x) [](const T& a, const T& b) { return a.x < b.x; } //for struct sorting

void printV(vector<int> v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " " ;
	}
	cout << endl;
}

void print2V(vvi v){
	FOR(i, 0, v.size()){
		FOR(j, 0, v[i].size()){
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}

int n, dp[200000], arr[200000];

int path(int cur){
//	cout << "inside with: " << cur << endl;
	if(cur > n){
//		cout << "outisde, returning inf" << endl;
		return INF;
	}
	if(cur == n){
//		cout << "on point, returning 0" << endl;
		return 0;
	}
	if(dp[cur] != -1){
//		cout << "already computed, returning: " << dp[cur] << endl;
		return dp[cur];
	}
	dp[cur] = min( path(cur+1) + abs(arr[cur]-arr[cur+1]), path(cur+2) + abs(arr[cur]-arr[cur+2]) );//normalde cur+2 ge�ebilirdi ama 0 at�ycam s�k�nt� ��kmas�n diye
	return dp[cur];
}

int main(){
	cin >> n;
	memset(dp, -1, sizeof dp);
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}
	cout << path(1);
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll solve(ll i){
    if(i==0) return 0;
    return (i*(i+1)) / 2;
}
string s;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>s;
    ll ans = 0;
    int n = s.size();

    ll cntlt = 0, cntgt=0;//<,>
    REP(i,n){
        if(s[i] == '<'){
            if(i && s[i-1]=='>'){
                if(cntlt > cntgt){
                    ans += solve(cntlt);
                    ans += solve(cntgt-1);
                }else{
                    ans += solve(cntlt-1);
                    ans += solve(cntgt);
                }

                cntlt = cntgt = 0;
            }
            
            cntlt++;
        }

        if(s[i] == '>'){
            cntgt++;
        }
    }

    if(cntlt > cntgt){
        ans += solve(cntlt);
        ans += solve(cntgt-1);
    }else{
        ans += solve(cntlt-1);
        ans += solve(cntgt);
    }

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

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
int ary[30][10000006]={0};
#define mp make_pair
signed main(){
    int n,C; cin>>n>>C;
    rep(i,n){
        int a,b,c;cin>>a>>b>>c;
        --c;a*=10;b*=10;
        ary[c][a-5]++;
        ary[c][b]--;
    }
    rep(i,30){
        rep(j,1000002-1)ary[i][j+1]+=ary[i][j];
    }
    int ans=0;
    rep(j,10000002-1){
        string hoge=to_string(j);
      
        int cnt=0;
        rep(i,30){
            if(ary[i][j])cnt++;
        }
        cmax(ans,cnt);
    }
    cout<<ans<<endl;
}



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

int main()
{
  int a,b,c,t,ans;
  cin >> a >> b >> c;
  if(a>b){
    t=a;
    a=b;
    b=t;
  }

  for(int i=a;i<=b;i++){

    if(c%i==0) ans++;
  }
		 
    cout << ans++ << endl;
  

  return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;


int main(){

    ll A, B, K;
    cin >> A >> B >> K;
    rep(i, K){
        if(i % 2 == 0){
            if(A % 2)A--;
            B += A / 2;
            A /= 2;
        }
        else{
            if(B % 2)B--;
            A += B / 2;
            B /= 2;
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()  {
    int n;
    cin>>n;
    int k;
    cin>>k;
    int ans = 0;
    while(n--)
    {
        int c;
        cin>>c;
        if(c>=k) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        ll l, r;
        cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import itertools
import numpy as np

def main():
    
    N, M, X = map(int, input().split())
    for i in range(N):
        row = np.array(list(map(int, input().split())))
        # print(row)
        if i == 0:
            c_array = row[0].reshape(1, 1)
            a_matrix = row[1:].reshape(1, len(row[1:]))
        else:
            c_array = np.append(c_array, row[0])
            a_matrix = np.vstack([a_matrix, row[1:].reshape(1, len(row[1:]))])
    # print(c_array)
    # print(a_matrix)
    min_cost = float("inf")
    for i in range(1, N+1):
        for v in itertools.combinations(np.arange(N), i):
            tmp = a_matrix[v, :].sum(axis=0)
            cost = c_array[list(v)].sum()
            # print(tmp)
            if tmp.min() >= X and cost <= min_cost:
                min_cost = cost
                
    if min_cost == float("inf"):
        print("-1")
    else:
        print(min_cost)
    
main()

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

int main() {
int N;
cin >> N;
int a=0,b=0;
  vector<int> vec(N);
for(int i=0;i<N;i++){
  cin >> vec.at(i);
}
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    cin >>vec.at(i);
    if(i%2==0){
      a+=vec.at(i);
    }
    else b+=vec.at(i);
  }
  cout <<a-b<<endl;
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed
 
    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)
 
    def add(self, i, x):
        # i: 0-indexed
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)
 
    def sum(self, i, j):
        # return sum of [i, j)
        # i, j: 0-indexed
        return self._sum(j) - self._sum(i)
 
    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res
 
    def lower_bound(self, x):
        s = 0
        pos = 0
        depth = self.n.bit_length()
        v = 1 << depth
        for i in range(depth, -1, -1):
            k = pos + v
            if k <= self.n and s + self.bit[k] < x:
                    s += self.bit[k]
                    pos += v
            v >>= 1
        return pos

n, q = map(int, input().split())
A = list(map(int, input().split()))

bit = BIT(n)
bit.init(A)

for _ in range(q):
  i, j, k = map(int, input().split())
  if i == 0:
    bit.add(j, k)
  else:
    print(bit.sum(j, k))

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

using namespace std;

#define REPEAT(i, N) for (int i = 0; i < (N); i++)

int main() {
  int S, W;
  
  cin >> S >> W;
  
  cout << (S <= W ? "unsafe" : "safe") << endl;
  
  return 0;
}

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(10)





void solve() {

	int h, n;
	cin >> h >> n;
	int sum = 0;
	while(n--) {
		int x;
		cin >> x;
		sum += x;
	}
	if(sum >= h) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}

Measured memory_bytes: 3600
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

simulate i k n' n
  | i > k = [-1, -1]
  | m == 0 && b' >= 0 && b' <= n && (i + b') <= n = [i, b']
  | otherwise = simulate (i + 1) k n' n
  where
    n'' = n' - 9 * i
    b' = n'' `div` 4
    m = n'' `mod` 4

main = do
  [n, y] <- getIntList
  let c = y `div` 1000
  if n > c
    then putStrLn "-1 -1 -1"
    else do
      let n' = c - n
      let [a, b] = simulate 0 (n' `div` 9) n' n
      if a == (-1)
        then putStrLn "-1 -1 -1"
        else do
          let c' = n - (a + b)
          putStrLn $ (show a) ++ " " ++ (show b) ++ " " ++ (show c')


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	string s[3];
	for(int i = 0 ; i < 3 ; i++)
		cin >> s[i];
	int idx[3] = {};
	int curr = 0;
	while(true){
		curr = s[curr][idx[curr]++]-'a';
		if(idx[curr] >= (int)s[curr].size()){
			cout<<char('A'+curr)<<"\n";
			return;
		}
	}
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3652
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll rcnt = 0;
    rep(i, n){
        if(s[i] == 'R') rcnt++;
    }
    ll ans = 0;
    rep(i, rcnt){
        if(s[i] == 'W'){
            ans++;
        }
    }
    cout << ans << endl;
}



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

#define MAX_POINTS (300*300+1)

typedef struct {
  int x;
  int y;
  int value;
} Point;

Point point[MAX_POINTS];

int solve(int begin, int end)
{
  return point[end].value - point[begin].value;
}

int main()
{
  memset(point, 0, sizeof(point));

  int height, width, diff;
  scanf("%d%d%d", &height, &width, &diff);
  for(int x = 0; x < height; x++) {
    for(int y = 0; y < width; y++) {
      int value;
      scanf("%d", &value);
      point[value].x = x;
      point[value].y = y;
    }
  }

  for(int i = diff+1; i <= height * width; i++) {
    point[i].value = point[i-diff].value + abs(point[i].x - point[i-diff].x)
      + abs(point[i].y - point[i-diff].y);
  }

  int num_tests;
  scanf("%d", &num_tests);
  for(int i = 0; i < num_tests; i++) {
    int begin, end;
    scanf("%d%d", &begin, &end);
    printf("%d\n", solve(begin, end));
  }
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  ll a, b, x;
  cin>>a>>b>>x;
  a = a - 1;
  if(a>=0) a = a/x + 1;
  else a = 0;

   b = b/x + 1;
   cout<<b - a<<endl;

  return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

lint app() {
  int n;
  cin>>n;

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }

  map<int,int> count;
  lint ans=0;
  rep(i,n){
    ans+=count[i-a[i]];
    count[a[i]+i]++;
  }

  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 21040
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int s,w; cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    
}


Measured memory_bytes: 3636
//
// Created by yuu on 2019-08-10.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int K,X;
    cin>>K>>X;

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


    for (int i = 0; i < ((K-1)*2+1); ++i) {
        cout<<X - K+i+1<<" ";
    }

    cout<<endl;


    return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

vector<int> vv;
int a[220000];
int n;
int fv[220000];

int get(int x) {
	int ans = 0;
	for (; x >= 0; x = ((x & (x + 1)) - 1))
		ans += fv[x];
	return ans;
}

void add(int x) {
	for (; x < vv.size(); x |= (x + 1))
		fv[x] += 1;
}
const ll INF = 1e18;

pair<ll, int> rmq[220000 * 4];
ll dd[220000 * 4];

void build(int v, int tl, int tr) {
	if (tl + 1 == tr) {
		rmq[v] = make_pair(0, tl);
		return;
	}
	int m = (tl + tr) >> 1;
	build(v * 2 + 1, tl, m);
	build(v * 2 + 2, m, tr);
	rmq[v] = max(rmq[v * 2 + 1], rmq[v * 2 + 2]);
}


void push(int v) {
	if (dd[v]) {
		dd[v * 2 + 1] += dd[v];
		rmq[v * 2 + 1].first += dd[v];
		dd[v * 2 + 2] += dd[v];
		rmq[v * 2 + 2].first += dd[v];
		dd[v] = 0;
	}
}

void add(int v, int tl, int tr, int l, int r, int d) {
	if (r <= tl || tr <= l)
		return;
	if (l <= tl && tr <= r) {
		rmq[v].first += d;
		dd[v] += d;
		return;
	}
	push(v);
	int m = (tl + tr) >> 1;
	add(v * 2 + 1, tl, m, l, r, d);
	add(v * 2 + 2, m, tr, l, r, d);
	rmq[v] = max(rmq[v * 2 + 1], rmq[v * 2 + 2]);
}

pair<ll, int> get(int v, int tl, int tr, int l, int r) {
	if (r <= tl || tr <= l)
		return make_pair(-INF, 0);
	if (l <= tl && tr <= r)
		return rmq[v];
	push(v);
	int m = (tl + tr) >> 1;
	return max(get(v * 2 + 1, tl, m, l, r), get(v * 2 + 2, m, tr, l, r));
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i], vv.push_back(a[i]);
	sort(vv.begin(), vv.end());
	vv.resize(unique(vv.begin(), vv.end()) - vv.begin());
	build(0, 0, vv.size());
	for (int i = 0; i < vv.size(); ++i)
		add(0, 0, vv.size(), i, i + 1, -vv[i]);
	for (int i = 0; i < n; ++i) {
		int x = lower_bound(vv.begin(), vv.end(), a[i]) - vv.begin();
		add(0, 0, vv.size(), x, vv.size(), 1);
	}
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		int x = lower_bound(vv.begin(), vv.end(), a[i]) - vv.begin();
		add(0, 0, vv.size(), x, vv.size(), -1);
		int go = get(0, 0, vv.size(), x, vv.size()).second;
		assert(go >= x);
		ans += vv[go] - a[i];
		a[i] = vv[go];
	}
	for (int i = 0; i < n; ++i)
		a[i] = lower_bound(vv.begin(), vv.end(), a[i]) - vv.begin();
	for (int i = n - 1; i >= 0; --i) {
		if (a[i] > 0)
			ans += get(a[i] - 1);
		add(a[i]);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 19060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

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

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

  int lim = x[n - 1];

  ll ans = -1;
  for (int i = 1; i <= lim; i++) {
    int p = i;
    ll sum = 0;
    for (int j = 0; j < n; j++) {
      int t = (x[j] - p) * (x[j] - p);
      sum += t;
    }

    if (ans == -1 || ans > sum) {
      ans = sum;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
/*
Character Drawing Adapted from FAKEUPDATE.NET
		   _    _____         _
		   \`,""   ,'7"r-..__/ \
		  ,'\ `, ,',','    _/   \
		 /   \, 7 / /     (   \ |
		J     \/ j  L______\  / |
		L   __JF"""/""\"\_,    /
		L,-"| O|  f O |  L_  _/
		F   \_ /  \__/   `-  j|
			.-'    `"""    ,' |          _..====.._
			\__/         r"_  A        ,' _..---.._`,
			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,
					  j   / / / 7"    `-<""=:'  '':. \ \
					 /   <,' /  F  . i , \   `,    :T W I
					 |    \,'  /    >X<  |     \   :| | L
					 |     `._/    ' ! ` |      I  :| |  G
					  \           \     /       |  :H T  |
					 __>-.__   __,-\   |        |  S P   |
					/     /|   | \  \  \_       | 'A R   |
				   /   __/ |   |  L  L   \      K./ /    L
				  /   |    |   4  I  I    |    E./ /   ,'
				 J    \    I    L F  I    |    // / _,'
		_________|     |   F    |J   F    |   //_/-'
		\   __   |    /   J     |/  J     |  /="
		\\  \_\  \__,' \  F     |   F     |
		\\\_____________\/      F__/      F
		 \\| 计算机编程 |_____/  (______/
		  \/从入门到入土/
*/
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
#include <functional>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	char chrNum1, chrNum2;
	cin >> chrNum1 >> chrNum2;
	if (chrNum1 < chrNum2)
		cout << "<\n";
	else if (chrNum1>chrNum2)
		cout << ">\n";
	else
		cout << "=\n";
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.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
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

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

  vector<pair<ll, ll>> A(N), B(N);
  rep0(i, N) { cin >> A[i].first; A[i].second = i; }
  rep0(i, N) { cin >> B[i].first; B[i].second = i; }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  rep0(i, N) {
    if (A[i].first > B[i].first) {
      cout << "No" << BR;
      return 0;
    }
  }

  rep(i, 0, N - 1) {
    if (A[i + 1].first <= B[i].first) {
      cout << "Yes" << BR;
      return 0;
    }
  }

  vector<ll> C(N);
  rep0(i, N) C[A[i].second] = B[i].second;
  int cnt = 1, p = C[0];
  while(p != 0) {
    p = C[p];
    cnt++;
  }
  if (cnt == N) cout << "No" << BR;
  else cout << "Yes" << BR;

  return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))

dis = [0] * N
for i in range(N):
    if i == N-1:
        dis[i] = K - A[i] + A[0]
    else:
        dis[i] = A[i+1] - A[i]

print(K-max(dis))

Measured memory_bytes: 32372
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int cou = 0;

    for(int i=0;i<n;i++){
      a[i] = sc.nextInt();
    }


    for(int i=0;i<n;i++){
      while(a[i]%2==0){
        cou += 1;
        a[i] = a[i]/2;
      }
    }


    System.out.println(cou);

  }
}


Measured memory_bytes: 34268
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
struct node
{
    ll value;
    ll time;
};

ll a;
ll b;
int n,m;

node s[300000];
int t=0;

bool cmp(node a, node b)
{
    return a.value > b.value;
}

int main()
{
    cin>>n>>m;
    for (int i=0; i<n; ++i)
    {
        scanf("%lld",&a);
        s[t].value = a;
        s[t].time = 1;
        t++;
    }
    for (int i=0; i<m; ++i)
    {
        scanf("%lld %lld",&a,&b);
        s[t].value = b;
        s[t].time = a;
        t++;
    }
    ll ans =0;
    sort(s,s+t,cmp);

    for (int i=0; i<t; ++i)
    {
        if (n==0) break;
        if (s[i].time<=n)
        {
            n-=s[i].time;
            ans+=s[i].time*s[i].value;
        }else
        {
            ans+=n*s[i].value;
            n=0;
        }
    }
    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 4352
#include <iostream>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main() {
  string s, t; cin >> s >> t;
  bool ans = false;
  rep ( i, s.size() ){ 
    if(s==t){
      ans = true; break; 
    }
  s = s.back() + s.substr(0, s.size()-1);
  }
  if (ans) puts ("Yes");
  else puts("No");
}

Measured memory_bytes: 256
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
temp = 0
cnt = 0
loop = 0
debug = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
while debug < 10:
    loop = 0
    temp = 0
    lst_a.sort(reverse=True)
    while loop < n-1:
        lst_a[loop] //= 2
        cnt += 1
        temp = max(temp,lst_a[loop])
        if cnt == m:
            print(sum(lst_a))
            sys.exit()
        if temp > max(lst_a[loop],lst_a[loop + 1]):
            break
        if lst_a[loop + 1] > lst_a[loop]:
            loop += 1
        
        

Measured memory_bytes: 14480
import copy

s = input()
t = input()
n = len(t)

ans = set()
flg = False
for i in range(len(s)):
    tmp = s[i: i + n]
    for j in range(n):
        try:
            if tmp[j] != "?" and tmp[j] != t[j]:
                flg = False
                break
            else:
                flg = True
        except IndexError:
            flg = False
            break
    if flg:
        if len(ans) > 0:
            ans.clear()
        s_1_l = list(copy.deepcopy(s))
        for k in range(len(s_1_l)):
            if s_1_l[k] == "?":
                s_1_l[k] = "a"
        s_1_l[i: i + n] = t
        ans.add("".join(s_1_l))

if len(ans) == 0:
    print("UNRESTORABLE")
else:
    print(*ans)


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

int main()
{
	string a,b;
	cin>>a>>b;

	ll a1,b1;
	a1=a.size();
	b1=b.size();
	vector<char> ans;

	ll dp[a1+1][b1+1];

	for(ll i=0;i<=a1;i++)
	{
		for(ll j=0;j<=b1;j++)
		{
		    if(i==0||j==0)
		    dp[i][j]=0;
		    
			else if(a[i-1]==b[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	//cout<<dp[a1][b1];
	
	ll u=a1;
	ll v=b1;
	while(u>0&&v>0)
	    {
	        if(dp[u][v-1]<dp[u-1][v])
	        u--;
	        else if(a[u-1]==b[v-1])
	        {
	            ans.push_back(a[u-1]); u--; v--;
	        }
	        else
	        v--;
	    }
	
	
	if(!ans.empty())
	{for(ll y=ans.size()-1;y>=0;y--)
	cout<<ans[y];}
	else
	cout<<" ";
	return 0;
}

Measured memory_bytes: 70656
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int H,W;
cin>>H>>W;
char G[H][W];
rep(i,H)rep(j,W)cin>>G[i][j];
// BFS のためのデータ構造
    vector<vector<int>> dist(H,vector<int>(W,-1)); // 全頂点を「未訪問」に初期化
    queue<int> que_y,que_x;
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};

rep(i,H)rep(j,W){
    if(G[i][j]=='.')continue;
    // 初期条件 (頂点 (sx,sy) を初期ノードとする)
    dist[i][j] = 0;
    que_y.push(i);
    que_x.push(j);
} 
    //移動方法4通り
    

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que_x.empty()) {
        int y = que_y.front(); // キューから先頭頂点を取り出す
        que_y.pop();
        int x = que_x.front();
        que_x.pop();

        // (x,y) から辿れる頂点をすべて調べる
       rep(i,4) {
            if ((y+dy[i]>=0)&&(y+dy[i]<H)&&(x+dx[i]>=0)&&(x+dx[i]<W)&&(G[y+dy[i]][x+dx[i]]=='.')){ //道でなければ飛ばす
            if(dist[y+dy[i]][x+dx[i]] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな頂点について距離情報を更新してキューに追加する
            dist[y+dy[i]][x+dx[i]] = dist[y][x] + 1;
            que_y.push(y+dy[i]);
            que_x.push(x+dx[i]);
            }
        }
    }
    int ans=0;
    rep(i,H)rep(j,W)ans=max(ans,dist[i][j]);
    cout<<ans<<endl;

return 0;
}

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

int Max(int x, int y) {
  if(x > y) return x;
  return y;
}

int Knapsack(int N, int capa, int value[], int weight[]) {
  int table[100][10000][2];
  int max = 0;

  for(int i = 0; i < N; i++) {
    for(int j = 0; j <= capa; j++) {
      if(i == 0) {
        if(j-weight[i] >= 0) {
          table[i][j][0] = value[i];
          table[i][j][1] = weight[i];
        }
        else {
          table[i][j][0] = 0;
          table[i][j][1] = 0;
        }
      }
      else {
        if(j-weight[i] >= 0) {
          int x = table[i-1][j][0];
          int y = table[i-1][j-weight[i]][0]+value[i];
          if(x > y) {
            table[i][j][0] = x;
            table[i][j][1] = table[i-1][j][1];
          }
          else {
            table[i][j][0] = y;
            table[i][j][1] = table[i-1][j-weight[i]][1]+weight[i];
          }
        }
        else {
          table[i][j][0] = table[i-1][j][0];
          table[i][j][1] = table[i-1][j][1];
        }
      }

      if(i == N-1 && table[i][j][1] <= capa && max < table[i][j][0])
        max = table[i][j][0];
    }
  }

  return max;
}

int main() {
  int N, capa;
  int value[100], weight[100];

  cin >> N >> capa;
  for(int i = 0; i < N; i++)
    cin >> value[i] >> weight[i];

  cout << Knapsack(N, capa, value, weight) << endl;

  return 0;
}

Measured memory_bytes: 10900