akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int a, b;
  cin >> a;
  cin >> b;
  if (a > b) {
    for (int i = 0; i < a; ++i) {
      printf("%d", b);
    }
  } else {
    for (int i = 0; i < b; ++i) {
      printf("%d", a);
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n, cap;
    cin >> n >> cap;
    vector<int> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    vector<vector<int>> dp(n + 1, vector<int>(cap + 1));
    rep(i, n){
        rep(j, cap + 1){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if(j - w[i] < 0){
                continue;
            }
            dp[i+1][j-w[i]] = max(dp[i+1][j-w[i]], dp[i][j] + v[i]);
        }
    }

    int ans = 0;
    rep(i, cap + 1){
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
//long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int isPal(string a,string b){
    int n=a.size();
    fori(0,n){
        if(a[i]!=b[i]) return 0;
        
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    //cout<<t;
    //scanf("%d",&t);
    while(t--){
        int n;
        cin>>n;
        int a[n];
        int x=0;
        fori(0,n){
            cin>>a[i];
            x=x^a[i];
        }
        fori(0,n){
            int c=x^a[i];
            cout<<c<<" ";
        }
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int amax = 0;
    for(int i =0; i < n-1;i++) {
        for(int j = i+1; j < n; j++) {
             amax = max(amax, abs(a[i] - a[j]));
        }
    }
    cout << amax << endl;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

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

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);

const int N = 2e5 + 10;

#define FILENAME ""

int n;
int m;

int dp[N][3];

int h[N][3];

void fdp() {
	for (int i = 0; i < 3; i++) {
		dp[n - 1][i] = h[n - 1][i];
	}
	for (int i = n - 1; i >= 1; i--) {
		for (int j = 0; j < 3; j++) {
			ii ind = mp ((j + 1) % 3, (j + 2) % 3);
			dp[i - 1][ind.fi] = max (dp[i - 1][ind.fi], dp[i][j] + h[i - 1][ind.fi]);
			dp[i - 1][ind.se] = max (dp[i - 1][ind.se], dp[i][j] + h[i - 1][ind.se]);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(NULL);
//	freopen(FILENAME ".in", "r", stdin);
//	freopen(FILENAME ".out", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i][0] >> h[i][1] >> h[i][2];
	}
	fdp();
	cout << max (max(dp[0][0], dp[0][1]), dp[0][2]);
	re 0;
}     







Measured memory_bytes: 3456
def main():
    N,M,C = map(int, input().split())
    B = list(map(int, input().split()))
    Aij = [list(map(int, input().split())) for i in range(N)]
    
    
    cnt = 0
    wa = C
    for i in range(N):
        wa = C
        for j in range(M):
            wa =  wa + Aij[i][j]*B[j]
        if wa > 0:
            cnt = cnt + 1
    print(cnt)
    
main()

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF=2e18;
ll N,K;
ll a[100010];
vector<ll> primes;
ll mem[100];
ll Count(ll n){
    if(mem[n]!=0)return mem[n];
    ll ret=0;
    for(ll i=1;pow(n,i)<=N;i++){
        ret+=N/pow(n,i);
    }
    return mem[n]=ret+1;
}
int main(){
    cin>>N;
    ll ans=0;
    for(ll i=2;i<=N;i++){
        bool f=true;
        for(ll j=2;j*j<=i;j++){
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f){
            primes.push_back(i);
        }
    }
    for(ll i=0;i<primes.size();i++){
        for(ll j=i+1;j<primes.size();j++){
            for(ll k=0;k<primes.size();k++){
                if(i==k || j==k)continue;
                ll a=primes[i];
                ll b=primes[j];
                ll c=primes[k];
                if(Count(a)>=5 && Count(b)>=5 && Count(c)>=3){
                    ans++;
                    //cout<<a<<" "<<b<<" "<<c<<endl;
                }
            }
        }
    }
    for(ll i=0;i<primes.size();i++){
        for(ll j=0;j<primes.size();j++){
            if(i==j)continue;
            ll a=primes[i];
            ll b=primes[j];
            if(Count(a)>=25 && Count(b)>=3){
                ans++;
            }
        }
    }

    for(ll i=0;i<primes.size();i++){
        for(ll j=0;j<primes.size();j++){
            if(i==j)continue;
            ll a=primes[i];
            ll b=primes[j];
            if(Count(a)>=15 && Count(b)>=5){
                ans++;
            }
        }
    }

    for(ll i=0;i<primes.size();i++){
        if(Count(primes[i])>=75){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int x[20][20];
int main()
{
	int n,d;int cnt=0;cin>>n>>d;
	for(int i=0;i<n;i++) for(int j=0;j<d;j++) scanf("%d",&x[i][j]);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int ans=0;
			for(int k=0;k<d;k++)
			{
				ans+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			int m=sqrt(ans);
			if(m*m ==ans) cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int n;
	string s;
	cin >> n >> s;
	FOR(i, 0, s.size() - 1) {
		if (s[i] + n <= 'Z') {
			s[i] = s[i] + n;
		}
		else {
			s[i] = s[i] + n - 26;
		}
	}
	pv(s);
	return(0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

#define chmin(a,b) a=min(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)

const int inf = 1e9;

int N, M;
int mc[100][100], mt[100][100];

int main()
{
    while (scanf("%d %d", &N, &M), N || M) {
        fill(mc[0], mc[M], inf);
        fill(mt[0], mt[M], inf);

        rep(i, M) mc[i][i] = mt[i][i] = 0;

        rep(i, N) {
            int a, b, cost, time; scanf("%d %d %d %d", &a, &b, &cost, &time); a--; b--;
            mc[a][b] = mc[b][a] = cost;
            mt[a][b] = mt[b][a] = time;
        }

        rep(k, M) rep(i, M) rep(j, M) {
            chmin(mc[i][j], mc[i][k] + mc[j][k]);
            chmin(mt[i][j], mt[i][k] + mt[j][k]);
        }

        int K; scanf("%d", &K);
        rep(i, K) {
            int p, q, r; scanf("%d %d %d", &p, &q, &r); p--; q--;
            printf("%d\n", r == 0 ? mc[p][q] : mt[p][q]);
        }
    }
}

Measured memory_bytes: 1104
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int z;
        if(a < b){
            z = a;
            a = b;
            b = z;
        }

        int temp = 1;
        while(temp != 0){
            temp = a % b;
            if(temp == 0){
                break;
            }
            a = b;
            b = temp;
        }

        System.out.println(b);
    }
}


Measured memory_bytes: 26220
#include<stdio.h>

int main(){
  int i;
  char ban[10];
  while(scanf("%s",ban)!=EOF){
    for(i=0;i<3;i++)
      if(ban[i*3]!='s')
	if(ban[i*3]==ban[i*3+1]&&ban[i*3+1]==ban[i*3+2]){
	  printf("%c\n",ban[i*3]);
	  goto end;
	}
    for(i=0;i<3;i++)
      if(ban[i+3*i]!='s')
	if(ban[i]==ban[i+3]&&ban[i+3]==ban[i+6]){
	  printf("%c\n",ban[i]);
	  goto end;
	}
    for(i=0;i<3;i++)
      if(ban[i]!='s')
	if(ban[i]==ban[4]&&ban[4]==ban[8-i]){
	  printf("%c\n",ban[i]);
	  goto end;
	}
    printf("d\n");
  end:;
  }
  return 0;
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

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

    int h,w;
    int ans = 0;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    rep(si,h)rep(sj,w){
        if(s[si][sj] == '#') continue;
        vector<vector<int>> dist(h,vector<int>(w,INF));
        queue<P> q;
        auto update = [&](int i, int j, int x){
            if(dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i,j));
        };
        update(si,sj,0);
        while(!q.empty()){
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            rep(dir,4){
                int ni = i + di[dir];
                int nj = j + dj[dir];
                if(ni<0||ni>=h||nj<0||nj>=w) continue;
                if(s[ni][nj] == '#') continue;
                update(ni,nj,dist[i][j] + 1);
            }

        }
        rep(i,h)rep(j,w){
            if(dist[i][j]==INF) continue;
            ans = max(ans,dist[i][j]); 
        }

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a = 0;
  int W,H,x,y,r;

    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0&&x+r<=W){
      if(y-r>=0&&y+r<=H)
	{
	  a=1;
     
    }
    }  
    else{
      a=0;
    }
    if(a==1){
      printf("Yes\n");
    }
    else if(a==0){
      printf("No\n");
    }
      return 0;
}



Measured memory_bytes: 2088
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  ans = LINF;
  rep(i, Size(s) - 3 + 1) {
    string co = "";
    co += s[i];
    co += s[i + 1];
    co += s[i + 2];
    cnt = stoll(co);
    ans = min(ans, abs(753 - cnt));
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n := scanInt(sc)
	as := nextIntSlice(sc, n+1)
	bs := nextIntSlice(sc, n)
	num := 0
	rest := as[0]
	for i := 0; i < len(bs); i++ {
		monsters := rest + as[i+1]
		killNum := min(monsters, bs[i])
		num += killNum
		if killNum > rest {
			rest = as[i+1] - (killNum - rest)
		} else {
			rest = as[i+1]
		}
	}
	return num
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

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

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

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

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

    map<ll,ll> A;
    REP(x,1,101) {
        REP(y,1,101) {
            REP(z,1,101) {
                ++A[x*x + y*y + z*z + x*y + y*z + z*x];
            }
        }
    }

    REP(i,1,N+1) PR(A[i]);

    return 0;
}

/*



*/

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

#define MOD 1000000007

long long combination(long long start, long long end, long long W)
{
    long long ret = 0;
    if (start > end)
    {
        swap(start, end);
    }
    if (1 > start)
    {
        return ret;
    }
    if (end > W)
    {
        return ret;
    }
    for (int i = 0; i < (1 << (W - 1)); i++)
    {

        bitset<16> bit(i << 1);
        bool is_valid = true;
        for (int j = 2; j < W; j++)
        {
            if (bit[j - 1] == 1 && bit[j] == 1)
            {
                is_valid = false;
                break;
            }
        }
        if (is_valid)
        {
            if (start == end)
            {
                if (start == 1)
                {
                    if (!bit[1])
                    {
                        ret++;
                    }
                }
                else if (start == W)
                {
                    if (!bit[W - 1])
                    {
                        ret++;
                    }
                }
                else
                {
                    if (!bit[start - 1] && !bit[start])
                    {
                        ret++;
                    }
                }
            }
            else
            {
                if (bit[start])
                {
                    ret++;
                }
            }
        }
    }
    return ret;
}

long long dfs(vector<vector<long long>> &dp, long long h, long long w, long long W)
{
    long long ret = 0;
    // constatnt
    if (w == 0 || w > W)
    {
        return ret;
    }
    if (h == 0)
    {
        if (w == 1)
        {
            ret++;
        }
        return ret;
    }

    // dfs and memolize
    if (dp[h - 1][w - 1] == -1)
    {
        dp[h - 1][w - 1] = dfs(dp, h - 1, w - 1, W);
    }
    if (dp[h - 1][w] == -1)
    {
        dp[h - 1][w] = dfs(dp, h - 1, w, W);
    }
    if (dp[h - 1][w + 1] == -1)
    {
        dp[h - 1][w + 1] = dfs(dp, h - 1, w + 1, W);
    }

    // sum
    ret = (ret + combination(w - 1, w, W) * dp[h - 1][w - 1]) % MOD;
    ret = (ret + combination(w, w, W) * dp[h - 1][w]) % MOD;
    ret = (ret + combination(w + 1, w, W) * dp[h - 1][w + 1]) % MOD;
    return ret;
}

int main()
{
    long long H, W, K;
    cin >> H >> W >> K;
    vector<vector<long long>> dp(H + 1, vector<long long>(W + 2, -1));
    cout << dfs(dp, H, K, W) << endl;
}


Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase
# from collections import defaultdict as dd
# from collections import deque as dq
# import itertools as it
# from math import sqrt, log, log2
# from fractions import Fraction

def main():
    t = int(input())
    print('Yes' if t>=30 else "No")
        # n = int(input())
        #x, y = map(int, input().split())
        #nums = list(map(int, input().split()))
        




































# 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: 9372
#include<bits/stdc++.h>
#include <iostream>

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,x,t,ans;
    cin>>n>>x>>t;
    ans=(n/x)*t;
    if(n%x>0)
        ans+=t;
    cout<<ans;
    return 0;
}


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

signed main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  for(int i=0;i<N;i++)v[i]--;
  std::vector<int> a(N),b(N);
  for(int i=0;i<N;i++)a[i]=i*4e4+1;
  for(int i=0;i<N;i++)b[N-i-1]=i*4e4+1;
  for(int i=0;i<N;i++)a[v[i]]+=i;
  for(int i=0;i<N;i++)cout<<a[i]<<" ";
  cout<<endl;
  for(int i=0;i<N;i++)cout<<b[i]<<" ";
  cout<<endl;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,x;cin>>n>>x;int arr[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }unsigned long long ans=0;
    for (int i=0;i<n-1;i++){
        if (arr[i]+arr[i+1]>x){
            ans+=arr[i]+arr[i+1]-x;
            if (arr[i+1]>=arr[i]+arr[i+1]-x)arr[i+1]-=arr[i]+arr[i+1]-x;
            else{
                arr[i+1]=0;
            }
        }
    }cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll ans = 0;
  ll mx = A[0];
  for (int i = 1; i < N; i++) {
    if (mx < A[i]) {
      mx = A[i];
    } else {
      ans += mx - A[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5208
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = 200000;

/* typedef */

/* global variables */

int ds[MAX_N], ts[MAX_M];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &ds[i]);
  sort(ds, ds + n);

  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) scanf("%d", &ts[i]);
  sort(ts, ts + m);

  bool ok = true;
  for (int i = 0, j = 0; i < m; i++) {
    while (j < n && ds[j] < ts[i]) j++;
    if (j >= n || ds[j] != ts[i]) {
      ok = false;
      break;
    }
    j++;
  }

  if (ok) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 1920
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# Nと空白区切の入力値を数値の配列で返却する
def gets_n_and_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

n, a_list = gets_n_and_i_list

a_list.sort!.reverse!

total = 0
count = n

0.upto(n) do |i|
  if count > 0
    total += a_list[i]
    count -= 1
  else
    break
  end

  if count > 0
    total += a_list[i]
    count -= 1
  else
    break
  end
end

puts total - a_list.first

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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  int maxdist = 0;
  maxdist = max(maxdist, e - a);
  maxdist = max(maxdist, e - b);
  maxdist = max(maxdist, e - c);
  maxdist = max(maxdist, e - d);
  maxdist = max(maxdist, d - a);
  maxdist = max(maxdist, d - b);
  maxdist = max(maxdist, d - c);
  maxdist = max(maxdist, c - a);
  maxdist = max(maxdist, c - b);
  maxdist = max(maxdist, b - a);

     
  if(maxdist > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool isok = true;
    for(int i=0; i<s.size(); i++){
        if(i==a){
            if(s[i]!='-'){
                isok = false;
            }
        }else{
            if(!('0'<=s[i] && s[i]<='9')){
                isok = false;
            }
        }
    }

    if(isok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N, Q = map(int, input().split())
INF = 2**31-1

LV = (N-1).bit_length()
N0 = 2**LV
data = [0]*(2*N0)
lazy = [0]*(2*N0)

def gindex(l, r):
    L = l + N0; R = r + N0
    lm = (L // (L & -L)) >> 1
    rm = (R // (R & -R)) >> 1
    while L < R:
        if R <= rm:
            yield R
        if L <= lm:
            yield L
        L >>= 1; R >>= 1
    while L:
        yield L
        L >>= 1

def propagates(*ids):
    for i in reversed(ids):
        v = lazy[i-1]
        if not v:
            continue
        lazy[2*i-1] += v; lazy[2*i] += v
        data[2*i-1] += v; data[2*i] += v
        lazy[i-1] = 0

def update(l, r, x):
    L = N0 + l; R = N0 + r
    while L < R:
        if R & 1:
            R -= 1
            lazy[R-1] += x; data[R-1] += x
        if L & 1:
            lazy[L-1] += x; data[L-1] += x
            L += 1
        L >>= 1; R >>= 1
    for i in gindex(l, r):
        data[i-1] = min(data[2*i-1], data[2*i]) + lazy[i-1]

def query(l, r):
    propagates(*gindex(l, r))
    L = N0 + l; R = N0 + r

    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])
        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s


ans = []
for q in range(Q):
    t, *cmd = map(int, readline().split())
    if t:
        s, t = cmd
        ans.append(str(query(s, t+1)))
    else:
        s, t, x = cmd
        update(s, t+1, x)

write("\n".join(ans))
write("\n")


Measured memory_bytes: 24588
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ll binpow(ll x, ll y) {
	ll z = 1;
	while (y) {
		if (y % 2) z = (z * x) % mod;

		y = y / 2;
		x = (x * x) % mod;
	}
	return z % mod;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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


	ll tc = 1;

//	cin >> tc;

	while (tc--) {
		ll bal = 100;
		ll rate = 1;
		ll t = 0;

		ld x;
		cin >> x;
		while (bal < x) {
			bal = bal + (bal * rate) / 100;
			t++;
		}

		cout << t << endl;



	}

}

Measured memory_bytes: 3720
class Dice:
  
  def __init__(self, input_dice):
    self.flow = [input_dice[3], input_dice[1], input_dice[0], input_dice[5], input_dice[2], input_dice[4]]
    self.dice = [i for i in range(6)]
  
  def setNumber(self, n0, n1, n2, n3, n4, n5):
    self.dice[0] = n0
    self.dice[1] = n1
    self.dice[2] = n2
    self.dice[3] = n3
    self.dice[4] = n4
    self.dice[5] = n5
    return self.dice
    
  def roll(self, dir):
    if dir == 'S':
      self.setNumber(self.flow[0], self.flow[2], self.flow[5], self.flow[1], self.flow[4], self.flow[3])
      self.flow = self.dice
      return self.dice
    if dir == 'N':
      self.setNumber(self.flow[0], self.flow[3], self.flow[1], self.flow[5], self.flow[4], self.flow[2])
      self.flow = self.dice
      return self.dice
    if dir == 'W':
      self.setNumber(self.flow[2], self.flow[1], self.flow[4], self.flow[0], self.flow[3], self.flow[5])
      self.flow = self.dice
      return self.dice
    if dir == 'E':
      self.setNumber(self.flow[3], self.flow[1], self.flow[0], self.flow[4], self.flow[2], self.flow[5])
      self.flow = self.dice
      return self.dice

dice = list(map(int, input().split()))
d = Dice(dice)
dir = list(input())
for i in range(len(dir)):
  d.roll(dir[i])
print(d.dice[2])


Measured memory_bytes: 5616
#include<stdio.h>
#define ll long long
ll prime(ll n){
    if(n < 2) return 0;
    for(ll i = 2; i * i <= n; i++)
        if(n % i == 0)
            return i;
    return n;
}
int main(){
    ll n;
    scanf("%lld",&n);
    ll p, q, r, ans = 0;
    while(n > 1){
        p = prime(n);
        q = 0;
        while(n % p == 0){
            q++;
            n /= p;
        }
        r = 1;
        while(r * (r + 1) / 2 <= q)
            r++;
        ans += r - 1;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1736
#include <cstring>
#include <algorithm>
#include <cstdio>

typedef long long ll;
const int N = 1000010;
int _w;

int n, m;

namespace G {
	int head[N], nxt[N], to[N], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v ) {
		to[eid] = v, nxt[eid] = head[u], head[u] = eid++;
		to[eid] = u, nxt[eid] = head[v], head[v] = eid++;
	}
}

int cnt[3], vis[N], q[N], begin, end;

int bfs( int s ) {
	using namespace G;
	begin = end = 0, q[end++] = s, vis[s] = 1;
	int type = 2;
	while( begin != end ) {
		int u = q[begin++];
		for( int i = head[u]; ~i; i = nxt[i] ) {
			int v = to[i];
			if( vis[v] == vis[u] ) {
				type = 1;
			} else if( !vis[v] ) {
				vis[v] = 3 - vis[u];
				q[end++] = v;
			}
		}
	}
	if( end == 1 ) return 0;
	else return type;
}

void solve() {
	ll ans = 0;
	if( cnt[0] ) {
		int m = n - cnt[0];
		ans += 1LL*n*n - 1LL*m*m;
	}
	if( cnt[1] ) {
		ans += 1LL * cnt[1] * (cnt[1] + cnt[2]);
	}
	if( cnt[2] ) {
		ans += 1LL * cnt[2] * (cnt[1] + cnt[2] * 2);
	}
	printf( "%lld\n", ans );
}

int main() {
	_w = scanf( "%d%d", &n, &m );
	G::init();
	for( int i = 0; i < m; ++i ) {
		int u, v;
		_w = scanf( "%d%d", &u, &v );
		G::link(u, v);
	}
	for( int i = 1; i <= n; ++i )
		if( !vis[i] )
			cnt[bfs(i)]++;
	solve();
	return 0;
}


Measured memory_bytes: 18048
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



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


    int n;
    cin >> n;

    auto ok = [&](int x) {
        int cnt = 0;
        for (int i = 1; i <= x; ++i) {
            if (x % i == 0) {
                ++cnt;
            }
        }
        return cnt == 8;
    };
    int res = 0;
    for (int i = 1; i <= n; i += 2) {
        if (ok(i)) {
            ++res;
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int main()
{
    int n,m;
  cin>>n>>m;
  int h[n+1];
  for(int i=1;i<=n;i++)
    cin>>h[i];
  vector<int>maxx(n+1);
  for(int i=0;i<m;i++)
  {
    int u,v;
    cin>>u>>v;
    maxx[u]=max(maxx[u],h[v]);
    maxx[v]=max(maxx[v],h[u]);
  }
  int count=0;
  for(int i=1;i<=n;i++)
  {
     if(h[i]>maxx[i])
       count++;
  }
 cout<<count<<endl;

  
  
  }


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

int main(void)
{
	int n;

	while(cin >> n, n >= 0){
		if(!n){
			cout << n << endl;
			continue;
		}
		stack<int> sta;
		while(n > 0){
			sta.push(n%4);
			n /= 4;
		}
		while(sta.size()){
			cout << sta.top();
			sta.pop();
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
/*standard declarations*/
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef vector<ll> vll;
typedef vector<pair<ll,ll> > vllp; 
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a;i>=b;i--)
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
#define pb push_back
 
/*comparators*/
struct cmp {
	bool operator() (const pair<ll,pair<ll, ll>> &a, const pair<ll,pair<ll, ll>> &b) const {
		if(a.ft!=b.ft){
            return a.ft<b.ft;
        }
        else{
            if(a.sd.ft!=b.sd.ft){
                return a.sd.ft<b.sd.ft;
            }
            else{
                return a.sd.sd<b.sd.sd;
            }
        }
	}
};
/*templates here*/
template <typename T>
void show(T *a, int size)
{
    int i;
    cout << endl
         << "The array is ";
    fr(i, 0, size)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}
 
template <typename T>
void show_vector(vector<T> v)
{
    cout << endl
         << "The vector is ";
    int i;
    fr(i, 0, v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}
/*global variables here*/
ll TESTTEST;
#define mxn 2000001
#define PI 3.14159265	
#define mod 1000000007	
ll dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
ll n,k;
/*global functions here*/


/*main function here*/							
void solve(){
    ll n;
    cin>>n;
    ll a[n+1][3];
    ll dp[n+1][3];
    fr(i,0,3)dp[0][i]=0;
    fr(i,1,n+1){
        fr(j,0,3){
            cin>>a[i][j];
        }
        fr(j,0,3){
            dp[i][j]=a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
        }
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<"\n";
    return;
}
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll zzz=1;
	//cin>>zzz;
	for(TESTTEST=1;TESTTEST<(zzz+1);TESTTEST++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 8296
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int a, p;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> a >> p;
  cout << (p + a * 3) / 2 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n<1200) cout << "ABC"; 
	else cout << "ARC";
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, k;
bool b[111][111];
void solve(){
	cin >> n >> k;
	k -= (n-1)*(n-2)/2;
	
	if(k > 0){
		cout << -1 << endl;
		return;
	}
	
	vector<int> v[111];
	vector<P> ans;
	for(int i = 2; i <= n; i++){
		//cout << 1 << " " << i << endl;
		ans.push_back({1,i});
		v[1].push_back(i);
		v[i].push_back(1);
		b[1][i] = b[i][1] = 1;
	}
	if(k != 0){
		for(int i = 2; i < n; i++){
			for(int j = i+1; j <= n; j++){
				if(b[i][j]) continue;
				b[i][j] = 1;
				k++;
				//cout << i << " " << j << endl;
				ans.push_back({i,j});
				if(k == 0) break;
			}
			if(k==0) break;
		}
	}
	cout << ans.size() << endl;
	for(auto i:ans){
		cout << i.first << " " << i.second << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 512
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
	ll a;
  	cin >> a;
  	ll syou = a/15;
  	ll kari = syou * 15 * 4 * syou;
  	ll amari = a%15;
  	int i = 1;
  	while(i<=amari){
      	if(i==1 || i==2 || i==4 || i==7 || i==8 || i==11 || i==13 || i==14)kari += syou*15 + i;
        i++;
    }
  cout << kari << endl;
}

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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>a>>b>>c;
    if(abs(b-a)<abs(c-a))
        cout<<"A";
    else
    {
        cout<<"B";
    }
    
	
	return 0;
}
	

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

using namespace std;

int f(int n) {
  if (n == 0) return 0;
  return n % 10 + f(n / 10);
}

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

  puts(n % f(n) == 0 ? "Yes" : "No");
}


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

int main() {
  int x, y,s,t;
  cin >> x>> y >> s>> t;
  //cin >> y;

  if (x+y > s+t) 
      {
        cout << "Left" << endl;
      }

   else if (x+y < s+t) //(x%500 > y)
         {
          cout << "Right" << endl;
        }
   else 
   {
    cout << "Balanced" << endl;
   }
   //else 
   //{
    //cout << "Yes" << endl;
   //}
   return 0;
    //else
        //{
         // cout << "No" << endl;
       // }
  

  //cout << "終了" << endl;
}



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

int main(){
  int X;
  cin >> X;
  int ans = X;
  for(int b=1;b<32;b++){
    for(int p=2;p<10;p++){
      int c = X - pow(b,p);
      if(0<=c)
        ans = min(ans,c);
    }
  }
  cout << X-ans << endl; 
}

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

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

  int n = S.size() - 1;

  ll ans = 0;
  rep(i, 1 << n) {
    int pos = 0;
    rep(j, n) {
      if (i & 1 << j) {
        ans += stoll(S.substr(pos, j + 1 - pos));
        pos = j + 1;
      }
    }
    ans += stoll(S.substr(pos, n + 1));
  }

  cout << ans << endl;
}

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

typedef long long ll;

const int inf = 1000000;

int n, m, q;
int a[55], b[55], c[55], d[55];
int res = 0;
void dfs(vector<int> &A) {
    if (A.size() == n) {
        int tmp = 0;
        for (int i = 0; i < q; i++) {
            if (A[b[i]]-A[a[i]] == c[i]) tmp += d[i];
        }
        res = max(res, tmp);
        return;
    }
    int s;
    if (A.size() == 0) s = 1;
    else s = A[A.size()-1];
    for (int v = s; v <= m; v++) {
        A.push_back(v);
        dfs(A);
        A.pop_back();
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<int>A;
    dfs(A);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int count = 0;
    sc.nextLine();
    String line = sc.nextLine();
    String[] array = line.split(" ");
    int pi;
    int min = a + 1;
    for(int i = 0; i < a ; i++){
      pi = Integer.parseInt(array[i]);
      if(min > pi) {
    	  count++;
    	  min = pi;
      }
    }
    
    System.out.println(count);
  }
}
    
    

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

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)

    return divisors
divisors = make_divisors(N)
ans = 0
for d in divisors:
    t = d - 1
    if t != 0 and N % t == N // t:
        ans += t
print(ans)


Measured memory_bytes: 3268
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class DWalkAndTeleport {
public:
	void solve(istream& in, ostream& out) {
        int n; ll a, b,ans = 0;
        in >> n >> a >> b;
        vector<ll> x(n),sa(n-1);
        rep(i,n) in >> x[i];
        rep(i,n-1) sa[i] = x[i+1] - x[i];

        rep(i,n-1) {
            if(sa[i] * a >= b) ans += b;
            else ans += sa[i] * a;
        }
        out << ans << endl;
	}
};

int main() {
	DWalkAndTeleport solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



signed main(){
	int H, W, CH, CW, DH, DW;
	cin >> H >> W >> CH >> CW >> DH >> DW;
	--CH;--CW;--DH;--DW;
	vector<string>s(H);
	cin >> s;

	vector<vector<int>>dist(H, vector<int>(W, INF));
	dist[CH][CW] = 0;
	using T = tuple<int, int, int>;
	priority_queue<T, vector<T>, greater<T>>que;
	que.push({dist[CH][CW], CH, CW});
	while(que.size()) {
		auto[cost, i, j] = que.top();
		que.pop();
		if(dist[i][j] != cost) continue;
		FOR(k, i - 2, i + 2 + 1) {
			FOR(l, j - 2, j + 2 + 1) {
				int distance = abs(i - k) + abs(j - l);
				if(distance == 0) continue;
				if(!IN(0, k, H) || !IN(0, l, W)) continue;
				if(s[k][l] == '#') continue;
				if(distance == 1) {
					if(CHMIN(dist[k][l], (int)cost)) {
						que.push({dist[k][l], k, l});
					}
				} else {
					if(CHMIN(dist[k][l], (int)cost + 1)) {
						que.push({dist[k][l], k, l});
					}
				}
			}
		}
	}
	if(dist[DH][DW] == INF) out(-1);
	else out(dist[DH][DW]);
}

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

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

    vector<long long> va(n), ca(n, 0);
    long long a;
    for (int i=0; i<n; i++) {
        cin >> a;
        va.at(i) = a;
        ca.at(a-1)++;
    }

    long long ans = 0;

    for (int i=0; i<n; i++) {
        if (ca.at(i) > 1) {
            ans += ca.at(i) * (ca.at(i)-1) / 2;
        }
    }

    long long tmpans; 

    for (int i=0; i<n; i++) {
        tmpans = ans;
        if (ca.at(va.at(i)-1) > 1) {
            tmpans -= (ca.at(va.at(i)-1)-1);
        }
        cout << tmpans << endl;
    }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

ll judge(set<ll> &x,set<ll>&y,vector<vector<char>> &z,ll h,ll w) {
  ll count=0;
  for(ll i=0;i<h;i++) {
for(ll j=0;j<w;j++) {
if(x.count(i) ) {
break;
}
  if(y.count(j) ){
    continue;
  }
  if(z[i][j]=='#') {
    count++;
  }
}
  }
  
  return count;
}

 
int main() {
  
ll H,W,K;
  cin>>H>>W>>K;
  ll ans=0;
  
  vector<vector<char>> vec(H,vector<char>(W));
  for(ll i=0;i<H;i++) {
for(ll j=0;j<W;j++) {
cin>>vec[i][j];
}
  }
  
  ll size=H+W;
  for(ll tmp=0;tmp<(1<<size);tmp++) {
bitset<12> s(tmp);
    set<ll> HS;
    set<ll> WS;
    for(ll i=0;i<H;i++) {
if(s.test(i)) {
HS.insert(i);
}
    }
    for(ll i=0;i<W;i++) {
if(s.test(i+H)) {
  WS.insert(i);
}
    }

    if(judge(HS,WS,vec,H,W)==K) {
      ans++;
    }
  }
  
  cout<<ans<<endl;
}


    

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int diff = A+B-C-D;
  
  if (diff>0){
    cout << "Left" << endl;
  }
  else if (diff==0) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256