akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

char c;

int main(){ 

cin.tie(0);
ios::sync_with_stdio(false);

cin>>c;

for(ll i=0; i<1000000000; i++){
	int x=0;
	int y=1;
	x++; y++;
}

if(c=='a'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='e'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='i'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='o'){
	cout<<"vowel"<<endl;
	return 0;
}
if(c=='u'){
	cout<<"vowel"<<endl;
	return 0;
}

cout<<"consonant"<<endl;

}



Measured memory_bytes: 256
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:y=sort(hstack((b%l-l,b%l)));A=l-a%l;l//=2;c+=sum(B(y,A)-B(y,A-l))%2*l
print(c)

Measured memory_bytes: 63832
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B, X;

  cin >> A >> B >> X;

  string ans = "NO";

  if (X - A <= B && X - A >= 0) ans = "YES";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// C - Vacation
// A. Bacca
#include <bits/stdc++.h>
using namespace std;

int n;
vector <vector <long long> > dp_days;
vector <long long> A, B, C;

void Recibir() {
	cin >> n;
	
	dp_days.resize(8);
	dp_days[3].assign(n, -1);
	dp_days[5].assign(n, -1);
	dp_days[6].assign(n, -1);
	dp_days[7].assign(n, -1);
	A.resize(n);
	B.resize(n);
	C.resize(n);
	
	for (int i=0; i<n; i++) cin >> A[i] >> B[i] >> C[i];
}

long long Costs(int d, bool ap, bool bp, bool cp) {
	long long vala {0}, valb {0}, valc {0};
	int dp_idx = (ap ? 4:0) + (bp ? 2:0) + (cp ? 1:0);
	
	// Hay datos guardados
	if (dp_days[dp_idx][d] != -1) return dp_days[dp_idx][d];
	
	// Caso base, es el último día
	if (d == n-1) {
		// Puede tomar cualquier actividad
		if (ap && bp && cp) return dp_days[dp_idx][d] = max(max(A[d], B[d]), C[d]);
		// No puede tomar A
		else if (bp && cp) return dp_days[dp_idx][d] = max(B[d], C[d]);
		// No puede tomar B
		else if (ap && cp) return dp_days[dp_idx][d] = max(A[d], C[d]);
		// No puede tomar C
		else return dp_days[dp_idx][d] = max(A[d], B[d]);
	}
	// Caso recursivo
	else {
		// Puede tomar cualquier actividad
		if (ap && bp && cp) {
			vala = Costs(d+1, false, true, true) + A[d];
			valb = Costs(d+1, true, false, true) + B[d];
			valc = Costs(d+1, true, true, false) + C[d];
			return dp_days[dp_idx][d] = max(max(vala, valb), valc);
		}
		// No puede tomar A
		else if (bp && cp) {
			valb = Costs(d+1, true, false, true) + B[d];
			valc = Costs(d+1, true, true, false) + C[d];
			return dp_days[dp_idx][d] = max(valb, valc);
		}
		// No puede tomar B
		else if (ap && cp) {
			vala = Costs(d+1, false, true, true) + A[d];
			valc = Costs(d+1, true, true, false) + C[d];
			return dp_days[dp_idx][d] = max(vala, valc);
		}
		// No puede tomar C
		else {
			vala = Costs(d+1, false, true, true) + A[d];
			valb = Costs(d+1, true, false, true) + B[d];
			return dp_days[dp_idx][d] = max(vala, valb);
		}
	}
}

int main() {
	Recibir();
	cout << Costs(0, true, true, true);
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

int main(){
	lint n,m,c;cin>>n>>m>>c;
	LIV b(m);rep(i,m)cin>>b[i];
	vector<LIV> a(n);
	lint ans=0;
	lint in;
	rep(i,n){
		lint ct=0;
		rep(j,m){
			cin>>in;
			a[i].push_back(in);
			ct+=a[i][j]*b[j];
		}if(ct+c>0)++ans;
	}cout<<ans<<endl;
}

//sub-EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,ans=0;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin>> A.at(i);
  sort(all(A));
  reverse(all(A));
  rep(i,N-1){
    ans+=A.at((i+1)/2);
  }
  cout << ans << endl;
}


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

const ll dv = 1000000007;


int main() {
  ll n,k;cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);

	ll base = 0; // 与えられた数列の転倒数
	rep(i,n-1){
		for(ll j=i+1;j<n;++j){
			if( a.at(i) > a.at(j) ) ++base;
		}
	}
	
	ll base2 = 0; //与えられた数列2つから一つずつ選んで作れる転倒した組の数
	for(ll i=0;i<n;++i){
		for(ll j=0;j<n;++j){
			if( a.at(i) > a.at(j) ) ++base2;
		}
	}

	ll ans = base*k%dv;
	ans += k*(k-1)/2%dv*base2%dv;

	// cout << "base : " << base << endl;
	// cout << "base2 : " << base2 << endl;

	cout << ans%dv << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mypow(ll a, ll b) {
    ll ret = 1;
    while (b--) {
        ret *= a;
    }
    return ret;
}

ll keta(ll a) {
    ll ret = 0;
    while (a) {
        ret++;
        a /= 10;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    ll nowx = 0, nowy = 0, nowt = 0;
    bool ans = true;
    rep(i, n) {
        ll t, x, y;
        cin >> t >> x >> y;

        if (!((t - nowt) >= abs(x - nowx) + abs(y - nowy) &&
              ((t - nowt) - (abs(x - nowx) + abs(y - nowy))) % 2 == 0)) {
            ans = false;
        }

        nowt = t;
        nowx = x;
        nowy = y;
    }

    if (ans)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

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

void solve() {
  int k;
  cin >> k;
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int s = 1; s <= k; s++) {
        ans += gcd(gcd(i, j), s);
      }
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3608
import java.util.Scanner
import scala.collection.mutable

object Main {

  def solve(sc: Scanner): String = {
    val s = sc.next()
    val mm = mutable.Map(s.distinct.map { c => c -> 0 }.toMap.toSeq: _*)
    s.indices.foreach { i =>
      mm(s(i)) += 1
    }
    val countList = mm.toList.map(_._2)
    if (countList == List(2, 2)) "Yes" else "No"
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


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

int main(void) {
    long a, n, min, max;
    long sum = 0;
    
    cin >> n;
    
    cin >> a;
    max = a;
    min = a;
    sum += a;
    for(int i = 1; i < n; ++i) {
        cin >> a;
        if(a < min) {
            min = a;
        }
        if(a > max) {
            max = a;
        }
        sum += a;
    }
    
    cout << min << ' ' << max << ' ' <<  sum << endl;
    
    return 0;
}



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

int main() {
	int n;
	cin >> n;
	long int a[n+1],b[n];
	for(int i=0;i<n+1;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	
	long int kill = 0;
	
	for(int i=0;i<n-1;i++){
		if(b[i]>a[i]+a[i+1]){
			kill += a[i] + a[i+1];
			a[i+1] = 0; 
		}
		else{
			kill += b[i];
			if(b[i]>a[i]){
				a[i+1] = a[i+1] + a[i] - b[i];
			}
		}
	}
	
	if(b[n-1]>(a[n-1]+a[n])){
		kill += a[n-1] + a[n];
	}
	else{
		kill += b[n-1];
	}
	
	cout << kill << endl;
	
	return 0;
}

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

int gcd (int a, int b);
int lcm (int a, int b);

int gcd (int a, int b) {

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

int lcm (int a, int b) {

    return a * b / gcd(a, b);
}

int main () {

    int N;
    cin >> N;

    cout << lcm(2, N) << endl;

    return 0;
}

Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase

def main():
    t = 1
    for _ in range(t):
        # n = int(input)
        n, k = map(int, input().split())
        nums = list(map(int, input().split()))
        
        start = 0
        for ind in range(k, n):
            if nums[ind] > nums[start]:
                print("Yes")
            else:
                print("No")
            start += 1



        




































# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 96128
def grouping(x: int, y: int)->bool:
    group = [
        [1, 3, 5, 7, 8, 10, 12],
        [4, 6, 9, 11],
        [2],
    ]
    for g in group:
        if x in g and y in g:
            return True
        elif x in g:
            return False
        elif y in g:
            return False
    return False


if __name__ == "__main__":
    x, y = map(int, input().split())
    yes = grouping(x, y)
    print('Yes' if yes else 'No')


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
//#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;
int main() {
	ll N, M,ans=0;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < A.size(); i++) {
		cin >> A[i];
	}
	map<int, int >m;
	vector<int> SUM(N + 1);
	for (int i = 0; i < N; i++) {
		SUM[i + 1] = (SUM[i] + A[i]) % M;
	}
	for (int i = 0; i < SUM.size(); i++) {
		ans += m[SUM[i]];
		m[SUM[i]]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3968
while 1:
    n=int(input())
    if n==0:break
    count=0
    S_keep=list(map(int,input().split()))
    while 1:
        S=[]
        for i in S_keep:
            S.append(S_keep.count(i))
        if S_keep==S:
            print(count)
            print(" ".join(map(str,S)))
            break
        else:
            count+=1
            S_keep=S


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    str S,T,U;
    int a,b;
    cin >> S >> T;
    cin >> a >> b;
    cin >> U;
    if(U==S){
        cout << a-1 << " " << b <<  endl;
    } else{
        cout << a << " "<< b-1 << endl;
    }
    return 0;
}

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

int main() {

    int n;

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

    sort(v.begin(), v.end());
    int maxi = 0;
    for(int i = n; i >= 0; i--) {
        auto p = lower_bound(v.begin(), v.end(), i);
        if(v.end() - p >= i && *p >= i) {
            maxi = i;
            break;
        }
    }
    cout << maxi << endl;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	cin>>N;
	int Cnt=0,Ans=0;
	int lst=-1;
	while(N--)
	{
		int X;
		cin>>X;
		if(lst>=X)
			Cnt++;
		else
		{
			Ans=max(Ans,Cnt);
			Cnt=0;
		}
		lst=X;
	}
	Ans=max(Ans,Cnt);
	cout<<Ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;
  int nmax = a[0] + k - a[n - 1];
  int itr = n;
  for (int i = 0; i < n - 1; ++i)
  {
    if (nmax < a[i + 1] - a[i])
    {
      nmax = a[i + 1] - a[i];
      itr = i;
    }
  }
  cout << k - nmax << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

long long MOD = 998244353;

long long dp[310][90310];
long long dp2[310][90310];

int main(){
    int n;
    cin >> n;
    int a[n];
    int s = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }

    dp[0][0] = 1;
    dp2[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 90000; j++){
            dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j]) % MOD;
            dp[i+1][j] = (dp[i+1][j] + 2*dp[i][j]) % MOD;

            dp2[i+1][j+a[i]] = (dp2[i+1][j+a[i]] + dp2[i][j]) % MOD;
            dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % MOD;
        }
    }

//    for(int i = 0; i <= n; i++){
//        for(int j = 0; j <= 2000; j++){
//            cerr << dp[i][j] << "\t";
//        }
//        cerr << endl;
//    }

    long c = 0;
    for(int i = (s+1)/2; i <= s; i++){
        c = (c + dp[n][i]) % MOD;
    }
    if(s%2 == 0){
        c = (c + (MOD-dp2[n][s/2])) % MOD;
    }
    c = c*3%MOD;

    long as = 1;
    for(int i = 0; i < n; i++){
        as = (as*3) % MOD;
    }
    as = (as+(MOD - c)) % MOD;
    cout << as << endl;
    
    return 0;
}


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

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
using namespace std;
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    string a, b;
    cin >> a >> b;
    ll p = stoll(a + b);
    if (p == pow((ll)sqrt(p), 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<iterator>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef ostream_iterator<int> os_iter_int;

const ll mod=1e9+7;

int len;
char ch[100010];
ll dp[30],val[30],ans;

template<typename inp_t>
void readx(inp_t& x)
{
	x=0; int k=1; char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}

int main()
{
	readx(len); 
	scanf("%s",ch+1);
	for (int i=1;i<=len;i++) ch[i]=ch[i]-'a'+1; 
	
	for (int i=1;i<=len;i++) dp[ch[i]]++;
	
	ll val=1;
	for (int i=1;i<=26;i++) val=val*(dp[i]+1)%mod;
	ans=(val-1+mod)%mod;
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const ll int INF = 1e18+5;
vector<int>edges[100003];
int in_degree[100003];
bool vis[100003];
int dist[100003];
void dfs(int a)
{
    vis[a]=1;
    for(int b:edges[a])
    {
        dist[b]=max(dist[b],dist[a]+1);
        in_degree[b]--;
        if(in_degree[b]==0&&vis[b]==0)
            dfs(b);
    }
}

int main()
{
    int v,e,v1,v2;
    cin >> v >> e;
    for(int i=0;i<e;i++)
    {
        cin >> v1 >> v2 ;
        edges[v1].push_back(v2);
        in_degree[v2]++;
    }
    for(int i=1;i<=v;i++)
    {
        if(!vis[i]&& in_degree[i]==0)
        {
            dfs(i);
        }
    }
    int ans=0;
    for(int i=1;i<=v;i++)
    {
        ans = max(ans,dist[i]);
    }
    cout << ans;
}


Measured memory_bytes: 9728
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

bool isExponential[1001];
int main(){
    std::ios::sync_with_stdio(false);
    
    isExponential[1] = true;
    for(int i=2;i<=1000;++i)
    {
        int exp = 2;
        int tmp = pow(i, exp);

        while(tmp <= 1000)
        {
            isExponential[tmp] = true;
            exp++;
            tmp = pow(i, exp);
        }
    }

    int x;
    cin >> x;
    for(int i=x; i>=0;--i)
    {
        if(isExponential[i])
        {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 512
# ########## ------ Import ------- ##########

import sys
import math
from collections import Counter
from collections import deque as deq
from functools import lru_cache

# ########## ------ Define -------- #########

INT_MAX = float("inf")
INT_MIN = float("-inf")

# ########## ------ Input Functions ---- #########

input = sys.stdin.readline


def inp():
    return(int(input()))


def inlt():
    return(list(map(int, input().split())))


def insr():
    s = input()
    return(list(s[:len(s) - 1]))


def invr():
    return(map(int, input().split()))


# ########## ------ Code ------- ##########
def go(i):
    if i == 0:
        dp[i] = 0
        return dp[i]
    if i == 1:
        dp[i] = abs(a[0] - a[i])
        return dp[i]

    if dp[i] != -1:
        return dp[i]

    dp[i] = min(abs(a[i] - a[i - 1]) + go(i - 1),
                abs(a[i] - a[i - 2]) + go(i - 2))
    return dp[i]


t = inp()
a = inlt()

if t == 1:
    print(0)
elif t == 2:
    print(abs(a[0] - a[1]))

else:
    dp=[-1]*t
    dp[0] = 0
    dp[1] = abs(a[0] - a[1])
    for i in range(2, t):
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1],
                    abs(a[i] - a[i - 2]) + dp[i - 2])


    print(dp[t - 1])


Measured memory_bytes: 14476
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int k;
	cin >> k;
	
	int num = 7 % k;
	for(int i = 0; i < k + 10; i++) {
		if(num == 0) {
			cout << (i + 1) << endl;
			return;
		}
		
		num *= 10;
		num += 7;
		num %= k;
	}
	
	cout << -1 << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

int main() {
  int n, m;
  long long k;
  cin >> n >> m >> k;
  vector<long long> a(n + 1), b(m + 2);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    a[i] = a[i - 1] + x;
  }
  for (int i = 1; i <= m; i++) {
    int x;
    cin >> x;
    b[i] = b[i - 1] + x;
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    if (a[i] > k) continue;
    int l = 0, r = m + 1, c;
    while (r - l > 1) {
      c = (l + r) / 2;
      ((a[i] + b[c] > k) ? r : l) = c;
    }
    if (ans < i + l) ans = i + l;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  vector<int> dp(N + 1, INF);
  dp[0] = 0;

  vector<int> cand;
  int i = 1;
  while (i <= 100000) {
    cand.pb(i);
    i *= 6;
  }
  i = 1;
  while (i <= 100000) {
    cand.pb(i);
    i *= 9;
  }

  rep(i, N) {
    rep(j, cand.size()) {
      int c = cand[j];
      if (i + c <= N) {
        chmin(dp[i + c], dp[i] + 1);
      }
    }
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left, bisect_right

N,D,A=map(int, sys.stdin.readline().split())
XH=[ map(int, sys.stdin.readline().split()) for _ in range(N) ]
XH.sort()

bit=[ 0 for _ in range(N+1) ]

#BIT 関数は全て1-indexed
def add(a,w):
    while a<=N:
        bit[a]+=w
        a+=a&-a

def sum(a):
    ret=0
    while 0<a:
        ret+=bit[a]
        a-=a&-a
    return ret

#区間[l,r]に一律wを加える
def range_add(l,r,w):
    add(l,w)
    add(r+1,w*-1)

#a番目のモンスターの体力を取得
def get_value(a):
    return sum(a)

X=[float("-inf")]
H=[float("-inf")]
for x,h in XH:
    X.append(x)
    H.append(h)

for i in range(1,N+1):
    if i==1:
        add(i,H[i])
    else:
        add(i,H[i]-H[i-1])  #区間に対する更新を行うため、値の差分をBITに持つ
    
ans=0

for i in range(1,N+1):
    h=get_value(i)
    if h<=0:    #モンスターの体力がゼロ以下だったら何もしない
        pass
    else:
        x=X[i]
        pos=bisect_right(X,x+2*D)-1 #攻撃範囲の一番右側を二分探索で決定
        if h%A==0:   #hがAで割り切れる場合
            cnt=h/A
            range_add(i,pos,A*cnt*-1)
        else:
            cnt=h/A+1   #hをAで割って余りが出る場合は攻撃回数を+１する
            range_add(i,pos,A*cnt*-1)
        ans+=cnt

print ans


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

using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	string T;
	cin >> T;
	int ans =0;
	int max=0;
	
	for(auto it = T.begin();it != T.end();++it){
		if((*it == 'A') or (*it =='T') or (*it =='C') or (*it == 'G')){
			++ans;
			if(max <ans)
				max = ans;
		}else{
			ans = 0;
		}
			
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 287644PV
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(10)<<(x)
int mod = 1000000000+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;

    int mini = 1e6;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        if(A[i] < mini)
            mini = A[i];
    }


    vector<int> dp(k+1,-1);
    for (int i = 0; i < mini; ++i) {
        dp[i] = false;
    }
    for (int i = 0; i <= k; ++i) {
        for(int x: A)
        {
            if(i+x > k)
                continue;
            if(dp[i] != -1 && dp[i+x] != 1)
                dp[i+x] = !dp[i];
        }
    }
    string sol;
    if(dp[k])
        cout << "First";
    else
        cout << "Second";

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define P pair<int, int>
#define PP pair<P, P>
#define mp make_pair
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;

const int xi[4] = {0, 1, 0, -1};
const int yi[4] = {1, 0, -1, 0};

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    rep(i, H) rep(j, W) cin >> a[i][j];

    vector<PP> resxy;
    rep(i, H) {
        
        if(i%2) {
            for(int j=W-1; j>=1; j--) {
                if(a[i][j]%2) {
                    a[i][j]--;
                    a[i][j-1]++;
                    resxy.pb(mp(mp(i+1, j+1), mp(i+1, j)));
                }
            }
            if(a[i][0]%2 && i<H-1) {
                a[i][0]--;
                a[i+1][0]++;
                resxy.pb(mp(mp(i+1, 1), mp(i+2, 1)));
            }
        } else {
            for(int j=0; j<W-1; j++) {
                if(a[i][j]%2) {
                    a[i][j]--;
                    a[i][j+1]++;
                    resxy.pb(mp(mp(i+1, j+1), mp(i+1, j+2)));
                }
            }
            if(a[i][W-1]%2 && i<H-1) {
                a[i][W-1]--;
                a[i+1][W-1]++;
                resxy.pb(mp(mp(i+1, W), mp(i+2, W)));
            }
        }
    }

    cout << resxy.size() << endl;
    rep(i, resxy.size()) {
        cout << resxy[i].f.f << " " << resxy[i].f.s << " ";
        cout << resxy[i].s.f << " " << resxy[i].s.s << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <map>
#include <numeric>

using namespace std;

int main() {

  string a;

  cin >> a;

  cout << ( a <= "2019/04/30" ? "Heisei" : "TBD") << endl;

  
  
  return 0;
}

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

using namespace std;


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

    bool flag = false;
    int ans = INT32_MAX;
    for(int i=0; i<N; i++) {
        if(A[i] >= H) {
            flag = true;
            ans = min(ans, B[i]);
        }
    }

    if(flag) {
        cout << ans << endl;
        return 0;
    }

    vector< vector<int> > dp(N, vector<int>(H+1));
    for(int j=0; j<=H; j++) {
        dp[0][j] = (j+A[0]-1)/A[0] * B[0];
    }
    for(int i=1; i<N; i++) {
        for(int j=0; j<A[i]; j++) {
            dp[i][j] = min(dp[i-1][j], B[i]);
        }
        for(int j=A[i]; j<=H; j++) {
            dp[i][j] = min({dp[i-1][j], dp[i-1][j-A[i]] + B[i], dp[i][j-A[i]] + B[i]});
        }
    }

    cout << dp[N-1][H] << endl;
    return 0;
}


Measured memory_bytes: 41344
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
#define Graph vector<vector<int>>;
#define iterG(next_v, G, v) for(auto next_v : G[v]
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int z, ans, tmp;
    //1439
    ans = a * x + b * y;
    repi(i, 1, max(x, y)+1){
        z = 2 * i; // ab
        tmp = a * max(0, (x-i)) + b * max(0, y-i) + c * z;
        ans = min(ans, tmp);
        
        
    }
    cout << ans << endl;
    return 0;
}



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

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

    vector <int> a(n);
    for (int i = 0; i < n; i ++){
        int _a;
        cin >> _a;
        a[i] = _a;
    }
    sort(a.begin(), a.end());

    int now_num = 0;
    int now_cnt = 0;
    int ans = 0;
    for (auto num : a){
        if (now_num != num){
            if (now_cnt < now_num){
                ans += now_cnt;
            }
            now_cnt = 0;
        }

        if (now_cnt == 0){
            now_num = num;
        }

        now_cnt += 1;
        if (now_cnt > now_num){
            ans += 1;
        }
    }

    if (now_cnt < now_num){
        ans += now_cnt;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a[200001];
    int k, n;
	cin >> k >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int x = (k + a[0]) - a[n - 1];
    for (int i = 0; i < n - 1; i++) {
        x = max(x, a[i + 1] - a[i]);
    }

    cout << k - x << endl;

    return 0;
}

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

void Main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  stack<int> l, r;
  for (int i = 0;i < N; i++) {
    if (S[i] == '(') {
      r.push(1);
    }
    if (S[i] == ')') {
      if (r.size()) r.pop();
      else l.push(1);
    }
  }

  for (int i = 0; i < l.size(); i++) {
    cout << '(';
  }
  cout << S;
  for (int i = 0; i < r.size(); i++) {
    cout << ')';
  }
  cout << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define N 100101
#define forn(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define F first
#define S second
int main()
{
         boost;
         int arr[3];
         forn(i,3)
         cin>>arr[i];
         sort(arr,arr+3);
         int ans=0;
         for(int i=1;i<3;i++)
         ans+=abs(arr[i]-arr[i-1]);
         
         cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
by.YXH_XianYu
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 100003

int n,L,
	a[MXN],
	l,r,pos;

int main(){

	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
		if(a[i]+a[i+1]>=L){
			pos=i;
			break;
		}
	if(pos==0)
		printf("Impossible\n");
	else{
		printf("Possible\n");
		for(int i=1;i<=n;i++)
			if(i!=pos)
				printf("%d\n",i);
			else
				break;
		for(int i=n-1;i>=1;i--)
			if(i!=pos)
				printf("%d\n",i);
			else
				break;
		printf("%d\n",pos);
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int INF = 1e9+7;

int dp[50001];


int main() {

    int n, m;
    cin >> n >> m;

    for (int i = 0; i <= n; ++i) dp[i] = INF;
    dp[0] = 0;

    vector<int> c(m);
    for (int i = 0; i < m; ++i) cin >> c[i];

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i-c[j] >= 0) {
                dp[i] = min(dp[i], dp[i-c[j]]+1);
            }
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define COUNTOF(array)  (sizeof(array) / sizeof(array[0]))
typedef long long ll;
typedef vector<int> VI;
typedef vector<string> VS;
using P = pair<int,int>;

int main() {
    int N , X , T;
    cin >> N >> X >> T;

    int temp = N / X;

    if(N % X != 0)  temp ++;

    int ans = temp * T;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = [I() for _ in range(N)]

    # 奇数個の山同士を相殺して偶数個の山にした後同数字ペアを作る
    # 奇数個の山の間に0個の山が無ければ全て取れる
    # 言い換えれば0個の山の間は0,1個残しで取り切れる
    A_cum = [0] * (N + 1)
    zero = [0]
    for i in range(N):
        A_cum[i+1] = A_cum[i] + A[i]
        if A[i] == 0:
            zero.append(i)
    zero.append(N)

    ans = 0
    for i in range(len(zero) - 1):
        ans += (A_cum[zero[i+1]] - A_cum[zero[i]]) // 2

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 19676
#include<iostream>
using namespace std;
string s[100];
bool used[100][100];
int h,w;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
main()
{
    while(cin>>h>>w,h)
    {
        for(int i=0;i<h;i++)
        {
            cin>>s[i];
            for(int j=0;j<w;j++)used[i][j]=0;
        }
        int x=0,y=0,f=0;
        while(!used[x][y])
        {
            used[x][y]=1;
            if(s[x][y]=='.')
            {
                f=1;
                cout<<y<<" "<<x<<endl;
                break;
            }
            int r=s[x][y]=='>'?0:s[x][y]=='<'?2:s[x][y]=='v'?1:3;
            x+=dx[r],y+=dy[r];
        }
        if(!f)cout<<"LOOP"<<endl;
    }
}


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

void trace (int A[], int N){
  for (int i = 0; i < N; i++){
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertionSort (int A[], int N){
  for (int i = 1; i < N; i++){
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}

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

  trace(A, N);
  insertionSort(A, N);

  return 0;
}


Measured memory_bytes: 3080
function Main(input) {
    var tmp = input.split(" ");
    var x = tmp[0];
    var a = tmp[1];
  	if(x < a) { 
      console.log(0) 
    } else {
      console.log(10)
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n")[0]);

Measured memory_bytes: 21064
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    S = input()
    T = input()
    ans = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9796
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
int A,B,C,D;
cin>>A>>B>>C>>D;
  
map<int,int> p,q,r;

for(int i=A;i<=B;++i) ++p[i];

for(int i=C;i<=D;++i) ++q[i];

for(int i=0;i<=100;++i) r[i]=p[i]+q[i];

int x=0;

for(int i=0;i<=100;++i) if(r[i]==2){++x;}

if(x==0){cout<<0<<endl;}
else{cout<<x-1<<endl;}

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000

using namespace std;
typedef long long ll;

int n,m;

vector<int> real(int k,vector<int> c){
	vector<int> ret;
	int a=0,b=n;
	for(int i=0;i<2*n;i++){
		if(i%2==0){
			ret.push_back(c[a]);
			a++;
		}else{
			ret.push_back(c[b]);
			b++;
		}
	}
	return ret;
}

vector<int> cut(int k,vector<int> c){
	vector<int> ret;
	for(int i=k;i<2*n;i++){
		ret.push_back(c[i]);
	}
	for(int i=0;i<k;i++){
		ret.push_back(c[i]);
	}
	return ret;
}


int main(){
	vector<int> c;
	for(int i=0;i<200;i++){
		c.push_back(i);
	}
		cin>>n>>m;
	for(int i=0;i<m;i++){
		int k;
		cin>>k;
		if(k==0)c=real(k,c);
		else c=cut(k,c);
//	for(int i=0;i<n*2;i++)cout<<c[i]+1;cout<<endl;

	}
	for(int i=0;i<n*2;i++)cout<<c[i]+1<<endl;
	return 0;
}

Measured memory_bytes: 1224
import math

n=int(input())

def culc(i,j,k):
    return i**2+j**2+k**2+i*j+j*k+k*i


ans=[0]*(n+1)

limit=math.ceil(n**0.5)
for x in range(1,limit+1):
    for y in range(1,limit+1):
        for z in range(1,limit+1):
            temp=culc(x,y,z)
            if temp<=n:
                ans[temp]+=1

for i in range(1,n+1):
    print(ans[i])



Measured memory_bytes: 9408
#include <stdio.h>

typedef long long ll;

ll T[1000];
ll A[1000];

ll maxi(ll a  ,ll b);

int main() {

	int N;

	scanf("%d",&N);

	int i;
	for (i = 0; i < N; i++) {
		scanf("%lld %lld",&T[i],&A[i]);
	}


	for (i = 0; i < N-1; i++) {
		if (T[i] < T[i + 1] && A[i] < A[i + 1]);
		else if (T[i] < T[i + 1] && A[i] > A[i + 1]) {
			ll xx;
			if (A[i] % A[i + 1] == 0) { xx = 0ll; }
			else { xx = 1ll; }
			T[i + 1] *= ((A[i] / A[i + 1]) + xx);
			A[i + 1] *= ((A[i] / A[i + 1]) + xx);
		}
		else if (T[i] > T[i + 1] && A[i] < A[i + 1]) { 
			ll xx;
			if (T[i] % T[i + 1] == 0) { xx = 0ll; }
			else { xx = 1ll; }
			A[i + 1] *= ((T[i] / T[i + 1]) + xx); 
			T[i + 1] *= ((T[i] / T[i + 1]) + xx); 
		}
		else if (T[i] > T[i + 1] && A[i] > A[i + 1]) { 
			ll xx;
			if (T[i] % T[i + 1] == 0) { xx = 0ll; }
			else { xx = 1ll; }
			ll xx2;
			if (A[i] % A[i + 1] == 0) { xx2 = 0ll; }
			else { xx2 = 1ll; }
			ll x = maxi(((A[i] / A[i + 1]) + xx2), ((T[i] / T[i + 1]) + xx)); 
			T[i + 1] *= x; 
			A[i + 1] *= x; 
		}
		else if (T[i] == T[i + 1] && A[i] > A[i + 1]) { 
			ll xx;
			if (A[i] % A[i + 1] == 0) { xx = 0ll; }
			else { xx = 1ll; }
			ll x = (A[i] / A[i + 1]) + xx; 
			T[i + 1] *= x; 
			A[i + 1] *= x; 
		}
		else if (T[i] == T[i + 1] && A[i] < A[i + 1]);
		else if (T[i] < T[i + 1] && A[i] == A[i + 1]);
		else if (T[i] > T[i + 1] && A[i] == A[i + 1]) {
			ll xx;
			if (T[i] % T[i + 1] == 0) { xx = 0ll; }
			else { xx = 1ll; }
			ll x = (T[i] / T[i + 1]) + xx; 
			T[i + 1] *= x; 
			A[i + 1] *= x; 
		}
	}

	printf("%lld\n",T[N-1]+A[N-1]);

	return 0;
}
ll maxi(ll a, ll b) {
	if (a >= b) { return a; }
	else { return b; }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n;
	int a[200005];
	set<int>s;
	cin>>n;
	REP(i,n)
	{cin>>a[i];
	s.insert(a[i]);
		}	
	if(s.size()==n)
		cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}



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

using namespace std;

#define int long long
#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 REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, Z, W;
VL a;

signed main() {
  cin >> N >> Z >> W;
  REP(i,N) a.emplace_back(IN());
  if(N == 1)
    cout << abs(W - a[N - 1]) << "\n";
  else
    cout << max(abs(W - a[N - 1]), abs(a[N - 1] - a[N - 2])) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=500+5;
const int N=500+5;
const ll oo=1e18+5;
const ll mod=998244353;

int dp[N][N];
bool used[N][N];

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

int n;
bool InSide(int x,int y){
	return (x>=0&&x<n&&y>=0&&y<n);
}

void bfs(int x,int y){
	queue<pair<int,int>> Q;
	Q.push({x,y});
	while(!Q.empty()){
		int x=Q.front().first;
		int y=Q.front().second;
		Q.pop();
		for(int dir=0;dir<4;++dir){
			int new_x=x+dx[dir];
			int new_y=y+dy[dir];
			if(!InSide(new_x,new_y)) continue;
			if(dp[new_x][new_y]>dp[x][y]+(used[x][y]==1?0:1)){
				dp[new_x][new_y]=dp[x][y]+(used[x][y]==1?0:1);
				Q.push({new_x,new_y});
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			dp[i][j]=min({i,j,n-1-i,n-1-j});
		}
	}
	ll ans=0;
	for(int i=0;i<n*n;++i){
		int pos;
		cin>>pos;
		--pos;
		int x=pos/n;
		int y=pos%n;
		ans+=dp[x][y];
		used[x][y]=1;
		bfs(x,y);
	}
	cout<<ans;
	return 0;
}


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

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

  return gcd(b, a%b);
}

ll lcm(ll a, ll b){
  return a * b / gcd(a, b);
}

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

  cout << lcm(a, b) << endl;

  return 0;
}

Measured memory_bytes: 256
mod = 998244353

n = 0
x = []
d = []

def search(s):
    lo = 0
    hi = n - 1
    while lo <= hi:
        mid = (lo + hi) // 2
        if s > x[mid]:
            lo = mid + 1
        elif s < x[mid]:
            hi = mid - 1
        else:
            return mid
    return max(lo, hi)


if __name__ == "__main__":
    xd = []
    n = int(input())
    for i in range(n):
        xi, di = map(int, input().split())
        xd.append((xi, di))

    xd.sort()
    x = list(map(lambda x: x[0], xd))
    d = list(map(lambda x: x[1], xd))

    dp = [0] * (n+1)
    dp[-1] = 1
    next = [0] * n

    st = []
    st.append((n, 2e9))

    for i in range(n-1, -1, -1):

        while st[-1][1] < x[i] + d[i]:
            st.pop()
        next[i] = st[-1][0]
        st.append((i, x[i]))

    for i in range(n - 1, -1, -1):
        dp[i] = (dp[next[i]] + dp[i + 1]) % mod
    
    print(dp[0])

Measured memory_bytes: 53940
n = gets.to_i
j = gets.to_i
min = j
max = j
ret = -1000000000

for i in 2..n
    j = gets.to_i
    if j <= min then
        ret = j - min if ret < j - min
        min = j
        max = j
    end
    if j > max then
         max = j
         ret = max - min if ret < max - min
    end

end

puts ret


Measured memory_bytes: 8864
x = int(input())
for i in range(int(x**(1/5))+1):
  ii = i**5
  for j in range(0,i+1):
    if ii + j**5 == x:
      print(i,-j)
      exit()
for i in range(2,1000):
  ii = i**5
  for j in range(1,i):
    if ii - j**5 == x:
      print(i,j)
      exit()
      
    
    
  

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

static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int maxv = -2000000000;
  int minv = R[0];

  for ( int i = 1; i < n; i++ )	{
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 3856