akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

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

	ll num = 3;
	int cnt = 1;
	while(num < n){
		num *= 3;
		cnt++;
	}
	cout << cnt << endl;

	return 0;
}

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

int N;
const int MAX_N = 2.0e5 + 100;
int P[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> P[i];

    int Q[N+1];
    for (int i = 0; i < N; i++) {
        Q[P[i]] = i;
    }

    int cnt = 1;
    int ans = 0;
    for (int i = 1; i <= N-1; i++) {
        if (Q[i] < Q[i+1]) {
            cnt++;
        }
        else {
            ans = max(ans, cnt);
            cnt = 1; 
        }
    }

    if (ans == 0) cout << ans << endl;
    else cout << N - ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int n, k, tmp = 0;
double ans = 0;

int main(){

	cin >> n >> k;

	if (n >= k){
		tmp += n - k + 1;
		ans += (double)tmp;
	}
	for (int i = 1; i <= n - tmp; i++){
		int x = i, cnt = 0;
		while (x < k){
			x = (x << 1);
			cnt++;
		}
		ans += ((double)1.0) / ((double)(1 << cnt));
	}
	ans /= ((double)n);

	cout << setprecision(18) << ans << endl;

	return 0;
}

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

using namespace std;
#define long long int int;
struct ab{
    int left,right;
};
bool comp(ab x,ab y)
{
    return x.right < y.right;
}
int call(ab* ar,int* dp,int start,int i)
{
    if(i == 0)
    return 0;
    if(dp[i] != -1)
    return dp[i];
    int ans = 0,opt1 = 0,opt2 = 0;
    if(ar[0].left >= start)
    {
        opt1 = call(ar+1,dp,ar[0].right,i-1) + 1;
    }
    opt2 = call(ar+1,dp,start,i-1);
    ans = max(opt1,opt2);
    dp[i] = ans;
    return ans;
}

int main()
{
    int n;
    cin>>n;
    int pos[n],range[n];
    for(int i=  0;i < n;i++)
    {
        cin>>pos[i]>>range[i];
    }
    ab ar[n];
    for(int i = 0;i < n;i++)
    {
        ar[i].left = pos[i] - range[i];
        ar[i].right = pos[i] + range[i];
    }
    sort(ar,ar+n,comp);
    int robot = 0,*dp = new int[n+1];
    for(int i = 0;i <= n;i++)
    dp[i] = -1;
    int ans = call(ar,dp,ar[0].left,n);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8448
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	a := make([]int, n)
	op := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		if i % 2 == 0 {
			op += a[i]
		} else {
			op -= a[i]
		}
	}
	for i := 0; i < n; i++ {
		fmt.Print(op, " ")
		op = 2 * a[i] - op
	}
}



Measured memory_bytes: 6144
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
S = sum(A)
l  = S / (4 * M)

if l % 1 == 0:
  l -= 1
  
a = len(list( i for i in A if i > l ))
if a >= M:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
n = int(input())
array = [int(num) for num in input().split()]

sorted_array = sorted(array)
count = 0

for num1, num2 in zip(array, sorted_array):
    if num1 != num2:
        count += 1

if count == 2 or count == 0:
    print("YES")
else:
    print("NO")


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

#define all(n) n.begin(),n.end()
#define ll long long

#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>

#define ff first
#define ss second

using namespace std;
const ll maxn=1e6+2;
const ll maxx=1e16;
const ll mod=998244353;
const ll mod1=998244353;

vector<ll>  ans[maxn];
pll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
    ll a;
     cin>>a;
     cout <<a+a*a+a*a*a;



}


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

vector<long long int> v;

void num(long long int a, int n){
	long long int b;
	if(a%10!=0){
		if(n<11){
			b = a*10LL+a%10-1;
			v.push_back(b);
			num(b, n+1);
		}
	}
	if(a%10!=9){
		if(n<11){
			b = a*10LL+a%10+1;
			v.push_back(b);
			num(b, n+1);
		}
	}
	if(n<11){
		b = a*10LL+a%10;
		v.push_back(b);
		num(b, n+1);
	}
}

int main() {
	int k; cin >> k;
	for(long long int i=1LL;i<=9LL;i++){
		v.push_back(i);
		num(i, 1);
	}
	sort(v.begin(), v.end());
	cout << v[k-1] << endl;
	return 0;
}

Measured memory_bytes: 10604
def p(S):
    D={}
    for i in range(len(S)):
        a=S[i]
        if a in D:
            D[a].add(i)
        else:
            D[a]={i}
    return D
S=input()
T=input()

A=sorted(p(S).values())
B=sorted(p(T).values())

if A==B:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 113352
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N;
  vector <long> a(5);
  cin>>N>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
  sort(a.begin(),a.end());
  if(N%a[0] != 0){
    cout << N/a[0]+5 << endl;
  }
  else{
    cout << N/a[0]+4 << endl;
  }
  return 0;
}
  


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

int main() {
  string s;
  cin >> s;
  bool ans = false;
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans = true;
  if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ans = true;
  if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) ans = true;
  if (ans) puts("Yes");
  else puts("No");
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    vector<int> c(n);
    for (int i = 0; i < n; i++)
        cin >> c[i];

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] - c[i] > 0)
            ans += (v[i] - c[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
using namespace std;
#define lli long long int
int main()
{
    int a[3][3];
        for (lli i = 0; i < 3; i++)
        {
            for (lli j = 0; j < 3; j++)
            {
                cin>>a[i][j];
                
            }
            
        }
    int n;
    cin>>n;
    int b[n+1];
    for (lli i = 0; i < n; i++)
    {
        
        cin>>b[i];
    }

    for (lli k = 0; k < n; k++)
    {
        for (lli i = 0; i < 3; i++)
        {
            for (lli j = 0; j < 3; j++)
            {
               if (a[i][j]==b[k])
               {
                   a[i][j]=-1;

               }
            }
            
        }
    }

  for (lli i = 0; i < 3; i++)
  {
      if(a[0][i]==-1 && a[1][i]==-1 && a[2][i]==-1 )
      {

          cout<<"Yes"<<endl;
          return 0;
      }
      else if(a[i][0]==-1 && a[i][1]==-1 && a[i][2]==-1)
      {
        cout<<"Yes"<<endl;
          return 0;   
      }
      else if(a[0][0]==-1 && a[1][1]==-1 && a[2][2]==-1)
        {
        cout<<"Yes"<<endl;
          return 0;   
      }

    else if(a[0][2]==-1 && a[1][1]==-1 && a[2][0]==-1)
    {
        cout<<"Yes"<<endl;
          return 0;   
      }

  }

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

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

int main() {
    
    int N; cin >> N;
    int MAX = 0;
    //vector<int> V(N); 
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        MAX = max(MAX, a);
        if(S.find(a) == S.end()){
            S.insert(a);
        }
        else S.erase(a);
        
    }
    
    cout << S.size() << endl;
}

Measured memory_bytes: 4864
//Authore :: Rabbi

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

#define ll long long
#define pb push_back
#define MOD   1000000000007
#define PI  acos(-1)
#define clr(x) memset(x,-1,sizeof(x))
#define End return 0
#define Start ios_base::sync_with_stdio(0);cin.tie(0);
vector<ll>v;

ll fun(ll n){
 ll i,j,ans;
 ans=sqrt(n);
 for(i=ans; i>=1; i--){
    if(n%i==0)return i;
 }
}


int main()
{
 Start;
 ll b,a,c,i,ok=0,pos,res,ans;
  cin>>a;
  res=fun(a);
  ans=a/res;
  cout<<(res-1)+(ans-1)<<endl;

 End;
}




Measured memory_bytes: 256
#include<stdio.h>
#define N 500000

int H;
int left(int);
int right(int);
void maxHeapify(int *,int);
void buildMaxHeap(int *);

int main(){
  int i;
  int a[N];

  scanf("%d",&H);

  for(i=1; i<=H; i++){
    scanf(" %d",&a[i]);
  }

  buildMaxHeap(a);

  for(i=1; i<=H; i++){
    printf(" %d",a[i]);
  }

  printf("\n");

  return 0;
}

int left(int c){
  return c*2;
}

int right(int c){
  return c*2 + 1;
}

void maxHeapify(int *a,int i){
  int l,r,largest,temp;

  l = left(i);
  r = right(i);

  if((l <= H) && (a[l] > a[i])) largest = l;
  else largest = i;
  if((r <= H) && (a[r] > a[largest])) largest = r;

  if(largest != i){
    temp = a[i];
    a[i] = a[largest];
    a[largest] = temp;
    maxHeapify(a,largest);
  }
}

void buildMaxHeap(int *a){
  int i;

  for(i=H/2; i>0; i--) maxHeapify(a,i);
}



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

int main(){
  using pii= pair<int, int>;
  int N,M;
  cin >> N >> M;

  vector<pii> conflicts(M);
  for(int i=0; i<M; i++){
    cin >> conflicts.at(i).first >> conflicts.at(i).second;
  }
  auto comp_sort= [](pii a, pii b){
    bool ans= (a.second != b.second) ? (a.second < b.second)
                                     : (a.first  < b.first);
    return ans;
  };
  sort(conflicts.begin(), conflicts.end(), comp_sort);

  set<int> blocked;
  int left, right;
  for(auto conflict:conflicts){
    tie(left, right)= conflict;

    auto itr1= blocked.lower_bound(left);
    auto itr2= blocked.lower_bound(right);
    if(distance(itr1, itr2)!= 0){ continue; }
    else{
      blocked.insert(right-1);
    }
  }
  
  cout << blocked.size() << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int arr[(int)2e5];
int main() {
    quick
int n,k; cin>>n>>k; long long ans=0;
for(int i=0;i<n;i++){cin>>arr[i];}
sort(arr,arr+n,greater<int>());
for(int i=0;i<n;i++){
if(k>0){k--; continue;}
else{ans+=arr[i];}
}
cout<<ans;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int q = scanner.nextInt();
    for (int i = 0; i < q; i++) {
      long a = scanner.nextLong();
      long b = scanner.nextLong();
      System.out.println(solve(a, b));
    }
  }

  private static long solve(long a, long b) {
    if (a > b) return solve(b, a);

    long ab = Math.multiplyExact(a, b);
    long i = findUpperRoot(ab);
    if (i == 0) return 0;
    long j = (ab - 1) / i;

    long res = Math.multiplyExact(i, 2);
    if (i == j) res--;
    if (i >= a) res--;

    return res;
  }

  private static long findUpperRoot(long n) {
    long ll = 0;
    long ul = (long) Math.sqrt(n) + 1;
    while (Math.addExact(ll, 1) < ul) {
      long mid = Math.addExact(ll, ul) / 2;
      if (Math.multiplyExact(mid, mid) < n) {
        ll = mid;
      } else {
        ul = mid;
      }
    }
    return ll;
  }
}


Measured memory_bytes: 21972
// agrawal117
//chahatagrawal117
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long int ll;
#define MAX 1005
int main()
{
    set<ll> st;
    ll a,b,c;
    cin>>a>>b>>c;
    st.insert(a);
    st.insert(b); st.insert(c);
    if(st.size()==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int ptr = sc.nextInt();
		int pts = sc.nextInt();
		int ptp = sc.nextInt();
		String t = sc.next();

		int pt = 0;
		int[] a = new int[n];

		for ( int i=0; i<k; i++ ) {
			switch ( t.charAt(i) ) {
				case 'r': pt = pt + ptp; break;
				case 's': pt = pt + ptr; break;
				case 'p': pt = pt + pts; break;
				default: break;
			}
		}

		for ( int i=k; i<n; i++ ) {
			if ( t.charAt(i) == t.charAt(i-k) & a[i-k] == 0 ) {
				a[i] = 1;
				continue;
			}
			switch ( t.charAt(i) ) {
				case 'r': pt = pt + ptp; break;
				case 's': pt = pt + ptr; break;
				case 'p': pt = pt + pts; break;
				default: break;
			}
		}
		System.out.println(pt);
	}
}

Measured memory_bytes: 27476
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String str = in.next();
        int max = 0;
        for (int i = 0; i < str.length(); i++){
            int sum = 0;
            for (int j = i; j < str.length(); j++){
                if (str.charAt(j) == 'A' || str.charAt(j) == 'C' || str.charAt(j) == 'G' || str.charAt(j) == 'T'){
                    sum++;
                    max = Math.max(max, sum);
                }
                else break;
            }
        }
        System.out.println(max);
    }
    
}

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

typedef unsigned int U;
#define L 1548576
bool HA[L];
char T[256];

int main() {
    U n, s, t;
    char c;
    T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( register U i = 0; i++ < n; ) {
        s = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            s += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[s] = true;
        } else {
            puts( HA[s] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   cout<<min(a,b)+min(c,d)<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ma = -INF;
  chmax(ma, a*c);
  chmax(ma, a*d);
  chmax(ma, b*c);
  chmax(ma, b*d);

  cout << ma << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

ll N,K;


ll man(ll N, ll val) {
  //  cout << val << endl;
  if(N==0) return val;
  return min(man(N-1, val*2),man(N-1, val + K));

}

int main() {
  ll N;
  ll M;
  cin >> N;
  map<int,int> mp;
  rep(i,N) {
	int a;
	cin >> a;
	mp[a]++;
  }
  bool f = true;
  cin >> M;
  rep(i,M) {
	int a;
	cin >> a;
	if(mp[a] == 0) f = false;
	mp[a]--;
  }
  cout << (f ? "YES" : "NO") << endl;
  
}



Measured memory_bytes: 12500
#include "bits/stdc++.h"
using namespace std;

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const int INF = 1 << 29;

signed main() {
	int n, m; cin >> n >> m;
	V balls(n, 1);
	vector<bool> ari(n);
	ari[0] = 1;
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (balls[x]) {
			balls[y]++;
			balls[x]--;
			if (ari[x]) {
				ari[y] = true;
				ari[x] = !!balls[x];
			}
		}
	}
	cout << accumulate(all(ari), 0) << endl;
	system("pause");
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (e);(i) --> (s);)
#define all(x) x.begin(),x.end()

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> V(N);
  rep(i,0,N) cin >> V[i];
  
  i64 ans = 0;

  rep(i,0,N + 1) rep(j,i, N + 1) {
    i64 remain = K - i - (N - j);
    if(remain < 0) continue;
    vector<i64> vec;
    i64 sum = 0;
    rep(s,0,i) vec.push_back(V[s]), sum += V[s];
    rep(s,j,N) vec.push_back(V[s]), sum += V[s];
    sort(all(vec));
    rep(s,0,std::min(remain, (i64)vec.size())) {
      if(vec[s] >= 0) break;
      sum -= vec[s];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    ll r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; ++i) {
        x = r * x - d;
        cout << x << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 200000

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

ll N;
ll A[MAX];
priority_queue<ll> pq;

int main() {

    cin >> N;

    ll temp = 0;
    REP(i, N) {
        cin >> A[i];
        pq.push(A[i]);        
    }

    REP(i, N) {
        ll top = pq.top();
        if(top == A[i]) {
            pq.pop();
            ll ans = pq.top();
            cout << ans << endl;
            pq.push(top);
        } else {
            cout << top << endl;
        } 
    }
    return 0;
}


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

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            // 出力用リスト生成
            List<int> intResultDataList = new List<int>();

            while (true)
            {
                // 入力
                string strInputData = Console.ReadLine();             

                // 入力「0」で終了
                if (strInputData == "0")
                {
                    break;
                }
                
                // 入力値の合計を計算
                else
                {
                    int intTempSumData = new int();

                    foreach (char charcter in strInputData)
                    {
                        intTempSumData += int.Parse(charcter.ToString());
                    }
                    
                    //結果を出力用リストに追加
                    intResultDataList.Add(intTempSumData);
                }
            }

            //出力
            foreach(int num in intResultDataList)
            {
                Console.WriteLine(num);
            }
        }
    }
}



Measured memory_bytes: 18020
#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>; 
    
    
    int main() {
     int n,m;
     
     cin >> n>> m;
     vector<int> a(n);
     
     
     rep(i,n)  cin >> a[i];
     
     int sum = 0;
     int count = 0;
     
     rep(i,n)  sum+=a[i];
     
     rep(i,n){
     	if(a[i]*4*m>=sum){
     		count++;
     	}
     }
     
     if(count>=m)	cout << "Yes" << '\n';
     else           cout << "No" << '\n';
     			
     
     return 0;
    }

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

string s;
int a[100009];
int main()
{
	cin>>s;
	int len=s.length() ;
	int sum=0;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='L')
		{
			a[i-1]+=(sum+1)/2;
			a[i]+=sum/2;
			sum=0;
		}
		else sum++;
	}
	sum=0;
	for(int i=len-1;i>=0;i--)
	{
		if(s[i]=='R')
		{
			a[i+1]+=(sum+1)/2;
			a[i]+=sum/2;
			sum=0;
		}
		else sum++;
	}
	for(int i=0;i<len;i++)
	{
		cout<<a[i]<<" "; 
	}
	return 0;
} 
/*
RRRLLRRRRLRRRRLL
0 0 2 3 0 0 0 0 2 3 0 0 0 3 3 0
0 0 3 2 0 0 0 0 2 3 0 0 0 3 3 0
*/

Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	string n;
	cin >> n;

	int t = 0;
	RBF(c, n) {
		t += c - '0';
		t %= 9;
	}
	t %= 9;

	if (t == 0) {
		col("Yes");
	}
	else {
		col("No");
	}
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout << '\n';
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

void solve(){
  int n; cin>>n;
  int cnt=0,f=0;
  int a,b;
  while(n--){
    cin>>a>>b;
    if(a==b) cnt++;
    else cnt=0;
    if(cnt>=3) f=1;
  }
  cout<<(f?"Yes":"No");LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1; //cin >> _;
  for(int i = 1 ; i <= _ ; i++){
    //cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long[] a = new long[3];
    for(int i = 0; i < 3; i++) {
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);
    long ans = 0;
    if(((a[0] % 2) == 1) && ((a[1] % 2) == 1) && ((a[2] % 2) == 1)) ans = (a[0] * a[1]);
    System.out.println(ans);
  }
}

Measured memory_bytes: 22356
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
    int N, A, B;
    string S;
    cin >> N >> A >> B;
    cin >> S;
    
    int pass = 0;
    int pass_b = 0;
    
    for(int i=0; i<N; i++) {
        if (S[i] == 'a') {
            if (pass < A + B) {
                cout << "Yes" << endl;
                pass++;
            }
            else {
                cout << "No" <<endl;
            }
        }
        else if (S[i] == 'b') {
            if (pass < A + B) {
                if (pass_b < B) {
                    cout << "Yes" << endl;
                    pass_b++;
                    pass++;
                }
                else {
                    cout << "No" << endl;
                }
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
    
    //cout << S << endl;
    
    //getline(cin, str);
    //vector < vector < int > > A(x, vector(y, 0));
    //int avg = round((float)accumulate(X.begin(), X.end(), 0.0) / N);
    return 0;
}

Measured memory_bytes: 896
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1,n-1):
    if p[i-1] < p[i] < p[i+1]:
        ans += 1
    elif p[i-1] > p[i] > p[i+1]:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

ll lcm(ll a, ll b){
  return a * b / gcd(a, b);
}

ll even_count(ll x){
  ll count = 0;
  while(x % 2 == 0){
    count++;
    x /= 2;
  }
  return count;
}

int main(){
  ll n, m;
  cin >> n >> m;
  ll x = 1;
  ll a;
  bool flag = false;
  ll count;
  ll prev = -1;
  rep(i, n){
    cin >> a;
    a /= 2;
    x = lcm(x, a);
    if (prev == -1){
      prev = even_count(a);
      continue;
    }
    else{
      count = even_count(a);
      if (prev != count){
        flag = true;
        break;
      }
    }
  }
  if (flag)
    cout << 0 << endl;
  else{
    ll ans = (m + x) / (2 * x);
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  itn int
using ll=int64_t;
#define rep(i,n) for (int i = 0; i < (int) (n); i++)
using vi = vector<int>;
using vll = vector<ll>;
/*//再帰関数木構造定型
int complete_time(vector<vector<int>> &children, int x) {
  // ベースケース
  if (children.at(x).size() == 0) {
    return 1;  // 子組織が無いような組織について、報告書が揃う時刻は0
  }// 再帰ステップ
  int receive_maisuu = 1;  // 受け取った時刻の最大値
  // x番の組織の子組織についてループ
  for (int c : children.at(x)) {receive_maisuu  += complete_time(children, c) ;}
  return  receive_maisuu ;
}*/


// 組織の関係から2次元配列を作る
//二次元配列入力定型
/*
vector<vector<int>> children(N);  // ある組織の子組織の番号一覧
  for (int i = 1; i < N; i++) {
    int parent = p.at(i);  // i番の親組織の番号
    children.at(parent).push_back(i);  // parentの子組織一覧にi番を追加
  }

  // num個分のスペースからなる文字列を返す (字下げに用いる)
  string space(int num) {
    string ret = "";
    for (int i = 0; i < num; i++) {
      ret += " ";
    }
    return ret;
  }*/


int main(){
int h,m, hh, mm,k;
cin>>h>>m>>hh>>mm>>k;
cout<<(hh*60+mm)-(h*60+m)-k;
  
  
  

  
  

}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    int x, y;
    cin >> x >> y;


    int a, b;

    int flag = 0;

    for(a = 0;a < 101;++a){
        b = x - a;
        if(4*a + 2*b == y && b > -1){
            flag = 1;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

bool revp2(const pair<ll,ll>&a,const pair<ll,ll>&b){return a.second>b.second;}

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

    ll n,a,b,x=0;
    cin>>n;
    map<pair<ll,ll>,ll>m;
    set<ll>s;
    vector<pair<ll,ll>>v,v2,v3;
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        m[{a,b}]=1;
    }
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        v2.push_back(make_pair(a,b));
        m[{a,b}]=2;
    }
    sort(v.begin(),v.end(),revp2);
    sort(v2.begin(),v2.end());
    for(int i=0;i<v2.size();i++){
        for(int j=0;j<v.size();j++){
            if(v[j].first<v2[i].first&&v[j].second<v2[i].second&&m[{v[j].first,v[j].second}]!=3){
                x++;
                m[{v[j].first,v[j].second}]=3;
                break;
            }
        }
    }
    cout<<x;
}


Measured memory_bytes: 3636
#include <cstdio>
#define maxn (100000+10)
int p[maxn*2];int *cnt=p+maxn;
int a[maxn];

int y,ans,n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		++cnt[a[i]];
		++cnt[a[i]-1];
		++cnt[a[i]+1];
	}
	  
	for (int i=-1;i<maxn;++i)
	  if (cnt[i]>y) y=cnt[i];
	printf("%d",y);
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    if (k > (n-1)*(n-2)/2) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, int>> edges;
    for (int i = 2; i <= n; ++i) {
        edges.push_back(make_pair(1, i));
    }
    int c = (n-1)*(n-2)/2 - k;
    for (int i = 2; i <= n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            if (c > 0) {
                edges.push_back(make_pair(i, j));
                --c;
            }
        }
    }
    cout << edges.size() << endl;
    for (auto edge : edges) {
        cout << edge.first << " " << edge.second << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

void main(){
  int a, b, c, d;
  scanf("%d %d %d %d",&a ,&b, &c, &d);
  
  while(1){
    c -= b;
    if(c<=0)
      break;
    a -= d;
    if(a<=0)
      break;    
  }
  if(a>0)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 1644
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    ll n,d,a;
    cin>>n>>d>>a;
    pll b[n];
    ll sum[n];
    ifr(i,0,n) cin>>b[i].ff>>b[i].ss,sum[i]=0;
    sort(b,b+n,greater<pll>());
    int j=0;
    ll ans = 0;
    for(int i=0;i<n;i++) {
        if(i-1>=0) sum[i]+=sum[i-1];
        if(b[i].ss-sum[i]<=0) continue;
        b[i].ss-=sum[i];
        ll x = b[i].ff-d;
        while(j<n) {
            if(b[j].ff<(x-d)) break;
            j++; 
        }
        ll cnt = (b[i].ss-1)/a + 1;
        ans+=cnt;
        sum[i]+=cnt*a;
        if(j<n) sum[j]-=cnt*a;
        // cout<<cnt<<" "<<j<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// Hamming Distance; ハミング距離
// ：文字数が等しい文字列sとtの不一致箇所の数を返す。[O(|s|)]
long long HammingDistance(const string &s, const string &t){
    long long stringSize = (long long)s.size(), distance = 0;
    for(long long i=0; i<stringSize; i++) if(s[i] != t[i]) distance++;
    return distance;
}

int main(){
    Init();
    string s; cin >> s;
    string t = "CODEFESTIVAL2016";
    cout << HammingDistance(s, t) << endl;
}

Measured memory_bytes: 3568
<?php
// https://atcoder.jp/contests/abc047/tasks/abc087_a
$x = (int) fgets(STDIN);
$a = (int) fgets(STDIN);
$b = (int) fgets(STDIN);


$x -= $a;

$amari = $x % $b;
$buy_b_count = ($x - $amari) / $b;
$x = $x - ($buy_b_count * $b);

echo $x;

Measured memory_bytes: 16136
import math
import itertools

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    N,K = map(int,input().split(" "))
    for i in range(1,K+1):
        if(i<=N-K+1):
            print(combinations_count(K-1,i-1)*combinations_count(N-K+1,i)%(10**9+7))
        else:
            print(0)

if __name__=='__main__':
    main()


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

int main() {
  
  int64_t W, H ,x, y;
  
  cin >> W >> H >> x >> y;
  
  cout << fixed << setprecision(10);
  
  cout << double(W) * double(H) / 2 << " ";
  
  if (x * 2 == W && y * 2 == H) cout << 1 << endl;
  
  else cout << 0 << endl;
  
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d[100010] = {};
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
        if(a[i] > 1) d[a[i] - 1]++;
        d[a[i]]++;
        d[a[i] + 1]++;
    }
    int ans = *max_element(d, d + 100010);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(;;){
        int n;
        cin>>n;
        if(!n) return 0;
        vector<string> w(n);
        rep(i,0,n) cin>>w[i];
        rep(i,0,n){
            int j=i;
            int res=0;
            while(j<n&&res<5){
                res+=w[j].length();
                j++;
            }
            if(res!=5) continue;
            res=0;
            while(j<n&&res<7){
                res+=w[j].length();
                j++;
            }
            if(res!=7) continue;
            res=0;
            while(j<n&&res<5){
                res+=w[j].length();
                j++;
            }
            if(res!=5) continue;
            res=0;
            while(j<n&&res<7){
                res+=w[j].length();
                j++;
            }
            if(res!=7) continue;
            res=0;
            while(j<n&&res<7){
                res+=w[j].length();
                j++;
            }
            if(res!=7) continue;
            cout <<i+1<<"\n";
            break;
        }
    }
}


Measured memory_bytes: 3172
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX = 220;
int num[MAX];
void solve(int n){
  int taro{};
  int hanako{};
  vector<int> Taro{};
  vector<int> Hanako{};
  int x;
  int n2 = 2 * n;
  for(int i{} ; i < n2 ; i++)
    num[i] = 1;
  for(int i{} ; i < n ; i++){
    scanf("%d",&x);
    Taro.push_back(x);
    num[x-1] = 0;
  }
  for(int i{} ; i < n2 ; i++){
    if(num[i])
      Hanako.push_back(i+1);
  }
  sort(Taro.begin(),Taro.end());
  int ix1{};
  int ix2{};
  int turn = -1;
  int now{};
  int sum{};
  while(true){
    if(Taro.size() == 0 || Hanako.size() == 0)
      break;
    if(turn == -1){
      if(ix1 >= Taro.size())
        ix1 = ix2 = now = 0;
      else{
        while(ix1 < Taro.size() && Taro[ix1] <= now)
          ix1++;
        if(ix1 == Taro.size())
          ix1 = ix2 = now = 0;
        else{
          now = Taro[ix1];
          Taro.erase(Taro.begin() + ix1);
        }
      }
    }
    else{
      if(ix2 >= Hanako.size())
        ix1 = ix2 = now = 0;
      else{
        while(ix2 < Hanako.size() && Hanako[ix2] <= now)
          ix2++;
        if(ix2 == Hanako.size())
          ix1 = ix2 = now = 0;
        else{
          now = Hanako[ix2];
          Hanako.erase(Hanako.begin() + ix2);
        }
      }
    }
    turn *= -1;
  }
  printf("%d\n",Hanako.size());
  printf("%d\n",Taro.size());
}
int main(){
  int n;
  while(true){
    scanf("%d",&n);
    if(n == 0)
      break;
    solve(n);
  }
}


Measured memory_bytes: 2664
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{    
    private struct Card
    {
        public string ch { set; get; }
        public int num { get; set; }
    }

    static void BubbleSort(Card[] data, int n)
    {
        bool flag = true;
        int k = 0;
        while (flag)
        {
            flag = false;
            for(int i = n - 1; i > k; i--)
            {
                if(data[i].num < data[i - 1].num)
                {
                    var temp = data[i];
                    data[i] = data[i - 1];
                    data[i - 1] = temp;
                    flag = true;
                }               
            }
            k++;
        }

    }

    static void SelectionSort(Card[] data, int n)
    {
        for(int i = 0; i < n - 1; i++)
        {
            int minj = i;
            for(int j = i; j < n; j++)
            {
                if(data[j].num < data[minj].num)
                {
                    minj = j;
                }
            }
            var temp = data[i];
            data[i] = data[minj];
            data[minj] = temp;
        }
    }

    static bool IsStable(Card[] select, Card[] bubule, int n)
    {
        for(int i = 0; i < n; i++)
        {
            if(select[i].ch != bubule[i].ch)
            {
                return false;
            }
        }
        return true;
    }


    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ');
        var bubblelist = new Card[n];
        var selectlist = new Card[n];

        for(int i = 0; i < n; i++)
        {
            bubblelist[i].ch = input[i].Substring(0, 1);
            bubblelist[i].num = int.Parse(input[i].Substring(1, 1));
            selectlist[i] = bubblelist[i];
        }

        BubbleSort(bubblelist, n);
        SelectionSort(selectlist, n);
       
        for(int i = 0; i < n; i++)
        {
            if(i == n - 1)
            {
                Console.WriteLine($"{bubblelist[i].ch}{bubblelist[i].num}");
            }
            else
            {
                Console.Write($"{bubblelist[i].ch}{bubblelist[i].num} ");
            }
        }

        Console.WriteLine("Stable");

        for (int i = 0; i < n; i++)
        {
            if (i == n - 1)
            {
                Console.WriteLine($"{selectlist[i].ch}{selectlist[i].num}");
            }
            else
            {
                Console.Write($"{selectlist[i].ch}{selectlist[i].num} ");
            }
        }

        if (IsStable(selectlist, bubblelist, n))
        {
            Console.WriteLine("Stable");
        }
        else
        {
            Console.WriteLine("Not stable");
        }
    }
}


Measured memory_bytes: 17988
#include <stdio.h>

#define LENGTH 256

int main(void){
  char input[LENGTH];
  int a, b, h;
  fgets(input, LENGTH - 1, stdin);
  sscanf(input, "%d", &a);
  fgets(input, LENGTH - 1, stdin);
  sscanf(input, "%d", &b);
  fgets(input, LENGTH - 1, stdin);
  sscanf(input, "%d", &h);

  int area = (a + b) * h / 2;

  printf("%d\n",area);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	vector<string> t = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	rep(i,7){
		if(t.at(i) == s){
			cout << 7 - i << endl;
		}
	}
}


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

string s,s2;
int memo[3010][3010];

int go(int ind,int ind2)
{
    if(memo[ind][ind2] != -1) return memo[ind][ind2];

    if(ind == s.size() or ind2 == s2.size()) return 0;

    if(s[ind] == s2[ind2]) return memo[ind][ind2] = 1+go(ind+1,ind2+1);
    return memo[ind][ind2] = max(go(ind+1,ind2),go(ind,ind2+1));
}

int main()
{
    cin>>s>>s2;
    memset(memo,-1,sizeof memo);
    int ans = go(0,0);
    //cout<<ans<<endl;

    for(int i = 0;i<s.size();i++){
        for(int j = 0;j<s2.size();j++){
           if(s[i] == s2[j] and memo[i][j] == ans){
            cout<<s[i];
            ans --;
            break;
           }
        }
    }
}

Measured memory_bytes: 35968
while true
  judges = gets.to_i
  break if judges == 0
  a=[]
  for i in 0..judges-1
    a<<gets.to_i
  end
  sum = 0
  min = a[0]
  max = a[0]
  for i in 0..judges-1
    sum=sum+a[i]
    if min > a[i]
      min=a[i]
    end
    if max < a[i]
      max = a[i]
    end
  end
  sum=(sum-max-min)/(judges-2)
  puts sum
end

Measured memory_bytes: 6104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll ans = 0;
ll N, T;

ll dp[3030][3030];

int main(){

    cin >> N >> T;
    vector<P>v(N);
    rep(i, N)cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());
    rep(i, N){
        ll A = v[i].first;
        ll B = v[i].second;
        for(ll t = 0; t <= T; t++)dp[i + 1][t] = dp[i][t];
        for(ll t = 0; t < T; t++){
            ll nxt = min(T, t + A);
            chmax(dp[i + 1][nxt], dp[i][t] + B);
        }
    }
    for(ll t = 0; t <= T; t++)chmax(ans, dp[N][t]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 71936
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,D,X;
  cin>>N>>D>>X;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int ans=X;
  for(int i=0;i<N;i++)
    ans+=1+((D-1)/A.at(i));
  cout<<ans<<endl;
  
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Max_N=4*1e5;
int N,A[Max_N+10]={},Del[Max_N+10]={};
pair<int,int> B[Max_N+10]={};
inline int lowbit(int x){
	return x & - x;
}
inline void ADD(int x,int k){
	if(!x) return;
	for(;x;x-=lowbit(x)) Del[x]=min(Del[x],k);
}
inline int ASK(int x){
	int Min=Del[x];
	for(;x<=N;x+=lowbit(x)) Min=min(Min,Del[x]);
	return Min;
}
struct kk{
	int l,r,Id1,Id2,Rev;
} T[Max_N*4+10]={};
inline void Build(int x,int l,int r){
	T[x].l=l; T[x].r=r;
	if(l==r){
		if(l%2) T[x].Id1=l;
		else T[x].Id2=l;
		return;
	}
	Build(x<<1,l,(l+r)>>1);
	Build((x<<1)+1,((l+r)>>1)+1,r);
	T[x].Id1=A[T[x<<1].Id1]<A[T[(x<<1)+1].Id1]?T[x].Id1=T[x<<1].Id1:T[x].Id1=T[(x<<1)+1].Id1;
	T[x].Id2=A[T[x<<1].Id2]<A[T[(x<<1)+1].Id2]?T[x].Id2=T[x<<1].Id2:T[x].Id2=T[(x<<1)+1].Id2;
}
inline void DownTag(int x){
	if(T[x].Rev){
		swap(T[x<<1].Id1,T[x<<1].Id2);
		swap(T[(x<<1)+1].Id1,T[(x<<1)+1].Id2);
		T[x<<1].Rev^=1; T[(x<<1)+1].Rev^=1;
		T[x].Rev=0;
	}
}
inline void Add(int x,int k,int Val){
	DownTag(x);
	if(T[x].l==T[x].r){
		A[k]=Val;
		return;
	}
	if(k<=T[x<<1].r) Add(x<<1,k,Val);
	else Add((x<<1)+1,k,Val);
	T[x].Id1=A[T[x<<1].Id1]<A[T[(x<<1)+1].Id1]?T[x].Id1=T[x<<1].Id1:T[x].Id1=T[(x<<1)+1].Id1;
	T[x].Id2=A[T[x<<1].Id2]<A[T[(x<<1)+1].Id2]?T[x].Id2=T[x<<1].Id2:T[x].Id2=T[(x<<1)+1].Id2;
}
inline void Change(int x,int l,int r){
	if(l<=T[x].l&&T[x].r<=r){
		swap(T[x].Id1,T[x].Id2);
		T[x].Rev^=1;
		return;
	}
	DownTag(x);
	if(l<=T[x<<1].r) Change(x<<1,l,r);
	if(r>T[x<<1].r) Change((x<<1)+1,l,r);
	T[x].Id1=A[T[x<<1].Id1]<A[T[(x<<1)+1].Id1]?T[x].Id1=T[x<<1].Id1:T[x].Id1=T[(x<<1)+1].Id1;
	T[x].Id2=A[T[x<<1].Id2]<A[T[(x<<1)+1].Id2]?T[x].Id2=T[x<<1].Id2:T[x].Id2=T[(x<<1)+1].Id2;
}
inline int Ask(int x,int l,int r,int Opt){
    DownTag(x);
	if(l<=T[x].l&&T[x].r<=r) return Opt==1?T[x].Id1:T[x].Id2;
	int Ans=0,Anss=0;
	if(l<=T[x<<1].r) Ans=Ask(x<<1,l,r,Opt);
	if(r>T[x<<1].r) Anss=Ask((x<<1)+1,l,r,Opt);
	if(A[Ans]>A[Anss]) Ans=Anss;
	return Ans;
}
inline void Solv(){
	for(int i=1;i<=N/2;i++){
		int Min=Ask(1,1,N,1);
		int r=ASK(Min);
		int Minn=Ask(1,Min,r,2);
//		cout<<Min<<' '<<Minn<<' '<<r<<endl;
		B[i]=make_pair(A[Min],A[Minn]);
		Add(1,Min,1<<30); Add(1,Minn,1<<30);
		if(Min+1<Minn-1) Change(1,Min+1,Minn-1);
		ADD(Min,Min); ADD(Minn,Minn);
	}
}
int main(){
	scanf("%d",&N); A[0]=1<<30;
	for(int i=1;i<=N;i++) scanf("%d",&A[i]);
	for(int i=0;i<=N;i++) Del[i]=N;
	Build(1,1,N); Solv();
	for(int i=1;i<=N/2;i++) printf("%d %d ",B[i].first,B[i].second); puts("");
	return 0;
} 

Measured memory_bytes: 30208