akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 5010;

struct edge{
    int to, cost; lint time;
    edge(int to, int c, lint t): to(to), cost(c), time(t){}
};

struct state{
    lint time; int v; int s;
    state(lint t, int v, int s): time(t), v(v), s(s){}
};

int n, m, s;
vector<edge> G[50];
int c[50];
lint d[50], ans[50][MAX+10];


int main(){
    scanf("%d%d%d", &n, &m, &s);
    chmin(s, MAX);
    rep(i, m){
        int u, v, a; lint b;
        scanf("%d%d%d%lld", &u, &v, &a, &b);
        --u; --v;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }
    rep(i, n) scanf("%d%lld", &c[i], &d[i]);
    auto cmp = [](const state &s1, const state &s2){return s1.time > s2.time;};
    priority_queue<state, vector<state>, decltype(cmp)> que(cmp);
    rep(i, n)rep(j, MAX) ans[i][j] = INF;
    ans[0][s] = 0;
    que.emplace(0, 0, s);
    while(!que.empty()){
        auto st = que.top(); que.pop();
        if(chmin(ans[st.v][min(MAX, st.s+c[st.v])], st.time + d[st.v])){
            que.emplace(st.time + d[st.v], st.v, min(MAX, st.s+c[st.v]));
        }
        for(auto &e: G[st.v])if(st.s >= e.cost){
            if(chmin(ans[e.to][st.s-e.cost], st.time + e.time)){
                que.emplace(st.time + e.time, e.to, st.s-e.cost);
            }
        }
    }
    For(i, 1, n){
        lint tmp = INF;
        rep(j, MAX) chmin(tmp, ans[i][j]);
        printf("%lld\n", tmp);
    }
}

Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ; 
	string s ;
	cin >> n >> s; 
	if(n&1){
		cout << "No\n";
		return ;
	}
	if(s.substr(0,n/2)==s.substr(n/2)) cout << "Yes\n";
	else cout << "No\n";
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  int A[N];
  int B[N - 1];
  for(int i = 0;i < N - 1;i++)
    scanf("%d",&B[i]);
  A[0] = B[0];
  for(int i = 1;i < N - 1;i++){
    if(B[i - 1] <= B[i])
      A[i] = B[i - 1];      
    else
      A[i] = B[i];
  }
  A[N - 1] = B[N - 2];
  int sum = 0;
  for(int i = 0;i < N;i++)
    sum += A[i];
  printf("%d",sum);
  return 0;
}

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

#define ff                   first
#define ss                   second
#define ll                  long long int
#define pii                  pair<int,int>
#define pb                   push_back
#define rep(i,a,b)           for(int i=a;i<b;i++)
#define t(x)                 int t; cin>>t; while(t--)
#define vi                   vector<int>
#define mii                  map<int,int>
#define min3(a, b, c)        min(min(a, b), c)
#define min4(a, b, c, d)     min(min(a, b), min(c, d))
#define max3(a, b, c)        max(max(a, b), c)
#define max4(a, b, c, d)     max(max(a, b), max(c, d))
#define ps(x,y)              fixed<<setprecision(y)<<x
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define all(x)               x.begin(),x.end()
#define FIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                      rng(chrono::steady_clock::now().time_since_epoch().count());

ll w, h, n;

bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
ll power(ll x, ll y)
{
    int res = 1;      // Initialize result

    // Update x if it is more than or
    // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) ;

        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) ;
    }
    return res;
}


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


    string s;
    cin >> s;
    int l = s.size();
    if (s[l - 1] == 's')
        cout << s << "es";
    else if (s[l - 1] != 's')
        cout << s << "s";



}

Measured memory_bytes: 3628
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <bitset>
#include <vector>
#include <string>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define REP(i, x, y)  for(int i = (int)x; i <= (int)y; i ++)
#define FOR(i, x, y)  for(int i = (int)x; i <  (int)y; i ++)
#define PER(i, x, y)  for(int i = (int)x; i >= (int)y; i --)
#define fi first
#define se second
#define pb push_back
#define mk make_pair
using namespace std;
typedef double db;
typedef long long LL;
typedef pair<int, int> PII;
const	int N = 100005;
const	int inf = 1e9;
const	LL Inf = 1e16;
const	int P = (int)1e9 + 7;

int sz[N], fac[N], inv[N], nxt[N];
int st[N << 1], tot;
int n, a[N], deg[N], DD[N], que[N], r, vis[N];

int Pow(int x, int y, int p){
	int an = 1;
	for(; y; y >>= 1, x = (LL)x * x % p) if(y & 1) an = (LL)an * x % p;
	return an;
}

int C(int x, int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return (LL)fac[x] * inv[y] % P * inv[x - y] % P;
}

void renew(int &x, const int y){
	x += y;
	if(x < 0) x += P;
	if(x >= P) x -= P;
}

int pret(){
	fac[0] = inv[0] = fac[1] = inv[1] = 1;
	REP(i, 2, n){
		fac[i] = (LL)fac[i - 1] * i % P;
		inv[i] = Pow(fac[i], P - 2, P);
	}
}

int getdp(){
	int fr = 0;
	REP(i, 1, tot) st[i + tot] = st[i];
	REP(i, 1, tot) if(sz[st[i]]){
		fr = i;
		break;
	}
	reverse(st + fr + 1, st + fr + tot);
	int pre = fr, a = fr + sz[st[fr]] - 1, b = a + 1, c = 1;
	REP(i, fr + 1, fr + tot - 1)if(sz[st[i]]){
		int na = i + sz[st[i]] - 1, nb = na + 1, cc = 0;
		if(a < i) renew(cc, c);
		if(b < i) renew(cc, c);
		a = na;
		b = nb;
		c = cc;
	}
	int ans = 0;
	if(a < fr + tot) renew(ans, c);
	if(b < fr + tot) renew(ans, c);
	return ans;
}

int ct[N];

int main(){
	scanf("%d", &n);
	REP(i, 1, n) scanf("%d", a + i), nxt[i] = a[i];
	REP(i, 1, n){
		deg[a[i]] ++;
		if(deg[a[i]] > 2){
			puts("0");
			exit(0);
		}
	}
	REP(i, 1, n) DD[i] = deg[i];
	REP(i, 1, n) if(!DD[i]) que[++r] = i;
	REP(l, 1, r){
		int u = que[l];
		--DD[nxt[u]];
		vis[u] = 1;
		if(!DD[nxt[u]]) que[++r] = nxt[u];
	}
	REP(i, 1, n) if(vis[i] && deg[i] >= 2){
		puts("0");
		exit(0);
	}
	REP(i, 1, n) if(vis[i] && !deg[i]){
		int x = i, cnt = 0;
		for(x = i; vis[x]; x = nxt[x])cnt++;
		sz[x] = cnt;
	}
	pret();
	int ans = 1;
	REP(i, 1, n)if(!vis[i]){
		int u = i, cu = 1;
		tot = 0;
		int res = 0;
		do{
			st[++tot] = u;
			cu &= !sz[u];
			vis[u] = 1;
			u = nxt[u];
		}while(u != i);
		if(cu){
			ct[tot] ++;
			res = 1;
		}else{
			res = getdp();		
		}
		ans = (LL)ans * res % P;
	}
	REP(i, 1, n) if(ct[i]){
		int tot = ct[i];
		int res = 0;
		for(int x = 0; x <= tot; x += 2){
			int cb = 1;
			cb = (LL)cb * Pow(i, (x >> 1), P) % P;
			cb = (LL)cb * C(tot, x) % P;
			cb = (LL)cb * fac[x] % P;
			cb = (LL)cb * inv[x >> 1] % P;
			cb = (LL)cb * Pow((P + 1) >> 1, x >> 1, P) % P;
			if((i > 1) && (i & 1)){
				cb = (LL)cb * Pow(2, tot - x, P) % P;
			}
			renew(res, cb);
		}
		ans = (LL)ans * res % P;
	}
	printf("%d\n", ans);
	return 0;
}




Measured memory_bytes: 4096
#include <stdio.h>
 
 
int main()
{
  long A,B,C,K;
  
  scanf("%lu %lu %lu %lu",&A,&B,&C,&K);
  
  long ans;
  
  if(A>=K)
    printf("%lu",K);
  else if(K-A-B <= 0)
    printf("%lu",A);
  else
  {
    ans=2*A+B-K;
    printf("%ld",A+A+B-K);
  }
 }

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

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

    size_t n;
    cin >> n;
    vector<uint_fast64_t> v(n);
    for_each(v.begin(), v.end(), [](uint_fast64_t &c) { cin >> c; });
    sort(v.begin(), v.end(), greater<uint_fast64_t>());
    vector<uint_fast64_t> l;

    uint_fast64_t p = 0;
    for (auto &&a: v) {
        if (p == a) {
            l.push_back(a);
            if (l.size() == 2) {
                break;
            }
            p = 0;
        } else {
            p = a;
        }
    }
    if (l.size() == 2) {
        cout << l[0] * l[1] << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import bisect
 
 
class SegTree:
 
    def __init__(self, n):
        # supposed that n = 2**m
        self.n = n
        self.val = [-1] * (2 * n - 1)
 
    def _update(self, a, b, v, k, l, r):
        # 区間[a, b)上の値をvに更新
        if r <= a or b <= l:
            return
        if a <= l and r <= b:
            self.val[k] = v
        else:
            self._update(a, b, v, 2 * k + 1, l, (l + r) // 2)
            self._update(a, b, v, 2 * k + 2, (l + r) // 2, r)
 
    def query(self, x):
        # ノードxの値を返す
        k = self.n + x - 1
        ret = self.val[k]
        while k > 0:
            k = (k - 1) // 2
            ret = max(ret, self.val[k])
        return ret
 
 
def main():
    N, Q = list(map(int, input().split(' ')))
    work_list = [list(map(int, input().split(' '))) for n in range(N)] 
    # 工事は出発地から遠い順に並べておく
    work_list.sort(key=lambda work: work[2], reverse=True)
    D = [int(input()) for q in range(Q)]
    # 一番最初に引っかかる工事のインデックスを求める
    QQ = 1
    while QQ < Q:
        QQ <<= 1
    tree = SegTree(QQ)
    for w, work in enumerate(work_list):
        s, t, x = work
        # s - x <= d < t - x だと工事に引っかかる
        left = bisect.bisect_left(D, s - x)
        right = bisect.bisect_left(D, t - x)
        tree._update(left, right, w, 0, 0, QQ)
    for q in range(Q):
        w = tree.query(q)
        if w == -1:
            print(-1)
        else:
            print(work_list[w][2])
 
 
if __name__ == '__main__':
    main()

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

/*
h * col + w * row - col * row = K
*/

// const int MAX = 10;
// int fac[MAX], ifac[MAX];

// int choose(int n, int k) {
// 	return fa
// }

int main() {
	int r, c, k;
	cin >> r >> c >> k;
	vector<vector<char>> grid(r, vector<char>(c));
	for(int i = 0; i < r; i++)
		for(int j = 0; j < c; j++)
			cin >> grid[i][j];
	int res = 0;
	for(int i = 0; i < (1 << r); i++) {
		for(int j = 0; j < (1 << c); j++) {
			int cnt = 0;
			for(int x = 0; x < r; x++) {
				for(int y = 0; y < c; y++) {
					if((i & (1 << x)) || (j & (1 << y)))
						continue;
					cnt += (grid[x][y] == '#');
				}
			}
			if(cnt == k)
				res++;
		}
	}
	cout << res << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
int main()
{
    lint num;
    lint sum = 0;
    cin >> num;
    for (lint i = 1; i <= num;i++)
    {
        if (i%3 != 0 && i%5 !=0)
            sum = sum + i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#define N 100
int main()

{
int kirito[N],kurain,asuna=0,i,j,sirika,rizu;

 scanf("%d",&kurain);
 for(i=0;i<kurain;i++)
     scanf("%d",&kirito[i]);

 
 
 for(i=0;i<kurain;i++){

   for(j=kurain-1;j>i;--j){
     if(kirito[j]<kirito[j-1]){
       sirika=kirito[j-1];
       kirito[j-1]=kirito[j];
       kirito[j]=sirika;
     
   asuna++;
     }
   }
 }


 for(i=0;i<kurain;i++){
   if(i>0)printf(" ");
   printf("%d",kirito[i]);
 }
 printf("\n");
 printf("%d\n",asuna);

 return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

//前から見ていくdpでできそう！！ナップサックの応用

void solve() {
	string s; cin >> s;
    int dp[100100];
    rep(i, 100100) dp[i] = 0;
    dp[0] = 1;
    int n = (int)s.size();
    rep(i, n) {
        if(i + 4 < n) {
            string u = s.substr(i, 5);
            if(u == "dream" || u == "erase") {
                dp[i + 5] |= dp[i];
            }
        }
        if(i + 5 < n) {
            string v = s.substr(i, 6);
            if(v == "eraser") {
                dp[i + 6] |= dp[i];
            }
        }
        if(i + 6 < n) {
            string v = s.substr(i, 7);
            if(v == "dreamer") {
                dp[i + 7] |= dp[i];
            }
        }
    }
    if(dp[n]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 848
// C - Half and Half
#include <bits/stdc++.h>
using namespace std;

int main(){
	int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
	int n = A+B > C*2? min(X, Y): 0;
	cout<< C*2*n + min(A, C*2)*(X-n) + min(B, C*2)*(Y-n) <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int X =sc.nextInt();
      int Y =sc.nextInt();
      
      for(int i=0; i<=X; i++){
      if(i*2+(X-i)*4==Y){
      System.out.println("Yes");
        return;
      }
      }
      System.out.println("No");
    }
}

Measured memory_bytes: 35704
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.14159265358979323846;
double pi2=pi/2.0;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,0,-1,0};
int dw[4]={0,1,0,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n];
    ll ans=0;
    rep(i,0,n){
        cin>>a[i];
        if(i>0){
            ans+=max((ll)0,a[i-1]-a[i]);
            Max(a[i],a[i-1]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5268
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <complex>


using namespace std;
typedef long long ll;


int main() {
	int H, N; cin >> H >> N;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		H -= a;
	}
	if (H <= 0) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    return buf
}

fn gcd(a: i64, b: i64) -> i64 {
  if b == 0 {
    return a;
  } 
  return gcd(b, a % b);
}

fn lcm(a: i64, b: i64) -> i64 {
  let g = gcd(a, b);
  return a / g * b;
}

fn main() {
  let line = gets();
  let n = line.trim().parse::<usize>().unwrap();
  let mut ans = 1;
  for _ in 0..n {
    let line = gets();
    let t = line.trim().parse::<i64>().unwrap();
    ans = lcm(ans, t);
  }
  println!("{}", ans);
}


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

    const int M = 26;
    int n; cin >> n;
    string in; cin >> in;

    for(auto& e : in) e = 'A' + ADD(e - 'A', n, M);

    cout << in << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    long int sum=0;
    cin>>n;
    for (int i=1;i<=n;i++){
        if(i%3==0){}
        else if(i%5==0){}
        else{sum+=i;}
        
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3548
open Scanf
open Printf

let id x = x

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f

let () =
  let s = scanf " %s" id in
  let s_len = String.length s in
  for_iter 0 (s_len-1) (fun i ->
    if s.[i] <> s.[i+1] then max (i+1) (s_len-1-i)
    else s_len)
  |> List.fold_left min s_len
  |> printf "%d\n"



Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int A[3][100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    
    rep(i, 3) {
        rep(j, N) cin >> A[i][j];
        sort(A[i], A[i] + N);
    }
    int ans = 0;
    rep(i, N) {
        int L = lower_bound(A[0], A[0] + N, A[1][i]) - A[0];
        int R = (A[2] + N) - upper_bound(A[2], A[2] + N, A[1][i]);
        //cout << L << "  " << R <<endl;
        ans += L * R;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	int n,c,k;
	cin >> n >> c >> k;
	vector<int> t(n);
	rep(i,n) cin >> t[i];
	sort(t.begin(),t.end());
	int l=-1; //バスの出発時刻
	int cnt=0;
	int res=0;
	rep(i,n){
		if(t[i]>l||cnt==c){
			l = t[i]+k;
			res++;
			cnt=1;
		}
		else
		{
			cnt++;
		}
		
	}
	cout << res << endl;
	return 0;
}



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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int A, B, X;
	cin >> A >> B >> X;
	cout << (A <= X && X <= A + B ? "YES" : "NO") << endl;
	return 0;
}


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

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int S = H1 * 60 + M1;
  int E = H2 * 60 + M2;
  cout << E - S - K << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> A;
  for (ll i = 0; i < N; i++ ) {
    ll a;
    cin >> a;
    A.push_back(a);
  }

  ll right = 0;
  ll sum = 0;
  ll res = 0;
  for (ll left = 0; left < N; left++) {
    while (right < N && (sum ^ A[right]) == (sum + A[right])) {
      sum += A[right];
      right++;
    }

    res += right - left;

    if (right == left) {
      right++;
    } else {
      sum -= A[left];
    }
  }

  cout << res << endl;
  return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000, MAX_M = 100000;
int n,m;
ll a[MAX_N];
pll cb[MAX_M];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> m;
  forn(i,n) cin >> a[i];
  forn(i,m) cin >> cb[i].snd >> cb[i].fst;

  sort(a,a+n);
  sort(cb,cb+m);

  int i = 0;
  for (int j = m-1; j >= 0; j--) {
    while (i < n && cb[j].snd > 0 && cb[j].fst > a[i]) {
      a[i] = cb[j].fst;
      cb[j].snd--;
      i++;
    }
    if (i >= n) break;
  }

  cout << accumulate(a,a+n,0LL) << endl;


  return 0;
}


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

int main(void)
{
    string s, t;
    cin >> s;
    cin >> t;

    int dp[3001][3001] = {0};
    int i;
    int j;
    for (i = 0; i < s.size(); i++) {
        for (j = 0; j < t.size(); j++) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            } else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    string result = "";

    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j]) {
            i--;
        } else if (dp[i][j] == dp[i][j - 1]) {
            j--;
        } else {
            result = s[i - 1] + result;
            i--;
            j--;
        }
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 35584
#include <stdio.h>

// clang-format off
#define MAX_N 100000
#define MAX_M 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
void myscanf(const char *fmt, int num, int *s, int *v) { REP(i,num) scanf(fmt, &s[i], &v[i]); }
// clang-format on

int N, M;
int L[MAX_N + 1];
int R[MAX_N + 1];

int main(void)
{
  scanf("%d %d\n", &N, &M);
  const char *fmt = "%d %d\n";
  myscanf(fmt, M, L, R);
  int minL = 0, minR = 100000;
  for (int i = 0; i < M; ++i) {
    if (minL < L[i]) minL = L[i];
    if (minR > R[i]) minR = R[i];
  }
  if ((minR - minL + 1) <= 0) {
    printf("0\n");
  }
  else {
    printf("%d\n", (minR - minL) + 1);
  }
  return 0;
}


Measured memory_bytes: 1024
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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



ll N,M,K;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;

  if(N>=30)
    cout<<"Yes"<<'\n';

  else
    cout<<"No\n";



}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}


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

using namespace std;

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

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

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

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




int n,m,r;
vector<int> vr;
ll g[205][205];
ll dist[205][205];

int main()
{

  cin>>n>>m>>r;
  rep(i, 0, r)
  {
    int x;
    cin>>x;
    vr.pb(x);
  }
  sort(vr.begin(), vr.end());
  repn(i, 0, n)
    repn(j, 0, n)
      dist[i][j] = INF;
  rep(i, 0, m)
  {
    int a, b, c;
    cin>>a>>b>>c;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  repn(k, 1, n)
    repn(i, 1, n)
      repn(j, 1, n)
      {
        if(dist[i][j] > (dist[i][k] + dist[k][j]))
        {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
  ll ans = LONG_MAX;
  do
  {
    ll aa = 0;
    int st = vr[0];
    rep(i, 1, r)
    {
      aa += dist[st][vr[i]];
      st = vr[i];
    }
    ans = min(ans, aa);
  }while(next_permutation(vr.begin(), vr.end()));
  cout<<ans<<endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  for(ll i = x;; ++i) {
    bool prime = true;
    for(ll j = 2; j * j <= i; ++j) {
      if(i % j == 0) prime = false;
    }
    if(prime) {
      out(i);
      break;
    }
  }
  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>
// #include <fstream>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SIZE(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) lower_bound(ALL(c),x)
#define UB(c,x) upper_bound(ALL(c),x)
#define COUNT(c,x) (int)(UB(c,x)-LB(c,x))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 998244353;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}

int powM(int x, int n){
  if(n == 0){
    return 1;
  }
  if(n % 2 == 0){
    return powM(mod(x * x), n / 2);
  }
  return mod(powM(x, n-1) * x);
}


signed main()
{
  // string filename; cin >> filename;
  // ifstream in(filename);
  // cin.rdbuf(in.rdbuf());

  int N; cin >> N;
  vector<int> x(N), y(N);
  rep(i, 0, N) {
    cin >> x[i] >> y[i];
  }

  int ans = powM(2, N);
  ans = mod(ans - 1);
  ans = mod(ans - N);
  rep(i, 0, N-1) {
    rep(j, i+1, N) {
      int num = 0;
      bool is_new = true;
      rep(k, 0, N) {
        if (i == k || j == k) {
          num++;
          continue;
        }
        if ((x[j]-x[i])*(y[k]-y[i]) == (y[j]-y[i])*(x[k]-x[i])) {
          if (k < j) {
            is_new = false;
            break;
          } else {
            num++;
          }
        }
      }
      if (is_new) {
        ans = mod(ans - (powM(2, num) - num - 1));
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
mod=10**9+7
n=int(input())
S=[list(input()) for _ in range(2)]
A=""

cnt=0
for i in range(n):
    if S[0][i]==S[1][i]:
        A +="A"
    else:
        cnt +=1
        if cnt==2:
            A +="B"
            cnt=0

ans=6 if A[0]=="B" else 3
for i in range(1,len(A)):
    num=A[i-1]+A[i]
    if num=="BA":continue
    elif num=="BB":ans *=3
    else:ans *=2
    ans %=mod

print(ans)

Measured memory_bytes: 38384
import math
import sys
sys.setrecursionlimit(4100000)
x, y = map(int, input().split(" "))
mod = 10**9+7

def c(n,k,m):
    n1, k = n+1, min(k, n-k)
    numer = denom = 1
    for i in range(1,k+1):
        numer = numer*(n1-i)%m
        denom = denom*i%m
    return numer*pow(denom,m-2,m)%m

if (x + y) % 3 != 0:
    print(0)
else:
    a = (2*y-x)//3
    b = (2*x-y)//3

    if a<0 or b < 0:
        print(0)
    else:
        ans = c(a+b,a,mod)
        print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
long long n,m,a[110],ans;
using namespace std;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=m;i++) ans+=a[n-i+1];
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(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<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

vector<pair<int,int>> direction = {make_pair(1,0), make_pair(0,1), make_pair(-1,0), make_pair(0,-1)};

vector<pair<int,int>> direction5 = {
  make_pair(2,0), make_pair(0,2), make_pair(-2,0), make_pair(0,-2),
  make_pair(2,2), make_pair(-2,-2), make_pair(-2,2), make_pair(2,-2),
  make_pair(1,2), make_pair(-1,-2), make_pair(-1,2), make_pair(1,-2),
  make_pair(2,1), make_pair(-2,-1), make_pair(-2,1), make_pair(2,-1),
  make_pair(1,1), make_pair(-1,-1), make_pair(-1,1), make_pair(1,-1)
};

int main() {
  int h,w;  cin >> h >> w;
  int ch,cw;  cin >> ch >> cw;
  int dh,dw;  cin >> dh >> dw;
  --ch, --cw, --dh, --dw;

  vector<string> grid(h);
  rep(i,h) cin >> grid[i];

  const int INF=1<<30;
  vector<vector<int>> dist(h, vector<int>(w, INF));
  dist[ch][cw] = 0;

  priority_queue<tuple<int,int,int>> pq;
  pq.emplace(0, ch, cw);

  while(pq.size()) {
    auto [d, hh, ww] = pq.top(); pq.pop();
    d = -d;
    if(dist[hh][ww] < d) continue;
    for(auto [dhh, dww] : direction) {
      int hhh=hh+dhh, www=ww+dww;
      if(hhh<0 || hhh >= h || www < 0 || www >= w) continue;
      if(grid[hhh][www] == '#') continue;
      if(dist[hhh][www] <= d) continue;
      dist[hhh][www] = d;
      pq.emplace(-d, hhh, www);
    }
    for(auto [dhh, dww] : direction5) {
      int hhh=hh+dhh, www=ww+dww;
      if(hhh<0 || hhh >= h || www < 0 || www >= w) continue;
      if(grid[hhh][www] == '#') continue;
      if(dist[hhh][www] <= d+1) continue;
      dist[hhh][www] = d+1;
      pq.emplace(-d-1, hhh, www);
    }
  }
  if(dist[dh][dw]==INF) cout << -1 << endl;
  else cout << dist[dh][dw] << endl;
}


Measured memory_bytes: 9552
import java.util.*

fun main() {
  val N = readInt()
  val AN = readInts().sortedDescending()

  val queue = PriorityQueue<Int>() { a, b -> b - a }

  var sum = 0L
  fun joinCircle(a: Int) {
    if (queue.isEmpty()) {
      queue.add(a)
    } else {
      val q = queue.poll()
      sum += q
      queue.add(a)
      queue.add(a)
    }
  }

  AN.forEach { joinCircle(it) }
  println(sum)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

void print_array(int* a, int n){
    for (int i = 0; i < n; i++){
        if (i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

int main (){
    int n;

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

    cin >> n;

    int a[n];

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

    print_array(a, n);

    for (int i = 1; i < n; i++){
        int key = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > key){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = key;

        print_array(a, n);
    }

    return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100006];
int main()
{   int n;
   int x;
     cin>>n;
     for(int i=0;i<n;i++)
            cin>>a[i];

     sort(a,a+n);
     ll sum=a[0];
       ll maxs=sum;
      for(int i=1;i<n;i++)
      {
          sum=__gcd(a[i],sum);
          if(sum==1)
          {
              maxs=1;
              break;
          }
         else  if(sum==0)
            sum=maxs;
          else
          {

              maxs=__gcd(maxs,sum);
              sum=maxs;

          }


      }
      cout<<maxs<<endl;


return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

cur_m = 1000
cur_s = 0

state = -1 # 1:up 0:down
prev = 0
for ai in a:
  if state == -1:
    prev = ai
    state = 0
  elif state == 1:
    if prev > ai: # peak
      # sell at prev
      cur_m += (prev * cur_s)
      cur_s = 0
      state = 0
  else:
    if prev < ai:
      # buy at prev
      buy_num = cur_m // prev
      cur_s += buy_num
      cur_m -= prev * buy_num
      state = 1
  prev = ai

if cur_s > 0:
  cur_m += (a[-1] * cur_s)

print(cur_m)

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
if 0 in a:
  ans = 0
else:
  for i in range(1, n):
    if ans < 10 ** 18:
      ans *= a[i]
    else:
      break
if ans > 10 ** 18:
  ans = -1
print(ans)

Measured memory_bytes: 21644
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
using namespace std;
#define N 100009
#define ll long long

int main(){
    int n;
    cin>>n;
    bool ans=false;
    for (int i=1; i<=9; i++){
        if (n%i==0 && n/i<=9) ans=true;
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

int a[100000];
int b[100000];

int main() {
    int n, k, i, j;
    long long ans = 0;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    
    for (i = 0; i <= 30; i++) {
        int x = k;
        long long sum = 0;
        
        if (x & (1 << i)) x ^= (1 << i);
        for (j = 0; j < i; j++) x |= (1 << j);
        
        if (x > k) continue;
        
        for (j = 0; j < n; j++) {
            if ((x | a[j]) == x) sum += b[j];
        }
        
        ans = max(ans, sum);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

struct UnionFind{
  vi par;
  vi rank;

  UnionFind(int n=1){
    init(n);
  }

  // n要素で初期化
  void init(int n=1){
    par.resize(n);
    rank.resize(n);
    REP(i, n){
      par[i]=i;
      rank[i]=0;
    }
  }

  // xの根を求める
  int find(int x){
    if(par[x]==x){
      return x;
    }
    else{
      return par[x]=find(par[x]);
    }
  }

  // xとyが属する集合を併合
  bool unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x==y){
      return false;
    }
    if(rank[x]<rank[y]){
      par[x]=y;
    }
    else{
      par[y]=x;
      if(rank[x]==rank[y]){
        ++rank[x];
      }
    }
    return true;
  }

  // xとyが同じ集合に属するか判定
  bool issame(int x, int y){
    return find(x)==find(y);
  }
};

int sz[252521];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m;
  cin>>n>>m;
  UnionFind uf(n);
  REP(i, m){
    int a, b;
    cin>>a>>b;
    --a;--b;
    uf.unite(a, b);
  }
  REP(i, n){
    ++sz[uf.find(i)];
  }
  int ans=0;
  REP(i, n){
    CHMAX(ans, sz[i]);
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 5480
import sys
input = sys.stdin.readline
S = input()
T = input()
q = int(input())
abcd= [list(map(int,input().split())) for i in range(q)]

# Segment Tree
class SegmentTree:
    def __init__(self,data,op,default):
        N = len(data)
        self.N = N
        self.op = op
        self.default = default
        self.l = 2**((N-1).bit_length())
        self.data = [default]*self.l + data + [default]*(self.l-N)
        for i in range(self.l-1,0,-1):
            self.data[i] = op(self.data[2*i], self.data[2*i+1])

    def get_data(self, i=None):
        if i is None:
            return self.data[self.l:self.l + self.N]
        else:
            return self.data[self.l+i]

    def set(self,i,val):
        i += self.l
        self.data[i] = val
        i = i//2
        while i > 0:
            self.data[i] = self.op(self.data[2*i], self.data[2*i+1])
            i = i//2

    def get(self,i,j):
        i += self.l
        j += self.l
        s = self.default 
        while j-i > 0:
            if i & 1:
                s = self.op(s,self.data[i])
                i += 1
            if j & 1:
                s = self.op(s,self.data[j-1])
                j -= 1
            i, j = i//2, j//2
        return s

convert = lambda x : 1 if x == 'A' else 2
nS = list(map(convert,S))
nT = list(map(convert,T))
segS = SegmentTree(nS,lambda x,y:x+y, 0)
segT = SegmentTree(nT,lambda x,y:x+y, 0)

# A -> BB -> AAAA -> A
# B -> AA -> BBBB -> B
# (S) -> AAAAA......
for a,b,c,d in abcd:
    rs = segS.get(a-1,b)
    rt = segT.get(c-1,d)
    if (rs-rt) % 3 == 0:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 115272
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <bitset>
#include <queue>

using namespace std;

int main(){

    int N, A, B;

    cin >> N;
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        if(A < x){
            A = x;
            B = y;
        }
    }

    cout << A + B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

double dist(double xa, double ya, double xb, double yb)
{
    return sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
}

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

    for (int i = 0; i < n; ++i) {
        double xa, ya, ra, xb, yb, rb;
        std::cin >> xa >> ya >> ra >> xb >> yb >> rb;

        double d = dist(xa, ya, xb, yb);
        if (d > ra + rb) std::cout << "0\n";
        else {
            if (d + rb < ra) std::cout << "2\n";
            else if (d + ra < rb) std::cout << "-2\n";
            else std::cout << "1\n";
        }
    }
}

Measured memory_bytes: 1196
while True:    
    a,b,c=map(int,input().split())
    if a==-1 and b==-1 and c==-1:
        break
    if a==-1 or b==-1:
        print("F")
    elif a+b>=80:
        print("A")
    elif a+b>=65:
        print("B")
    elif a+b>=50 or c>=50:
        print("C")
    elif a+b>=30:
        if c>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")
    



Measured memory_bytes: 5596