akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

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

signed main(){
    int r0, w0, c, r;
    while( cin >> r0 >> w0 >> c >> r, r0 ){
        int cur = r0;
        int cnt = 0;
        while( cur < c * w0 ){
            cur += r;
            cnt++;
        }

        cout << cnt << endl;
    }
}



Measured memory_bytes: 3072
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys, math, bisect, random, itertools
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if (a + b) % 2:
        print("IMPOSSIBLE")
        return
    print((a + b) // 2)
    return

#B
def B():
    n = II()
    p = LI()
    for i in range(n):
        for k in range(i+1, n):
            pi = p[::1]
            pi[i], pi[k] = pi[k], pi[i]
            for j in range(n-1):
                if pi[j] > pi[j + 1]:
                    break
            else:
                print("YES")
                return
    print("NO")
    return

#C
def C():
    n = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(n):
        if a[i] >= b[i]:
            ans += b[i]
            continue
        ans += a[i]
        b[i] -= a[i]
        if a[i + 1] >= b[i]:
            ans += b[i]
            a[i + 1] -= b[i]
            continue
        ans += a[i + 1]
        a[i + 1] = 0
    print(ans)
    return

#D
def D():
    s = S()
    s = s[::-1]
    dp = [[0] * 13 for _ in range(len(s))]
    remain = 1
    if s[0] == "?":
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(s[0])] = 1
    for i in range(1, len(s)):
        remain = (remain * 10) % 13
        dpi = dp[i]
        dpi1 = dp[i-1]
        if s[i] == "?":
            for k in range(10):
                for j in range(13):
                    dpi[(j + remain * k) % 13] += dpi1[j]
                    dpi[(j + remain * k) % 13] %= mod
        else:
            for j in range(13):
                dpi[(j + remain * int(s[i])) % 13] += dpi1[j]
    print(dp[-1][5])
    return

#E
def E():
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    C()


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

#define co(x) cout << x << endl

int main ()
{
    int numw , numh , sum = 0 , cov = 0 ;

    cin >> numw >> numh ;

    sum = numh * 2 ;

    if (sum >= numw )
    {
        cov = 0 ;
    }
    else if (sum < numw)
    {
        cov = numw - sum ;
    }

    co (cov) ;

    return 0 ;
}


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

vector<ll> n;

void dfs(ll a, ll b, ll c) {
  if (b == c) {
    n.push_back(a);
    return;
  }
  rep(i, 3) {
    if (0 <= a % 10 + i - 1 && a % 10 + i - 1 <= 9)
      dfs(a * 10 + a % 10 + i - 1, b + 1, c);
  }
}

int main() {
  int k; cin >> k;
  rep(i, 9) n.push_back(i+1);
  rep(i, 9) rep(j, 9) dfs(j+1, 1, i + 2);
  cout << n[k-1] << endl;
  return 0;
}

Measured memory_bytes: 2420
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

let (H, W) = readInts () |> pair
let table =
  let s = [| for _ in 1..H -> readStr().ToCharArray() |> Array.map (fun c -> c = '.') |]
  Array2D.init H W (fun y x -> s.[y].[x])

let inline memo2 h w f =
  let dp = Array2D.init h w (fun _ _ -> None)
  let rec g y x =
    match Array2D.get dp y x with
    | None ->
      let v = f g y x
      Array2D.set dp y x (Some v)
      v
    | Some v -> v
  g

let isWhite y x = Array2D.get table y x

let calc =
  memo2 104 104 (fun calc' y x ->
    let black = not (isWhite y x)
    let cost y' x' = (if black && isWhite y' x' then 1 else 0) + (calc' y' x') 
    match (y+1 = H), (x+1 = W) with
    | true, true -> if black then 1 else 0
    | true, false -> cost y (x+1)
    | false, true -> cost (y+1) x
    | false, false -> min (cost y (x+1)) (cost (y+1) x)
  )

calc 0 0 |> printfn "%d"

Measured memory_bytes: 14556
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int L,R;
  cin >> L >> R;
  
  R=min(R,L+4038);
  int ans =2018;
  
  for(long long int i=L;i<=R;i++){
    for(long long int j=i+1;j<=R;j++){
      int x=i*j%2019;
      ans=min(x,ans);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();

        System.out.println(s1.charAt(0) + "" + s2.charAt(1) + "" + s3.charAt(2));
    }
}


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

int main() {
    string a,b,c;
    cin >> a >>b >>c;
    if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "

int main()
{
    ll N; cin >> N;
    VLL A(N), B(N);
    rep(i,N){
        cin >> A.at(i) >> B.at(i);
    }
    VI count(N);
    ll plus=0;
    repd(i,N){
        A.at(i)+=plus;
        if(A.at(i)==0){
            continue;
        }
        if(A.at(i)<B.at(i)){
            count.at(i)=B.at(i)-A.at(i);
            plus+=B.at(i)-A.at(i);
            continue;
        }
        if(A.at(i)%B.at(i)==0){
            continue;
        }
        else{
            count.at(i)=B.at(i)-(A.at(i)%B.at(i));
            plus+=B.at(i)-(A.at(i)%B.at(i));
        }
    }
    ll sum=0;
    rep(i,N){
        sum+=count.at(i);
    }
    cout << sum << endl;
}

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

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    int ans = h * w;
    char ch[11][1001];
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cin >> ch[i][j];
    // cout<<(2&(1<<1))<<"\n";
    for (int mask = 0; mask < (1 << h); mask++)
    {
        int cou[11] = {0};
        int tans = __builtin_popcount(mask);
        int jprev = 0;
        for (int j = 1; j <= w; j++)
        {
            int t = 0;
            for (int i = 1; i <= h; i++)
            {
                if (ch[i][j] == '1')
                    cou[t]++;
                if ((mask & (1 << (i - 1)))>0)
                {
                    // cout<<"*";
                    // cout<<i<<"*";
                    t++;
                }
            }
            int c = 0;
            for (int i = 0; i <= 10; i++)
                if (cou[i] > k)
                {
                    c = 1;
                    break;
                }
            if (c)
            {
                if (j == jprev)
                {
                    tans = 1e+7;
                    break;
                }
                // cout << j << " ";
                tans++;
                for (int i = 0; i <= 10; i++)
                    cou[i] = 0;
                jprev = j;
                j--;
            }
        }
        // cout << mask << " " << tans << "\n";
        ans = min(ans, tans);
    }
    cout << ans;
}

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

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

    long long  A = 0;
    long long  B = 0;

    for(A= -1000 ; A < 1000; A++){
        for( B = -1000 ; B < 1000 ;B++ ){
            if(pow(A,5) - pow(B,5) == X){
                cout << A << " "<< B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4084
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n;
    cin >> n;
    int nSqrt=sqrt(n);
    cout << nSqrt*nSqrt << endl;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
S,F,countS,countF = 0,0,0,0
if a<=c:
  countS = c
  S = a
else:
  countS = a
  S = c
if b <= d:
  countF = b
  F = d
else:
  countF = d
  F = b
count=0
flagC = False
for i in range(S,F+1):
  if flagC:
    count+=1
  if i == countS:
    flagC = True
  if i == countF:
    break
print(count)

Measured memory_bytes: 9044
using System;


	public class Max
	{
		public static void Main(string[] args)
		{
			int count=int.Parse(Console.ReadLine());			
			int min=int.Parse(Console.ReadLine());
			int ex=int.Parse(Console.ReadLine());
			int max=ex-min;//???????????????????????§????????????
			if(min>ex)
			{
				min=ex;
			}
			
			
			for(int j=0;j<count-2;j++)
			{
				ex=int.Parse(Console.ReadLine());
				
				if(min>ex)
				{
					min=ex;
				}
				
			    else if(max<ex-min)
				{
					max =ex-min;
				}
				
			}
			Console.WriteLine(max);
		}
	}

Measured memory_bytes: 9252
#include <iostream>
#include <list>
using namespace std;
int main(){
    int q; cin >> q;
    list<int> lis;
    auto it = lis.end();
    for(int i = 0; i < q; ++i){
        int x; cin >> x;
        if(x == 0){
            int val; cin >> val;
            lis.insert(it,val);
            it--;
        }
        else if(x == 1){
            int d; cin >> d;
            if(d > 0){
                for(int i = 0; i < d; ++i) it++;
            }
            else{
                for(int i = d; i != 0; ++i) it--;
            }
        }
        else if(x == 2){
            it = lis.erase(it);
        }
    }
    for(auto ite = lis.begin(); ite != lis.end(); ++ite){
        cout << *ite << endl;
    }
    return 0;
}


Measured memory_bytes: 18556
/********************************************

	Title		ARC080E.cpp
	Author 		TomatoLoveCoconut
	Time		2018-3-18
	History		Created 2018-3-18
	
	Version		1.0.0
	
	Tags:		RMQ
			priority_queue


	while(true) RP++;
	
		 QAQ

*********************************************/


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define base 311
#define mod 19260817
#define maxlongint 2147483647
#define maxint 32767
#define pi (double)acos(-1.0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
//SGT
#define MID (l+r)>>1
#define lson o<<1
#define rson o<<1|1
//clear the array
#define cla(a) memset(a,0,sizeof(a))
#define clb(a) memset(a,INF,sizeof(a));
#define clc(a) memset(a,-1,sizeof(a));
#define maxn 200100


using namespace std;


//complex
struct Complex{
    double x,y;
    Complex(double xx=0,double yy=0){x=xx,y=yy;}
};
inline Complex operator + (Complex a,Complex b){return Complex(a.x+b.x,a.y+b.y);}
inline Complex operator - (Complex a,Complex b){return Complex(a.x-b.x,a.y-b.y);}
inline Complex operator * (Complex a,Complex b){return Complex(a.x*b.x-a.y*b.y,a.y*b.x+b.y*a.x);}
//BIT
inline int lowbit(int x){return x&(-x);}




//var
int f[maxn][18],g[maxn][18];
int a[maxn],b[maxn],c[maxn];
int n;
int logn[maxn];
int M[maxn];
inline int getmin(int tp,int l,int r)
{
	int k=logn[r-l+1];
	if (tp==1)
	{
		return min(f[l][k],f[r-(1<<k)+1][k]);
	}
	else{
		return min(g[l][k],g[r-(1<<k)+1][k]);
	}
}

#define piii pair<int,pii>
priority_queue<piii,vector<piii >,greater<piii > > Q;

int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	int k=0;
	for (int i=0;i<=n+1;i++)
	{
		if ((1<<(k+1)<=i))++k;
		logn[i]=k;
	}
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		M[a[i]]=i;
		if (i&1)
		{
			b[i]=a[i];
			c[i]=maxlongint;
		}
		else
		{
			c[i]=a[i];
			b[i]=maxlongint;
		}
		f[i][0]=b[i];
		g[i][0]=c[i];
	}
	for (int k=1;(1<<k)<=n;k++)
	{
		for (int i=1;i+(1<<k)-1<=n;i++)
		{
			f[i][k]=min(f[i][k-1],f[i+(1<<(k-1))][k-1]);
			g[i][k]=min(g[i][k-1],g[i+(1<<(k-1))][k-1]);
		}
	}
	int x=getmin(1,1,n);
	Q.push(mp(x,mp(1,n)));
	int cnt=0;
	int l,r;
	while (!Q.empty() && cnt<=n)
	{
		pair<int,pii > xx=Q.top();
		Q.pop();
		int L=xx.second.first;
		int R=xx.second.second;
		int x=xx.first;
		int pos=M[x]+1;
		int y=getmin(pos&1,pos,R);
		cnt+=2;
		cout<<x<<" "<<y<<" ";
		l=M[x];
		r=M[y];
		if (L!=l)
			Q.push(mp(getmin(L&1,L,l-1),mp(L,l-1)));
		if (l+1!=r)
			Q.push(mp(getmin((l+1)&1,l+1,r-1),mp(l+1,r-1)));
		if (r!=R)
			Q.push(mp(getmin((r+1)&1,r+1,R),mp(r+1,R)));
	}
	return 0;

}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

bool check(vector<ll> &H_, ll A, ll B, ll c) {
  vector<ll> H = H_;
  int N = H.size();
  for (int i = 0; i < N; i++) {
    H[i] -= c * B;
  }

  for(int i = 0; i < N; i++) {
    if (H[i] <= 0) continue;
    c -= (H[i] + (A - B - 1)) / (A - B);
  }
  return c >= 0;
}

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

  ll ok = 1e10;
  ll ng = 0;
  while(ok - ng > 1) {
    ll c = (ok + ng) / 2;
    if (check(H, A, B, c)) {
      ok = c;
    } else {
      ng = c;
    }
  }
  cout << ok << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int masu[100001];
int main(){
    ll n;
    cin>>n;
    ll ans=1;
    ll z=1000000007;
    for(int i=1;i<=n;i++){
        ans=(ans*i)%z;
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
// Problem : D - Coloring Dominoes
// Contest : AtCoder - AtCoder Beginner Contest 071
// URL : https://atcoder.jp/contests/abc071/tasks/arc081_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}
void solve()
{
int n;cin>>n;
string s1,s2;cin>>s1>>s2;
if(n==1)
{
	cout<<3;
	return;
}
int ans=1;int prev=-1;
for(int i=0;i<n;i++)
{
	if(s1[i]==s2[i])
	{
		if(prev==-1)
		ans=3;
		else if(prev==0)
		{
			ans=(ans*2)%md;
		}
		prev=0;
	}
	else
	{
		if(prev==-1)ans=6;
		else if(prev==0)
		{
			ans=(ans*2)%md;
		}
		else
		{
			ans=(ans*3)%md;
		}
		prev=1;
		i++;
	}
}
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N=2e5+10;
int n,a[N];
long long sum,cnt[N],ans[N];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    for(int i=1;i<N;i++)
    {
        if(cnt[i])sum+=cnt[i]*(cnt[i]-1)/2;
    }
    for(int i=0;i<n;i++)
    {
        sum-=cnt[a[i]]*(cnt[a[i]]-1)/2;
        sum+=(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
        printf("%lld\n",sum);
        sum-=(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
        sum+=cnt[a[i]]*(cnt[a[i]]-1)/2;
    }
    return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;



typedef long long ll;
typedef pair<int,int> P;

const int mod=1e9+7;

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

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

    int cnt=0;
    for(int i=0;i<n;i++){
//        cout << "a.size()=" << a.size() << endl;
        for(int j=a.size()-1;j>=0;j--){
            if(a[j]==j+1){
                ans.push_back(a[j]);
                a.erase(a.begin()+j);
                cnt++;
                break;
            }
        }
    }
    if(cnt!=n){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cout << ans[n-1-i] << endl;
    }
    return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  if(m<=n){
    cout << 0;
    return 0;
  }
  vector<int>x(m);
  for(int i=0; i<m; i++)cin >> x[i];
  sort(x.begin(), x.end());
  priority_queue<int, vector<int>, greater<int>>q;
  for(int i=1; i<m; i++){
    if(x[i]-x[i-1]>1)q.push(x[i]-x[i-1]-1);
  }
  if(q.size()+1<=n)cout << m-n;
  else {
    int ret=m-n, qn=q.size()+1;
    for(int i=0; i<qn-n; i++){
      ret+=q.top();
      q.pop();
    }
    cout << ret;
  }
  return 0;
}

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

using namespace std;

int main()
{
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n; cin >> n;
        int h[n+1];
        for (int i=1; i<=n; i++) cin >> h[i];
        int dp[n+1];
        for (int i=0; i<=n; i++) dp[i] = 1000000000;
        dp[1] = 0;
        for (int i=2; i<=n; i++)
        {
                if (i-1>=1) dp[i] = min(dp[i], abs(h[i]-h[i-1]) + dp[i-1]);
                if (i-2>=1) dp[i] = min(dp[i], abs(h[i]-h[i-2]) + dp[i-2]);
        }
        cout << dp[n];
        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,g,b;
  cin >> r >> g >> b;
  int a = (r*100 +  g*10 + b) % 4;
  if ( a==0 ) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
from fractions import gcd

N, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
  x[i] = abs(x[i]-X)
g = abs(x[0])
for i in range(1,N):
  g = gcd(x[i],g)
print(g)

Measured memory_bytes: 16296
#include "bits/stdc++.h"

using namespace std;

void Main() {
    vector<int> edges(3, 0);
    cin >> edges[0] >> edges[1] >> edges[2];


    sort(edges.begin(), edges.end());
    cout << (0.5 * edges[0] * edges[1]) << endl;
}

int main() {
    //std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

char s1[10], s2[10];
char f[] = "%00d";
int main() {
	int a, l;
	while (scanf("%d%d", &a, &l), l) {
		f[2] = l + '0';
		map<int, int>mp;
		mp[a] = 0;
		for (int i = 1;; i++) {
			sprintf(s1, f, a); sort(s1, s1 + l);
			sprintf(s2, f, a); sort(s2, s2 + l, greater<>());
			a = atoi(s2) - atoi(s1);
			if (mp.find(a) != mp.end()) {
				printf("%d %d %d\n", mp[a], a, i - mp[a]);
				break;
			}
			mp[a] = i;
		}
	}
}

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

#define lint long long
#define P pair<int, int>


int main(){
    int A, B, K;
    
    cin >> A >> B >> K;
    
    int i = min(A, B) + 1;
    int cnt = 0;
    while(cnt < K){
        i--;
        if(A % i == 0 && B % i == 0){
            cnt++;
        }
    }
    cout << i << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double sum = 0;
    for (int i = 0, n = sc.nextInt(); i < n; i++)
      sum += (double) 1 / sc.nextInt();
    System.out.println((double) 1 / sum);
  }
}

Measured memory_bytes: 22740
N=int(input())
S=input()
dp_D,dp_M=[0]*(N+1),[0]*(N+1)
dp_DM=[0]*(N+1)
C=[]

for i in range(N):
  dp_D[i+1]=dp_D[i]
  dp_M[i+1]=dp_M[i]
  dp_DM[i+1]=dp_DM[i]
  if S[i]=="D":
    dp_D[i+1]+=1
  if S[i]=="M":
    dp_M[i+1]+=1
    dp_DM[i+1]+=dp_D[i]
  if S[i]=="C":
    C.append(i+1)
    
Q=int(input())
K=[int(k) for k in input().split()]
for k in K:
  ans=0
  for c in C:
    ans+=dp_DM[c-1]-dp_D[max(c-k,0)]*(dp_M[c-1]-dp_M[max(c-k,0)])-dp_DM[max(c-k,0)]
  print(ans)

Measured memory_bytes: 117484
#include "bits/stdc++.h"
using namespace std;
using ll = int64_t;
template <typename T> using iit = istream_iterator<T>;
template <typename T> using oit = ostream_iterator<T>;
template <typename T> void write(ostream& out, T t) {
    out << t << '\n';
}
template <typename T, typename... Args>
void write(ostream& out, T t, Args... args) {
    out << t << ' ';
    write(out, args...);
}

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

    string s;
    cin >> s;
    int n = s.size();
    vector<pair<ll, ll>> S(1 + n);
    S[n] = {1, 0};
    for (int i = n - 1; i + 1; i--) {
        ll d = 0;
        ll cnt = 0, sum = 0;
        for (int j = i + 1; j <= n; j++) {
            d *= 10;
            d += (s[j - 1] - '0');

            ll rcnt, rsum;
            tie(rcnt, rsum) = S[j];

            sum += d * rcnt + rsum;
            cnt += rcnt;
        }
        S[i] = {cnt, sum};
    }
    cout << S[0].second << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int n,m;
	cin >> n >> m;
	vector<int> box(n+1,1),red(n+1,0);
	red[1]=1;
	int before,after;
	for(int i=0; i<m; i++){
		cin >> before >> after;
		if(red[before])red[after]=1;
		box[before]--;box[after]++;
		if(box[before]==0)red[before]=0;
	}
	int ans=0;
	for(int i=1; i<=n; i++){
		if(red[i])ans++;
	}
	cout << ans << endl;
	return 0;
}	


Measured memory_bytes: 1024
import itertools
import math

def distance(a,b):
    x  = (a[0]-b[0])**2
    x += (a[1]-b[1])**2
    return math.sqrt(x)

def fact(n):
    ans = 1
    for i in range(1,n+1):
        ans *= i 
    return ans

N =  int(input())
Data = []
for _ in range(N):
    Data.append(list(map(int,input().split())))

seq = []
for i in range(N):
    seq.append(i)

sum1 = 0.0
for a in itertools.permutations(seq):
    for i in range(N-1):
        sum1 += distance(Data[a[i]], Data[a[i+1]])
print( sum1 / float(fact(N)))


Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  int i,j;
  int n;
  int u[500];
  int sum;
  int cnt;

  while(scanf("%d", &n), n!=0){
    for(i=0; i<n; i++){
      scanf("%d", &u[i]);
    }
    cnt=0;

    for(i=n-1; i>0; i--){
      for(j=0; j<i; j++){
	if(u[j]>u[j+1]){
	  sum=u[j];
	  u[j]=u[j+1];
	  u[j+1]=sum;
	  cnt++;
	}
      }
    }
    printf("%d\n", cnt);
  }
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int k;
    cin >> k;
    if (k < 10) {
        cout << k << '\n';
        return 0;
    }
    int dp[10][1000] = {{0}};
    for (int i=0; i<10; i++) dp[0][i] = 1;
    int j = 0, first;
    bool done = false;
    int sum = 9;
    while (++j) {
        for (int i=0; i<10; i++) {
            for (int l=max(i-1, 0); l<=i+1 && l<10; l++) {
                dp[j][i] += dp[j-1][l];
            }
            if (i > 0) sum += dp[j][i];
            if (sum >= k) {
                first = i;
                done = true;
                k -= sum - dp[j][i];
                break;
            }
        }
        if (done) break;
    }
    string ans(1, '0' + first);
    int prev = first;
    for (int i=j-1; i>=0; i--) {
        int sum = 0;
        for (int l=max(prev-1, 0); l<=prev+1 && l < 10; l++) {
            sum += dp[i][l];
            if (sum >= k) {
                prev = l;
                ans += ('0' + l);
                k -= sum - dp[i][l];
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
x = int(input())

from collections import deque
z = []
u = deque([])
for a in range(0,1000):
    for b in range(-1000,1000):
        z.append(a**5-b**5)
        u.append((a,b))

for i in range(10**6+1):
    if z[i] == x:
        print(u[i][0],u[i][1])
        break

Measured memory_bytes: 170408
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"2
12 5
1000 2000"# => "1",

r#"3
21 -11
81234 94124 52141"# => "3",

r#"1
12 5
2000"# => "1",
}

// 23, 0, 10, 10, 10

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        t: f64,
        a: f64,
        h: [f64; n],
    }
    let mut avg:Vec<(f64, usize)> = (0..n).map(|i| ((a - (t - h[i] * 0.006)).abs(), i + 1)).collect();
    avg.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
    avg[0].1.to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

ll help(ll a,ll b){
    if(b==0)return 1;
    if(b==1)return a;
    ll ans = 1;
    if(b&1){
        ans = help(a,b-1)*a;
    }
    else {
        ans  = help(a,b/2);
        ans = ans * ans;
    }
    return ans%mod;
}

int main(){
    ll n;
    cin>>n;
    ll x = help(10,n);
    ll y = help(9,n);
    ll z = help(8,n);
    ll res = (x-2*y+z+2*mod)%mod;
    cout<<res;
    return 0;    
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,n){
      int m,e,j;
      cin>>m>>e>>j;

      if(m==100 || e==100 || j==100)
        cout<<"A"<<endl;

      else if(m+e>=180)
        cout<<"A"<<endl;

      else if(m+e+j>=240)
        cout<<"A"<<endl;

      else if(m+e+j>=210)
        cout<<"B"<<endl;

      else if(m+e+j>=150 &&( m>=80 || e>=80 ))
        cout<<"B"<<endl;

      else
        cout<<"C"<<endl;

    }
  }
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
struct node{
    int from,to,day;
};
queue<int> a[100005];
queue<node> q;
int vis[100005];
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,temp;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n-1;j++){
            cin>>temp;
            a[i].push(temp);
        }
    }
    for(int i=1;i<=n;i++){
        int x=a[i].front();
        int y=a[x].front();
        if(vis[x]||vis[y]) continue;
        if(y==i){
            q.push(node{i,x,1});
            vis[x]=vis[y]=1;
        }
    }
    int ans=0;
    while(!q.empty()){
        node t=q.front();
        int u=t.from,v=t.to,w=t.day,x=-1,y=-1;
        a[u].pop(),a[v].pop(),q.pop();
        ans=max(w,ans);
        if(!a[u].empty()) x=a[u].front();
        if(!a[v].empty()) y=a[v].front();
        if(x!=-1){
            if(a[x].front()==u) q.push(node{x,u,w+1});
        }
        if(y!=-1){
            if(a[y].front()==v) q.push(node{y,v,w+1});
        }
    }
    for(int i=1;i<=n;i++){
        if(!a[i].empty()){
            cout<<-1;
            return 0;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 71296
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int x[10],y[10];
int main(void)
{
    int n;
    double a=0;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> x[i] >> y[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
                a+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    a/=n;
    printf("%.9f" ,a);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define maxn 100005 
using namespace std;

char s[maxn];
int cnt[maxn];

int main(int argc, char** argv)
{
	int n, q;
	scanf("%d%d%s", &n, &q, s);
	for(int i=1; i<n; i++)
		cnt[i] = (s[i - 1] == 'A' && s[i] == 'C')? cnt[i - 1] + 1: cnt[i - 1];
	while(q--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		printf("%d\n", cnt[y - 1] - cnt[x - 1]);
	}
	return 0;
}

Measured memory_bytes: 1280
package main

import(
    "bufio"
    "fmt"
    "os"
)

var r = bufio.NewReader(os.Stdin)

func main() {
    var a,b int
    fmt.Fscan(r,&a)
    fmt.Fscan(r,&b)
    if a < b {
        fmt.Println("a < b")
    }
    if a > b {
        fmt.Println("a > b")
    }
    if a == b {
        fmt.Println("a == b")
    }
}



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

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

ll power(ll x, ll y)
{
    ll res = 1;

    while (y > 0) {

        if (y & 1)
            res = res * x;


        y = y >> 1;
        x = x * x;
    }
    return res;
}

vector<int> w[200010];

int vis[200010];

void dfs(int nxt , int prev , int val)
{
    vis[nxt] += val;
    for(int i=0;i<(int)w[nxt].size();i++)
        if(w[nxt][i]!=prev)
            dfs(w[nxt][i],nxt,vis[nxt]);
}

int main()
{
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        w[a].push_back(b);
        w[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int p,x;
        cin>>p>>x;
        vis[p]+=x;
    }
    dfs(1,0,0);
    for(int i=1;i<=n;i++) cout<<vis[i]<<" ";
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 29696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 1000000007;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

ll T, n;
ll s[100000], t[100000];
ll sum[100001];

int main(){
    cin >> T >> n;
    rep(i,n){
        cin >> s[i] >> t[i];
        sum[i+1] += t[i]-s[i]+sum[i];
    }
    ll ans = 0;
    rep(i,n){
        ll cnt = 0;
        int st = i, en = n, mid;
        while(en-st > 1){
            mid = (st+en)/2;
            if(s[mid] <= s[i]+T) st = mid;
            else en = mid;
        }
        cnt = sum[st]-sum[i]+min(t[st],s[i]+T)-s[st];
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}

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

int main() {
    int n; 
	scanf("%d", &n); bool ok = 1;
    while(n --) {
        int x; scanf("%d", &x);
        if(x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
            ok = 0;
        }
    }
    puts(ok ? "APPROVED" : "DENIED");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;

int main(){
    ll a,b,h;
    cin>>a>>b>>h;
    if(a+b==h||b+h==a||a+h==b)cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ct[26];
int main(){
    string s;
    cin >> s;
    long long ans = 1;
    for (int i = 0; i < s.size(); i++){
        ans += i-ct[s[i]-'a'];
        ct[s[i]-'a']++;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 640
/*
   1 2 3
   4 5 6
   7 8 9

   1
   2
   3

   c1=1*1+2*2+3*3
   c2=4*1+5*2+6*3
   c3=7*1+8*2+9*3
*/

#include<stdio.h>
#define SIZE 101

int main(void)
{
  int n, m;
  int A[SIZE][SIZE];
  int b[SIZE];
  int i, j, c;

  scanf("%d %d", &n, &m);
  for(i=1; i <= n; i++){
    for(j = 1; j <= m; j++){
      scanf("%d", &A[i][j]);
    }
  }
  for(i = 1; i <= m; i++){
    scanf("%d", &b[i]);
  }

  for(i = 1; i <= n; i++){
    c = 0;
    for(j = 1; j <= m; j++){
      c = c + A[i][j] *b[j]; 
    }
    printf("%d\n", c);
  }

  return(0);
}

Measured memory_bytes: 640
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let ans = (1..n + 1)
        .map(|x| x.to_string())
        .filter(|x| x.len() % 2 == 1)
        .count();

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
using System;
using System.IO;
using System.Collections.Generic;

namespace ABC100C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var A = ss.Next(int.Parse, N);

            var ans = 0;
            for (var i = 0; i < A.Length; i++)
            {
                while (A[i] % 2 == 0)
                {
                    A[i] /= 2;
                    ans++;
                }
            }

            sw.WriteLine(ans);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 14176
#include<stdio.h>

int n,a[1000],i,j,v;

void print(){
    for(int i=0 ; i<n ; i++)
        if(i==n-1)    printf("%d\n", a[i]);
        else            printf("%d ", a[i]);
}

int main(void){
    scanf("%d", &n);
    for(i=0 ; i<n ; i++) 
        scanf("%d", &a[i]);
    print();
    for(i=1 ; i<n ; i++){
        j=i;
        while(j>0 && a[j-1] > a[j]){
            v=a[j-1], a[j-1]=a[j], 
            a[j]=v, j--;
        }
        print();
    }
    return 0;
}


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

int N, K, R, S, P;
string T;
int r = 0; int s = 0; int p = 0;
ll sr = 0; ll ss = 0; ll sp = 0;


int main(){
  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;

  vector<bool> used(N, false);

  for(int i = 0; i < N; i++){
    char c = T[i];
    if(c == 'r') sr += 1;
    else if(c == 's') ss += 1;
    else if(c == 'p') sp += 1;
    if(used[i]) continue;
    if(i+K < N && T[i+K] == c){
      if(c == 'r') r += 1;
      else if(c == 's') s += 1;
      else if(c == 'p') p += 1;
      used[i+K] = true;
    }
    used[i] = true;
  }

  cout << (sr-r) * P + (ss-s) * R + (sp-p) * S << endl;
  return 0;  
}
  

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 
 
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {
 
    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}
 
ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod ){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}
 
ll mul(ll a,ll b,ll m)
{
    return (a%m*b%m)%m;
}
  
 
 
 
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a;ll s = 0;
    vector<ll> m(100050,0);
    for(int i=0;i<n;i++)
    {
        cin>>a;
        s+=a;
        m[a]++;
    }
     ll q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;
        s+=(m[b]*(c-b));
        m[c]+=m[b];
        m[b] = 0;
        cout<<s<<"\n";
    }
   
    
    return 0;
}

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

void run() {
    int x;
    cin >> x;
    if (x >= 30) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    run();
    return 0;
}


Measured memory_bytes: 3576
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];
        int key1 = 0;
        int val1 = 0;
        int val2 = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        for (int i = 0; i < n; i++) {
            if (a[i] > val1) {
                val2 = val1;
                key1 = i;
                val1 = a[i];
            } else if (a[i] > val2) {
                val2 = a[i];
            }
        }
        for (int i = 0; i < n; i++) {
            if (i == key1) {
                System.out.println(val2);
                continue;
            }
            System.out.println(val1);
        }
    }

}


Measured memory_bytes: 121644
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a ,b;
  	cin >>a >> b;
  	long long int i=0,m = a.length();
  	for(i=0;i<m;i++){
    	if(a[i]!=b[i]){break;}
    }
  	if(i!=m){cout <<"No"<<endl;}
  	else cout << "Yes"<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int binarySearch(int,int,int *);

int main()
{
  int i,S[100000],T[50000],Sn,Tn,key,cnt=0;
  scanf("%d",&Sn);
  for(i=0;i<Sn;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&Tn);
  for(i=0;i<Tn;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<Tn;i++){
    key = T[i];
    if(binarySearch(Sn,key,S)==1) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

int binarySearch(int n,int key,int *A){
  int right,left,mid;
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]) return 1;
    else if(key < A[mid]) right = mid;
    else left = mid +1;
  }
  return 0;
}



Measured memory_bytes: 2332
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    int k;
    cin>>k;
    vll v(n);
    rep(i,0,n)cin>>v[i];
    ll ans=-INF;
    rep(l,0,k+1){
        rep(r,0,(k+1)-l){
            if(l+r>n)continue;
            ll throwaway=k-(l+r);
            ll res=0;
            priority_queue<ll,vll,greater<ll>> q;
            rep(i,0,l)q.push(v[i]),res+=v[i];
            rep(j,0,r)q.push(v[n-1-j]),res+=v[n-1-j];
            while(!q.empty()&&q.top()<0&&throwaway){
                res-=q.top();
                q.pop();
                throwaway--;
            }
            chmax(ans,res);
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
x,y = map(int,input().split())
z = y - 2*x
if z%2 == 1:
    print("No")
else:
    b = z // 2
    a = (y - 4*b) // 2
    if (y - 4*b) % 2==1:
        print("No")
    elif a + b == x and a>=0 and b>=0:
        print("Yes")

    else:
        print("No")

Measured memory_bytes: 9188