akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll 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;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    string s,t;
    cin>>n>>s>>t;
    ll mini=INF;
    rep(i,n){
        string subs=s.substr(n-i-1,i+1),subt=t.substr(0,i+1);
        if(subs==subt) mini=min(mini,2*n-(i+1));
    }
    if(mini!=INF) cout<<mini<<endl;
    else cout<<n*2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> b(N), w(N);
    rep(i, 0, N) {
        if (S[i] == '.') w[i] = 1;
        if (S[i] == '#') b[i] = 1;
        if (i != 0) b[i] += b[i - 1];
    }
    rrep(i, 0, N) {
        if (i != N - 1) w[i] += w[i + 1];
    }
    int ans = min(w[0], b[N - 1]);
    rep(i, 1, N) {
        int tmp = w[i] + b[i - 1];
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace std;
int main(){
  while (1) {
    int i, m, h;
    string card, tmp;
    cin >> card;
    if (card=="-") break;
    cin >> m;
    for (i=0; i<m; i++) {
      cin >> h;
      tmp = card.substr(0, h);
      card.erase(0, h);
      card+=tmp;
    }
    cout << card << endl;
  }
}


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

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

  vector<string> S(N);
  vector<int> P(N);

  set<string> town;

  for (int i = 0; i < N; i++)
  {
    cin >> S.at(i);
    cin >> P.at(i);
    town.insert(S.at(i));
  }

  vector<int> ans;

  for (auto val : town)
  {
    vector<int> point_list;
    for (int i = 0; i < N; i++)
    {
      if (S.at(i) == val){
        point_list.push_back(P.at(i));
      }
    }
    
    sort(point_list.rbegin(), point_list.rend());

    for (auto point : point_list)
    {
      for (int i = 0; i < N; i++)
      {
        if (P.at(i) == point)
        {
          ans.push_back(i + 1);
        }
      }
    }
  }  
   
  for (auto val : ans)
  {
    cout << val << endl;
  }
}

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

int main(){
  string S;
  cin >> S;
  bool easy = true;
  for(int i=0; i<S.size(); i++){
    if(i %2 == 0 && S.at(i) == 'L'){
      easy = false;
    }
    if(i %2 == 1 && S.at(i) == 'R'){
      easy = false;
    }
  }
  if(easy){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# a〜z -- START --
alf=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
# a〜z --- END ---

def main():
  n=I()
  ans=''
  while True:
    if n<=0:
      break
    x=n%26
    n-=1
    n//=26
    ans+=alf[x-1]
    # print(ans)

  ans=list(ans)
  ans.reverse()
  return ''.join(ans)

# main()
print(main())


Measured memory_bytes: 10776
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        if (a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)) {
            _out.println("YES");
        } else {
            _out.println("NO");
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 22608
import java.math.BigDecimal
import java.math.BigInteger

fun main(args: Array<String>) {

    var H = BigInteger(readLine()!!.toString())

    if (H == BigInteger.ONE) {
        println(1)
        return
    }

    var n = (Math.log(H.toDouble())/Math.log(2.toDouble()) + 1).toInt()

    var answer = BigInteger(BigDecimal(Math.pow(2.toDouble(),n.toDouble())).toString())

    println(answer.minus(BigInteger.ONE))
}

Measured memory_bytes: 33840
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<list>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main() {
  int L;
  cin >> L;
  double ans;
  ans = (L*L*L)/27.0;
  cout << fixed << setprecision(6) << ans << endl;
}

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

void BubbleSort(vector<string> A, int N) {
	for (int i = 0; i < N - 1;++i) {
		for (int j = N-1;i+1<=j ;--j) {
			if ((A[j])[1]<(A[j-1])[1]) {
				string tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
			}
		}
	}
	rep(i,N-1) {
		cout << A[i] << " ";
	}
	cout << A[N - 1] << endl;
	cout << "Stable" << endl;
}
bool IsStable(vector<string> In, vector<string> Out, int N) {
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			for (int a = 0; a < N - 1; ++a) {
				for (int b = a + 1; b < N; ++b) {
					if ((In[i])[1] == (In[j])[1] && In[i] == Out[b] && In[j] == Out[a]) {
						return false;
					}
				}
			}
		}
	}
	return true;
}
void SelectionSort(vector<string> A, vector<string> inA, int N) { // N 個の要素を含む 0-オリジンの配列 A
	for (int i = 0; i < N-1;++i) {
		int minj = i;
		for (int j = i; j < N ;++j) {
			if ((A[j])[1]<(A[minj])[1]) {
				minj = j;
			}
		}
		if (i!=minj) {
			string tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
		}
	}
	rep(i,N-1) {
		cout << A[i] << " ";
	}
	cout << A[N - 1] << endl;
	if(IsStable(inA,A,N))cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}


int main() {
	int N;
	cin >> N;
	vector<string> a(N);
	rep(i,N) {
		cin >> a[i];
	}
	BubbleSort(a,N);
	SelectionSort(a,a,N);
	return 0;
}





Measured memory_bytes: 3240
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll n,m,q;
void solve()
{
    cin>>m;ll ar[m+1],cnt=0;
    for(ll i=1;i<=m;i++)
        cin>>ar[i];
    ll chk=1;
    for(ll i=2;i<=m;i++)
    {
        if(ar[i-1]>=ar[i])
            cnt++;
        else
        {
            ans=max(cnt,ans);
            cnt=0;
        }
    }
    if(cnt)
        ans=max(cnt,ans);
    cout<<ans<<endl;
}   

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int N,A[100],c=0,i,j,t;
 
int main()
{
    for(i=0,scanf("%d",&N);i<N;scanf("%d",&A[i++]));
    for(i=0;i<N;i++)
    {
        for(t=j=i;j<N;j++)
            if(A[j]<A[t])
                t=j;
        if(i!=t)
        {
            A[i]^=A[t]^=A[i]^=A[t];
            c++;
        }
    }
    for(i=0;i<N;i++)
        printf("%d%s",A[i],i==N-1?"\n":" ");
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 600
N = int(input())
lsT = list(map(int,input().split()))
M = int(input())
sum1 = sum(lsT)
lsP = []
for i in range(M):
    lsP.append(list(map(int,input().split())))

for i in range(M):
    print(sum1-lsT[lsP[i][0]-1]+lsP[i][1])

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

using namespace std;

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;
	vector < int >A(Q);
	for (int i = 0; i < Q; i++) {
		cin >> A[i];
	}

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

	int cntIndex = 0;

	for (int i = 1; i <= N; i++) {
		int cnt = 0;
		while (A[cntIndex] == i && cntIndex < Q) {
			cnt++;
			cntIndex++;
		}
		if (K - Q + cnt > 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7
// https://atcoder.jp/contests/abc167/tasks/abc167_d
int main() {
    ll n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) {int x; cin >> x; a[i] = x - 1;}

    vector<int> path; // i回目の移動後にどこにいるか
    path.push_back(0);

    vector<bool> seen(n, false);
    seen[0] = true;

    int looptown;
    while (true) {
        int from = path[path.size() - 1];
        int to = a[from];
        if (seen[to]) {
            looptown = to;
            break;
        }
        seen[to] = true;
        path.push_back(to);
    }

    int loopidx;
    rep(i, 0, path.size()) {
        if (path[i] == looptown) loopidx = i;
    }

    ll ans;
    if (k < loopidx) {
        ans = k;
    } else {
        ans = (k - loopidx) % (path.size() - loopidx) + loopidx;
    }
    cout << path[ans] + 1 << endl;
}


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


using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"

const ll maxn=3e5+50;

const ll maxx=1e13;
const ll mod=1000000007;
const ll mod1=998244353;
vector<ll> adj[maxn];

ll a[maxn];
ll b[maxn];
ll c[maxn];
ll d[maxn];
ll e[maxn];
ll n, m, q;
ll mx=0;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    //freopen("FRAC.INP", "r", stdin);
    // freopen("WALKING.OUT", "w", stdout);
    ll n;
     cin>>n;
     ll t=100;
     ll cnt=0;
     while (t<n)
     {
         t=t+t/100;
         cnt++;
     }
     cout <<cnt;

}


Measured memory_bytes: 10644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

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

int main() {
  ll k, total = 0, tmp;
  cin >> k;
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
        tmp = gcd(a, b);
        total += gcd(tmp, c);
      }
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 3636
import scala.annotation.tailrec
import scala.io.StdIn._

object Main extends App {
  solve()
  @tailrec def solve(): Unit = {
    val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0 && m == 0) return
    val union = new DiffUnionFind(n)
    for (_ ← 0 until m) {
      readLine.trim.split(' ') match {
        case Array("!", a, b, w) ⇒ union.setRelation(a.toInt - 1, b.toInt - 1, w.toInt)
        case Array("?", a, b) ⇒
          union.findDiff(a.toInt - 1, b.toInt - 1) match {
            case Some(d) ⇒ println(d)
            case None ⇒ println("UNKNOWN")
          }
        case _ ⇒ ???
      }
    }
    solve()
  }
}


class DiffUnionFind(val size: Int) {
  private val parent = Array.fill(size){-1}
  private val diff = Array.fill(size){0L}
  private def find(a: Int): (Int, Long) = {
    if (parent(a) < 0) {
      (a, 0L)
    }else {
      val (p, d) = find(parent(a))
      parent(a) = p
      diff(a) += d
      (p, diff(a))
    }
  }
  def setRelation(a: Int, b: Int, w: Int): Boolean = {
    val (ar, ad) = find(a)
    val (br, bd) = find(b)
    if (ar != br) {
      if (parent(ar) < parent(br)) {
        parent(ar) += parent(br)
        parent(br) = ar
        diff(br) = ad + w - bd
      }else {
        parent(br) += parent(ar)
        parent(ar) = br
        diff(ar) = bd - ad - w
      }
    }
    ar != br || ad + w == bd
  }
  def findDiff(a: Int, b: Int): Option[Long] = {
    val (ar, ad) = find(a)
    val (br, bd) = find(b)
    if (ar == br) Some(bd - ad)
    else None
  }
}


Measured memory_bytes: 454200
//author Eterna King
#define Hello the_cruel_world!
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#include<numeric>
#define max(x,y) ((x) > (y) ? (x) : (y))
#define min(x,y) ((x) < (y) ? (x) : (y))
#define lowbit(x) ((x) & (-(x)))
#define FRIN freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.in", "r", stdin)
#define FROUT freopen("C:\\Users\\Administrator.MACHENI-KA32LTP\\Desktop\\1.out", "w", stdout)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define outd(x) printf("%d\n", x)
#define outld(x) printf("%lld\n", x)
#define memset0(arr) memset(arr, 0, sizeof(arr))
#define il inline
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int maxn = 2e5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const double eps = 1e-7;
const double Pi = acos(-1.0);
il int read_int() {
	char c;
	int ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll read_ll() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
il ll quick_pow(ll base, ll index) {
	ll res = 1;
	while (index) {
		if (index & 1)res = res * base % mod;
		base = base * base % mod;
		index >>= 1;
	}
	return res;
}
struct query {
	bool operator < (const query& rhs)const {
		return c > rhs.c;
	}
	int b, c;
}op[maxn + 5];
priority_queue<int, vector<int>, greater<int>> q;
int arr[maxn + 5], n, m;
ll res;
int main()
{
	n = read_int(), m = read_int();
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i];
		q.push(arr[i]);
	}
	for (int i = 1; i <= m; ++i) {
		cin >> op[i].b >> op[i].c;
	}
	sort(op + 1, op + 1 + m);
	for (int i = 1; i <= m; ++i) {
		int b = op[i].b, c = op[i].c;
		while (!q.empty() && b && c > q.top()) {
			res += c;
			q.pop();
			--b;
		}
		if (b)break;
	}
	while (!q.empty()) {
		res += q.top();
		q.pop();
	}
	cout << res << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1912
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  string s, t;
  bool flag = false;

  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());

  if(s.size() < t.size()){
    for(int i = 0; i < s.size(); i++){
      if(s[i] != t[i]) flag = false;
      else flag = true;
    }
  }

  int r = min(s.size(), t.size());
  for(int i = 0; i < r; i++){
    if(s[i] == t[i]) continue;
    if(s[i] > t[i]){
      flag = false;
      break;
    }else{
      flag = true;
      break;
    }
  }

  if(s == t) flag = false;

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001
#define mod 1000000007
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl>
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define cy cout << "YES" << endl
#define cn cout << "NO" << endl
#define google cout << "Case #" << ++it << ": " << ans << endl;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll it = 0, ans = 0;

ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (auto i=2; i<MAXN; i++)
  		spf[i] = i;
  	for (auto i=4; i<MAXN; i+=2)
        spf[i] = 2;
    for (auto i=3; i*i<MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (auto j=i*i; j<MAXN; j+=i)
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
	return;
}

vl getFactorization(ll x)
{
    vl ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}


void check()
{
	ll n;
	cin >> n;
	vl a(n), b(n);
	for(int i=0;i<n;i++) {
		ll x,y;
		cin >> x >> y;
		a[i] = x+y;
		b[i] = x-y;
	}
	cout << max(abs(*min_element(a.begin(),a.end())-*max_element(a.begin(),a.end())), abs(*min_element(b.begin(),b.end())-*max_element(b.begin(),b.end())));
    return ;
}

int32_t main()
{
    fastio
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}


Measured memory_bytes: 6328
import java.util.Scanner;

public class Main {
	
	static int[] memo = new int[45];
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			if (isPrime(a)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
	
	static boolean isPrime(int a) {
		if (a <= 1) return false;
		
		if (a != 2 && a%2 == 0) return false;
		
		int max = (int) Math.sqrt(a)+1;
		for (int i = 3; i < max; i++) {
			if (a%i == 0) return false;
		}
		return true;
	}
}



Measured memory_bytes: 44208
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n,m;cin>>n>>m;
	int maxi = 0;
	
	for(int i = 1;i*i<=m;i++)
	{
		if(m%i) continue;
		
		int b = m/i;
		
		if(b >= n) maxi = max(maxi , i);
		
		if(i >= n) maxi = max(maxi , b);	
	}
	
	
	cout<<maxi<<endl;
	
	return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n,W,w[MAXN],v[MAXN];
int dp[109][109][309];
int rec(int pos,int taken,int mod){
	if(taken*w[1]+mod>W)
		return -INF;
	if(pos>n)
		return 0;
	int &ret=dp[pos][taken][mod];
	if(~ret)
		return ret;
	return ret=max(rec(pos+1,taken,mod),rec(pos+1,taken+1,mod+(w[pos]-w[1]))+v[pos]);	
}
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	memset(dp,-1,sizeof dp);
	scanf("%d%d",&n,&W);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&w[i],&v[i]);
	printf("%d\n",rec(1,0,0));	
	return 0;
}


Measured memory_bytes: 14592
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ans = 0
if n == 1:
    print(a1[0] + a2[0])
    exit()
for i in range(1, n):
    ans = max(sum(a1[:i])+sum(a2[i-1:]), ans)
print(ans)


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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 200003



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    str[3]='8';
    cout<<str;
    
    
    return 0;
}



Measured memory_bytes: 256
use proconio::{input, fastout};
const MOD: u64 = 1000000007;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut sum: u64  = a.iter().sum();
    let mut ans = 0;

    for i in 0..n {
        sum -= a[i];
        ans += ((sum % MOD) * a[i]) % MOD;
        ans %= MOD;
    }

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


Measured memory_bytes: 5644
import java.util.*;

     
    class Main {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 5; i++) {
          if (sc.nextInt() == 0)
            System.out.println(i + 1);
        }
      
      }
    }

Measured memory_bytes: 35880
s = input()

m = 1000000007
dp = [0] * 4
dp[0] = 1

for c in s:
  if c=='A':
    dp[1] += dp[0]
  elif c=='B':
    dp[2] += dp[1]
  elif c=='C':
    dp[3] += dp[2]
  elif c=='?':
    dp = [(dp[0]*3)%m, (dp[0]+dp[1]*3)%m, (dp[1]+dp[2]*3)%m, (dp[2]+dp[3]*3)%m]

print(dp[3]%m)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#include<sstream>
#define endl '\n'
#define ll long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    double a,b,h,m;
    cin>>h>>m>>a>>b;
    
    double j = (b*6);
    double i = (a*30)+b/2;
    
    double an = abs(i-j);
    if(an>=180)
    {
        an=360-an;
    }

    //cout<<an<<" "<<(cos(PI))<<" ";
    double ans = sqrt(h*h +m*m- 2*h*m*(cos(an*PI/180)));
    cout<<sp(15)<<ans;
    
    return 0;
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a,b,c;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n; a.resize(n); b.resize(n); c.resize(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans = 0;
    rep(i,n){
        ans += (lower_bound(all(a),b[i]) - a.begin()) * ( c.end() - upper_bound(all(c),b[i]) ) ;
    }
    print(ans);
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n,k; cin>>n>>k;
	int64_t ans=(k!=0?0:-n);
	for(int64_t i=k+1;i<=n;++i){
		ans+=n/i*(i-k)+max(0l,n%i-k+1);
	}
	cout<<ans<<"\n"s;
}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;
signed main(){
	
	cin>>a;

	if(a%10==3) cout<<"bon";
	else if(a%10==0 || a%10==1 || a%10==6 || a%10==8) cout<<"pon";
	else cout<<"hon";

	
 return 0;
}


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

using namespace std;

int main() {
  /* 初期化 */
  int table[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
  bool signs[3][3] = {{false,false,false},{false,false,false},{false,false,false}};
  
  /* 入力 */
  for (int i = 0; i < 3; i++) {
    for (int n = 0; n < 3; n++) {
      cin >> table[i][n];
    }
  }
  
  int N = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int tmp = 0;
    cin >> tmp;
    
    for (int n = 0; n < 3; n++) {
      for (int m = 0; m < 3; m++) {
        if (table[n][m] == tmp) {
          signs[n][m] = true; // 印をつける
        }
      }
    }
  }
  
  /* 1つめの添字を固定したときビンゴが成立しているか？ */
  
  for (int i = 0; i < 3; i++) {
    for (int n = 0; n < 3; n++) {
      if (signs[i][n] == false) {
        break;
      }
      
      if (n == 2) {
        // 端まですべてtrueで埋められていた、よってビンゴ成立
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  /* もう1方の方向はどうか？ */
  
  for (int i = 0; i < 3; i++) {
    for (int n = 0; n < 3; n++) {
      if (signs[n][i] == false) {
        break;
      }
      
      if (n == 2) {
        // 端まですべてtrueで埋められていた、よってビンゴ成立
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  
  /* 斜めは2パターンしか存在しない*/
  
  for (int i = 0; i < 3; i++) {
    if (signs[i][i] == false) {
      break;
    }
    
    if (i == 2) {
      // 端まですべてtrueで埋められていた、よってビンゴ成立
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  for (int i = 0; i < 3; i++) {
    if (signs[i][2 - i] == false) {
      break;
    }
    
    if (i == 2) {
      // 端まですべてtrueで埋められていた、よってビンゴ成立
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

l = list()
for _ in range(3):
    l += nl()
n = ni()
b = set([ni() for _ in range(n)])
g = [(x in b) for x in l]
f = g[0]&g[1]&g[2]
f |= g[3]&g[4]&g[5]
f |= g[6]&g[7]&g[8]
f |= g[0]&g[3]&g[6]
f |= g[1]&g[4]&g[7]
f |= g[2]&g[5]&g[8]
f |= g[0]&g[4]&g[8]
f |= g[2]&g[4]&g[6]
print('YNeos'[1^f::2])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int mx = 0;
    for (int i = 0; i < S.size(); i++) {
        int j = i;
        if (S[i] == 'S') continue;
        for (; j < S.size() && S[i] == S[j]; j++) {}
        mx = max(mx, j - i);
        i = j;
    }
    cout << mx << '\n';
}


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

int main() {
  int n, answer=1;
  cin>>n; vector<int> mochis(n);
  for(int i=0; i<n; i++){
    cin>>mochis.at(i);
  }
  sort(mochis.begin(), mochis.end());
  for(int i=0; i<n-1; i++){
    if(mochis.at(i)<mochis.at(i+1)){answer++;}
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[200000];

ll comb(ll a, ll b) {
  ll ue = frac[a], sh1=1, sh2=1;
  ll tsh1, tsh2;
  ll two, h;
  h = mod - 2;
  while(h>0) {
    two = 1;
    tsh1 = frac[b];
    tsh2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      tsh1 *= tsh1;
      tsh2 *= tsh2;
      tsh1 %= mod;
      tsh2 %= mod;
    }
    h -= two;
    sh1 *= tsh1;
    sh2 *= tsh2;
    sh1 %= mod;
    sh2 %= mod;
  }
  return ue*sh1%mod*sh2%mod;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<200000;++i) frac[i] = frac[i-1]*i%mod;
  ll N, M;
  cin>>N>>M;
  vector<ll> prime;
  map<ll, int> amap;
  for(ll i=2;i*i<=M;++i) {
    if(M%i==0) prime.push_back(i);
    while(M%i==0) {
      amap[i]++;
      M /= i;
    }
  }
  if(M>1) {
    prime.push_back(M);
    amap[M]++;
  }
  ll ans = 1;
  for(int i=0;i<prime.size();++i) {
    ans *= comb(amap[prime[i]]+N-1, amap[prime[i]]);
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5180
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b>=a){
        int cnt=0;
        for(int i=a; i<=b; i++){
            if(c%i == 0){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


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

s = input().strip()
t = input().strip()
n = len(s)
m = len(t)
p = 0
q = 0
fold = 0
l = [[] for _ in range(26)]
lim = [0 for _ in range(26)] 
for i, x in enumerate(s):
	l[ord(x) - 97].append(i)
	lim[ord(x) - 97] += 1
r = [0 for _ in range(26)]
cur = -1
while (q < m):
	x = t[q]
	ind = ord(x) - 97
	#print(x, cur)
	if l[ind] == []:
		print(-1)
		exit(0)
	else:
		#print("HERE", r[ind], lim[ind])
		if r[ind] >= lim[ind]:
			fold += 1
			r = [0 for _ in range(26)]
			cur = -1
		else:
			c = l[ind][r[ind]]
			flag = True
			while (c <= cur):
				r[ind] += 1
				if r[ind] >= lim[ind]:
					flag = False
					break
				c = l[ind][r[ind]]
			if flag == False:
				fold += 1
				r = [0 for _ in range(26)]
				cur = -1
			elif c > cur:
				cur = c
				q += 1
				r[ind] += 1
			else:
				fold += 1
				r = [0 for _ in range(26)]
				cur = -1
#print(fold, n, cur)
print(fold * n + cur + 1)




 

Measured memory_bytes: 46300
#include <bits/stdc++.h>
// #pragma GCC diagnostic warning "-std=c++11"

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll maxval, n, weight, w[110], v[110], dp[100010];
int main()
{
	cin>>n>>weight;
	for(ll i=1;i<=n;i++)
	{
		slc(w[i]);
		slc(v[i]);
	}
	memset(dp, -1, sizeof dp);
	dp[0]=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=weight;j>=w[i];j--)
		{
			if(dp[j-w[i]]==-1)
				continue;
			dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
			maxval = max(maxval, dp[j]);
			// cout << i << " " << j << " " << dp[j] << endl;
		}
	}
	cout << maxval << endl;
	
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<math.h>

double jrt(double);

int main(){
  double x,y,x1,y1,j,xt,yt;
  double l;
  
  scanf("%lf%lf",&x,&y);

  scanf("%lf%lf",&x1,&y1);

  xt=jrt(x1-x);
  yt=jrt(y1-y);

 l= sqrt(xt+yt);

 printf("%f\n",l);
 return 0;
}


    double jrt(double x){
    return x*x;
  }

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

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N), B(N), C(N);
	for (ll i = 0; i < N; ++i) {cin >> A[i];}
	for (ll i = 0; i < N; ++i) {cin >> B[i];}

	if (accumulate(A.begin(), A.end(), 0ll) < accumulate(B.begin(), B.end(), 0ll))
	{
		std::cout << -1 << std::endl;
		return 0;
	}

	vector<ll> A_B, B_A;
	for (ll i = 0; i < N; ++i)
	{
		if (A[i] < B[i])
			B_A.push_back(B[i] - A[i]);
		else
			A_B.push_back(A[i] - B[i]);
	}

	
	ll res = B_A.size();
	ll S = accumulate(B_A.begin(), B_A.end(), 0ll);

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

	while (S > 0)
	{
		S -= A_B.back();
		A_B.pop_back();
		++res;
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 3580
#include <iostream>
using namespace std;
int main(void){
    int n,k;
    cin >> n >> k;
    char flag[n];
    for(int i=0;i<n;i++){
        flag[i]=0;
    }
    for(int j=0;j<k;j++){
        int dj;
        cin >> dj;
        for(int t=0;t<dj;t++){
            int ai;
            cin >> ai;
            flag[ai-1]=1;
        }
    }
    int counter=n;
    for(int i=0;i<n;i++){
        if(flag[i]) counter--;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001;

int N,K,Q,A[2000],ok[2000];
int ans = MOD;

void solve() {
    vi z;
    for (int i = 0; i < N; ) {
        if (!ok[i]) {
            i ++; 
            continue;
        }
        vi v;
        while (i < N && ok[i]) v.pb(A[i++]);
        sort(all(v));
        F0R(i,sz(v)-K+1) z.pb(v[i]);
    }
    sort(all(z));
    if (sz(z) < Q) return;
    ans = min(ans,z[Q-1]-z[0]);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K >> Q;
    F0R(i,N) cin >> A[i];
    vpi v;
    F0R(i,N) v.pb({A[i],i});
    sort(v.rbegin(),v.rend());
    for (auto a: v) {
        ok[a.s] = 1;
        solve();
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

const int MAX = 200001;
double dp[20][MAX];

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

    vector<int> a(N);
    for(int i = 0; i < N; ++i) cin >> a[i];

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < MAX; ++j) dp[i][j] = -1;
    }

    for(int i = 0; i < N; ++i) {
        for(int j = 1; j < MAX; ++j) {
            dp[i][j] = max(dp[i][j], fabs(a[i]-j) / (double)a[i]);
            //cout << i << ' ' << j << ' ' << dp[i][j] << endl;

            if(i+1 < N) {
                for(int k = j; k < MAX; k += j) {
                    if(dp[i+1][k] < 0 || dp[i+1][k] > dp[i][j]) {
                        dp[i+1][k] = dp[i][j];
                    }
                }
                for(int k = j; k >= 0; k -= j) {
                    if(dp[i+1][k] < 0 || dp[i+1][k] > dp[i][j]) {
                        dp[i+1][k] = dp[i][j];
                    }
                }
            }
        }
    }

    double ans = 1e10;
    for(int i = 1; i < MAX; ++i) {
        ans = min(ans, dp[N-1][i]);
    }

    printf("%.8f\n", ans);

    return 0;
}

Measured memory_bytes: 31000
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

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


int main(void)
{
	char s[100+2];
	while(scanf("%100[LRUD]\n", s)==1)
	{
		int ans=1;

		for(int i=0;s[i];i++)
		{
			if((i%2)==0)
			{
				if(s[i]=='L') ans=0;
			}
			else
			{
				if(s[i]=='R') ans=0;
			}
		}
		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 128
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, M = in_nn()

    ans = 1
    inf = M // N + 1
    for i in range(inf, 1, -1):
        if i * N <= M and M % i == 0:
            ans = i
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define MOD 998244353
#define MAX 3005
#define MAX_W 1001
int A[MAX];
long long int dp[MAX][MAX][2][2];
int N,S;
void initialize(int N,int S)
{
    int i,j,k,l;
    for(i=0;i<=N;i++)
    {
        for(j=0;j<=S;j++)
        {
            for(k=0;k<2;k++)
            {
                for(l=0;l<2;l++)
                {
                    dp[i][j][k][l]=-1;
                }
            }
        }
    }
}
long long int counter(int index,int sum,int b=0,int e=0)
{
    if(index==N) return (sum==0);
    if(dp[index][sum][b][e]!=-1)
    {
        return dp[index][sum][b][e];
    }
    dp[index][sum][b][e]=counter(index+1,sum,b,e)%MOD;
    if(A[index]<=sum)
    {
        long long int current=1;
        if(b==0) current=(current*(index+1))%MOD;
        if(A[index]==sum) current=(current*(N-index))%MOD;
        current=(current*counter(index+1,sum-A[index],1,(sum-A[index]==0)))%MOD;
        dp[index][sum][b][e]=(dp[index][sum][b][e]+current)%MOD;
    }
    return dp[index][sum][b][e];
}
int main()
{
    int i;
    scanf("%d %d",&N,&S);
    for(i=0;i<N;i++)
    {
        scanf("%d",&A[i]);
    }
    initialize(N,S);
    long long int ans=counter(0,S);
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 282368
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

short checkTable[1001][1001];

int tmp_max=0;


void calc(int index,char pattern[],char to_search[],int to_search_length){

	for(int i=to_search_length-1;i>=0;i--){
		if(to_search[i]==pattern[index]){
			checkTable[index][i]=1;
			if(pattern[index+1]!='\0' && i < to_search_length-1){
				checkTable[index][i] = checkTable[index+1][i+1] + checkTable[index][i];
			}
		}else{
			if(i != to_search_length-1){
				if(pattern[index+1] != '\0'){
					checkTable[index][i]=(checkTable[index+1][i]>checkTable[index][i+1])
							?checkTable[index+1][i]:checkTable[index][i+1];

				}else{
					checkTable[index][i]=(checkTable[index][i+1]>0)?checkTable[index][i+1]:0;
				}
			}else{
				if(pattern[index+1] != '\0'){
					checkTable[index][i]=(checkTable[index+1][i]>0)?checkTable[index+1][i]:0;
				}else{
					checkTable[index][i] = 0;
				}
			}
		}
		tmp_max = (tmp_max >= checkTable[index][i])?tmp_max:checkTable[index][i];
	}
}

int main(){

	int q,left_length,right_length;
	char left[1001],right[1001];

	scanf("%d",&q);

	for(int i=0;i<q;i++){
		left_length=0;
		right_length=0;
		scanf("%s %s",left,right);
		for(int k=0;left[k]!='\0';k++)left_length++;
		for(int k=0;right[k]!='\0';k++)right_length++;

		if(right_length>=left_length){

			for(int k=left_length-1;k>=0;k--)calc(k,left,right,right_length);
		}else{

			for(int k=right_length-1;k>=0;k--)calc(k,right,left,left_length);
		}
		printf("%d\n",tmp_max);
		tmp_max=0;
	}

    return 0;
}


Measured memory_bytes: 5136