akhauriyash/Code-Regression huggingface dataset:
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
r = sorted(r,reverse = True)
p = p[A-X:]
q = q[B-Y:]
if X+Y<C:
    r = r[:X+Y]
px = 0
qx = 0
for i in range(C):
    if px == len(p) and qx == len(q):
        break
    elif px == len(p):
        if min(q[qx],r[i])==q[qx]:
            q[qx] =r[i]
            qx += 1
        else:
            break
    elif qx == len(q):
        if min(p[px],r[i])==p[px]:
            p[px] =r[i]
            px += 1
        else:
            break
    else:
        if min(p[px],q[qx],r[i]) ==p[px]:
            p[px] = r[i]
            px +=1
        elif min(p[px],q[qx],r[i]) ==q[qx]:
            q[qx] = r[i]
            qx += 1
        else:
            break
print(sum(p)+sum(q))

Measured memory_bytes: 23216
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int[] num = new int[4];
        for (int i = 0; i < 4; i++)
        {
            num[i] = cin.nextInt();
        }

        int s = Math.Max(num[0], num[2]);
        int g = Math.Min(num[1], num[3]);
        Console.WriteLine(Math.Max(0, g - s));
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' '};

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

static const int N = 1000;

int Ics(string X, string Y) {
	int c[N + 1][N + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
	for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

	for ( int i = 1; i <= m; i++ ) {
		for (int j = 1; j <= n; j++ ) {
			if ( X[i] == Y[j]){
				c[i][j] = c[i - 1] [j - 1] + 1;
			} else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}

	return maxl;
}

int main() {
	string s1, s2;
	int n; cin >> n;
	for ( int i = 0; i<n; i++ ) {
		cin >> s1 >> s2;
		cout << Ics(s1, s2) << endl;
	}
	return 0;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    vector< int > a(N);
    cin >> a;
    
    auto dp = make_vector(N, N, 0ll);
    range(i, 0, N) {
        dp[i][i] = (N & 1 ? 1 : -1) * a[i];
    }

    range(d, 1, N) {
        range(r, d, N) {
            int l = r - d;
            if ((d & 1) == (N & 1)) {
                dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r]);
            } else {
                dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r]);
            }
        }
    }

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

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

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

using namespace std;

int main()
{
  string b;
  cin >> b;
  
  for(char a: b)
  {
    switch(a)
    {
        case 'A':
        	cout << 'T';
        	break;
        case 'T':
        	cout << 'A';
        	break;
        case 'C':
        	cout << 'G';
        	break;
        case 'G':
        	cout << 'C';
        	break;
    }
  }
  cout << endl;
  
  return 0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli n, k;
	string s;
	if ( cin >> n >> k );
	else return false;
	
	if ( k == 1 ) cout << 0 << '\n';
	else cout << n-k << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}



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

int main() {
  string S; cin >> S;
  int a = 0, b = 0;
  for(int i = 1; i <= S.size(); ++i) {
    if(a == 0 && S[i] == S[i-1]) a++, i++;
    else a = 0;
    b++;
  }
  cout << b << endl;
  return 0;
}


Measured memory_bytes: 640
N = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
MAX_T = 200
MAX_V = 100
INF = 1e9
index = 0
tsum = 0
T = sum(t)
dp = [[-INF] * (2*MAX_V+1) for i in range(2*T+1)]
dp[0][0] = 0.0
for i in range(2*T):
    if i+1 > 2 * (tsum + t[index]):
        tsum += t[index]
        index += 1
    for j in range(2*MAX_V+1):
        jj = 0.5 * j
        if jj > v[index]:
            continue
        if jj < v[index]:
            dp[i+1][j+1] = max((dp[i+1][j+1], dp[i][j] + 0.5 * jj + 0.125))
        if jj > 0:
            dp[i+1][j-1] = max((dp[i+1][j-1], dp[i][j] + 0.5 * jj - 0.125))
        dp[i+1][j] = max((dp[i+1][j], dp[i][j] + 0.5 * jj))

print(dp[2*T][0])


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

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

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	int res;
	int cnt = 0;

	for (int i = 0;i <= A;i++) {
		for (int j = 0;j <= B;j++) {
			for (int k = 0;k <= C;k++) {
				res = 500 * i + 100 *  j+ 50 * k;
				if (X == res) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

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


int main(){
	int n,i;
	scanf("%d",&n);
	char a[100003];
	scanf("%s",a);
	int ans=0;
	for(i=0;i<n;i++){
		while(i<n-1 && a[i]==a[i+1]){
			i++;
		}
		ans++;
	}
	printf("%d\n",ans );
}


Measured memory_bytes: 384
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

// int c[idx]; 

// int dp(int idx){
//     if(idx < 0) return 0 ;
//     if(~c[idx]) return c[idx];
//     int res = min(dp(idx - 2) + a[idx] , dp(idx - 1)); 
//     return c[idx] = res ;
// }
// 2:
// ; 2^3 - 1^3 
void solve()
{
    int n , k ;
    cin >> n >> k ;
    int cnt[k + 1]= {};
    int ans = 0 ;
    for(int gc = 1 ; gc <= k ; ++gc){
        int mul = k/gc; 
        cnt[gc] = po(mul, n);
    }
    for(int i = k ; i >= 1 ; --i){
        for(int j = 2 * i ; j <= k ; j += i){
            cnt[i] = (cnt[i] - cnt[j] + mod) % mod ;
            // lower gcd poss is removed. 
        }
    }
    for(int i = 1 ; i <= k ; ++i) /*cout << cnt[i] << ' ' ,*/ ans = (ans + (i * cnt[i]) % mod) % mod ;
    cout << ans ;
}   

// don't choose 1 or don't choose 5 
// or choose both.  ? ?  ? ? ?? ? ? ?
// 1 | (2 3 4 5)
// 1 2 3 4 | 5
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 4368
#include <stdio.h>
int main()
{
int N,i,j,S,d[100];
scanf("%d", &N);
for(i=0;i<=N;i++)
	scanf("%d",&d[i]);
for(i=0;i<N;i++){
	for(j=i+1;j<N;j++){
		S=S+d[i]*d[j];
	}
}
printf("%d",S);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
typedef long long ll;
typedef pair<ll,ll> pll;
ll A[305][305],dist[305][305];
bool done[305][305];
vector<pll> graph[305];
int root[305];
vector<pair<ll,pll> > edges;

ll findroot(ll x){
	while(x!=root[x]) x=root[x];
	return root[x];
}

void uni(ll x, ll y){
	int a=findroot(x);
	int b=findroot(y);
	root[a]=b;
}

int main(){
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin >> A[i][j];
			if(i!=j) {
				graph[i].pb(mp(j,A[i][j]));
				edges.pb(mp(A[i][j],mp(i,j)));
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++) {dist[i][j]=INT_MAX; done[i][j]=false;}
		dist[i][i]=0;
		priority_queue<pll,vector<pll>,greater<pll> > pq;
		pq.push(mp(0,i));
		while(!pq.empty()){
			pll best=pq.top();
			pq.pop();
			ll x=best.ss;
			if(done[i][x]) continue;
			done[i][x]=true;
			int len=graph[x].size();
			for(int j=0;j<len;j++){
				if(dist[i][x]+graph[x][j].ss<dist[i][graph[x][j].ff]){
					dist[i][graph[x][j].ff]=dist[i][x]+graph[x][j].ss;
					pq.push(mp(dist[i][graph[x][j].ff],graph[x][j].ff));
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(dist[i][j]!=A[i][j]){
				cout << "-1\n";
				return 0;
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			bool pick=true;
			for(int k=1;k<=n;k++){
				if(k!=i && k!=j){
					if(A[i][k]+A[k][j]==A[i][j]) pick=false;
				}
			}
			if(pick)ans+=A[i][j];
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
    int n, d, x;
    cin >> n;
    cin >> d >> x;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int eatnum = 0;
    for(int i = 0; i < n; i++){
        eatnum += (d-1)/a[i] + 1;
    }

    cout << eatnum+x << endl;
    return 0;
}

Measured memory_bytes: 3568
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
'''
p = 10 ** 9 + 7
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
'''


#a = list(map(int, input().split()))

n,k = list(map(int, input().split()))

count = 0
now = 1
for i in range(99999):
    if(now<=n):
        now*=k
        count+=1
    else:
        break
        
print(count)





























Measured memory_bytes: 69100
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  auto s = 0.;
  for (int i = 0; i < N; ++i)
    {double A; cin >> A;
    s += 1. / A;}
  cout << setprecision(16) << 1. / s << endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	string s1,s2;
	cin>>s1>>s2;
	ll ct = 0;
	REP(i,0,s1.size()){
		if(s1[i] != s2[i]) ct++;
	}
	cout<<ct<<endl;
	return 0;
}

Measured memory_bytes: 3864
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = input()
ans = 0

while N:
    if N[0] == "9":
        ans += 9
        N = N[1:]
    else:
        break

if all([n=="9" for n in list(N[1:])]) and len(N) >= 2:
    print(ans + int(N[0]) + len(N[1:])*9)
elif ans == 0:
    if len(N) == 1:
        ans = int(N)
    else:
        ans += int(N[0]) - 1 + len(N[1:])*9
    print(ans)
elif len(N)==0:
    print(ans)
else:
    print(ans - 1 + len(N)*9)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const int N=1e3+5;
bool f;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);

  int n,m;
  cin>>n>>m;
  cout<<n*m;
go;
}





Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<string>
#define ll long long
#define lld long double
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define mod1 998244353
#define pi 3.1415926535897
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(9);
    //std::cout << std::fixed;
    ll a[3];
    gll(a,3);
    sort(a, a+3);
    cout<<a[0]+a[1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}
class UF{
  vector<int> par,rank,size_uf;
public:
  UF(int size){
    for (int i = 0; i < size; i++) {
      par.push_back(i);
      rank.push_back(0);
      size_uf.push_back(1);
    }
  }
  int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y]){
      par[x]=y;
      size_uf[y]+=size_uf[x];
    }
    else{
      par[y]=x;
      size_uf[x]+=size_uf[y];
      if(rank[x]==rank[y])rank[x]++;
    }
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  int operator [](int x){
    return this->find(x);
  }
  int size(int x){
    x=find(x);
    return size_uf[x];
  }
};

const string YES = "YES";
const string NO = "NO";

ll N,M;
vector<ll> K;


int main(){
  scanf("%lld%lld", &N,&M);
  K.resize(N);
  UF uf(N+M);
  For(i,N){
    scanf("%lld", &K[i]);
    For(j,K[i]){
      ll L;
      scanf("%lld", &L);
      uf.unite(i,N+L-1);
    }
  }
  bool f=true;
  For(i,N){
    if(uf.same(0,i)==false){
      f=false;
      break;
    }
  }
  if(f){
    cout<<YES<<endl;
  }else{
    cout<<NO<<endl;
  }
  return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define abs(x) ((x)>0?(x):-(x))
#define INF 1e18
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int ara[n];
    for(int i=0;i<n;i++)
        cin>>ara[i];
        int i=0;
    for(i=0;i<n;i++)
    {
        if(!(ara[i]%2))
        {
            if(ara[i]%3==0 || ara[i]%5==0)
                continue;
            else break;
        }
    }
    if(i==n) cout<<"APPROVED";
    else cout<<"DENIED";
}



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

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

long long N;
long long a[100000];
long long p[100001] = {0};
long long Q;
vector<long long> ans;

int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i];
    p[a[i]] += 1;
  }

  long long sum = 0;
  rep(i, N) {
    sum += a[i];
  }
  cin >> Q;
  rep(i, Q) {
    long long b, c;
    cin >> b >> c;
    long long s = c - b;
    sum += s * p[b];
    ans.push_back(sum);
    p[c] += p[b];
    p[b] = 0;
  }

  rep(i, ans.size()) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

using namespace std;

int main(void){
    char X,Y;
    cin>>X>>Y;
    if(X==Y)        cout<<'='<<endl;
    if(X>Y)         cout<<'>'<<endl;
    if(X<Y)         cout<<'<'<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	bool flg = true;
	ll n, ans = 0;
	in(n);
	vll a(n);
	rep(i, 0, n) {
		in(a[i]);
	}

	if (a[0] != 0) {
		outn(-1);
		return 0;
	}

	for (ll i = a.size() - 1; i > 0; i--) {
		ans += a[i];
		if (a[i] - a[i - 1] > 1) {
			flg = false;
		}
		else if(a[i]-a[i-1]==1) {
			ans -= a[i-1];
		}
	}


	if (flg) {
		outn(ans);
	}
	else {
		outn(-1);
	}

	return 0;


}


Measured memory_bytes: 1920
#include <cstdio>
using namespace std;

int A[20];
int m;
int n;
bool dfs(int i, int s){
  if (s == m)
    return true;
  if (s > m || i>=n )
    return false;
  return dfs(i+1, A[i]+s) || // Using A[i]
         dfs(i+1, s);        // Not use A[i]
}

int main(){
  scanf("%d", &n);
  for (int i=0;i<n;i++)
    scanf("%d", A+i);

  int mi[2000];
  int q;
  scanf("%d", &q);
  for (int i=0;i<q;i++){
    scanf("%d", mi+i);
  }
  for (int i=0;i<q;i++){
    m = mi[i];
    printf("%s\n",dfs(0,0)?"yes":"no");
  }
  return 0;
}




Measured memory_bytes: 2616
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, M, R, r[11], A, B, C;

  std::cin >> N >> M >> R;

  std::set<int> set;

  for (int i = 0; i < R; i ++) {
    std::cin >> r[i];

    r[i] --;

    if (i != 0 && i != R - 1)
      set.insert(r[i]);
  }

  int m[222][222];

  memset(m, 0x3f, sizeof(m));

  for (int i = 0; i < 111; i ++)
    m[i][i] = 0;

  for (int i = 0; i < M; i ++) {
    std::cin >> A >> B >> C;

    A --;
    B --;

    m[A][B] = m[B][A] = C;
  }

  for (int k = 0; k < N; k ++)
    for (int i = 0; i < N; i ++)
      for (int j = 0; j < N; j ++)
        m[i][j] = std::min(m[i][k] + m[k][j], m[i][j]);

  std::sort(r, r + R);

  int dm = INF;

  do {
    int d = 0;

    for (int i = 0; i < R - 1; i ++)
      d += m[r[i]][r[i + 1]];

    dm = std::min(d, dm);
  } while (std::next_permutation(r, r + R));

  std::cout << dm << std::endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int inf=(1<<12);


int main(void){
    int n,u;
int total=0;
int m[100][100];
int d[100];

    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int k;
            cin>>k;
            if(k==-1){
                m[i][j]=inf;
            }
            else{
                m[i][j]=k;
            }
            d[j]=inf;
        }
    }
    
    d[0]=0;
    while(1){
        u=-1;
        int min=inf;
        for(int i=0;i<n;i++){
            if(min>d[i]&&d[i]!=-1){
                min=d[i];
                u=i;
            }
        }
        if(u==-1)break;
        total+=min;
        d[u]=-1;
        for(int i=0;i<n;i++){
            if(d[i]!=-1&&d[i]>m[u][i]){
                d[i]=m[u][i];
            }
        }
    }
    cout<<total<<endl;
    return 0;
}



Measured memory_bytes: 3108
def main():
    K, N = map(int, input().split())
    A = [int(i) for i in input().split()]
    
    max_dt = K - A[-1] + A[0]
    #print(max_dt)
    for i in range(len(A) - 1):
        max_dt = max(max_dt, A[i+1] - A[i])

    print('{}'.format(K - max_dt))

if __name__ == '__main__':
    main()


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

signed main() {
  string s;
  cin >> s;
  int ret = 0;
  rep(i, s.size()) if (s[i] == 'x') ret++;
  cout << ((ret <= 7) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 100010
#define Pa 99991
#define Maxi 1e18

int main()
{
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    ll i;
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n][4];
    memset(dp,0,sizeof(dp));
    dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
    for(i=1;i<n;i++)
    {
        dp[i][0]+=(a[i]+max(dp[i-1][1],dp[i-1][2]));
        dp[i][1]+=(b[i]+max(dp[i-1][0],dp[i-1][2]));
        dp[i][2]+=(c[i]+max(dp[i-1][1],dp[i-1][0]));
        
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

struct sieve {
    vector<int> lp, pr;
    sieve(int n) : lp(n + 1, -1) {
        for (int i = 2; i <= n; i++) {
            if (lp[i] == -1) {
                lp[i] = i;
                pr.push_back(i);
            }
            for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= n; j++) {
                lp[i * pr[j]] = pr[j];
            }
        }
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int mxa = 0;
    int g = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mxa = max(mxa, a[i]);
        if (i == 0) {
            g = a[i];
        } else {
            g = gcd(g, a[i]);
        }
    }
    sieve s(mxa);
    vector<int> v(mxa + 1, -1);
    bool pc = true;
    for (int i = 0; pc && i < n; i++) {
        int x = a[i];
        if (x == 1) continue;
        if (v[x] == -1) {
            v[x] = i;
        } else if (v[x] != i) {
            pc = false;
            break;
        }
        while (x != 1) {
            if (v[s.lp[x]] == -1) {
                v[s.lp[x]] = i;
            } else if (v[s.lp[x]] != i) {
                pc = false;
                break;
            }
            x /= s.lp[x];
        }
    }

    if (pc) {
        cout << "pairwise coprime" << endl;
    } else if (g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}


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

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

signed main() {
  int H, W;
  cin >> H >> W;
  char s[55][55];
  for (int i = 0; i < 55; i++) {
    for (int j = 0; j < 55; j++) {
      s[i][j] = '.';
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] == '#') {
        bool flag = false;
        for (int t = 0; t < 4; t++) {
          int x = j + dx[t], y = i + dy[t];
          if (s[y][x] == '#') {
            flag = true;
          }
        }

        if (!flag) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int q;
    cin >> q;
    rep(i, q){
        ll a, b;
        cin >> a >> b;
        if(a == b){
            cout << 2 * (a - 1) << endl;
        }else{
            if(a > b)swap(a, b);
            ll ans = 2 * (a - 1);
            ll x = sqrt(a * b) + 0.001;
            if(x * x == a * b){
                ans += 2 * (x - a) - 1;
                cout << ans << endl;
            }else{
                if(x * (x + 1) < a * b){
                    ans += 2 * (x - a) + 1;
                }else{
                    ans += 2 * (x - a);
                }
                cout << ans << endl;
            }
        }
    }
    
}

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

const int MAX = 5e5 + 1;

struct Query
{
    int l, r, idx;
    Query(int left, int right, int index) : l(left), r(right), idx(index) {}
};

bool cmp(Query x, Query y)
{
    return x.r < y.r;
}

void update(int idx, int val, int bit[], int n)
{
    for (; idx <= n; idx += idx&-idx)
        bit[idx] += val;
}

int query(int idx, int bit[], int n)
{
    int sum = 0;
    for (; idx>0; idx-=idx&-idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(vector<int>& arr, int n, vector<Query>& queries, int q)
{
    int bit[n+1];
    memset(bit, 0, sizeof(bit));
    int last_visit[MAX];
    memset(last_visit, -1, sizeof(last_visit));

    int ans[q];
    int query_counter = 0;

    for (int i=0; i<n; i++)
    {
        if (last_visit[arr[i]] !=-1)
            update (last_visit[arr[i]] + 1, -1, bit, n);

        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                     query(queries[query_counter].r + 1, bit, n)-
                     query(queries[query_counter].l, bit, n);
            query_counter++;
        }
    }

    for (int i=0; i<q; i++)
        cout << ans[i] << endl;
}

void solve() {
    int N, Q;
    cin >> N >> Q;
    vector<int> C(N);
    for (int& c : C) cin >> c;
    vector<Query> q;
    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        q.emplace_back(l, r, i);
    }
    sort(q.begin(), q.end(), cmp);
    answeringQueries(C, N, q, Q);
}

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

    int t = 1;
    while(t--) {
        solve();
    }
}


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

using namespace std;
typedef long long ll;
static const ll inf=1e9+7;

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

    vector<ll> A(26);
    for(int i=0;i<N;i++){
        A[S[i]-'a']++;
    }
    ll ans=1;
    for(int i=0;i<26;i++){
        ans=(ans*(A[i]+1))%inf;
    }
    cout << (ans==0 ? inf -1 : ans-1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define int long long int
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll m = 998244353;
int power(int x,int y, int m) 
{ 
    if (y == 0) 
        return 1;
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
int modInverse(int a, int m) 
{     
        return power(a, m-2, m); 
}
int mod(int x)
{
	if(x<0)return -x;
	else return x;
 } 
signed main()
{
read(n);
int a[n+1]={0},b[n+1]={0},c[n+1]={0},a1=0,b1=0,c1=0,a2=0,b2=0,c2=0;
FOR(i,1,n)
{
	cin>>a[i]>>b[i]>>c[i];
	if(i==1)
	{
		a1=a[i];b1=b[i];c1=c[i];
	}
	else
	{
		a2=a[i]+max(b1,c1);
		b2=b[i]+max(a1,c1);
		c2=c[i]+max(a1,b1);
		a1=a2;b1=b2;c1=c2;
	}
}
cout<<max(a1,max(b1,c1))<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector <ll> a(n);
    REP(i,n)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());

    ll res = 0;
    REP(i,n)
    {
        if(i % 2 == 0)res += a[i];
        else res -= a[i];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5, INF = 1 << 30;
ll arr[maxn];
int seg[4 * maxn];
void build(int index, int left, int right) {
	if (left == right) {
		seg[index] = arr[left];
		return;
	}
	int mid = (left + right) / 2;
	build(2 * index, left, mid);
	build(2 * index + 1, mid + 1, right);
	seg[index] = max(seg[2 * index], seg[2 * index + 1]);
}
int query_left(int index, int left, int right, int lo, int hi, int val) {
	if (left == right)
		return left;
	int mid = (left + right) / 2;
	if (hi <= mid)
		return query_left(2 * index, left, mid, lo, hi, val);
	else if (lo > mid)
		return query_left(2 * index + 1, mid + 1, right, lo, hi, val);
	else if (lo <= left && right <= hi) {
		if (seg[2 * index + 1] < val)
			return query_left(2 * index, left, mid, lo, hi, val);
		else
			return query_left(2 * index + 1, mid + 1, right, lo, hi, val);
	}
	int a = query_left(2 * index, left, mid, lo, hi, val), b = query_left(2 * index + 1, mid + 1, right, lo, hi, val);
	return arr[b] > val? b: a;
}
int query_right(int index, int left, int right, int lo, int hi, int val) {
	if (left == right)
		return left;
	int mid = (left + right) / 2;
	if (hi <= mid)
		return query_right(2 * index, left, mid, lo, hi, val);
	else if (lo > mid)
		return query_right(2 * index + 1, mid + 1, right, lo, hi, val);
	else if (lo <= left && right <= hi) {
		if (seg[2 * index] < val)
			return query_right(2 * index + 1, mid + 1, right, lo, hi, val);
		else
			return query_right(2 * index, left, mid, lo, hi, val);
	}
	int a = query_right(2 * index, left, mid, lo, hi, val), b = query_right(2 * index + 1, mid + 1, right, lo, hi, val);
	return arr[a] > val? a: b;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	arr[0] = arr[n + 1] = INF;
	for (int i = 1; i <= n; ++i)
		cin >> arr[i];
	build(1, 0, n + 1);
	ll res = 0;
	for (ll i = 1; i <= n; ++i) {
		ll Left = query_left(1, 0, n + 1, 0, i - 1, arr[i]), Right = query_right(1, 0, n + 1, i + 1, n + 1, arr[i]);
		if (Left == 0 && Right == n + 1)
			continue;
		else if (Left == 0) {
			ll RRight = query_right(1, 0, n + 1, Right + 1, n + 1, arr[i]);
			res += arr[i] * (i * (RRight - Right));
		}
		else if (Right == n + 1) {
			ll LLeft = query_left(1, 0, n + 1, 0, Left - 1, arr[i]);
			res += arr[i] * ((Left - LLeft) * (n + 1 - i));
		}
		else {
			ll LLeft = query_left(1, 0, n + 1, 0, Left - 1, arr[i]);
			ll RRight = query_right(1, 0, n + 1, Right + 1, n + 1, arr[i]);
			res += arr[i] * (Left - LLeft) * (Right - i);
			res += arr[i] * (i - Left) * (RRight - Right);
		}
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(void){ 
    int n;
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
     
        scanf("%d",&n);
        printf("%d\n",A[n-1]);
    
    return 0;
} 



Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	char s[200001];
	cin >> s;
	int len = strlen(s);
	int sum = 0;
	for (int i = 0; i < len; i++) {
		sum += s[i] - '0';
	}
	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int arr[109];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n;
	cin >> n;
	
	for (int i=0; i<n; i++) {
		cin >> arr[i];
	}
	
	int ans = 0;
	
	while (true) {
		int l = 0;
		while (l < n) {
			if (arr[l] > 0) {
				ans++;
			}
			else {
				l++;
				continue;
			}
			while (arr[l] > 0) {
				arr[l]--;
				l++;
				if (l >= n) break;
			}
		}
		//for (int i=0; i<n; i++) cout << arr[i] << ' ';
		//cout << ans << '\n';
		bool flag = true;
		for (int i=0; i<n; i++) if (arr[i]) flag = false;
		if (flag) break;
	}
	
	cout << ans << '\n';
	
	return 0;
}	


Measured memory_bytes: 256
# coding: utf-8
 
 
def main():
    a, b = map(str, input().split())
    # print(b)
 
    a = int(a)
    b = str(b)
    # print(b)
    
    b = b[0] + b[2] + b[3]
    # b = b[0] + b[2] + b[3]
    b = int(b)
    # print(b)
    # exit()
    
    return a*b // 100
 
 
print(main())

Measured memory_bytes: 9180
function main(input) {
	var a = input[0].split(' ')
	var ans = 0
	for(var i = parseInt(a[0]); i <= parseInt(a[1]); i++){
		if(parseInt(a[2])%i==0){
			ans += 1
		}
	}
	console.log(ans)
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});

Measured memory_bytes: 8840
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        int x, y; char c;
        scanf("%d %c %d", &x, &c, &y);
        if(c == '(') cnt += y;
        else cnt -= y;
        puts(cnt ? "No" : "Yes");
    }
    return 0;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        char c;
        cin >> c;
        if (islower(c))
            cout << "a";
        else
            cout << "A";
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3648
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

def solve(H,W,start,S,T):
    limit = [W,H]
    offsets = [0]*4

    for s,t in zip(reversed(S),reversed(T)):
        offsets[t^1] = max2(offsets[t^1]-1,0)
        offsets[s] += 1
        if offsets[s]+offsets[s^1] >= limit[s//2]:
            return False
    h,w = start
    l,r,u,d = offsets
    return l <= w < W-r and u <= h < H-d



if __name__ == '__main__':
    H,W,N = map(int,input().split())
    start = tuple(map(lambda x: int(x)-1,input().split()))

    d = {'L':0,'R':1,'U':2,'D':3}

    S = tuple(d[c] for c in input())
    T = tuple(d[c] for c in input())


    print('YES' if solve(H,W,start,S,T) else 'NO')

Measured memory_bytes: 94528
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int sx,sy,gx,gy;
	cin>>sx>>sy>>gx>>gy;
	REP(i,abs(sy-gy))cout<<"U";
	REP(i,abs(sx-gx))cout<<"R";
	REP(i,abs(sy-gy))cout<<"D";
	REP(i,abs(sx-gx)+1)cout<<"L";
	REP(i,abs(sy-gy)+1)cout<<"U";
	REP(i,abs(sx-gx)+1)cout<<"R";
	cout<<"D";
	cout<<"R";
	REP(i,abs(sy-gy)+1)cout<<"D";
	REP(i,abs(sx-gx)+1)cout<<"L";
	cout<<"U";
	
	cout<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
ll check(vi &v,bool p=false)
{
    if(!p)shuffle(v.begin(),v.end(),rng);
    vi temp=v;
    while(temp.size()>1)
    {
        if(p)
        {
//            for(auto x:temp)cout<<x<<' ';
//            cout<<endl;
        }
        vi t;
        for(int i=1;i+1<temp.size();i++)
        {
            vi r;
            r.push_back(temp[i]);
            r.push_back(temp[i+1]);
            r.push_back(temp[i-1]);
            sort(r.begin(),r.end());
            t.push_back(r[1]);
        }
        temp=t;
    }
    return temp[0];
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n,x;
        cin>>n>>x;
        if(x==2*n-1||x==1)
        {
            cout<<"No"<<endl;
            return 0;
        }
        vi ans(2*n-1);
        ans[n-1]=x;
        ans[n-2]=x-1;
        ans[n]=x+1;
        vi taken(2*n);
        taken[x]=taken[x+1]=taken[x-1]=1;
        if(n!=2)
        {
            if(x!=2)ans[n+1]=x-2,taken[x-2]=1;
            if(x!=2*n-2)ans[n-3]=x+2,taken[x+2]=1;
            ll l=1;
            for(auto &x:ans)
            {
                while(l<2*n&&taken[l]==1)l++;
                if(x==0)x=l,taken[l]=1;
            }
        }
//        assert(check(ans,1)==x);
        cout<<"Yes"<<endl;
        for(auto x:ans)cout<<x<<' ';
        cout<<endl;
    }

}

Measured memory_bytes: 4608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n,a[1001];
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
}

for(int i=n-1;i>=0;i--){
    printf("%d",a[i]);
    if(i==0){break;}
    printf(" ");
}
printf("\n");
}



Measured memory_bytes: 2060
#define DBG 0 //submit 0
#if DBG
    #include <algorithm>
    #include<array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    int j,k,tmp = 0,tmpi = 0;
    long long i,ans = 0,temp = 0;
    long long N;
    //string S;
    cin >> N;
	
  	temp = (long long)sqrt((double)N);
	for(i = temp;i>0;i--){
      if(N % i == 0) break;
    }
    ans = i + N/i - 2;

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char ch[500000];
int main(){
	scanf("%s",ch);
	int len=strlen(ch);
	for(int i=0;i<len;i++){
		if((i%2==1&&ch[i]=='R') || (!(i%2)&&ch[i]=='L')){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
(N, M), *ABs = readlines.map{_1.split.map(&:to_i)}

@g = ABs.each_with_object(Array.new(N + 1){[]}){|(a, b), g|  g[a] << b; g[b] << a}
@ans = Array.new(N + 1, nil); @ans[1] = 0
q = [1]
while !q.empty?
  u = q.shift
  @g[u].each do |v|
    next if @ans[v]
    q << v
    @ans[v] = u
  end
end
puts ['Yes'] + @ans[2, N - 1]

Measured memory_bytes: 64464