akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	int n;
	cin >> n;
	int x = 0, y = 0, t = 0;
	REP(i, n) {
		int tt, tx, ty;
		cin >> tt >> tx >> ty;
		int dis = abs(tx - x) + abs(ty - y);
		if (dis > tt-t || (dis + abs(tt - t)) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
		x = tx;
		y = ty;
		t = tt;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000
#define NIL -1

struct Node {
  int p,l,r;
};

struct Node T[MAX];

int n;
int D[MAX],H[MAX];

int main() {
  int i,v,l,r;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++) {
    T[i].p = NIL;
  }

  for(i = 0 ; i < n ; i++) {
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL )
      T[l].p = v;
    if ( r != NIL )
      T[r].p = v;
  }

  for (i = 0 ; i < n ; i++){
    D[i] = getDepth(i);
    H[i] = 0;
  }

  for (i = 0 ; i < n ; i++){
    if (T[i].l == NIL && T[i].r == NIL) {
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
        if (p == NIL)
          break;
        if (H[p] < c)
          H[p] = c;
        c++;
        p = T[p].p;
      }
    }
  }
  for (i = 0 ; i < n ; i++)
    print(i);
  return 0;
}


int getDepth(int x) {
  int d = 0;

  while(1) {
    x = T[x].p;
    if(x == NIL)
      break;
    d++;
  }
  return d;
}

int getSibling(int x) {
  if(T[x].p == NIL)
    return NIL;
  if(T[T[x].p].l != x && T[T[x].p].l != NIL)
    return T[T[x].p].l;
  if(T[T[x].p].r != x && T[T[x].p].r != NIL)
    return T[T[x].p].r;
  return NIL;
}

int print(int x){
  int degree = 0;

  printf("node %d: ", x);
  printf("parent = %d, ", T[x].p);
  printf("sibling = %d, ", getSibling(x));

  if ( T[x].l != NIL )
    degree++;
  if ( T[x].r != NIL )
    degree++;
  printf("degree = %d, ", degree);
  printf("depth = %d, ", D[x]);
  printf("height = %d, ", H[x]);

  if ( T[x].p == NIL ){
    printf("root\n");
  }
  else if ( T[x].l == NIL && T[x].r == NIL ){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}



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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    map<int,int>b;
    rep(i,n)b[a[i]]++;
    rep(i,n){
        if(a[i]==0&&b[a[i]]!=1){
            cout<<0<<endl;
            return 0;
        }
        if(a[i]!=0&&b[a[i]]!=2){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans=1;
    n/=2;
    while(n>0){
        ans*=2;
        ans%=MOD;
        n--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll calc(set<PL>&, ll);

void add(set<PL> &st, ll x, ll y){
    // cout << "add " << x << " " << y << endl;
    if (calc(st,x) <= y) return;
    auto itr = st.lower_bound(PL(x, y));
    while (itr != st.end()){
        // cout << itr->first << endl;
        if (itr->second - y >= itr->first - x){
            st.erase(itr++);
        }else{
            break;
        }
    }
    itr = st.lower_bound(PL(x,y));
    // cout << "ha" << endl;
    while (itr != st.begin()){
        itr--;
        // cout << itr->first << endl;
        if (itr->second - y >= x - itr->first){
            st.erase(itr);
        }else{
            break;
        }
        itr = st.lower_bound(PL(x,y));
    }
    st.insert(PL(x,y));
}

ll calc(set<PL> &st, ll x){
    auto itr = st.lower_bound(PL(x, 0));
    ll ret = 1e18;
    if (itr != st.end()){
        ret = min(ret, itr->second + itr->first - x);
    }
    if (itr != st.begin()){
        itr--;
        ret = min(ret, itr->second + x - itr->first);
    }
    return ret;
}

void out(set<PL> &st){
    for (PL p : st) cout << p.first << " " << p.second << endl;
    cout << endl;
}

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


    VL x(q);
    REP(i,q){
        scanf("%lld", &x[i]);
        x[i]--;
    }

    set<PL> st;
    st.insert(PL(a, abs(b - x[0])));
    add(st, b, abs(a - x[0]));


    ll sum = 0;
    FOR(i,1,q-1){
        ll d = abs(x[i-1] - x[i]);
        ll y = calc(st, x[i]) - d;
        // cout << y << endl;
        add(st, x[i-1], y);
        // out(st);
        sum += d;
    }

    ll mi = 1e18;
    for (PL p : st){
        mi = min(mi, p.second);
    }
    cout << sum + mi << endl;

    return 0;
}


Measured memory_bytes: 1792
A, B, C = (int(x) for x in input().split())
d = A*6

if C<d:
    if C%A == 0:
        print(C//A)
    if C%A > 0 :
        print(C//A+1)

if C>=d:
    D = A*7+B
    E = C%D
    F = C//D
    x = E//A
    y = E%A
    if x < 7 :
        if y == 0:
            print(F*7+x)
        if y > 0 :
            print(F*7+x+1)
    if x >= 7:
        print((F+1)*7)


Measured memory_bytes: 5604
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    string S,T,U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (U==S){
        A-=1;
    }
    else if (U==T){
        B-=1;
    }
    cout << A << " " << B;
    return 0;
}


Measured memory_bytes: 256
// Problem : D - Floor Function
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 3 * 1e6 + 2;

int a, b, n;

int solve(int i){
  return (a * i) / b - a * (i / b);
}

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> a >> b >> n;
  int res = solve(n);
  int cnt = 0;
  for(int i = b - 1; i <= n && cnt < 1000000; i += b){
    res = max(res, solve(i));
    ++cnt;
  }
  cout << res << '\n';

	return 0;
}






Measured memory_bytes: 3636
let readCharArray () = stdin.ReadLine().ToCharArray()
let choice ok ng bool = if bool then ok else ng

readCharArray ()
|> Array.indexed
|> Array.exists (fun (i, c) -> i % 2 = 0 && c = 'L' || i % 2 = 1 && c = 'R')
|> choice "No" "Yes"
|> printfn "%s"


Measured memory_bytes: 29540
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int A,B,M;
    cin>>A>>B>>M;
    vector<int> a(A);
    vector<int> b(B);
    vector<int> x(M);
    vector<int> y(M);
    vector<int> c(M);
    rep(i,A)    cin >> a[i];
    rep(i,B)    cin >> b[i];
    rep(i,M)    cin >> x[i] >> y[i] >> c[i];

    int ans=10000000;
    rep(i,M) {
        ans=min(a[x[i]-1]+b[y[i]-1]-c[i],ans);
    }

    sort(all(a));
    sort(all(b));
    ans=min(ans,a[0]+b[0]);

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

int main() {
    Int m, d;
    cin >> m >> d;
    Int cnt = 0;
    for (Int j = 1; j <= m; j++) {
        for (Int i = 1; i <= d; i++) {
            if (i / 10 < 2) continue;
            if (i % 10 < 2) continue;
            if ((i / 10) * (i % 10) == j) cnt++;
        }
    }
    dump(cnt);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		s string
	)
	fmt.Scan(&s)
	S := make([]string, 15)
	for _, ss := range s {
		switch ss {
		case 'B':
			S = S[:len(S)-1]
		default:
			S = append(S, string(ss))
		}
	}
	fmt.Println(strings.Join(S, ""))
}


Measured memory_bytes: 1836
#include<cstdio>

int main() {
	int n; scanf("%d", &n);
	
	int ma = 0, ans = 0;
	for(int i=1;i<=n;i++) {
		int x; scanf("%d", &x);
		if(x>=ma) {
			ans++;
			ma = x;
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
A = [int(x) for x in input().split()]
M = max(A)
cnt = 0
d = 0
for i in range(3):
  c = (M - A[i]) // 2
  cnt += c
  A[i] += 2 * c
  if A[i] != M:
    d += 1
cnt += (3 - d) % 3
print(cnt)

Measured memory_bytes: 3064
import sys
f = sys.stdin

# a1が左下、a2が右上とされている事がポイント
for line in f:
    xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 = map(float, line.split())
    print('NO'  if xb2 < xa1 or xa2 < xb1 or yb2 < ya1 or ya2 < yb1 else 'YES')

Measured memory_bytes: 6736
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int l[2][500][500];
bool c[2][500][500];
int memo[2][250001];

struct level{
  int l;
  int x;
  int y;
  level(int a,int b,int c){
    l=a; x=b; y=c;
  }
};

bool operator < (const level &a, const level &b){
  return a.l > b.l;
}

int main(){
  int r;
  while(r = getInt()){
    int w[2],h[2],x[2],y[2];
    REP(k,2){
      w[k] = getInt();
      h[k] = getInt();
      x[k] = getInt() - 1;
      y[k] = getInt() - 1;
      REP(i,h[k]) REP(j,w[k]){
        l[k][i][j] = getInt();
        c[k][i][j] = false;
      }

      priority_queue<level> pq;
      pq.push(level(1,x[k],y[k]));
      c[k][y[k]][x[k]] = true;

      int cnt = 0;
      int now = 1;

      memo[k][cnt++] = 0;
      while(!pq.empty()){
        level lv = pq.top();
        int ll = lv.l;
        int xx = lv.x;
        int yy = lv.y;
        pq.pop();
        //printf("%d %d %d\n",ll,xx,yy);

        memo[k][cnt++] = (now = max(ll, now));
        if(cnt == r+1) break;

        REP(i,4){
          int xxx = xx + _dx[i];
          int yyy = yy + _dy[i];

          if(ISIN(xxx,yyy,w[k],h[k]) && !c[k][yyy][xxx]){
            c[k][yyy][xxx] = true;
            pq.push(level(l[k][yyy][xxx], xxx, yyy));
          }
        }
      }

      //REP(i, w[k]*h[k]+1) printf("%d ",memo[k][i]); puts("");
    }

    int end = min(r, w[0] * h[0]) + 1;
    int start = max(0, r - w[1] * h[1]);
    int ans = INT_MAX;
    rep(i,start,end)
      ans = min(ans, memo[0][i] + memo[1][r-i]);
    print(ans);
  }

  return 0;
}

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

int main() {
    int a, b, c = 0;
    char pscode[50];
    scanf("%d %d", &a, &b);
    scanf("%s", &pscode);
    for (int i = 0; i < strlen(pscode); i++) {
        if (pscode[a] != '-') {
            printf("No");
            return 0;
        }
        if (pscode[i] >= '0' && pscode[i] <= '9') {
            c++;
        }
    }
    if (c != (a+b)) {
        printf("No");
        return 0;
    }
    printf("Yes");
}

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

int n, k, a[100005];

bool check(ll P) {
    int l = 0, r = n-1, cnt = 0;
    while (cnt < k && l < n) {
        int sum = 0;
        //while (sum + a[r] <= P && l <= r) sum += a[r--];
        while (sum + a[l] <= P && l < n) sum += a[l++];
        cnt++;
    }
    return cnt <= k && l > r;
}

void solve(){
    cin >> n >> k;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    //sort(a, a + n);
    ll l = 0, r = sum, res = sum;
    while (l <= r) {
        ll mid = (l + r) / 2;
        if (check(mid)) {
            r = mid - 1;
            res = mid;
        }
        else l = mid + 1;
    }
    cout << res << '\n';
}

int main() {
   
    solve();
}



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

int main(){
    ll n,res,sum=0;
    cin>>n;
    res = n;
    ll k = log10(n);
    while(n>0) {
        sum += n%10;
        n /= 10;
    }
    ll l = pow(10,k);
    ll c = res/l;
    if(sum == c+9*k) cout<<c+9*k;
    else cout<<c+9*k-1;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
    int n,x,y;
    cin>>n>>x>>y;x--;y--;
    vector<int>cnt(n);
    rep(i,n)rep(j,n)if(i<j)cnt[min(j-i,abs(x-i)+1+abs(y-j))]++;
    for(int i=1;i<n;i++)cout<<cnt[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N;
string S;

int main() {
    cin >> N >> S;
    if (N % 2) {
        cout << "No" << endl;
        return 0;
    }
    bool flag = true;
    for (int i = 0; i < N / 2; i++) {
        if (S[i] != S[N / 2 + i]) {
            flag = false;
            break;
        }
    }
    cout << (flag? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
N = int(input())
def factorization(n):
  a = n
  p = 2
  D = {}
  while a != 1:
    cnt = 0
    while a % p == 0:
      cnt += 1
      a //= p
    if cnt != 0:
      D[p] = cnt
    p += 1
    if p * p > n and a != 1:
      D[a] = 1
      break
  return D
DF = factorization(N-1)
DFF = factorization(N)
X = [[i, DFF[i]] for i in DFF]
cnt = 1
S = 1
for i in DF:
  S *= DF[i] + 1
if N != 2:
  cnt += S - 1
Y = 1
for i in X:
  Y *= i[1] + 1
n = len(X)
for k in range(1, Y):
  L = [0 for m in range(n)]
  tmp = k
  for m in range(n):
    L[m] = tmp % (X[m][1] + 1)
    tmp //= (X[m][1] + 1)
  Z = 1
  for m in range(n):
    Z *= X[m][0] ** L[m]
  M = N
  while M % Z == 0:
    M //= Z
  if M % Z == 1:
    cnt += 1
print(cnt-1)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int D, N;
    cin >> D >> N;
    int num = N;
    if(N != 100){
        for(int i = 0; i < D; i++){
            num *= 100;
        }
    }else{
        num++;
        for(int i = 0; i < D; i++){
            num *= 100;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
int a,b,ans=0,i;
scanf ("%d%d",&a,&b);
  for (i=a;i<b+1;i++){
  if (i/10000 == i%10){
    if ((i-((i/10000)*10000))/1000 == (i-((i/100)*100))/10){
    ans++;
    }
  }
  }
  printf ("%d",ans);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
	int S;
	cin >> S;
	int H = S / 100;
	int U = S - H * 100;
	if ((U==0 || U>12)&&(H==0 || H>12)) {
		cout << "NA" << endl;
	}
	else if (U == 0 || U > 12) {
		cout << "MMYY" << endl;
	}
	else if (H == 0 || H > 12) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "AMBIGUOUS" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <pair<int, int> > a(n);
	vector <pair<int, int> > b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i].first >> a[i].second;
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i].first >> b[i].second;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	set<int> y;
	int p = 0;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		while (p < n && a[p].first < b[i].first) {
			y.insert(a[p].second);
			p++;
		}
		set<int>::iterator it = y.lower_bound(b[i].second);
		if (it != y.begin()) {
			y.erase(--it);
			ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
  string s, t;
  cin>>s>>t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, k = map(int, input().split())

    ans = 0
    for i in range(k, n+2):
        l = (i-1) * i / 2
        u = (2*n-i+1) * i / 2
        ans += u - l + 1
        ans = ans % (10 ** 9 + 7)
    print(int(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10468
#include<stdio.h>
const int N=10000;

int main()
{
	int a[N]={0},n,maxn=-1000005,minn=1000005;
	long long sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>maxn)
		{
			maxn=a[i];
		}
		if(a[i]<minn)
		{
			minn=a[i];
		}
		sum+=a[i];
	}
	printf("%d %d %lld\n",minn,maxn,sum);
	
	return 0;
}


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

ans = 0
mod = 10**9 + 7


b = bin(max(A))

l = len(b) - 2


for j in range(l):
    tmp = 0
    for i in range(N):
        if (A[i] >> j) % 2 == 1:
            tmp += 1

    ans += (2**j) * tmp * (N-tmp)
    ans %= mod
print(ans)


Measured memory_bytes: 122808
#include <bits/stdc++.h>
 
#define int         long long
#define ll          long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
} 
void solve(){
    int n,k;
    cin >> n >> k;
    vector<int>v(n+5);
    FOR(i,1,n+1)cin >> v[i];
    FOR(i,k+1,n+1)if(v[i] > v[i-k])cout << "Yes\n";
    else cout << "No\n";
}
 
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 4820
#include "bits/stdc++.h" //template by Benq
using namespace std;

using ll = long long;
using ld = long double;

using pi = pair<int, int>;
using pl = pair<long long, long long>;
using pd = pair<long double, long double>;

using vi = vector<int>;
using vl = vector<long long>;
using vs = vector<string>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;
using vpd = vector<pair<double, double>>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define si(s) ((int)(s).size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rs resize
#define ins insert
#define nl "\n"
#define trav(i, x) for(auto& i: x)

const long long INF = 1e18;
const long double PI = acos((long double)-1);
const long long MOD = 998244353;

template<class A> void re(complex<A>& c);
template<class A, class B> void re(pair<A, B>& p);
template<class A> void re(vector<A>& v);
template<class A, size_t SZ> void re(array<A, SZ>& a);
 
template<class T> void re(T& x) { cin >> x; }
void re(double& d) { string t; re(t); d = stod(t); }
void re(long double& d) { string t; re(t); d = stold(t); }
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
 
template<class A> void re(complex<A>& c) { A a, b; re(a, b); c = {a, b}; }
template<class A, class B> void re(pair<A, B>& p) { re(p.first, p.second); }
template<class A> void re(vector<A>& x) { for(auto& i: x) re(i); }
template<class A, size_t SZ> void re(array<A, SZ>& x) { for(auto& i: x) re(i); }
 
void pr() {}
template <typename H, typename... T> 
void pr(H var1, T... var2) {
    cout << var1; 
    pr(var2...); 
}
void ps() { cout << nl; }
template<typename H, typename... T>
void ps(H var1, T... var2) {
	cout << var1 << ' ';
	ps(var2...);
}

void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a / (gcd(a, b)) * b); }
ll pow(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; }
void CowGoesMoo() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(20); }

int n, k;
vi a;

int main() {
	CowGoesMoo();
	
	re(n, k);
	a.rs(n);
	re(a);
	sort(all(a));
	int sum = 0;
	for(int i = 0; i < k; i++) {
		sum += a[i];
	}
	ps(sum);
}

Measured memory_bytes: 3604
#include <stdio.h>
int main(){
    int H[300], W[300], i, j, k;
    for (i=0; i<300; i++){
        scanf("%d%d", &H[i], &W[i]);
        if (H[i] == 0 && W[i] == 0){
            break;
        }
    }
    for (i=0; i<300; i++){
        if (H[i] == 0 && W[i] == 0){
            break;
        }
        for (k=0; k<H[i]; k++){
            for (j = 0; j < W[i]; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int mt[9] = {2,5,5,4,5,6,3,7,6};
int dp[10][10001];
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v(m);
    rep(i,m){cin>>v[i];}
    sort(v.begin(),v.end());
    rep(i,10){
        rep(j,10001){
            dp[i][j]=-100;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<m;i++){
        int mts=mt[v[i]-1];
        for(int j=0;j<10001;j++){
            dp[i+1][j]=dp[i][j];
            if(j-mts>=0){
                dp[i+1][j]=max(dp[i+1][j-mts]+1,dp[i+1][j]);
            }
        }
    }
   // rep(i,m+1){rep(j,n+1){cout<<dp[i][j]<<" ";}cout<<endl;}
    //cout<<dp[m][n]<<endl;
    
   
    int nn=n;int pos=m;
 //   cout<<mt[v[pos-1]-1];
    
    while(nn>0){
        while(true){
            if(nn-mt[v[pos-1]-1]>=0&&dp[pos][nn-mt[v[pos-1]-1]]+1==dp[pos][nn]&&pos>0){
                cout<<v[pos-1];
                nn-=mt[v[pos-1]-1];
            }else{
                break;
            }
        }
        pos--;
    }
    
    
    
    
return 0;
}


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

const long long INF = 1 << 60;

int main() {
    int n, k;
    while (cin >> n >> k) {
        if (n == 0 && k == 0) break;

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

        vector<long long> s(n + 1, 0);
        for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];

        long long ans = -INF;
        for (int i = 0; i < n - k + 1; i++) {
            ans = max(ans, s[k + i] - s[i]);
        } 

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


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

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    char c;
    cin >> c;

    print(c - 'A' <= 26 ? 'A' : 'a');
    
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int n;
double dp[301][301][301];

void output() {
    rep(i, n + 1) {
        cout << "i " << i << endl;
        rep(j, n + 1) {
            cout << "j " << j << endl;
            rep(k, n + 1) cout << dp[i][j][k] << " "; cout << endl;
        }
    }
}

int main() {
    cin >> n;
    
    int a = 0, b = 0, c = 0;
    rep(i, n) {
        int num;
        cin >> num;
        if (num == 3) a++;
        else if (num == 2) b++;
        else c++;
    }
    // cout << a << " " << b << " " << c << endl;
    
    rep(i, n + 1) rep(j, n + 1) rep(k, n + 1) {
        if (i == 0 && j == 0 && k == 0) continue;
        double res = 0;
        // 式変形した 自己ループ忘れないよう
        if (i) res = 1.0 * i * dp[i - 1][j + 1][k];
        if (j) res += 1.0 * j * dp[i][j - 1][k + 1];
        if (k) res += 1.0 * k * dp[i][j][k - 1];
        res += n;
        res /= (i + j + k);
        dp[i][j][k] = res;
        
        if (i == a && j == b && k == c) {
            cout << fixed << setprecision(10) << res << '\n';
            // output();
            return 0;
        }
    }
   
}



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

int main() {
  int l,r,d,ans = 0;
  cin >> l >> r >> d;
  rep(i,l,r+1) if(i%d == 0) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
int main() {
  int n, t, i, m=-1;
  std::cin>>n>>t;
  int tmp, c[n];
  for(i=0;i<n;++i) {
    std::cin>>c[i]>>tmp;
    m = (tmp<=t?m<0?i:c[i]<c[m]?i:m:m);
  }
  if(m < 0) {
    std::cout << "TLE" << "\n";
  }
  else {
    std::cout << c[m] << "\n";
  }
}


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

int main(){
  ll N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  int first = S[0] - '0';
  vector<ll> v;
  ll cnt = 1;
  if(first == 0) v.push_back(0);
  for(int i = 1; i < S.size(); ++i){
    if(S[i] == S[i-1]){
      cnt++;
    }else{
      v.push_back(cnt);
      cnt = 1;
    }
  }
  v.push_back(cnt);
  if(S.back() == '0') v.push_back(0);

  vector<ll> sums(v.size()+1, 0);
  for(int i = 0; i < v.size(); ++i){
    sums[i+1] = sums[i] + v[i];
  }

  ll res = 0;
  for(int left = 0; left < v.size(); left += 2){
    int right = left + 2 * K + 1;
    if(right > v.size()) right = v.size();
    res = max(res, sums[right] - sums[left]);
  }
  cout << res << endl;
  
}


Measured memory_bytes: 2164
def main():
    N , M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))

    al = [0]
    bl = [0]

    for i in range(N) :
        al.append(al[i] + A_list[i])
    for i in range(M) :
        bl.append(bl[i] + B_list[i])
    #print("al = %s" % al)
    #print("bl = %s" % bl)
    book = 0
    re = M

    for i in range(N+1) :
        if al[i] > K :
            break
        #for j in range(M+1) :
        #    if bl[re] <= K - al[i] :
        #        break
        #    else :
        #        re -= 1
        while bl[re] > K - al[i] :
            re -= 1

        book = max(book, i + re)

    print(book)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48936
#include "bits/stdc++.h"
using namespace std;

struct edge { int to, cap, rev; };

vector<edge> G[210];
int level[210];
int iter[210];
int INF = 10000000;

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

void add_multi_edge(int v1, int v2, int cap) {
	G[v1].push_back({ v2, cap, (int)G[v2].size() });
	G[v2].push_back({ v1, cap, (int)G[v1].size() - 1 });
}

void BFS(int S) {
	memset(level, -1, sizeof(level));
	queue<int> Q;
	level[S] = 0;
	Q.push(S);
	while (!Q.empty()) {
		int V = Q.front(); Q.pop();
		for (edge E : G[V]) {
			if (E.cap > 0 && level[E.to] < 0) {
				level[E.to] = level[V] + 1;
				Q.push(E.to);
			}
		}
	}
}

int DFS(int V, int T, int F) {
	if (V == T) return F;
	for (int& i = iter[V]; i < G[V].size(); i++) {
		edge& E = G[V][i];
		if (E.cap > 0 && level[V] < level[E.to]) {
			int D = DFS(E.to, T, min(F, E.cap));
			if (D > 0) {
				E.cap -= D;
				G[E.to][E.rev].cap += D;
				return D;
			}
		}
	}
	return 0;
}

int max_flow(int S, int T) {
	int flow = 0;
	while (1) {
		BFS(S);
		if (level[T] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		int F;
		while ((F = DFS(S, T, INF)) > 0) {
			flow += F;
		}
	}
}

int main() {
	string S[100];
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == 'S') {
				add_edge(200, i, INF);
				add_edge(200, j + 100, INF);
			}
			if (S[i][j] == 'T') {
				add_edge(i, 201, INF);
				add_edge(j + 100, 201, INF);
			}
			if (S[i][j] == 'o') {
				add_multi_edge(i, j + 100, 1);
			}
		}
	}
	int ANS = max_flow(200, 201);
	if (ANS >= INF) cout << -1 << endl;
	else cout << ANS << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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;

#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()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,x;
    cin >> n >> x;
    ll a[n+1];
    F0R(i,n) cin >> a[i];
    a[n] = x;
    sort(a,a+n+1);
    ll temp = a[0];
    F0R(i,n+1) a[i] -= temp;

    ll d = 0;
    FOR(i,1,n+1){
      d = __gcd(d,a[i]);
    }
    cout << d<<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 1024
solve :: String -> String -> Int -> Int 
solve [] _ ans                 = ans
solve s@(sh:sx) t@(th:tx) ans  = solve sx tx newAns
  where newAns = ans + if sh == th then 0 else 1

main :: IO ()
main = do 
 s <- getLine :: IO String
 t <- getLine :: IO String
 print $ solve s t 0

Measured memory_bytes: 20028
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool mtrx[3][3];
	ll m[3][3];
	rep(i,3)rep(j,3)mtrx[i][j]=false;
	rep(i,3)rep(j,3)cin>>m[i][j];
	ll n;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	rep(i,n){
		rep(j,3)rep(k,3){
			if(m[j][k]==v[i])mtrx[j][k]=true;
		}
	}
	bool ans=false;
	rep(i,3){
		bool bingo=true;
		rep(j,3)bingo&=mtrx[i][j];
		ans|=bingo;
	}
	rep(j,3){
		bool bingo=true;
		rep(i,3)bingo&=mtrx[i][j];
		ans|=bingo;
	}
	ans|=(mtrx[0][0]&&mtrx[1][1]&&mtrx[2][2]);
	ans|=(mtrx[0][2]&&mtrx[1][1]&&mtrx[2][0]);
	
	Yn(ans);
}


Measured memory_bytes: 256
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make2(ll,r,g);
    make2(ll,b,n);
    ll ans=0;
    for(ll i=0;i<=n/r;i++){
        for(ll j=0;j<=(n-i*(r))/b;j++){
            if(n-i*r-j*b>=0 &&(n-i*r-j*b)%g==0) ans++;
        }
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
long long  n,m;
const int N = 1e9+5;
int main() {
	IO
	cin>>n;
	m=n%10;
    if(m==3)
    {
        cout<<"bon"<<endl;
    }else if(m==0||m==1||m==6||m==8)
    {
        cout<<"pon"<<endl;
    }
    else
        cout<<"hon"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int x;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a > b) {
		x = b;
		b = a;
		a = x;
	}
	
	if (b > c) {
		x = c;
		c = b;
		b = x;
	}
	
	if (a > b) {
		x = b;
		b = a;
		a = x;
	}
	
	printf("%d %d %d\n", a, b, c);
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

    std::vector<int> values;

    for (int n = 0; n < N; ++n) {
        int value;
        std::cin >> value;
        values.push_back(value);
    }

    std::sort(values.begin(),values.end(),std::greater<int>());

    int buf = 114514;
    int count = 0;
    for(auto v : values){
        if(buf > v){
            ++count;
        }
        buf = v;
    }

    std::cout << count << std::endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();


      if ((a < 10) && (b < 10)) {
         System.out.println(a*b);
      }
      else {
         System.out.println(-1);
      }
   }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<double >    vecd;
typedef vector<vector<int> >  vec2int;
typedef vector<vector<double> >  vec2d;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<vector< bool > > vec2bool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  int n; cin >> n;
  vecint a(n,0);
  REP(i,n) cin >> a[i];
  int i = 0;
  vecint v;
  REP(i,n){
    int cnt = 1;
    while(i < n - 1&&a[i] == a[i + 1]){
      i ++;
      cnt ++;
    }
    v.push_back(cnt);
  }
  int ans = 0;
  REP(i,v.size()){
    ans += v[i]/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll n, sum = 0;
  cin >> n;
  vll a(n+2, 0);
  for (ll i = 1; i <= n+1; i++) {
    if (i <= n) cin >> a[i];
    sum += abs(a[i]-a[i-1]);
  }
  
  for (ll i = 1; i <= n; i++) {
    cout << sum + abs(a[i+1]-a[i-1]) - abs(a[i+1]-a[i]) - abs(a[i]-a[i-1]) << endl;
  }
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve(long long a, long long b){
  if((a*b)%2){
    std::cout << "Odd" << std::endl;
  }else{
    std::cout << "Even" << std::endl;
  }
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


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

int main() {
  int N,K;
  cin >> N >> K;
  
  int total = 0;
  for( int i = 0; i < N; i++ ){
    int x;
    cin >> x;
    
    if( ( K - x ) < x ){
      total += ( K - x ) * 2;
    }else{
      total += x * 2;
    }
  }
  cout << total << endl;
  
  
}

Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map(&:to_i)

job = []

for i in 1..n do
    job.push(gets.chomp.split(" ").map(&:to_i))
end
job.sort! {|a,b| (a[0] <=> b[0]).nonzero? || (b[0] <=> a[0])}

# p job

sum = 0
stack = []
for i in 1..m do
    if ! job.empty?
        while job[0][0] <= i
            tar = job.shift
            if stack.empty?
                stack.push(tar)
            else
                head = 0
                tail = stack.size-1
                mid = ((head+tail)/2.0).ceil
                while head <= tail
                    if tar[1] == stack[mid][1]
                        break
                    elsif tar[1] < stack[mid][1]
                        head = mid + 1
                    else
                        tail = mid - 1
                    end
                    mid = ((head+tail)/2.0).ceil
                end
                if mid > stack.size
                    stack.push(tar)
                else 
                    stack.insert(mid,tar)
                end
            end
            if job.empty?
                break
            end
        end
    end
    if ! stack.empty?
        tar = stack.shift
        sum += tar[1]
    end
    # print i," ", stack,"\n"
end

p sum

Measured memory_bytes: 14660
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X,Y,ans=0;
    cin>>X>>Y;
    
    for(ll i=1;i*X<=Y;i=(i<<1)) ++ans;

    put(ans);
}

Measured memory_bytes: 256
N = int(input())

score = []
ans = 0
for _ in range(N):
    s = int(input())
    ans += s
    score.append(s)

if ans % 10 == 0:
    score.sort()
    for s in score:
        if s % 10 != 0:
            ans -= s
            break
    else:
        ans = 0

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N; 
    cin >> N;
    vector<int> vec(N);
    vector<int> ans;
    
    for(int i = 0; i < N; ++i)
      cin >> vec[i];
    
    sort(vec.begin(), vec.end());
    
    int last;
    for(int i = 0; i < N; ++i)
    {
        if(ans.size() == 0 || last != vec[i])
        {
            last = vec[i];
            ans.push_back(vec[i]);
        }
    }
    
    for(int i = 0; i < ans.size(); ++i)
      cout << (i == 0 ? "" : " ") << ans[i];
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3728