akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
typedef long long ll;
int main()
{
    char s[1000];
    scanf("%s",s+1);
    int len=strlen(s+1);
    int flag=0;
    for(int i=1;i<=len;i++)
    {
        if(i&1)
        {
            if(s[i]=='L')
            {
                flag=1;
                break;
            }
        }
        else
        {
            if(s[i]=='R')
            {
                flag=1;
                break;
            }
        }
    }
    if(flag==1)
        puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

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

    int x = min(a, b);
    int y = max((int)0, a + b - n);

    cout << x << " " << y << endl;
    return 0;
}


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

int max(int a, int b){
  if(a>b) return a;
  else return b;
}

int min(int a, int b){
  if(a<b) return a;
  else return b;
}

int main(){

  int a,b,c;
  cin >> a >> b >> c;
  int d =max(a,max(b,c));
  int e =min(a, min(b,c));
  int f =a+b+c-d-e;
  
  cout << e << " " << f << " " << d << endl;
  
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
 
int main(){
	ll q,c,x;
	cin >> q;
	set<ll> se;
	while(q--){
		cin >> c >> x;
		if(c==1){
			cout << se.count(x) << endl;
		}else if(c==0){
			se.insert(x);
			cout << se.size() << endl;
		}else if(c==2){
			se.erase(x);
		}
	}
}


Measured memory_bytes: 12412
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1<<17
int n,dat[2*(MAX_N)-1];

//INT＿MAXで初期化
void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=0;
}

//k番目の要素をaに変更
void update(int k,int a){
  k+=n-1;
  dat[k]+=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=dat[k*2+1]+dat[k*2+2];
  }
}

//[a,b)の合計を求める
int query(int a,int b,int k=0,int l=0,int r=n){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return dat[k];
  else{
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return vl+vr;
  }
}

int main(){
  int q;
  cin>>n>>q;
  init(n);
  for(int i=0;i<q;i++){
    int com,x,y;
    cin>>com>>x>>y; //com=1でfind,elseでupdate
    if(com)cout<<query(x-1,y)<<endl;
    else update(x-1,y);
  }
  return 0;
}



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

class list
{
    int L[1000001];
    int head, tail, MAX;
public:
    list();
    void initialize();
    void ins(int);
    void del(int);
    void del_first();
    void del_last();
    void show();
};

list::list() : MAX(1000001){}

void list::initialize(){ head = tail = 0; }

void list::ins(int key)
{
    L[head] = key;
    head++;
    if(head == MAX) head = 0;
    return;
}

void list::del(int key)
{
    int i = head, j;
    do{
        if(i == 0) i = MAX;
        i--;
        if(i == tail && L[tail] != key) return;
    }while(L[i] != key);
    // ????????£???????????§L[i]????????????key. ???????????°??????????????????
    j = i;
    do{
        if(j == MAX - 1){
            L[j] = L[0];
        }else{ L[j] = L[j + 1]; }
        j++;
        if(j == MAX) j = 0;
    }while(j != head);
    // ?????????head???1???????????????
    head--;
    if(head < 0) head = MAX - 1;
	return;
}

void list::del_first()
{
    head--;
    if(head < 0) head = MAX - 1;
    return;
}

void list::del_last()
{
    tail++;
    if(tail == MAX) tail = 0;
    return;
}

void list::show()
{
    int i = head;

    while(i != tail){
        if(i == 0) i = MAX;
        printf("%d", L[i - 1]);
        i--;
        if(i != tail) printf(" ");
    }
    printf("\n");
    return;
}

int main()
{
    list l = list();
    char order[13];
    int i, n, key;
    l.initialize();

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s", &order);
        if(order[0] == 'i'){
            scanf("%d", &key);
            l.ins(key);
        }else if(!order[6]){
            scanf("%d", &key);
            l.del(key);
        }else{
            if(order[6] == 'F') l.del_first();
            if(order[6] == 'L') l.del_last();
        }
    }
    l.show();

    return 0;
}

Measured memory_bytes: 4936
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
ll fac[1000005],finv[1000005],inv[1000005];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000005; 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll x,y,n,m;
  cin >> x >> y;
  if((x+y)%3!=0) {
    cout << 0 << endl;
    return 0;
  }
  n=(2*y-x)/3,m=(2*x-y)/3;
  COMinit();
  cout << COM(n+m,m) << endl;
}

Measured memory_bytes: 23680
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <chrono> 
using namespace std::chrono;
#define fl(i,z,n) for(int i=z;i<=(n);i++)
#define flr(i,z,n) for(int i=z;i>=(n);i--)
using namespace std;
#define ll long long 
#define pa(a,s) fl(i,0,s-1) cout<<*(a+i)<<" "; cout<<nl;
#define pv(v) fl(i,0,v.size()-1) cout<<v[i]<<" "; cout<<nl;
#define read(v) fl(i,0,v.size()-1) cin>>v[i];
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define vll vector<ll>
#define sll set<ll>
#define spll set<pll>
#define debnl(x) cout<<#x<<"="<<x<<nl;
#define deb(x) cout<<#x<<"="<<x<<" ";
#define mkp(x,y) make_pair(x,y)
#define ump unordered_map
#define ff first
#define ss second
#define in insert
#define sz size
#define len length
#define nl '\n'
#define pb push_back
#define in insert
#define ub upper_bound
#define lb lower_bound
#define ld long double
const int MXN=1e5;
ll mod=1e9+7;
void solve(){
    string s;
    cin>>s;
    ll sum=0;
    fl(i,0,s.length()-1) sum+=s[i]-'0';
    if(sum%9) cout<<"No"<<nl;
    else cout<<"Yes"<<nl;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); ll t=1;
    //cin>>t; //comment for single test
    while(t--) solve();
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#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, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

ll modpow(ll x, ll y){
    if(y == 0) return 1;
    if(y == 1) return x;
    return x * modpow(x, y-1) % MOD;
}

signed main(){ INIT;
    VAR(int, n);
    VEC(int, a, n);
    sort(ALL(a));
    if(n%2){
        FOR(i, 1, n){
            if(a[i]%2 || a[i] != (i + 1)/2*2){
                OUTL(0);
                RET;
            }
        }
    }else{
        REP(i, n){
            if(!(a[i]%2) || a[i] / 2 != i / 2){
                OUTL(0);
                RET;
            }
        }
    }
    OUTL(modpow(2, n/2));
RET;}

Measured memory_bytes: 1408
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int a; cin>>a;
    string s; cin>>s;
    if(3200 <= a) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long dp[60][60][2510];
int main() {
	int n, A;
	cin >> n >> A;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= 2500; k++) {
				if (a[i] <= k && j >= 1) {
					dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - a[i]];
				} else {
					dp[i + 1][j][k] = dp[i][j][k];
				}
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		ans += dp[n][i][i * A];
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 60544
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

class UnionFind {
    public:

    vector<int> v;

    UnionFind(int n) : v(vector<int>(n, -1)) {}

    int GetParent(int a) {
        
        if(v[a] < 0)
            return a;

        return v[a] = GetParent(v[a]); 

    }

    bool Unit(int a, int b) {

        int p_a = GetParent(a);
        int p_b = GetParent(b);

        if(p_a == p_b)
            return false;

        if(v[p_a] > v[p_b])
            swap(p_a, p_b);
        v[p_a] += v[p_b];
        v[p_b] = p_a;

        return true;

    }

    bool IsSame(int a, int b) {

        return GetParent(a) == GetParent(b);

    }

    int size(int a) {

        int p = GetParent(a);
        return -v[p];

    }

};

int main() {

    int N, M, K;

    cin >> N >> M >> K;

    UnionFind u(N);
    vector<set<int>> blocks(N);

    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        blocks[a].insert(b);
        blocks[b].insert(a);
        u.Unit(a, b);
    }

    for(int i = 0; i < K; ++i) {

        int a, b;
        cin >> a >> b;
        a--; b--;
        if(!u.IsSame(a, b))
            continue;
        blocks[a].insert(b);
        blocks[b].insert(a);
    }
    
    for(int i = 0; i < N; ++i) {

        int ans = u.size(i) - 1 - blocks[i].size();
        if(i)
            cout << " ";
        cout << ans;

    }

    cout << endl;

    return 0;
}

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

using namespace std;

int main() {
  vector<int> kth{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};
  int k;
  cin >> k;
  cout << kth[k - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int W, H, x, y, r;
    scanf("%d %d %d %d %d ",&W ,&H, &x, &y, &r);
    if(x - r < 0 || y - r < 0 || y + r > H || x + r > W ){
        printf("No\n");
    }
    else{
    printf("Yes\n");}
    return 0;
}



Measured memory_bytes: 2676
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var charArr = Console.ReadLine().ToCharArray();
        
        bool IsExist7 = charArr.Any(c => c == '7'); 
        
        if (IsExist7){
           Console.WriteLine("Yes");
        }
        else{
           Console.WriteLine("No");  
        }
    }
}


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

int main() {
	int a,b;
	cin >> a >> b;
	if (a == 1) {
		if (b == 1) {
			cout << "Draw" << endl;	
		} else {
			cout << "Alice" << endl;
		}
	} else {
		if (b == 1) {
			cout << "Bob" << endl;	
		} else {
			if (a == b) {
				cout << "Draw" << endl;
			} else if (a > b) {
				cout << "Alice" << endl;
			} else {
				cout << "Bob" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    std::string s;
    in >> s;
    out((s.find('A') != std::string::npos && s.find('B') != std::string::npos) ? "Yes" : "No");
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define REP(i,n) for(long long int (i)=0;(i)<(n);i++)


using namespace std;


int main(){
  priority_queue<int,vector<int>,less<int>>Q;
  int n;
  REP(i,10){
    cin >> n;
    Q.push(n);
  }
  REP(i,3){ cout << Q.top()<<endl;Q.pop();
  }
  return 0;
}



Measured memory_bytes: 3124
n,x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1,n):
    if a[i] + a[i-1] > x:
        t = a[i] + a[i-1] - x
        ans += t
        if a[i] >= t:
            a[i] = a[i] - t
        else:
            a[i-1] -= (t-a[i])
            a[i] = 0
print(ans)


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

int main() {
  int K; cin >> K;
  if (K % 7 == 0) K /= 7;
  int ans =-1;
  int tmp = 1;
  for (int i =1; i<=K; i++) {
    tmp *= 10;
    if (tmp % (K * 9) == 1) {
      ans = i;
      break;
    } else {
      tmp %= K * 9;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
 
#define ll               long long int
#define llu              long long unsigned int
#define pb               push_back
#define ist              insert
#define mp               make_pair
 
#define dot(x)           fixed << setprecision(x)
#define full(x)          x.begin(), x.end()
#define remove(x, y)     x.erase(remove(x.begin(), x.end(), y), x.end())
#define iremove(x, y)    x.erase(x.begin() + y)
#define debug(x)         cout << #x << " = " << x << endl
#define debug2(x, y)     cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define fastIO           ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
 
#define MOD              (1000000007)
#define PI               (acos(-1.0)) //3.1415926535897932384626
#define EPS              (1e-7)
#define LOG(b, x)        (log(x)/log(b))
 
template <class T> T gcd(T a, T b){ if(a == 0) return b; return gcd(b%a, a); }
template <class T> T lcm(T a, T b){ return ((a*b)/gcd(a, b)); }

int main(){
 
    fastIO;
#ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
 
    int n;
    cin >> n;
    if(n) cout << 0 << endl;
    else cout << 1 << endl;

 
#ifndef ONLINE_JUDGE
    fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
#endif
 
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    int k = sc.nextInt();

    HashSet<String> uniqueSubStringSet = new HashSet<String>();
    for (int i = 0; i < s.length(); i++) {
      for (int j = 1; j <= k; j++) {
        uniqueSubStringSet.add(s.substring(i, Math.min(s.length(), i + j)));
      }
    }
    String[] uniqueSubStrings = uniqueSubStringSet.toArray(new String[0]);
    Arrays.sort(uniqueSubStrings);
    System.out.println(uniqueSubStrings[k - 1]);
  }
}


Measured memory_bytes: 25148
#include<bits/stdc++.h>
using namespace std;
#define M 1000000000
typedef long long int ll;

int main(){

	ll x, y = 100;
	cin >> x;
	for(int i = 0; ; i++){
		if(y >= x){
			cout << i << endl;
			return 0;
		}
		y = y*1.01;
	}

	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
string s;

int main () {
	cin >> s;
	n = sz (s);
	int ans = 0, cur = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] > '0') ans = max (ans, cur + s[i] - '1' + (n - i - 1) * 9);
		cur += s[i] - '0';
	}	
	ans = max (ans, cur);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

long long h, w, n, x[N * 3], y[N * 3], maxRow = 0, maxColumn = 0;

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> h >> w >> n;

    map<long long, long long> r, c;
    set<pair<long long, long long>> s;

    for(long long i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        s.insert({x[i], y[i]});
        r[x[i]]++, c[y[i]]++;
        maxRow = max(maxRow, r[x[i]]);
        maxColumn = max(maxColumn, c[y[i]]);
    }

    set<long long> xs, ys;
    for(long long i = 1; i <= n; i++){
        if(r[x[i]] == maxRow){
            xs.insert(x[i]);
        }
        if(c[y[i]] == maxColumn){
            ys.insert(y[i]);
        }
    }

    long long ans = maxRow + maxColumn - 1;
    for(auto row : xs){
        for(auto col : ys){
            if(!s.count({row, col})){
                ans++;
                return cout << ans, 0;
            }
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 92680
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N;
    cin >> N;
    double p[N];
    rep(i,N) cin >> p[i];
    double dp[N+1]={};
    double ans=0;
    dp[0]=1;
    rep(i,N) for(int j=N;j>0;j--) dp[j]+=dp[j-1]*p[i],dp[j-1]*=(1-p[i]);
    for(int i=(N+1)/2;i<=N;i++) ans+=dp[i];
    cout << ans << endl;
}

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

nonzero = [0]*60

for i in range(N):
    for j in range(60):
        tmp = (A[i] >> j) & 1
        if tmp != 0:
            nonzero[j] += 1

ans = 0
MOD = 10**9+7

for i in range(60):
    ans += ((N-nonzero[i])*nonzero[i]*(2**i))%MOD
    
print(ans%MOD)
    

Measured memory_bytes: 122808
# https://atcoder.jp/contests/abc116/tasks/abc116_b

a = s = gets.to_i
h = {}
i = 1
loop do
  if h[a]
    puts i
    break
  end
  h[a] = true
  a = a.even? ? a / 2 : a * 3 + 1
  i += 1
end



Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long


int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s1.begin(), s1.end());

    if(s1 == s2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)

int main(){
  int n;
  cin >> n;
  VS s(n);
  set<string> ans;
  REP(i,0,n){
    cin >> s[i];
    ans.insert(s[i]);
  }
  
  cout << ans.size() << endl;
  
  return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  for(int x = 1; x <= 100; x++) {
    for(int y = 1; y <= 100; y++) {
      for(int z = 1; z <= 100; z++) {
        int m = x*x + y*y + z*z + x*y + y*z + z*x;
        mp[m]++;
      }
    }
  }
  REP(i,n+1) {
    cout << mp[i] << endl;
  }
}

Measured memory_bytes: 5380
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
template <typename T>
int lcs(const T &seq1, const T &seq2) {
  const int seq1_sz = seq1.size(), seq2_sz = seq2.size();
  vector<vector<int> > dp(seq1_sz + 1, vector<int>(seq2_sz + 1, 0));
  REP(i, seq1_sz) REP(j, seq2_sz) {
    if (seq1[i] == seq2[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
    else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
  }
  return dp[seq1_sz][seq2_sz];
}

template <typename T>
T lcs2(const T &seq1, const T &seq2) {
  const int seq1_sz = seq1.size(), seq2_sz = seq2.size();
  vector<vector<int> > dp(seq1_sz + 1, vector<int>(seq2_sz + 1, 0));
  REP(i, seq1_sz) REP(j, seq2_sz) {
    if (seq1[i] == seq2[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
    else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
  }
  T res;
  int i = seq1_sz, j = seq2_sz;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) --i;
    else if (dp[i][j] == dp[i][j - 1]) --j;
    else {
      res.push_back(seq1[i - 1]);
      --i;
      --j;
    }
  }
  reverse(ALL(res));
  return res;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s, t; cin >> s >> t;
  if (s.size() & 1) {
    string ans = lcs2(s, t);
    int s_sz = s.size(), t_sz = t.size();
    vector<vector<int> > dp(s_sz + 1, vector<int>(t_sz + 1, 0));
    REP(i, s_sz) REP(j, t_sz) {
      if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
    }
    if (ans.size() != dp[s_sz][t_sz]) cout << "WA\n";
    else cout << ans << '\n';
  } else {
    int ans = lcs(s, t);
    int s_sz = s.size(), t_sz = t.size();
    vector<vector<int> > dp(s_sz + 1, vector<int>(t_sz + 1, 0));
    REP(i, s_sz) REP(j, t_sz) {
      if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
      else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
    }
    string res;
    int i = s_sz, j = t_sz;
    while (i > 0 && j > 0) {
      if (dp[i][j] == dp[i - 1][j]) --i;
      else if (dp[i][j] == dp[i][j - 1]) --j;
      else {
        res.push_back(s[i - 1]);
        --i;
        --j;
      }
    }
    if (res.size() != ans) cout << "WA\n";
    else {
      reverse(ALL(res));
      cout << res << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 35616
from fractions import gcd

N = int(input())
AAA = list(map(int, input().split()))

# DP
dp_l = [0] * (N + 1)
dp_r = [0] * (N + 1)
for i in range(1, N):
    dp_l[i] = gcd(dp_l[i - 1], AAA[i-1])
    dp_r[i] = gcd(dp_r[i-1], AAA[-i])

max_m = -1
for i in range(N+1):
    m = gcd(dp_l[i], dp_r[N-i-1])
    max_m = max(max_m, m)
print(max_m)


Measured memory_bytes: 16124
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
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;}


map<ll, vector<ll> > E;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N,M; cin >> N >> M ;
  
    
  rep(i,M){
    ll a, b; cin >> a >> b ;
    E[a].pb(b);
    E[b].pb(a);
  }
  
  rep(i,E[1].size()){
    ll now = E[1][i];
    rep(j,E[now].size()){
      if(E[now][j] == N){
	cout << "POSSIBLE" << endl;
	return 0;
      }
    }
  } 

  cout << "IMPOSSIBLE" << endl;
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 23656
#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 a, b, k;
    cin >> a >> b >> k;
    int val = min(a, b);
    vector<int> cnt;
    for (int i=1; i<=val; i++) {
        if (a % i == 0 && b % i == 0) {
            cnt.push_back(i);
        }
    }
    reverse(cnt.begin(), cnt.end());
    cout << cnt[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a); i >= (b); --i)
#define sz(a) int((a).size())
#define pconent(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef long double ld;
const ll MOD =  1e9 + 7;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(v) (cout<<v<<" ** "<<endl)
template <class T> inline void dbv(T a) { for(auto x : a){ cout<<x<<" ** " ;} cout<<endl;}
void output()
{
    ll n;
    cin>>n;
    vector<ll> a(n);
    FOR(i,0,n)
    {
        cin>>a[i];
    }
    vector<ll> xcum(n);
    vector<ll> scum(n);
    xcum[0] = a[0];
    scum[0] = a[0];
    FOR(i,1,n)
    {
        xcum[i] = xcum[i-1]^a[i];
        scum[i] = scum[i-1]+a[i];
    }
    xcum.pb(-LINF);
    scum.pb(LINF);
    ll ans = 0;
    FOR(i,0,n)
    {
        ll low = i;
        ll high = n+1;
        while(low<high)
        {
            ll mid = (low+high)/2;
            ll x,s;
            if(i==0)
            {
                x = xcum[mid];
                s = scum[mid];
            }
            else
            {
                x = xcum[mid]^xcum[i-1];
                s = scum[mid]-scum[i-1];
            }
            if(x<s)
            {
                high = mid;
            }
            else
            {
                low = mid+1;
            }
        }
        ans += (low-i);
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t =1;
    FOR(i,0,t)
    {
        output() ;
    }
    return 0 ;
}

Measured memory_bytes: 8036
from functools import reduce

def gcd_two(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def gcd(*numbers):
    return reduce(gcd_two, numbers)

#values
INF = 10**9

#input
N,X = map(int, input().split())
x_list = [int(i) for i in input().split()]

d_list = [abs(X-i) for i in x_list]
print(gcd(*d_list))

Measured memory_bytes: 14596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY
// memset(a,0,sizeof(a[0][0])*n*n); //2D array
//memset(a, 0, sizeof(a));  //1D array
//memset(str, 't', sizeof(str)); // string
void solve()
{
   ll k,n;cin>>k>>n;
   ll a[n];
   f(i,0,n) cin>>a[i];
sort(a,a+n);
   ll gap=0;
   f(i,1,n)
   {
   		if(a[i]-a[i-1]>gap)
   			gap=a[i]-a[i-1];
   } 
   if(a[0]+k-a[n-1]>gap) gap=a[0]+k-a[n-1];
   cout<<k-gap;
    
}


int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    while(t--)
    {
    
    solve();
    
    }

}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main {
    public static void main(String args[]) {
		 Scanner sc = new Scanner(System.in);
		 int k = sc.nextInt();
		 int n = sc.nextInt();
		 int iBefore = sc.nextInt();
		 int i0 = iBefore;
		 int max = Integer.MIN_VALUE;
		 int in = 0;
		 for (int j = 1; j<n ; j++) {
			in = sc.nextInt();
			max = Math.max(max,in - iBefore);
			iBefore = in;
		 }
		 System.out.println(k - Math.max(max,k - in + i0));
	}
}

Measured memory_bytes: 62504
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){

    string S;
    string T;

    cin >> S >> T;

    sort(S.begin(), S.end());
    sort(T.begin(), T.end(), greater<char>());

    bool fumiya = true;
    for(int i = 0; i < S.size(); i++){
        if(S.size() >= T.size()){
        if(S.at(i) < T.at(i)){
            break;
        }
        if(S.at(i) > T.at(i)){
            fumiya = false;
            break;
        }
        if(i == T.size() - 1){
            fumiya = false;
            break;
        }
        
        }
        if(S.size() < T.size()){
        if(S.at(i) < T.at(i)){
            break;
        }
        if(S.at(i) > T.at(i)){
            fumiya = false;
            break;
        }
        if(i == S.size() - 1){
            break;
        }            
        }
        
    }

    if(fumiya){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n;
    cin >> n;
    int a[n][3];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }
    int dp[n + 1][3];
    for(int i = 0; i < 3; i++){
        dp[0][i] = 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            int mx = 0;
            for(int k = 0; k < 3; k++){
                if(j == k){
                    continue;
                }
                if(mx <= dp[i][k]){
                    mx = dp[i][k];
                }
            }
            dp[i + 1][j] = mx + a[i][j];
        }
    }
    sort(dp[n], dp[n] + 3);
    cout << dp[n][2] << "\n";
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			
			String s = Integer.toBinaryString(n);
			boolean go =  true;
			for(int i=s.length();i>0;i--){
				String t = s.substring(i-1,i);
				if(t.compareTo("1")==0){
					if(go==false)System.out.print(" ");
					System.out.print((int)Math.pow(2,s.length()-i));
					go = false;
				}
			}
			System.out.println();
		}
	}	
}

Measured memory_bytes: 17236
/*
a ÷ b ： d (整数)
a ÷ b の余り ： r (整数)
a ÷ b ： f (浮動小数点数)
*/
#include <stdio.h>

int main(void)
{
    int a;
    int b;

    scanf("%d %d", &a, &b);

    printf("%d %d %.6f\n", a / b, a % b, a / (double)b);

    return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 1e5 + 10;
const int M = (int) 101;
const ll big =  (1LL << 51);
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int INF1 = (int) 1e9 + 3;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;

int n, m, k;

pii get(int x, int y) {
  if (y == 0) return mp(0, x);
  if (x == n) return mp(1, y);
  if (y == m) return mp(2, n - x);
  if (x == 0) return mp(3, m - y);
  return mp(-1, -1);
}

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    cin >> n >> m >> k;
    vector<pair<pii, int> > q;
    int sz = 0;
    while (k--) {
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      pii a = get(x1, y1), b = get(x2, y2);
      if (a > b)
        swap(a, b);
      if (a.f >= 0) {
        ++sz;
        q.push_back(mp(a, -sz));
        q.push_back(mp(b, sz));
      }
    }
    sort(all(q));
    stack<int> st;
    for (auto it : q) {
      //cout << it.f.f << ' ' << it.f.s < << endl;
      if (it.s < 0) {
        st.push(-it.s);
      } else {
        if (st.top() != it.s) {
          cout << "NO";
          return 0;
        }
        st.pop();
      }
    }
    cout << "YES";
    return 0;
}

Measured memory_bytes: 4724
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)

using namespace std;
int main() {

    int n;
     cin >> n;
     vector<int> p(n);
     rep(i, n) cin >> p[i];
     int k = 0;
     rep(i, n) if(p[i] != i + 1) k++;
     if(k <= 2) cout << "YES" << endl;
     else cout << "NO" << endl;
     return 0;
     }





Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

typedef long long ll;
const int N=101000;

ll s[N];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",s+i);
	ll x=2,y=2;
	bool flag=1;

	for(int i=n;i;i--)
	{
		x-=x%s[i];
		y+=((s[i]-y%s[i])%s[i]);

		x+=s[i]-1;

//		printf("%lld--%lld\n",y,x);

		if(x<y)
		{
			flag=0;
			break;
		}
		
	}

	if(!flag)printf("%d\n",-1);
	else printf("%lld %lld\n",y,x);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

void outputArray(int arr[], int n) {
    for (int i = 0; i < n; i++)
        if (i == n - 1) {
            cout << arr[i] << endl;
        } else {
            cout << arr[i] << " ";
        }
}

void bubble_sort(int A[], int N) {
    int temp, cnt = 0;
    int flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j > i; j--) {
            if (A[j] < A[j - 1]) {
                temp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = temp;
                flag = 1;
                cnt++;
            }
        }
    }

    outputArray(A, N);
    cout << cnt << endl;
}

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

    bubble_sort(array, n);

    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define debug(x) cerr<<"\tDEBUG: "<<#x<<" = "<<(x)<<endl
#define debug2(a,b) cerr<<#a<<"\t"<<#b<<" = "<<(b)<<endl
using namespace std;
const int maxn=2e5+100;
bool cur1;
int n,A[maxn];
int Max1[maxn],Max2[maxn];
bool cur2;
int main(){
//	double sz=&cur1-&cur2;
//	cout<<sz/1024/1024<<endl;
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&A[i]);
	for(int i=1;i<=n;i++){
		Max1[i]=max(Max1[i-1],A[i]);
	}
	for(int i=n;i>=1;i--){
		Max2[i]=max(Max2[i+1],A[i]);
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",max(Max1[i-1],Max2[i+1]));
	}
	return 0;
}

Measured memory_bytes: 3968
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  long long s;
  cin >> s;
  long long x2,y2,x3,y3;
  x2 = 1000000000;
  y2 = 1;
  x3 = s%1000000000;
  if(x3 != 0) x3 = -(x3 - 1000000000);
  y3 = (s+x3)/1000000000;
  cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by dezhonger on 2019/4/13
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        char[] c = new char[]{'0', '1'};
        int cc = 0;
        int count1 = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != c[cc]) {
                count1++;
            }
            cc = 1 - cc;
        }

        int count2 = 0;
        cc = 1;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != c[cc]) {
                count2++;
            }
            cc = 1 - cc;
        }
        System.out.println(Math.min(count1, count2));

    }
}


Measured memory_bytes: 27840
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,k;
cin>>n>>k;
vector<ll>v;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    v.pb(a);
}
vector<double>pre(n+1,0);
for(ll i=1;i<=n;i++)
{
    pre[i]=pre[i-1]+v[i-1];
}
double ans=0.0000;
for(ll i=k-1;i<n;i++)
{
    ll sum=pre[i+1]-pre[i+1-k];
    sum+=k;
    double x=sum/2.0;
    ans=max(ans,x);
}
cout<<fixed<<setprecision(10)<<ans<<endl;
return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ff first
#define ss second

using namespace std;
typedef pair <int, int> pii;

vector <pii> v;
vector <pii> ans;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  pii aup;
  int n, m;
  cin >> n >> m;
  v.resize(m);
  for(int i = 0; i < m; ++i)  cin >> v[i].ff >> v[i].ss;
  sort(v.begin(), v.end());
  ans.push_back(v[0]);
  for(int i = 1; i < v.size(); ++i){
    if(ans.size() && v[i].ff < min(v[i].ss, ans.back().ss)){
      aup = ans.back(), ans.pop_back();
      aup.ff = v[i].ff;
      aup.ss = min(aup.ss, v[i].ss);
      ans.push_back(aup);
    }
    else  ans.push_back(v[i]);
  }
  cout << ans.size() << "\n";

  return 0;
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    if (B <= A*N) {
        cout << B << endl;
    }
    else {
        cout << A*N << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b,t;
	scan(a>>b>>t);
	prin(t/a*b);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int X = stdIn.nextInt();
		if(X >= 30){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
		stdIn.close();
	}
}

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

int main() {
  int K, S;
  cin >> K >> S;
  ll ans = 0;
  rep(i, 0, K+1) rep(j, 0, K+1) {
    int z = S - i - j;
    if(z >= 0 && z <= K) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256