akhauriyash/Code-Regression huggingface dataset:
from collections import namedtuple
Card = namedtuple('Card', 'suit value')

def partition(A,p,r):
    x = A[r]
    i = p
    for j in range(p,r):
        if A[j].value <= x.value:
            A[i],A[j] = A[j],A[i]
            i += 1
    A[i],A[r] = A[r],A[i]
    return i

def quickSort(A,p,r):
    if p < r:
        q = partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)

def isStable(Co,Cs):
    C = Cs[:]
    for ci in Co:
        j = C.index(ci)
        if j > 0:
            if Cs[j-1].value == ci.value:
                return False
        del C[j]
    return True

if __name__=='__main__':
    n = int(input()) 
    Co = list(map(lambda X: Card(X[0],int(X[1])), [input().split() for _ in range(n)]))
    Cs = Co[:]
    quickSort(Cs,0,n-1)
    print("Stable" if isStable(Co,Cs) else "Not stable")
    for c in Cs: print(c.suit,c.value)

Measured memory_bytes: 42572
def main():
    n = int(input())
    b = list(map(int, input().split()))

    a = [0]*n

    for i,e in enumerate(b):
        if i == 0:
            a[0] = b[0]
        else:
            a[i] = min(b[i-1], b[i])

    a[-1] = b[-1]
            # if a[i] >= a[i+1] and e <= b[i-1]:
            #     a[i] = e
            # else:
            #     a[i+1] = e

    print(sum(a))

if __name__ == '__main__':
    main()

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

int main()
{
	int a;
	cin >> a;
	int k;
	cin >> k;
	string n;
	cin >> n;
	if(n[k-1]=='A')
	{
		n[k-1]='a';
	}else if(n[k-1]=='B')
	{
		n[k-1]='b';
	}else if(n[k-1]=='C')
	{
		n[k-1]='c';
	}
	cout << n << endl;

	
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

class LCA {
private:
  const int n = 0;
  const int log2_n = 0;
  VVI par;
  vector<vector<PII>> g;
  VI depth, d;

  // parとdを構築する
  void dfs(int v, int p, int dist, int n_depth) {
    par[0][v] = p; d[v] = dist; depth[v] = n_depth;
    for (auto e : g[v]) {
      if (e.first != p) dfs(e.first, v, dist + e.second, n_depth+1);
    }
  }

public:
  LCA(int n_=1e5) :
    n(n_), log2_n(log2(n)+1), par(log2_n, VI(n)), g(n, vector<PII>()), depth(n), d(n) {}
  // u-vに重みcostの辺を張る
  void add_edge(int u, int v, int cost) { g[u].PB({v, cost}); g[v].PB({u, cost}); }
  // rootを根としてparとdを構築
  void build(int root = 0) {
    dfs(root, -1, 0, 0);
    REP(k, log2_n-1) {
      REP(v, n) {
        if(par[k][v] < 0) par[k+1][v] = -1;
        else par[k+1][v] = par[k][par[k][v]];
      }
    }
  }
  // uとvのlcaを返す
  int get(int u, int v) {
    if (depth[u] > depth[v]) std::swap(u, v);
    for (int k = 0; k < log2_n; k++) {
      if ((depth[v] - depth[u]) >> k & 1) {
        v = par[k][v];
      }
    }
    if (u == v) return u;
    for (int k = log2_n - 1; k >= 0; k--) {
      if (par[k][u] != par[k][v]) {
        u = par[k][u];
        v = par[k][v];
      }
    }
    return par[0][u];
  }
  // uとvの距離を返す
  int length(int u, int v) {
    int lca = get(u, v);
    return d[u] + d[v] - 2*d[lca];
  }
  void debug() {
    cout << depth << endl << d << endl;
  }
};

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

  int n;
  cin >> n;
  LCA graph(n);
  REP(i, n-1) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    graph.add_edge(a, b, c);
  }
  graph.build();
  // graph.debug();
  int q, k;
  cin >> q >> k; k--;
  REP(i, q) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    cout << graph.length(a, k) + graph.length(b, k) << endl;
  }

  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll cnt = 0;
    REP(a,1,N+1) {
        REP(b,1,(N+1)/a+1) {
            if(N - a * b > 0) ++cnt;
        }
    }
    PR(cnt);


    return 0;
}

/*



*/

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >>n;

  bool kanoukadouka=true;
  ll h[n];
  for(int i=0;i<n;i++)cin >>h[i];
  
  for(int i=n-2;i>=0;i--){
    if(h[i]<=h[i+1]);
    else if(h[i]==h[i+1]+1){
      h[i]=h[i+1];
    }
    else{
      kanoukadouka=false;
      break;
    }
  }

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


}

Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,x=0;
    cin>>n;
    double i=1;
    for(i=1;i<=50000;i++) if(int(i*1.08)==n) x=i;
    if(x==0) cout<<":(";
    else cout<<x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
void exgcd(int a, int b, int &x, int &y) {
	if (b == 0) {
		x = 1, y = 0;
		return;
	}
	int q = a / b, r = a % b;
	exgcd(b, r, y, x);
	y -= q * x;
}
int inv(int x, int p) {
	int a = 0, b = 0;
	exgcd(x, p, a, b);
	return (a % p + p) % p;
}
struct info {int x, y, c; } q[MAXN];
int top, a, b, c, x, y;
void work(int c, int d){
	q[top = 0] = (info) {0, 0, 0};
	int x, a = 1, b = 0;
	while (d != 0) {
		info tmp = q[top];
		q[++top] = (info) {tmp.x + c / d * a, tmp.y + c / d * d, c / d};
		for (int t = 1; t <= 2 && d != 0; t++){
			if (t == 1) b += c / d * a;
			else a += c / d * b;
			x = c % d, c = d, d = x;
		}
	}
}
ll func(ll x, ll y) {
	if (x < 0) return -1;
	else return x / y;
}
int main() {
	int T; read(T);
	while (T--) {
		read(a), read(x), read(b), read(y), read(c);
		int g = __gcd(a, b); a /= g, b /= g, c /= __gcd(c, g);
		g = __gcd(a, c), a /= g, c /= g, y /= g;
		g = __gcd(b, c), b /= g, c /= g, x /= g;
		a %= c, b %= c;
		if (c == 1) {
			printf("%d\n", x + y);
			continue;
		}
		int d = 1ll * a * inv(b, c) % c; work(c, d);
		if (q[top].x != c) q[++top] = (info) {c, c, 1};
		int ans = 0;
		for (int i = 1; i <= top; i++) {
			int lx = q[i - 1].x, rx = q[i].x;
			int ly = c - q[i - 1].y, ry = c - q[i].y;
			int dx = (rx - lx) / q[i].c, dy = (ly - ry) / q[i].c;
			int l = ans + 1, r = x + y;
			while (l <= r) {
				int mid = (0ll + l + r) / 2;
				ll s = func(x - 1ll * mid * lx, dx);
				ll t = func(y - 1ll * mid * ry, dy);
				if (s >= 0 && t >= 0 && s + t >= 1ll * q[i].c * mid) ans = mid, l = mid + 1;
				else r = mid - 1;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		boolean j = false;

if(A < C && B > C) {
	j= true;
}

if(A > C && B < C) {
	j = true;
}

if(j) {
	System.out.println("Yes");
}else {
	System.out.println("No");
}

	}

}


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

int main(){
    ll a,b,n;
    cin >> a >> b;
    vector<ll> vec(n);
    if(a>9||b>9){
        cout << "-1" << endl;
    }else{
        cout << a*b << endl;
    }

    return 0;
}

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

#define N 8
#define FREE -1
#define N_FREE 1

int Row[N], Col[N], dpos[2*N-1], dneg[2*N-1];

bool x[N][N];

void Initialize(){
  for(int i=0; i<N; i++)
  {
    Row[i]=FREE, Col[i]=FREE;
  }
  for(int i=0; i<2*N-1; i++)
  {
    dpos[i]=FREE; dneg[i]=FREE;
  }
}

void printBoard(){
  for(int i=0; i<N; i++)
  {
    for(int j=0; j<N; j++)
    {
      if(x[i][j])
      {
        if(Row[i] != j)
          return;
      }
    }
  }
  for(int i=0; i<N; i++)
  {
    for(int j=0; j<N; j++)
    {
      cout << ((Row[i] == j) ? "Q" : ".");
    }
    cout << endl;
  }
}

void recursive(int i){
  if(i == N){
    printBoard();
    return;
  }

  for(int j=0; j<N; j++)
  {
    if(N_FREE == Col[j] ||
       N_FREE == dpos[i+j] ||
       N_FREE == dneg[i-j+N-1])
      continue;

    Row[i]=j;
    Col[j]=dpos[i+j]=dneg[i-j+N-1]=N_FREE;
    recursive(i+1);
    Row[i]=Col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  Initialize();

  for(int i=0; i<N; i++)
  {
    for(int j=0; j<N; j++)
    {
      x[i][j]=false;
    }
  }

  int k;
  cin >> k;

  for(int i=0; i<k; i++)
  {
    int r, c;
    cin >> r >> c;
    x[r][c]=true;
  }

  recursive(0);

  return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    set<char> s;
    rep(i, n){
        char c; cin >> c;
        s.insert(c);
    }

    int sz = s.size();
    cout << (sz == 4 ? "Four":"Three") << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
from itertools import groupby

def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(str(input()))

    freqs = groupby(Counter(l).most_common(), lambda x:x[1])
    d = [val for val,count in next(freqs)[1]]
    d.sort()
    for i in d:
        print(i)

main()

Measured memory_bytes: 45032
/*キュー*/

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

struct Process{
    string name;
    int time;
};

class Queue{
    int head;
    int tail;
    Process a[100000];
    int n;
public:
    Queue(int num) {
        head = 0;
        tail=0;
        n = num;
    }
    bool isEmpty(){
        if(head == tail){
            return true;
        }
        else{
            return false;
        }
    }
    void enq(Process p){  
        if(tail == n+1){
            tail = 0;
        }   
        a[tail++] = p;
    }

    Process deq(){
        if(head == n+1){
            head = 0;
        }
        return a[head++];
    }
};

int main()
{
    int n, t;
    cin >> n >> t;

    Process p;
    Queue q(n);
    rep(i, n){
        cin >> p.name >> p.time;
        q.enq(p);
    }

    int now_time = 0;
    while(!q.isEmpty()){
        Process tmp = q.deq();
        if(tmp.time > t){
            tmp.time -= t;
            q.enq(tmp);
            now_time += t;
        }
        else{
            now_time += tmp.time;
            cout << tmp.name << " " << now_time << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 7036
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, a[1000][999], p[1000];
set<int> in[1000], w, fin;

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, n - 1) {
		cin >> a[i][j];
		a[i][j]--;
	}
	}
	
	inc(i, n) { w.insert(i); }
	int ans = -1;
	inc(i, n * n) {
		if(SI(fin) == n) { ans = i; break; }
		
		RF(e, w) { in[a[e][p[e]]].insert(e); }
		
		set<int> nex;
		RF(e, w) {
			if(in[e].count(a[e][p[e]]) == 1) {
				nex.insert(e);
				nex.insert(a[e][p[e]]);
			}
		}
		
		w.clear();
		RF(e, nex) {
			in[e].erase(a[e][p[e]]);
			p[e]++;
			if(p[e] < n - 1) { w.insert(e); } else { fin.insert(e); }
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Set<String> said = new HashSet<>();
    String w0 = sc.next();
    char nextHead = w0.charAt(w0.length()-1);
    said.add(w0);
    for (int i = 0; i < N-1; i++) {
      String w = sc.next();
      if (w.charAt(0) != nextHead || !said.add(w)) {
        System.out.println("No");
        return;
      }
      nextHead = w.charAt(w.length()-1);
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main() {
	ll n,x; cin>>n>>x;
	VL s(n); rep(i,n) cin>>s[i]; sort(ALL(s));
	VVL dp(n+1,VL(x+1,0LL));
	rep(i,x+1) dp[0][i]=i;
	rep(i,n){
		rep(j,x+1){
			dp[i+1][j]+=dp[i][j%s[i]]; dp[i+1][j]%=MOD;
			dp[i+1][j]+=dp[i][j]*i%MOD; dp[i+1][j]%=MOD;
		}
	}
	cout<<dp[n][x]<<endl;
	return 0;
}


Measured memory_bytes: 158592
int main() {
	int a, b, c;
	int k;
	scanf("%d" "%d" "%d", &a, &b, &c);
	scanf("%d", &k);
	for (int i = 0; i < k; i++) {
		if (a >= c) {
			c *= 2;
			continue;
		}
		if (a >= b) {
			b *= 2;
			continue;
		}
		if (b >= c) {
			c *= 2;
			continue;
		}
	}
	if (a < b && b < c)
		printf("Yes");
	else printf("No");
	
	
	return 0;
}

Measured memory_bytes: 1696
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  n     <- readLn :: IO Int
  [t,a] <- map (1000*) .map (read::String->Int) . words <$> getLine
  hs    <- map (read::String->Int) . words <$> getLine
  let tmps = map (abs .(a-) .(t-) .(*6)) hs
  print $ fst $minimumBy (comparing snd) $zip [1..n] tmps

Measured memory_bytes: 5100
//written by: rishav2416
#include <bits/stdc++.h>
#define ll long  long
#define lli long long int
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define arrinit(arr,n,k) for(ll c1=0;c1<n;c1++) arr[i]=k;
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define revrep(i,a,n) for(ll i=a; i>=n ; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define INF 1e18a



ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}


std::string str="All Good Till Here";

/////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    fastio
	ll tt,i,j,x;
	//cin>>tt;
  tt=1;
    cin>>x;
    rep(i,-120,121)
    {
      rep(j,-121,121)
      {
        if((ll)(pow(i,5)-pow(j,5))==x)
        {
          cout<<i<<" "<<j<<"\n";
          return 0;
        }
      }
    }

}


Measured memory_bytes: 4036
alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", 
            "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] * 2

n = int(input())
string = input()

output = ''
for s in string:
    for i in range(26):
        if alphabet[i] == s:
            output += alphabet[i + n]

print(output)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC113
{
    class Program
    {
        static int n, t, a, ans;
        static int[] h;
        static void Main(string[] args)
        {
            Place();
            
        }
       static void Place()
        {
            n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();
            t = int.Parse(input[0]);
            a = int.Parse(input[1]);
            h = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
            
            double dmin = 1000000000d;
            

            for (int i = 0; i < n; i++)
            {
                var dtmp = Math.Abs(a - (t - 0.006 * h[i]));
                if (dmin > dtmp)
                {
                    dmin = dtmp;
                    ans = i;
                }
            }
            Console.WriteLine(ans+1);
        }
    }
    
}



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

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

  int n, k;
  string s;
  cin >> n >> k;
  vector<string>v;
  for(int i = 0; i < n; ++i){
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end());
  for(auto ss: v)cout << ss;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> t(n+1, 0);
    vector<int> x(n+1, 0);
    vector<int> y(n+1, 0);
    for(int i = 1; i < n+1; ++i) {
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }

    bool flg = true;
    for(int i = 1; i < n+1; ++i) {
        int rest = t.at(i) - t.at(i-1);
        int len = abs(x.at(i)-x.at(i-1)) + abs(y.at(i)-y.at(i-1));
        if(rest < len) {
            flg = false;
            break;
        }else {
            if((rest-len) % 2 != 0) {
                flg = false;
                break;
            }
        }
    }

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

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

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

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

    // start
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    // end

    return 0;
}


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

int main (){
  
  int K;
  cin>>K;
  
  if(K==1) cout<<1<<endl;
  else if(K==2) cout<<1<<endl;
  else if(K==3) cout<<1<<endl;
  else if(K==4) cout<<2<<endl;
  else if(K==5) cout<<1<<endl;
  else if(K==6) cout<<2<<endl;
  else if(K==7) cout<<1<<endl;
  else if(K==8) cout<<5<<endl;
  else if(K==9) cout<<2<<endl;
  else if(K==10) cout<<2<<endl;
  else if(K==11) cout<<1<<endl;
  else if(K==12) cout<<5<<endl;
  else if(K==13) cout<<1<<endl;
  else if(K==14) cout<<2<<endl;
  else if(K==15) cout<<1<<endl;
  else if(K==16) cout<<14<<endl;
  else if(K==17) cout<<1<<endl;
  else if(K==18) cout<<5<<endl;
  else if(K==19) cout<<1<<endl;
  else if(K==20) cout<<5<<endl;
  else if(K==21) cout<<2<<endl;
  else if(K==22) cout<<2<<endl;
  else if(K==23) cout<<1<<endl;
  else if(K==24) cout<<15<<endl;
  else if(K==25) cout<<2<<endl;
  else if(K==26) cout<<2<<endl;
  else if(K==27) cout<<5<<endl;
  else if(K==28) cout<<4<<endl;
  else if(K==29) cout<<1<<endl;
  else if(K==30) cout<<4<<endl;
  else if(K==31) cout<<1<<endl;
  else  cout<<51<<endl;
  
  return 0;
  
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(m)]

ab.sort(key=lambda x: x[1])

bridge = ab[0][1] - 1
ans = 1
for i in range(m):
    s, t = ab[i][0], ab[i][1]
    if bridge < s:
        bridge = t - 1
        ans += 1

print(ans)

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    const ll mod=1000000007;
    int n;
    cin >> n;
    map<array<ll,2>,vector<int>> m;
    vector<array<ll,2>> v(n+1,{0,0});
    vector<ll> p(n+1,1);
    for(int i=1;i<=n;i++) p[i]=(2*p[i-1])%mod;
    ll one=0,two=0;
    vector<bool> vis(n+1,0);
    ll zero=0;
    for(int i=1;i<=n;i++)
    {
        ll a,b;
        cin >> a >> b;
        ll g=gcd(a,b);
        if(g>0)
        {
            a/=g;
            b/=g;
        }
        if(a==0&&b==0) zero++;
        else if(a==0&&b!=0) one++;
        else if(a!=0&&b==0) two++;
        else if(a!=0&&b!=0) m[{a,b}].push_back(i);
        if(a==0||b==0) vis[i]=1;
        v[i]={a,b};
    }
    ll res=(p[one]+p[two]-1+mod)%mod;
    auto rm=[&](ll a,ll b)->ll
    {
        for(int x:m[{a,b}]) vis[x]=1;
        return m[{a,b}].size();
    };
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==1) continue;
        auto [a,b]=v[i];
        one=rm(a,b)+rm(-a,-b);
        two=rm(-b,a)+rm(b,-a);
        res=(res*(p[one]+p[two]-1+mod))%mod;
    }
    res=(res-1+zero+mod)%mod;
    cout << res << "\n";
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

struct Edge {
	int v, s, p;
	double t;
	int d, c;
	
	Edge(int v_, int s_, int p_, double t_, int d_ = 0, int c_ = 0)
	: v(v_), s(s_), p(p_), t(t_), d(d_), c(c_) {}
	
	bool operator > (const Edge& e) const { return t > e.t; }
};

int n, m, s, g;
vector< vector< Edge > > edges;

void solve() {
	double time[33][33][33];
	for_(i,0,33) for_(j,0,33) for_(k,0,33) time[i][j][k] = 1e9;
	
	priority_queue< Edge, vector< Edge >, greater< Edge > > q;
	q.push(Edge(s, 0, 0, 0));
	time[s][0][0] = 0;
	
	while (!q.empty()) {
		Edge e = q.top(); q.pop();
		
		if (time[e.v][e.s][e.p] < e.t) continue;
		
		for_(i,0,(int)edges[e.v].size()) {
			Edge ei = edges[e.v][i];
			
			if (ei.v != e.p) {
				for_(d,-1,2) {
					int ns = e.s + d;
					
					if (ns > 0 && ei.c >= ns) {
						double nt = e.t + (double)ei.d / (double)ns;
						if (time[ei.v][ns][e.v] > nt) {
							time[ei.v][ns][e.v] = nt;
							q.push(Edge(ei.v, ns, e.v, nt));
						}
					}
				}
			}
		}
	}
	
	double ans = 1e9;
	for_(k,0,33) ans = min(ans, time[g][1][k]);
	if (ans > 1e8) cout << "unreachable" << endl;
	else printf("%.9lf\n", ans);
}

int main() {
	while (cin >> n >> m, n) {
		cin >> s >> g;
	
		edges.assign(n+1, vector< Edge >());
	
		for_(i,0,m) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			edges[x].push_back(Edge(y, 0, 0, 0, d, c));
			edges[y].push_back(Edge(x, 0, 0, 0, d, c));
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 2224
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

typedef pair<ll, ll> pll;

ll n, c;
vector<pll> in;

vector<ll> cw, ccw;
vector<ll> max_cw, max_ccw;

int main(){
  scanf("%lld%lld", &n, &c);
  in.resize(n);
  for(int i = 0;i < n;++i)
    scanf("%lld%lld", &in[i].fi, &in[i].se);

  sort(all(in));

  cw.resize(n), ccw.resize(n);
  max_cw.resize(n), max_ccw.resize(n);

  ll sum = 0;
  for(int i = 0;i < n;++i){
    sum += in[i].se;
    ll dist = in[i].fi;
    cw[i] = sum - dist;
  }
  max_cw[0] = max(0LL, cw[0]);
  for(int i = 1;i < n;++i)
    max_cw[i] = max(cw[i], max_cw[i - 1]);

  sum = 0;
  for(int i = n - 1;i >= 0;--i){
    sum += in[i].se;
    ll dist = c - in[i].fi;
    ccw[i] = sum - dist;
  }
  max_ccw[n - 1] = max(0LL, ccw[n - 1]);
  for(int i = n - 2;i >= 0;--i)
    max_ccw[i] = max(max_ccw[i + 1], ccw[i]);

  ll best = max(max_cw[n - 1], max_ccw[0]);

  for(int i = 0;i + 1 < n;++i){
    ll val = max_ccw[i + 1] + cw[i] - in[i].fi;
    relaxMax(best, val);
  }

  for(int i = n - 1;i > 0;--i){
    ll val = max_cw[i - 1] + ccw[i] - (c - in[i].fi);
    relaxMax(best, val);
  }

  printf("%lld\n", best);

  return 0;
}



Measured memory_bytes: 4992
n = int(input())
length_array = list(map(int, input().split()))
length_array.sort()

count = 0
for c_i in range(2, n):
    for b_i in range(1, c_i):
        for a_i in range(b_i):
            a, b, c = length_array[a_i], length_array[b_i], length_array[c_i]
            if a + b > c and c + a > b:
                if a != b and b != c:
                    count += 1

print(count)


Measured memory_bytes: 9092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.Numerics;
using System.Diagnostics;

class Program
{
    public void Slove()
    {
        string[] inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int cap = int.Parse(inputs[1]);
        long[] dp = new long[cap + 1];
        dp[0] = 0;
        foreach(int i in Enumerable.Range(0, n))
        {
            inputs = Console.ReadLine().Split();
            int weight = int.Parse(inputs[0]);
            int value  = int.Parse(inputs[1]);
            foreach(int j in Enumerable.Range(0, cap + 1).Skip(weight).Reverse())
            {
                dp[j] = Math.Max(dp[j - weight] + value, dp[j]);
            }
        }   
        foreach(int i in Enumerable.Range(1, cap))
            dp[i] = Math.Max(dp[i], dp[i - 1]);
        //Console.WriteLine(string.Join(",", dp));
        Console.WriteLine(dp[cap]);
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


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

N = int(input())
A = list(map(int, input().split()))
lb, ub = 0, N
while ub - lb > 1:
    m = (lb + ub) // 2
    stack = []
    for a in A:
        if not stack or stack[-1][0] < a:
            stack.append([a, 1])
        elif stack[-1][0] == a:
            stack[-1][1] += 1
        else:
            cur, cnt = stack.pop()
            while stack and stack[-1][0] >= a:
                b, c = stack.pop()
                # cnt = ceil(cnt / m**(cur - b)) + c - 1
                x = 1
                if m > 1:
                    for i in range(cur - b):
                        if x >= cnt:
                            break
                        x *= m
                cnt = (cnt + x - 1) // x + c - 1
                cur = b
            if cur > a:
                # cnt = ceil(cnt / m**(cur - a))
                x = 1
                if m > 1:
                    for i in range(cur - a):
                        if x >= cnt:
                            break
                        x *= m
                cnt = (cnt + x - 1) // x
            stack.append([a, cnt + 1])
    cur, cnt = stack.pop()
    while stack:
        b, c = stack.pop()
        # cnt = ceil(cnt / m**(cur - b)) + c - 1
        x = 1
        if m > 1:
            for i in range(cur - b):
                if x >= cnt:
                    break
                x *= m
        cnt = (cnt + x - 1) // x + c - 1
        cur = b
    # if cnt <= m**cur, ok
    x = 1
    if m > 1:
        for i in range(cur):
            if x >= cnt:
                break
            x *= m
    if cnt <= x:
        ub = m
    else:
        lb = m
print(ub)


Measured memory_bytes: 244940
#include<stdio.h>
#include<stdlib.h>

#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;

  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  
  z->parent=y;
  if(y==NIL) root=z;
  else{
    if(z->key < y->key) y->left=z;
    else y->right = z;
  }
}

Node find(Node u,int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  Node U;
  int n,i,x,y;
  char com[20];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0]=='f'){
      scanf("%d",&y);
      U=find(root,y);
      if(U!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 20428
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

int getIntSubstr(string s,int start_index,int length){
    return atoi(s.substr(start_index,length).c_str());
}
int main(){

    
    string S;
    cin >> S;
    int tar;
    tar = getIntSubstr(S,S.size()-1,1);
    if(tar==3){
        cout << "bon" << endl;
    }else if(tar==0||tar==1||tar==6||tar==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    

}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
ll gcm(ll i, ll j) {//?????§??¬?´???°
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
bool sfind(string s, string l) {//?????????1??????????????????2????????????
	for (ll i = 0; i <= s.size() - l.size(); i++) {
		str t = "";
		for (ll j = 0; j < l.size(); j++)
			t += s[i + j];
		if (t == l)
			return 1;
	}
	return 0;
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m, h, d;
int a[30][10];
bool solve(int i, int j) {
	if (i == d) {
		if (j == h) return 1;
		return 0;
	}
	return solve(i + 1, a[i][j]);
}
signed main() {
	while (cin >> n&&n != 0) {
		cin >> m >> h >> d;
		m--, h--;
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n; j++)
				a[i][j] = j;
		}
		for (int i = 0; i < d; i++) {
			string u;
			cin >> u;
			for (int j = 0; j < n - 1; j++) {
				bool t = (int)u[j] - '0';
				if (t)
					a[i][j] = j + 1, a[i][j + 1] = j;
			}
		}
		if (solve(0, m)) {
			cout << 0 << endl;
			continue;
		}
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < n - 1; j++) {
				if (a[i][j] == j&&a[i][j + 1] == j + 1) {
					a[i][j] = j + 1, a[i][j + 1] = j;
					if (solve(0, m)) {
						cout << i + 1 << " " << j + 1 << endl;
						goto stop;
					}
					a[i][j] = j, a[i][j + 1] = j + 1;
				}
			}
		}
		cout << 1 << endl;
	stop:;
	}
}

Measured memory_bytes: 3152
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <string>
using namespace std;
int main(void){
    // Your code here!
int N;
cin >> N;
long long A;
long long MAX;
MAX=0;
long long count=0;
for(int i=0;i<N;i++){
    cin >> A;
    if(A>=MAX){MAX=A;}else{count=count+MAX-A;}
}
cout << count << endl;
}


Measured memory_bytes: 3576
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val d = readLine.split(" ").map(_.toInt)
  println((0 until n)
    .combinations(2)
    .foldLeft(0)((acc, t) => {
      acc + (d(t(0)) * d(t(1)))
    }))
}


Measured memory_bytes: 32792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		final long MOD = 1000000007L;
		int[] sumA = new int[n + 1];
		int[] sumC = new int[n + 1];
		int[] sumX = new int[n + 1];
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) == 'A') sumA[i + 1] = sumA[i] + 1;
			else sumA[i + 1] = sumA[i];
			if(s.charAt(i) == 'C') sumC[i + 1] = sumC[i] + 1;
			else sumC[i + 1] = sumC[i];
			if(s.charAt(i) == '?') sumX[i + 1] = sumX[i] + 1;
			else sumX[i + 1] = sumX[i];
		}
		long[] three = new long[n + 1];
		three[0] = 1;
		for(int i = 0; i < n; i++) three[i + 1] = (three[i] * 3) % MOD;
		long ans = 0;
		for(int i = 1; i < n; i++) {
			if(s.charAt(i) == 'B' || s.charAt(i) == '?') {
				int tailC = sumC[n] - sumC[i + 1];
				int tailX = sumX[n] - sumX[i + 1];
				long head = (sumA[i] * three[sumX[i]] + sumX[i] * (sumX[i] == 0 ? 1 : three[sumX[i] - 1])) % MOD;
				long tail = (tailC * three[tailX] + tailX * (tailX == 0 ? 1 : three[tailX - 1])) % MOD;
				ans = (ans + (head * tail) % MOD) % MOD;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26320
import java.util.*;
import java.util.Map.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n, m;
            while((n = scn.nextInt()) > 0 | (m = scn.nextInt()) > 0) {
                HashMap<Integer, Integer> locations = new HashMap<>();
                for(int i = 0; i < m; i++) {
                    locations.put(-~i, 0);
                }

                for(int i = 0; i < n; i++) {
                    for(int j = 0; j < m; j++) {
                        if(scn.nextInt() > 0) {
                            locations.put(-~j, -~locations.get(-~j));
                        }
                    }
                }

                ArrayList<Entry<Integer, Integer>> list = new ArrayList<>(locations.entrySet());
                Collections.sort(list, new LocationComparator());

                StringBuilder sb = new StringBuilder();
                for(Entry<Integer, Integer> entry : list) {
                    sb.append(entry.getKey() + " ");
                }
                System.out.println(sb.toString().trim());
            }
        }
    }
}

class LocationComparator implements Comparator<Entry<Integer, Integer>> {
    @Override
    public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2) {
        return o2.getValue().compareTo(o1.getValue());
    }
}

Measured memory_bytes: 70100
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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 Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}
vector<ll> ans;
void dfs(ll n){
  if(n<=1000000000){
    ans.push_back(n);
    dfs(n*10+3);
    dfs(n*10+5);
    dfs(n*10+7);
  }else{
    return;
  }
}
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  dfs(3);
  dfs(5);
  dfs(7);
  sort(ALL(ans));
  vector<ll> ans1;
  for(auto tmp:ans){
    string str=to_string(tmp);
    if(count(str.cbegin(),str.cend(),'3')>=1 && count(str.cbegin(),str.cend(),'5')>=1 && count(str.cbegin(),str.cend(),'7')>=1) ans1.push_back(tmp);
  }
  cout<<upper_bound(ALL(ans1),n)-ans1.begin()<<endl;
}

Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*切り上げの計算！*/
int maxtime(int x) {
	return(x + 9) / 10 * 10;

}
int main() {
	long long int N;
	cin >> N;
	vector <long long int>key;
	for (int i = 0; i < 5; i++) {
		long long int b;
		cin >> b;
		key.push_back(b);
	}
	sort(key.begin(), key.end());
	cout << 4 + (N + (key[0] - 1)) / key[0] ;
}

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

using namespace std;

int findhcf(int m, int n){
    
    if (n%m == 0 || m==1)
        return m;
    
    //cout << m << ' ';
    return findhcf(n%m, m);
    
}

int main() {
    
    long long int a,b;
    cin >> a; cin >> b;
    long long int temp;
    
    if (a>b)
    {
        temp = b;
        b = a;
        a = temp;
    }
    
    long long int hcf = findhcf(a, b);
    //cout << hcf << endl;
    long long int lcm = (a*b)/hcf;
    
    cout << lcm << endl;
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<string> cities(n);
  vector<int> points(n);
  vector<int> ans(n,0);
  for(int i=0;i<n;i++){
    cin>>cities.at(i)>>points.at(i);
  }
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      if(i==j){continue;}
      else if(cities.at(i)>cities.at(j)){sum++;}
      else if(cities.at(i)==cities.at(j)&&points.at(i)<points.at(j)){sum++;}
    }
    ans.at(sum)=i+1;
  }
  for(int x:ans){cout<<x<<endl;}
}

Measured memory_bytes: 256
import sys
import numpy as np

input = sys.stdin.readline

N = int(input())

a = [0]*N
b = [0]*N
c = [0]*N
dp = [[0 for i in range(N)] for j in range(3)]

for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

dp[0][0] = a[0]
dp[1][0] = b[0]
dp[2][0] = c[0]

for i in range(1, N):
    dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i]
    dp[1][i] = max(dp[2][i-1], dp[0][i-1]) + b[i]
    dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i]

print(max(dp[0][-1], dp[1][-1], dp[2][-1]))    

Measured memory_bytes: 36140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> s = new HashSet<>();

        for (int i = 0; i < n; i++) {
            s.add(sc.nextInt());
        }

        System.out.println(s.size() == n ? "YES" : "NO");
    }
}

Measured memory_bytes: 100716
n=int(input())
t0,a0=1,1
for i in range(n):
  t,a=map(int,input().split())
  if t0/a0>t/a:
    while t0%t != 0:
      t0+=1
    a0=t0*a//t
  elif t0/a0<t/a:
    while a0%a != 0:
      a0+=1
    t0=a0*t//a
print(t0+a0)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int now = 1;
	int ans = 0;
	while (true) {
		if (n <= 1) {
			ans += now;
			break;
		}
		ans += now;
		n /= 2;
		now *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256