akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(ABC074_B());
        }

        static int ABC074_B()
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var xi = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var sum = 0;
            for (var i = 0; i < N; i++)
            {
                var a = xi[i] * 2;
                var b = (K - xi[i]) * 2;
                sum += Math.Min(a, b);
            }
            return sum;
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	int* data = new int[N];
	memset(data, 0, sizeof(int) * N);
	int d, tmp;
	for (int i = 1; i <= K; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> tmp;
			data[tmp-1] = 1;
		}

	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (data[i] == 0)
			cnt++;
	}
	cout << cnt << endl;

}


Measured memory_bytes: 3636
N, M = map(int, input().split())
a, b = [0 for _ in range(N)], [0 for _ in range(N)]
for i in range(N):
    a[i], b[i] = (list(map(int, input().split())))
c = []
for i in range(N):
    c.append([a[i],b[i],i])
c = sorted(c, key=lambda x: x[0])
m = 0
cnt = 0
for i in range(N):
    
    cnt += c[i][1]
    m += c[i][0] * c[i][1]
     
    if cnt == M:
        print(m)
        break
    elif cnt > M:
        print(m - c[i][0] * (cnt - M))
        break
    else:
        continue

Measured memory_bytes: 26720
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> V;

int main() {
    int n, k;
    cin >> n >> k;
    int c = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h >= k) {
            c++;
        }
    }
    cout << c << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> dp(n+1);
    dp[0] = 1;
    const int M = 2e5+5;
    vector<int> last(M);
    const ll MOD = 1e9+7;
    rep(i,1,n+1) {
        int c;
        cin >> c;
        --c;
        if(last[c]==0 || last[c]==i-1) dp[i]=dp[i-1];
        else {
            dp[i]=(dp[i-1]+dp[last[c]])%MOD;
        }
        last[c] = i;
    }
    cout<<dp[n]<<"\n";
}


Measured memory_bytes: 2560
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=998244353;
#define N 510100
ll int n,l;
ll int a[N],b[N];
main(){
    n=lin();
    l=lin();
    rep(i,n){
        a[i]=in();
    }
    rep2(i,1,n-1){
        b[i-1]=a[i]+a[i-1];
    }
    if(*max_element(b,b+(n-1))<l){
        cout<<"Impossible";
    }
    else{
        cout<<"Possible\n";
        int id=max_element(b,b+(n-1))-b;
        rep2(i,1,id)cout<<i<<endl;
        rep3(i,n-1,id+2)cout<<i<<endl;
        cout<<id+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}


int n,a,b;

int main(){
	cin>>n>>a>>b;
	if((b-a)%2==0){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Borys"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int dp[100005][13];
string s;
int N;
int MOD = int(1e9)+7;
int pre[10][13];
long long int fun(int i, int prevmod){
    if(i==0){ 
        if(prevmod==0) return 1;
        else return 0;
    }
    if(dp[i][prevmod]!=-1) return dp[i][prevmod];
    //cout<<i<<"--"<<prevmod<<endl;
    if(s[i-1]=='?'){ 
        long long int ans=0;
        //cout<<"Entering loop"<<endl;
        for(int j=0;j<10;j++){
            ans+=fun(i-1,pre[j][prevmod])%MOD;
            //cout<<":"<<ans<<":";
        }
       // cout<<endl;
        dp[i][prevmod]=ans%MOD;
    }
    else{
        dp[i][prevmod]=fun(i-1,pre[s[i-1]-'0'][prevmod]);
       // cout<<"some cons\n";
        
    }
    return dp[i][prevmod];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cin>>s;
	memset(dp,-1,sizeof(dp));
	N=s.size();
	for(int i=0;i<10;i++){
	    for(int j=0;j<13;j++){
	        pre[i][(j*10+i)%13]=j;
	    }
	}
// 	for(int i=0;i<10;i++){
// 	    for(int j=0;j<13;j++){
// 	       cout<< pre[i][j]<<" ";
// 	    }
// 	    cout<<endl;
// 	}
	cout<<fun(N,5)<<"\n";
// 	for(int i=0;i<=N;i++){
// 	    cout<<"i="<<i<<":";
// 	    for(int j=0;j<13;j++) cout<<dp[i][j]<<" ";
// 	    cout<<endl;
// 	}
// 	cout<<dp[s.size()+1][5]<<"\n";
    return 0;
}
  	
  

Measured memory_bytes: 16848
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

double a,b;

int main(void){
	scanf("%lf%lf",&a,&b);
	if(b<a)swap(a,b);
	if(b-a<=180.0)printf("%.9f\n",(a+b)/2.0);
	else{
		b-=360.0;
		double c=(a+b)/2.0;
		printf("%.9f\n",c>0?c:360.0+c);
	}
	return 0;
}

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

typedef long long LL;
typedef unsigned long long ULL;

const int PI = 3.141592653589793;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 200007;

int main(){

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int n; cin >> n;
        string str; cin >> str;
        int cntR = 0;
        for (auto i: str) {
                if (i == 'R') cntR++;
        }
        int safe = 0;
        for (int i = 0; i < cntR; i++) {
                if (str[i] == 'R') safe++;
        }
        cout << cntR - safe << endl;
        return 0;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int sum = 0;
  for (int i = 0; i < n - 2; i++){
    if (s.at(i) == 'A'){
      if (s.at(i + 1) == 'B'){
        if (s.at(i + 2) == 'C'){
          sum++;
        }
      }
    }
  }
  cout << sum << endl;
}
          

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
class Solver{
public:
    static const int MAXN=2e5+10;
    static const ll MOD=1e9+7;
    int N;
    vector<int>G[MAXN];
    ll fct=1;
    int tsz[MAXN];
    ll ans[MAXN];
    ll qpow(ll n,ll k){
        ll rt=1;
        while(k){
            if(k&1)rt=(rt*n)%MOD;
            n=(n*n)%MOD;
            k>>=1;
        }
        return rt;
    }
    void get_tcz(int rt,int fa){
        tsz[rt]=1;
        for(int v:G[rt]){
            if(v==fa)continue;
            get_tcz(v,rt);
            tsz[rt]+=tsz[v];
        }
        fct=(fct*tsz[rt])%MOD;
    }
    void dfs(int rt,int fa){
        for(int v:G[rt]){
            if(v==fa)continue;
            ans[v]=ans[rt]*tsz[v]%MOD*qpow(N-tsz[v],MOD-2)%MOD;
            dfs(v,rt);
        }
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin>>N;
        for(int u=0;u<N-1;u++){
            int a,b;
            cin>>a>>b;
            G[a].emplace_back(b);
            G[b].emplace_back(a);
        }
        get_tcz(1,-1);
        ans[1]=1;
        for(ll u=1;u<=N;u++){
            ans[1]=ans[1]*u%MOD;
        }
        ans[1]=ans[1]*qpow(fct,MOD-2)%MOD;
        dfs(1,-1);
        for(int u=1;u<=N;u++)cout<<ans[u]<<"\n";
    }
};
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    (new Solver())->solve();
}

Measured memory_bytes: 16244
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define PI 3.14159265359
 
int main(){
  ll X, A, B, i, j;
  
  cin >> X;
  
  for (ll A = -400; A <= 400; A++){
    for(ll B = -400; B <= 400; B++){
      if(pow(A, 5) - pow(B, 5) == X){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();

    }

    private void solve() {
        int N = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int s = sc.nextInt();
            int e = sc.nextInt();
            ans += e - s + 1;
        }
        
        System.out.println(ans);
    }
}


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

int main()
{
	int d, S;

	while (cin >> d)
	{
		S = 0;
		if (cin.eof()) return 0;
		for (int i = 1; i < 600 / d; i++)
		{
			S += i * d * i * d * d;
		}
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
q=[0]
for  i in p:
    q.append((1+i)/2)
from itertools import accumulate
q=list(accumulate(q))
for i in range(k,n+1):
    ans=max(ans,q[i]-q[i-k])
print(ans)

Measured memory_bytes: 80520
#include <stdio.h>

int main(void)
{
	int a[10];
	int i, j;
	int tmp;
	

	for (i = 0; i < 10; i++){
		scanf("%d", &a[i]);
	}
	
	for (i = 0; i < 10; i++){
		for (j = i; j < 10; j++){
			if (a[i] < a[j]){
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", a[i]);
	}
	
	return (0);
}

Measured memory_bytes: 1860
#include <iostream>

using namespace std;

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

	if (a == 1) {
		cout << (b == 1 ? "Draw" : "Alice") << endl;
	}
	else if (b == 1) {
		cout << "Bob" << endl;
	}
	else {
		if (a == b) {
			cout << "Draw" << endl;
		}
		else {
			cout << (a > b ? "Alice" : "Bob") << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

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

    int n;
    cin >> n;
    int d[n];
    fill(d, d+n, 0);
    for (int i = 0; i < n - 1; i++) {
        int p;
        cin >> p;
        d[--p]++;
    }

    for (int i = 0; i < n; i++) {
        cout << d[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4396
#include<iostream>
#include<iomanip>
#include<cstdio>

int main(){
	double a,b,c,d,e,f;
	while(std::cin>>a>>b>>c>>d>>e>>f){
		double x,y;
		y=(c*d-a*f)/(b*d-a*e);
		x=(c-b*y)/a;
		if(x==0)x=0.000;
		if(y==0)y=0.000;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

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

int main()
{
	int c[3], sum, de;
	bool oc[30];

	while (cin >> c[0] >> c[1] >> c[2]){
		de = 0;
		sum = c[0] + c[1];
		for (int i = 1; i <= 10; i++){
			oc[i] = false;
		}

		for (int i = 0; i < 3; i++){
			oc[c[i]] = true;
		}

		for (int i = 0; i < (20 - sum) && i < 10; i++){		
			if (oc[i + 1] == false) de++;
		}
		if (de > 3) cout << "YES" << endl;
		else cout << "NO" << endl;
		
	}
	return (0);
}

Measured memory_bytes: 1152
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int R = sc.nextInt();
    if(R < 1200){
      System.out.println("ABC");
    }else if(R < 2800){
      System.out.println("ARC");
    }else{
      System.out.println("AGC");
    }
  }
}


Measured memory_bytes: 20948
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		int c=0;
		for(int i=0;i<n-1;i++) {
			int min=a[i];
			int mins=i;
			for(int j=i+1;j<n;j++) {
				if(min>a[j]) {
					min=a[j];
					mins=j;
				}
			}
			if(min!=a[i]) {
				c++;
				int h=a[i];
				a[i]=a[mins];
				a[mins]=h;
			}

		}
		if(c<2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
 
using ll = long long;
const ll mod = 100000000+7;
const ll MAX_N = 1000;
 
ll sx,sy,tx,ty;
int main(){
  cin>>sx>>sy>>tx>>ty;
  ll memo2=tx-sx;
  ll memo1=ty-sy;
 
  rep(i,memo1)cout<<'U';
  rep(i,memo2)cout<<'R';
 
  rep(i,memo1)cout<<'D';
  rep(i,memo2)cout<<'L';
 
  cout<<'L';
  rep(i,memo1)cout<<'U';
  cout<<'U';
  cout<<'R';
  rep(i,memo2)cout<<'R';
  cout<<'D';
 
  cout<<'R';
  rep(i,memo1)cout<<'D';
  cout<<'D';
  cout<<'L';
  rep(i,memo2)cout<<'L';
  cout<<'U';
 
  cout<<endl;
}

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

namespace B___Palindromic_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int count = 0;

            for (int i = A; i <= B; ++i)
            {
                string s = i.ToString();

                System.Globalization.StringInfo si = new System.Globalization.StringInfo(s);

                string s1 = si.SubstringByTextElements(0, 1);

                string s2 = si.SubstringByTextElements(1, 1);

                string s4 = si.SubstringByTextElements(3, 1);

                string s5 = si.SubstringByTextElements(4, 1);

                if (s1 == s5 && s2 == s4)
                {
                    count += 1;
                }

                i = int.Parse(s);
            }

            Console.Write(count);
        }
    }
}


Measured memory_bytes: 17360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,m,q;
    cin >> n >> m >> q;
    vector<int> a(q),b(q),c(q),d(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;b[i]--;
    }
    stack<vector<int>> st;
    rep(i,m) st.push({i});
    int sum_max = 0;
    while(!st.empty()) {
        vector<int> A = st.top();
        st.pop();
        if(A.size() == n) {
            int sum = 0;
            rep(i,q) if(A[b[i]]-A[a[i]] == c[i]) sum+=d[i];
            chmax(sum_max,sum);
        } else {
            A.push_back(A.back());
            for(int i = A.back(); i < m; i++) {
                A.back() = i;
                st.push(A);
            }
        }
    }
    cout << sum_max << endl;
}


Measured memory_bytes: 3648
<?php

class Simulator
{
    private $inputs;
    private $backslash = array();
    private $area_pond = array();
    private $pending_area = array();

    public function __construct()
    {
        $this->inputs = trim(fgets(STDIN));
    }

    public function calculateAreas()
    {
        $count = 0;

        for ($index = 0; $index < strlen($this->inputs); $index++) {
            if ($this->inputs[$index] == "\\") {
                $this->backslash[] = $index;
            } elseif ($this->inputs[$index] == "/" and $this->backslash) {
                $last_bs_index = array_pop($this->backslash);
                $diff = $index - $last_bs_index;
                $count += $diff;
                while ($this->area_pond and end($this->area_pond) > $last_bs_index) {
                    $diff += array_pop($this->pending_area);
                    array_pop($this->area_pond);
                }
                $this->area_pond[] = $last_bs_index;
                $this->pending_area[] = $diff;
            }
        }
        echo $count . PHP_EOL;
        echo implode(" ", array_merge([count($this->area_pond)], $this->pending_area)) . PHP_EOL;
    }
}

$simulator = new Simulator();
$simulator->calculateAreas();



Measured memory_bytes: 12148
(defparameter N (read))
(defparameter *lst* '())
 
(loop for i from 1 to N do
      (defparameter name (read))
      (defparameter value (read))
      
      (push `(,name ,value ,i) *lst*))
 
(defparameter answer
  (sort (copy-list *lst*)
        #'(lambda (x y) (or (string< (car x) (car y))
                            (and (string= (car x) (car y))
                                 (> (cadr x) (cadr y)))))))
 
(dolist (v answer) (print (third v)))

Measured memory_bytes: 13540
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;
const double PI=3.14159265358979323846;

int main(){
    int N;
    cin>>N;
    
    cout<< N*PI*2 <<endl;
}


Measured memory_bytes: 3784
from collections import deque
S = deque(list(input()))
Q = int(input())

r_count = 0
for query in range(Q):
  query = deque(list(input().split()))
  t = query[0]
  if (t == '1'):
    r_count += 1
  elif (t == '2'):
    f = query[1]
    if(f == '1' and (r_count % 2 == 0)):
      S.appendleft(query[2])
    elif(f == '1' and (r_count % 2 == 1)):
      S.append(query[2])
    elif(f == '2' and (r_count % 2 == 0)):
      S.append(query[2])
    elif(f == '2' and (r_count % 2 == 1)):
      S.appendleft(query[2])

if (r_count % 2 == 1):
  for i, s in enumerate(reversed(S)):
    if (i == len(S) - 1):
      print(s)
    else:
      print(s, end="")
else:
  for i, s in enumerate(S):
    if (i == len(S) - 1):
      print(s)
    else:
      print(s, end="")


Measured memory_bytes: 7520
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}
const int D = 60;
int to[D][MX];

signed main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    FOR(i, 1, n+1) {
        int m = i;
        double cnt = 1;
        while(k>m) {
            m *= 2;
            cnt *= 1.0/2.0;
        }
        
        ans += 1.0/n*cnt;
    }
    cout << std::setprecision(15)<<ans << endl;

}

Measured memory_bytes: 4992
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = sc.nextInt();
    int[] dp = new int[n];
    for (int i = 1; i < n; i++) {
      dp[i] = dp[i - 1] + Math.abs(a[i] - a[i - 1]);
      if (i > 1)
        dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(a[i] - a[i - 2]));
    }
    System.out.println(dp[n - 1]);
  }
}

Measured memory_bytes: 52832
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
const int MOD = 1000000007;

void add (int & a, int b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

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

    int N, K;
    cin >> N >> K;
    vector<int> A(N + 1);
    for (int i = 1; i <= N; i++)
        cin >> A[i];

    vector<vector<int>> dp(N + 1, vector<int>(K + 1));
    vector<vector<int>> pref(N + 1, vector<int>(K + 1));

    dp[0][0] = 1;
    for (int j = 0; j <= K; j++)
        pref[0][j] = 1;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= K; j++) {
            // dp[i][j] = sum(dp[i-1][j - A[i] ... j])
            int min_val = max(0, j - A[i]);

            dp[i][j] = pref[i-1][j];
            //cerr << "? " << MOD - (min_val - 1 >= 0 ? pref[i-1][min_val-1] : 0) << "\n";
            add(dp[i][j], MOD - (min_val - 1 >= 0 ? pref[i-1][min_val-1] : 0));
            //cerr << "( " << dp[i][j] << "\n";

            if (j)
                pref[i][j] = pref[i][j-1];
            add(pref[i][j], dp[i][j]); 
        }
    }

    cout << dp[N][K] << "\n";

    return 0;
}


Measured memory_bytes: 79736
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include <cmath>

using namespace std;

int main()
{
	double a, b, rad, c;
	int deg;
	double S, L, h;

	cin >> a >> b >> deg;
    
	rad = deg * M_PI / 180;

	S = a * b*sin(rad) / 2;
	c = sqrt(pow(a,2) + pow(b,2) - 2 * a*b*cos(rad));
	L = a + b + c;
	h = 2 * S / a;

	cout << fixed << setprecision(10);
	cout <<  S << endl;
	cout <<  L << endl;
	cout <<  h << endl;
	return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;

typedef tuple<string, int, int> TUP;

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

int main()
{
    int X, N;
    cin >> X >> N;
    vector<int> P(N);
    int sa = 63767;
    int kotae = 0;
    for (int i = 0; i < N;i++)
    {
        cin >> P[i];
    }

    for (int i = 0; i <= 101; i++)
    {
        bool use = false;
        for (int j = 0; j < N; j++)
        {
            if(P[j] == i){
                use = true;
            }
        }
        if(use == false){
            if(sa > abs(X - i)){
                sa = abs(X - i);
                kotae =i;
            }
        }
    }
    cout << kotae << endl;
}


Measured memory_bytes: 3628
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    A=LIST()
    ans=0
    mina=0
    for a in A:
        mina=max(mina,a)
        ans+=max(0,mina-a)
    
    print(ans)
    
if __name__ == '__main__':
    do()

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>k>>n>>m;

	(abs(k-n)>abs(m-k))?cout<<"B"<<endl:cout<<"A"<<endl;



}


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

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  
  int ans=0;
  int b=0;
  while(ans<n){
    if(b==1){
      break;
    }
    ans++;
    b = a.at(b)-1;
    }
  
  if(b!=1){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
 }
  

Measured memory_bytes: 640
n = input()
sign = ["+", "-"]
for op1 in sign:
    for op2 in sign:
        for op3 in sign:
            f = n[0]+op1+n[1]+op2+n[2]+op3+n[3]
            if eval(n[0]+op1+n[1]+op2+n[2]+op3+n[3]) == 7:
                print(f + "=7")
                exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define getarray(a,n)  for(int i=0;i<n;i++) cin>>a[i]
#define ll long long
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vi vector<int>
#define w(t) int t;cin>>t;while(t--)
using namespace std;

int main()
{
    fast
    ll n, k; //no of stones
    cin >> n >> k;
    ll height[n]; // height of each stone
    getarray(height, n); //input
    //dp array
    vector<ll> dp(n, 999999999);
    dp[0] = 0; //cause we are standing on the first element
    dp[1] = abs(height[1] - height[0]);
    //here we need to see the sub problem the best we can do by reaching the ith stone
    for (int i = 2; i < n; i++)
    {
        if (i - k >= 0)
        {
            for (int j = i - k; j < i; j++)
            {
                dp[i] = min(abs(height[i] - height[j]) + dp[j], dp[i]); //the best we can do to reach the current step
            }
        }
        else
        {
            for (int j = 0; j < i; j++)
            {
                dp[i] = min(abs(height[i] - height[j]) + dp[j], dp[i]);
            }
        }
    }


    cout << dp[n - 1];

    return 0;
}


Measured memory_bytes: 4808
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long ans = Long.MIN_VALUE;
		if (n % 2 == 0) {
			long[] b0 = new long[n + 2];
			long[] b1 = new long[n + 2];
			for (int i = 0; i < n - 1; i+=2) {
				b0[i + 2] = b0[i] + a[i];
			}
			for (int i = 0; i < n - 1; i+=2) {
				b1[i + 2] = b1[i] + a[i + 1];
			}

			for (int i = 0; i < n; i++) {
				long val0 = b0[(i + 1) / 2 * 2] - b0[0];
				long val1 = b1[n] - b1[(i + 1) / 2 * 2];
				long val = val0 + val1;
				ans = Math.max(ans, val);
			}
		} else {
			long[][] dp = new long[n][3];
			dp[0][0] = a[0];
			dp[1][0] = a[0];
			dp[2][0] = a[0] + a[2];
			dp[1][1] = a[1];
			dp[2][1] = a[1];
			dp[2][2] = a[2];
			for (int i = 3; i < n; i++) {
				if (i % 2 == 0) {
					dp[i][0] = dp[i - 2][0] + a[i];
					dp[i][1] = dp[i - 1][1];
					dp[i][2] = Math.max(dp[i - 2][2], dp[i - 3][1]) + a[i];
				} else {
					dp[i][0] = dp[i - 1][0];
					dp[i][1] = Math.max(dp[i - 2][1], dp[i - 3][0]) + a[i];
					dp[i][2] = dp[i - 1][2];
				}
			}
//			for (int i = 0; i < dp.length; i++) {
//				for (int j = 0; j < dp[i].length; j++) {
//					System.out.print(dp[i][j] + "\t");
//				}
//				System.out.println();
//			}
			for (int i = 0; i < 3; i++) {
				ans = Math.max(ans, dp[n - 3 + i][i]);
			}
		}
		System.out.println(ans);
	}
}


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

int main(){
    long long int A,B,N;
    cin >> A >> B >> N;
    long long int X1 = (N/B)*B-1;
    long long int X2 = N;
    long long int ans;
    if(X1<0){ans = (A*X2)/B - A*(X2/B);}
    else{
        long long int ans1 = (A*X1)/B - A*(X1/B);
        long long int ans2 = (A*X2)/B - A*(X2/B);
        ans = max(ans1,ans2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    if(b>=a){
        cout << a<<endl;
    }
    else{
        cout << a-1<<endl;
    }
    return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  string s, t;

  void solve() {
    cin >> s >> t;
    vector<string> ans;
    int ls = s.size();
    int lt = t.size();
    for (int i = 0; i + lt <= ls; ++i) {
      string tmp = s;
      bool match = true;
      for (int j = 0; j < lt; ++j) {
        //s'[i+j] == t[j]?
        if (tmp[i + j] == '?') {
          tmp[i + j] = t[j];
        } else if (tmp[i + j] != t[j]) {
          match = false;
        }
      }
      if (match) {
        replace(tmp.begin(), tmp.end(), '?', 'a');
        ans.push_back(tmp);
      }
    }
    sort(ans.begin(), ans.end());
    if (ans.empty()) {
      cout << "UNRESTORABLE" << endl;
    } else {
      cout << ans[0] << endl;
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        mut a: i32,
        b: i32,
        mut c: i32,
        d: i32,
    }
    loop {
        c -= b;
        if c <= 0 {
            break;
        }
        a -= d;
        if a <= 0 {
            break;
        }
    }

    println!("{}", if c <= 0 {"Yes"} else {"No"});
}


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

int main(){
    int H,W;
    char X[53][53];
    bool flag = true;

    cin>>H>>W;
    
    for(int j=0;j<=W+1;j++){
        X[0][j]='.';
        X[H+1][j]='.';
    }
    for(int i=0;i<=H+1;i++){
        X[i][0]='.';
        X[i][W+1]='.';
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>X[i][j];
        }
    }
    
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(X[i][j]=='#'){
                if(X[i-1][j]=='.' && X[i+1][j]=='.' && X[i][j-1]=='.' && X[i][j+1]=='.'){
                    flag=false;
                }
            }    
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    


    
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		v[a - 1]++;
		v[b - 1]++;
	}
	REP(i, n) {
		cout << v[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
typedef multiset<ll> mlset;
typedef set<ll> mset;
typedef struct node* pnode;
int main()
{
    string s;
    cin>>s;
    ll l=s.length();
    if(s[l-1]=='s')
    {
        s+="es";
        cout<<s<<endl;
    }
    else
    {
        s+="s";
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int n,k;
cin >> n >> k;
cout << n-k+1 << endl;
}


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

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int e[3];
		cin >> e[0] >> e[1] >> e[2];
		sort(e, e+3);
		if(e[0]*e[0] +e[1]*e[1] == e[2]*e[2]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2980
N=int(input())
numbers=list(map(int,input().strip().split()))

target_number=1

for i in range(N):
  if(numbers[i]==target_number):
    target_number+=1
  
if(target_number>1):
  print(N-target_number+1)
  
elif(target_number==1):
  if(1 in numbers):
    print(N-1)
  else:
    print(-1)

Measured memory_bytes: 77516
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a,b,c;
  cin >>a>>b>>c;
  char x,y,z;
  x=a.at(0)-0x20;
  y=b.at(0)-0x20;
  z=c.at(0)-0x20;
  cout <<x<<y<<z<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, w = LI()
wv = LIR(n)
dp = [0] * (w + 1)
for i in range(n):
    wi, vi = wv[i]
    for j in range(w, wi - 1, -1):
        dp[j] = max(dp[j], dp[j - wi] + vi)

print(max(dp))

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

#define LL long long

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n;
	cin >> n;
	deque<LL> s(1<<n);
	for (LL i = 0; i < s.size(); i++)
		cin >> s[i];
	sort(s.rbegin(),s.rend());
	multiset<LL> slimes = {s[0]};
	multiset<LL> rest;
	for (LL i = 1; i < s.size(); i++)
		rest.insert(s[i]);
	while (slimes.size() < s.size()){
		vector<LL> generated;
		for (auto x : slimes){
			auto it = rest.lower_bound(x);
			if (it == rest.begin()){
				cout << "No\n";
				return 0;
			}
			it--;
			generated.push_back(*it);
			rest.erase(it);
		}
		for (auto x : generated)
			slimes.insert(x);
	}
	cout << "Yes\n";
}


Measured memory_bytes: 16256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

int main() {
    string S;
    cin >> S;
    string y = string("") + S[0] + S[1] + S[2] + S[3];
    string m = string("") + S[5] + S[6];
    string d = string("") + S[8] + S[9];
    if ((y >= "2019" && m >= "05") || y >= "2020") {
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }
}


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

using namespace std;

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int v1, v2;
	scanf("%d %d", &v1, &v2);
	long long ans = 0;
	for (int i = 0; i < k && i < n; i++) {
		ans += v1; 		
	}
	for (int i = k; i < n; i++) {
		ans += v2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim nks As Integer() = Cin.IntArr()
    Dim n As Integer = nks(0)
    Dim k As Integer = nks(1)
    Dim s As Integer = nks(2)
    Dim o As Integer = If(s = 1000000000, 1, s + 1)
    Dim c As Integer = 0
    Dim ans(0 To n - 1) As Integer
    For i As Integer = 0 To n - 1
      c += 1
      If c <= k Then
        ans(i) = s
      Else
        ans(i) = o
      End If
    Next
    Console.WriteLine(String.Join(Of Integer)(" ", ans))
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 23132
def is_all_even(li):
    for x in li:
        if x % 2 != 0:
            return False

    return True


def all_div_2(li):
    for i in range(len(li)):
        li[i] /= 2

    return li


N = int(input())
a = list(map(int, input().split()))
cnt = 0

while is_all_even(a):
    a = all_div_2(a)
    cnt += 1

print(cnt)


Measured memory_bytes: 38640
N = int(input())
luca_tbl = {}
def lucas(X):
    if X in luca_tbl:
        return luca_tbl[X]
    else:
        if X == 0:
            luca_tbl[0] = 2
            return 2
        elif X == 1:
            luca_tbl[1] =1
            return 1
        else:
            luca_tbl[X] = lucas(X-1)+lucas(X-2)
            return lucas(X-1)+lucas(X-2)
            
print(lucas(N))

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <stack>
#include <array>
#include <fstream>
#include <deque>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int (i) = 0;(i) < (n) ; ++(i))
#define REPS(a,i,n) for(int (i) = (a) ; (i) < (n) ; ++(i))
#define REVERSE(i,n) for(int (i) = n-1;(i) >= 0 ; --i)
#define ALL(c) (c).begin() , (c).end()
#define EACH(it,c) for(auto(it,(c).begin());it != (c).end();)
#define cx real()
#define cy imag()
#define px first
#define py second
#define LL long long
#define int LL
#define inf  (1LL << 60)
#define mod 1000000007
#define QUICK_CIN ios::sync_with_stdio(false); cin.tie(0);
#define lower lower_bound
#define upper upper_bound
#define ZERO(c,n) memset(&c[0],0,sizeof(int)*n)
#define ZERO2(c,n) memset(&c[0][0],0,sizeof(int)*n
#define pl(a) cout << ""#a": " << a << endl;
#ifdef _DEBUG
#define debug_io fstream cin("input.txt");ofstream cout("output.txt");
#else
#define debug_io ;
#endif
#define debug_input debug_io
#define pb(a) push_back(a)
template<class T>void scan(vector<T>& a, int n, istream& cin)
{
	T c; REP(i, n) { cin >> c; a.push_back(c); }
}
using vs = vector<string>; using vi = vector<int>; using pii = pair<int, int>;
using psi = pair<string, int>; using vvi = vector<vi>; using pss = pair<string, string>;
template<class T>bool valid(T x, T w) { return 0 <= x&&x < w; }
int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 };
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------


vector<pii> a;
int ans[100010];
bool ed[100010];

signed main()
{
	QUICK_CIN;
	//debug_input;

	int a , b;

	cin >> a >> b;

	cout << (a + b) % 24 << endl;
	return 0;
}

Measured memory_bytes: 256
class Node
  attr_accessor :key, :parent, :left, :right

  def initialize(key)
    @key = key
    @parent = -1
    @left = nil
    @right = nil
  end

  def add_left(left)
    @left = left
    @left.parent = self
  end

  def add_right(right)
    @right = right
    @right.parent = self
  end

end


class BinaryTree
  attr_accessor :root

  def initialize(root)
    @root = Node.new(root)
  end

  def insert(key)
    n = @root
    while true
      if key < n.key
        if n.left
          n = n.left
          next
        else
          n.add_left(Node.new(key))
          break
        end
      else
        if n.right
          n = n.right
          next
        else
          n.add_right(Node.new(key))
          break
        end
      end
    end
  end

  def pre
    # 行きがけ順探索(左上から順に)
    @list = []
    traverse(@root, :pre)
    @list
  end

  def in
    # 通りがけ順探索
    @list = []
    traverse(@root, :in)
    @list
  end

  def post
    # 帰りがけ順探索(左下から順に)
    @list = []
    traverse(@root, :post)
    @list
  end

  private
  def traverse(node, type)
    @list << node.key if type == :pre
    traverse(node.left, type) if node.left
    @list << node.key if type == :in
    traverse(node.right, type) if node.right
    @list << node.key if type == :post
  end
end


n = gets.to_i
cmds = []
n.times do
  stdin = gets.chomp
  if stdin.match(/insert/)
    cmd, key = stdin.split
    cmds << [cmd, key.to_i]
  else
    cmds << [stdin, nil]
  end
end

tree = nil
cmds.each do | cmd, key |
  if cmd.match(/insert/)
    unless tree
      tree = BinaryTree.new(key)
    else
      tree.insert(key)
    end
  else
    puts " #{tree.in.join(' ')}"
    puts " #{tree.pre.join(' ')}"
  end
end


Measured memory_bytes: 203448
import sys
import heapq as hq

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    f = list()
    g = list()
    ans = 0
    for i in range(n):
        k, l, r = nm()
        if l > r:
            ans += r
            g.append((k, l-r))
        else:
            ans += l
            f.append((k+1, r-l))
    g.sort()
    f.sort(reverse=True)
    h = list()
    # print(f)
    # print(g)
    for k in range(len(g), 0, -1):
        while g and g[-1][0] >= k:
            _, c = g.pop()
            hq.heappush(h, -c)
        if h:
            ans -= hq.heappop(h)
    h = list()
    for k in range(len(g)+1, n+1):
        while f and f[-1][0] <= k:
            _, c = f.pop()
            hq.heappush(h, -c)
        if h:
            ans -= hq.heappop(h)
    print(ans)
    return

T = ni()
for _ in range(T):
    solve()


Measured memory_bytes: 34676
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
P=p[0:X]
Q=q[0:Y]
N=P+Q+r
N.sort(reverse=True)
print(sum(N[0:(X+Y)]))


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

int main() {
  char b;
  cin >> b;
  
  if (b == 'A'){
    cout << 'T' << endl;
  }
  else if (b == 'T'){
    cout << 'A' << endl;
  }
  else if (b == 'G'){
    cout << 'C' << endl;
  }
  else{
    cout << 'G' << endl;
  }
}

Measured memory_bytes: 256