akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int arr[] = new int[n]; 
		int res[] = new int[n];
		String s[]=br.readLine().split(" ");
		for (int i = 0; i < s.length; i++) {
			arr[i]=Integer.parseInt(s[i]);
			res[i]=arr[i];
		}
		
		Arrays.sort(res);
		int num = res[res.length/2];
		
		for (int i = 0; i < s.length; i++) {
			int temp = arr[i];
			if(temp < num) {
				System.out.println(res[(res.length+1)/2 ]);
			}
			else {
				System.out.println(res[(res.length+1)/2 -1]);
			}
		}
		/*int  n =Integer.parseInt(s[0]);
		int  m =Integer.parseInt(s[1]);
		int  x =Integer.parseInt(s[2]);
		int arr[] = new int[m];
		String s1[] = br.readLine().split(" ");
		for (int i = 0; i < s1.length; i++) {
			arr[i]=Integer.parseInt(s1[i]);
		}
		int res=0;
		int left = 0;
		int right = m-1;
		if(x > arr[m-1] || x< arr[0]) {
			System.out.println(0);
			
		}
		else {
		while(left<right) {
			int mid = (left+right)/2;
			//System.out.println("mid"+mid);
			if(arr[mid] < x) {
				res = mid;
				left = mid+1;
			}
			else {
				right = mid-1;
			}
		}
		if(arr[m-1] == n) {
			System.out.println(Math.min(res+1, m-res-2));
		}
		else
		System.out.println(Math.min(res+1, m-res-1));
		}
		int res=0;
		for (int i = 0; i < arr.length; i++) {
			if(arr[i]<x) {
				res++;
			}
			else {
				break;
			}
		}
		System.out.println(Math.min(res, m-res));*/
	}

}


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

using ll = long long;

#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;

    vector<ll> sum;
    ll all_or = 0;
    rep(i, N) {
        ll s = 0;
        for (int j = i; j < N; j++) {
            s += A[j];
            sum.push_back(s);
            all_or |= s;
        }
    }
    // set<int> idx;
    unordered_set<int> idx;
    for (int i = 0; i < sum.size(); i++) {
        idx.insert(i);
    }

    ll ans = 0;
    for (ll b = (1LL << 41); b > 0; b >>= 1) {
        if (!(all_or & b)) continue;
        // set<int> on;
        unordered_set<int> on;
        for (int i : idx) {
            if (sum[i] & b) {
                on.insert(i);
            }
        }
        if (on.size() >= K) {
            ans |= b;
            idx = on;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 29420
#include <iostream>
using namespace std; 
const int maxn = 1e5+5;
typedef long long ll;
ll n, W, w[maxn], v[maxn], f[maxn];
int main() {
  cin >> n >> W;
  for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
  for (int i = 1; i <= n; i++)
    for (ll l = W; l >= w[i]; l--)
      if (f[l - w[i]] + v[i] > f[l]) f[l] = f[l - w[i]] + v[i];
  cout << f[W];
  return 0;
}

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

using namespace std;

long long int INV(long long int m, long long int p) {
	vector<int> bit; // 2^0, 2^1, 2^2, 2^3, 
	long long int u = p - 2;
	while (u > 0) {
		bit.push_back(u % 2); u /= 2;
	}

	vector<long long int> W;
	long long int TMP = m;
	for (int i = 0; i < (int)bit.size(); i++) {
		TMP %= p;
		W.push_back(TMP);
		TMP *= TMP;
	}

	long long int ret = 1;

	for (int i = 0; i<(int)bit.size(); i++) {
		if (bit[i] == 1) { ret *= W[i];  ret %= p; }
	}

	return ret;
};

int H, W, A, B;

long long int C1[200005], C2[200005];

long long int M = 1000000007;

int main(void) {

	cin >> H >> W >> A >> B;

	//==== C2 ===
	C2[H] = 1;
	for (int i = H; i >= 1; i--) {
		C2[i - 1] = ((((H-i+W-B)*INV(H-i+1,M)) % M)*C2[i]) % M;
	}
	//===========

	//==== C1 ===
	C1[1] = 1;
	for (int i = 1; i <= H - A - 1; i++) {
		C1[i + 1] = (((B + i - 1)*INV(i, M) % M)*C1[i] % M);
	}
	//============


	long long int ans = 0;
	for (int i = 1; i <= H - A; i++) {
		ans = (ans + C1[i] * C2[i]) % M;
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1792
N=int(input())
maxi=0
smaxi=0
flag=0
ls=[]
x=0
for i in range(N):
  x=int(input())
  ls.append(x)
  if (maxi<x):
    smaxi=maxi
    maxi=x
  elif (maxi==x):
    smaxi=maxi
  elif (smaxi<x):
    smaxi=x
for i in range(N):
  if (ls[i]==maxi):
    print(smaxi)
  else:
    print(maxi)


Measured memory_bytes: 12520
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s; 
    cin >> s;
    if(s=="Sunny") cout << "Cloudy";
    else if(s=="Cloudy") cout << "Rainy";
    else if(s=="Rainy") cout << "Sunny";
}

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

int main(void){
    std::string S;
    int b=0, w=0, ans;
    std::cin >> S;

    for (int i=0; i<S.size(); ++i){
        if (i % 2 == 0){
            if (S.at(i) == '0') ++b;
            else ++w;
        } else {
            if (S.at(i) == '0') ++w;
            else ++b;
        }
    }

    ans = std::min(b, w);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3692
from fractions import gcd

N, X = map(int, input().split())
P = list(map(int, input().split()))
P.append(X)
P.sort()
x0 = P[0]
P = [x - x0 for x in P]
ans = 0
for x in P:
    ans = gcd(ans, x)

print(ans)


Measured memory_bytes: 16208
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

void gen() {exit(0);}
int main() {
    #ifdef DEBUG
    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    
    int n, m;
    scanf("%d %d", &n, &m);
    if (m == 0) {
        printf("0\n");
        exit(0);
    }
    vector<ll> x(n);
    vector<ll> y(n);
    vector<ll> z(n);
    forn(i, 0, n) {
        ll a, b, c;
        scanf("%lld %lld %lld", &a, &b, &c);
        x[i] = a;
        y[i] = b;
        z[i] = c;
    }
    
    ll ans = 0;
    forn(i, 0, n) {
        ll as = abs(x[i]) + abs(y[i]) + abs(z[i]);
        vector<ll> cur;
        forn(j, 0, n) {
            if (i == j) continue;
            ll q = 0;
            if ((x[i] > 0 && x[j] > 0) || (x[i] < 0 && x[j] < 0)) {
                q += abs(x[j]);
            } else {
                q -= abs(x[j]);
            }
            if ((y[i] > 0 && y[j] > 0) || (y[i] < 0 && y[j] < 0)) {
                q += abs(y[j]);
            } else {
                q -= abs(y[j]);
            }
            if ((z[i] > 0 && z[j] > 0) || (z[i] < 0 && z[j] < 0)) {
                q += abs(z[j]);
            } else {
                q -= abs(z[j]);
            }
            cur.push_back(q);
        }
        sort(all(cur));
        ll p = as;
        for (int i = (int)cur.size() - 1, r = 1; i > -1 && r < m; i--, r++) {
            p += cur[i];
        }
        ans = max(ans, p);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
A = [ [0]*3 for i in range(3)];

for i in range(3) :
	s = input().split(' ');
	for j in range(3) :
		A[i][j] = int(s[j]);

Check = [ [0]*3 for i in range(3)];

n = int(input());
for i in range(n) :
	b = int(input());
	for j in range(3) :
		for k in range(3) :
			if A[j][k] == b :
				Check[j][k] = 1;
ans = 0;
for i in range(3) :
	bingo = 0;
	for j in range(3) :
		bingo += Check[i][j];
		if bingo == 3 :
			ans = 1;

for i in range(3) :
	bingo = 0;
	for j in range(3) :
		bingo += Check[j][i];
		if bingo == 3 :
			ans = 1;

bingo = 0;
for i in range(3) :
	bingo += Check[i][i];
	if bingo == 3 :
			ans = 1;

bingo = 0;
for i in range(3) :
	bingo += Check[i][2-i];
	if bingo == 3 :
			ans = 1;

if ans :
	print('Yes');
else :
	print('No');


Measured memory_bytes: 3064
import math
# from functools import reduce
import itertools


def gcd(a, b, c):
    ans = math.gcd(a, b)
    ans = math.gcd(ans, c)

    return ans

# def gcd(*numbers):
#     return reduce(math.gcd, numbers)

k = int(input())

elem = [i+1 for i in range(k)]

combs = itertools.combinations_with_replacement(elem, 3)

tmp = [1, 2, 3]

s = 0
for comb in combs:
    s += sum(tmp[:len(set(comb))]) * gcd(comb[0], comb[1], comb[2])
# for a in range(1, k+1):
#     for b in range(1, k+1):
#         for c in range(1, k+1):
#             s += gcd(a, b, c)

print(s)


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	vi p(N); rep(i, N) cin >> p.at(i); // 0-ind
	int ans = 0;
	rep(i, N - 1) {
		if (p.at(i) == i + 1) {
			ans++;
			swap(p.at(i), p.at(i + 1));
		}
	}
	if (p.at(N - 1) == N) ans++;
	cout << ans << endl;	
}

Measured memory_bytes: 640
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        int m[]=new int[a];
        for(int i=0;i<a;i++)
            m[i]=sc.nextInt();
        Arrays.sort(m);
        int flag=0;
        for(int i=1;i<a;i++){
            if(m[i]==m[i-1]){
                System.out.println("NO");
                flag++;
                break;
            }
        }
        if(flag==0)
            System.out.println("YES");

    }
}


Measured memory_bytes: 89724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b) {
			System.out.println(a-1);
		} else {
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 21844
function solve(lines: string): void {
  const s = lines[0];
  if (s.match(/AC/)) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
  const s = process.stdin.read();
  if (s !== null) { buf += s.toString(); }
});
process.stdin.on('end', () => {
  solve(buf.trim().split("\n"));
});

Measured memory_bytes: 11596
#include<iostream>
#include<map>
#include<string>
#include<vector>

using namespace std;

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

	map<string, int> count;
	vector<string> word;

	for (int i = 0; i < N; i++) {
		string w;
		cin >> w;
		word.push_back(w);
	}

	int size = word[0].size();
	string word_end = word[0].substr(size - 1);
	count[word[0]] = 1;
	bool ans = true;

	for (int i = 1; i < N; i++) {
		size = word[i].size();
		string word_first = word[i].substr(0, 1);

		if (word_first != word_end) {
			ans = false;
			break;
		}

		// count up
		if (count.find(word[i]) == count.end()) {
			count[word[i]] = 1;
		}
		else {
			ans = false;
			break;
		}

		word_end = word[i].substr(size - 1);
	}

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


Measured memory_bytes: 256
s = input()
num = len(s)
a = [0]*(num+1)
 
for i in range(num):
    if s[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)
 
for i in range(1, num+1):
    if s[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))

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

#define mp make_pair
#define pb push_back

typedef pair<int, int> ii;
typedef long long ll;
typedef pair<ll, ll> l4;


const int maxn = 1e5+1;
int n, k, a[maxn];

int solve(int x)
{
  int K = k-1;
  return (x+K-1)/K;
}
int main()
{
  scanf("%d %d", &n, &k);
  int one = -1;
  for (int i = 1; i <= n; ++i)
    {
      scanf("%d", a+i);
      if (a[i] == 1) one = i;
    }
  assert(one != -1);
  int ans = n;
  for (int i = 1; i <= one; ++i)
    if (one-i+1 <= k)
      {
        int tmp = 1 + solve(i-1) + solve(n-(i+k)+1);
        ans = min(ans, tmp);
      }
  printf("%d\n", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n, p;
    cin >> n >> p;
    if (n == 0 && p == 0){
      break;
    }
    int p2 = p;
    vector<int> cnt(n, 0);
    int x = 0;
    while (1){
      if (p == 0){
        p = cnt[x];
        cnt[x] = 0;
      } else {
        p--;
        cnt[x]++;
        if (cnt[x] == p2){
          cout << x << endl;
          break;
        }
      }
      x++;
      if (x == n){
        x = 0;
      }
    }
  }
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#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 stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#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 << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, T;
    cin >> N >> T;
    VLL t(N);
    rep(i,N){
        cin >> t[i];
    }
    ll time=0;
    rep(i,N-1){
        if(t[i+1]-t[i]>T){
            time+=T;
        }
        else {
            time+=t[i+1]-t[i];
        }
    }

    cout << time+T << endl;

}


Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

ll gcd(ll a, ll b) { return a ? gcd(b % a, a) : b; }

int main() {
  //
  ll n, m, d;
  cin >> n >> m >> d;
  double ans = 0;
  if (d == 0) {
    cout << setprecision(10) << fixed << (double)(m - 1) / (double)n << endl;
  } else {
    cout << setprecision(10) << fixed
         << (double)(m - 1) * 2 * (double)(n - d) / n / n << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int a;
    int cnt[4] = {};
    REP(i,6){
        cin >> a;
        a--;
        cnt[a]++;
    }
    REP(i,4){
        if(!(cnt[i] == 1 || cnt[i] == 2)){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	cout << n * (n + 1) / 2 << ' ';
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int a[n];
  vector<int> b(n);
  rep(i, n) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.rbegin(), b.rend());
  int mx1 = b[0], mx2 = b[1];
  rep(i, n) {
    if (a[i] == mx1)
      cout << mx2 << endl;
    else
      cout << mx1 << endl;
  }

  return 0;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
int main() {
  string answer, s;
  cin >> s;
  for (char c : s) {
    if (c == 'B' && !answer.empty()) {
      answer.pop_back();
    } else if (c != 'B') {
      answer.push_back(c);
    }
  }
  cout << answer;
}

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

int main(){
    int n;
    while(cin >> n){
        if(n == 0)  break;

        int ans = 0;
        while(n != 1){
            ans++;
            if(n%2)   n = 3*n+1;
            else        n /= 2;
        }

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


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
void add(int &a, const int &b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i != 0)A[i] ^= A[i - 1];
	}

	if (A.back() != 0) {
		vector<int> dp(2, 0);
		dp[0] = 1;
		for (int i = 0; i < N - 1; i++) {
			if (A[i] == 0) {
				add(dp[0], dp[1]);
			}
			else if (A[i] == A.back()) {
				add(dp[1], dp[0]);
			}
		}
		res = dp[0];
		
	}
	else {
		vector<vector<int> > dp(1 << 20);
		vector<int> zero(N + 3, 0);
		dp[0].push_back(0);
		zero[0]++;
		for (int i = 0; i < N; i++) {
			dp[A[i]].push_back(i + 1);
			if (A[i] == 0) {
				zero[i + 1]++;
			}
		}
		for (int i = 1; i < N + 3; i++) {
			zero[i] += zero[i - 1];
		}

		for (int i = 1; i < (1 << 20); i++) {
			if (dp[i].size() > 0) {
				int ans = 0;
				int sum = 1;
				int last = -1;
				for (int k = 0; k < dp[i].size(); k++) {
					if (last == -1) {
						ans = 1;
					}
					else {
						int num = zero[dp[i][k]] - zero[last];
						add(sum, (ans * num) % MOD);
						add(ans, sum);
					}

					last = dp[i][k];
				}
				add(res, ans);
			}
		}
		//cerr << res << endl;
		{
			int ans = 1;
			for (int i = 0; i < N - 1; i++) {
				if (A[i] == 0) {
					ans = (ans * 2) % MOD;
				}
			}
			add(res, ans);
		}
	}





	cout << res << endl;
}

Measured memory_bytes: 42992
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

void display(vector<int> const &v)
{
    rep(i, v.size())
    {
        if(i > 0) cout << " ";
        cout << v.at(i);
    }
    cout << endl;
}

int bubbleSort(vector<int> &v, int const & N)
{
    int sw = 0;
    for ( int i = 0; i < N-1; ++i)
    {
        for ( int j = N-1; j > i; --j)
        {
            if ( v.at(j) < v.at(j-1))
            {
                swap(v.at(j), v.at(j-1));
                ++sw;
                // display(v);
            }
        }
    }
    display(v);
    return sw;
}

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v.at(i);
    int sw;

    sw = bubbleSort(v, N);
    cout << sw << endl;

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int n;
	cin >> n;
	cout.precision(10);
	vector<double> v(n);
	for(int i=0; i<n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	double ans = (v[0] + v[1])/2;
	for(int i=2; i<n; i++) {
		ans = (ans + v[i])/2; 
	}
	cout << ans << endl;
}


Measured memory_bytes: 888
from typing import List


def answer(n: int, a: List[int]) -> int:
    count = 1
    while all(i % 2 ** count == 0 for i in a):
        count += 1
    return count - 1


def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(answer(n, a))


if __name__ == '__main__':
    main()


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

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

    std::sort(S.begin(), S.end());

    if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void* x, const void* y)
{
	return *(int*)x - *(int*)y;
}
int b[100005], c[100005];
int asc2(const void* x, const void* y)
{
	return c[*(int*)y] - c[*(int*)x];
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < m; i++)
		scanf("%d %d", &b[i], &c[i]);
	qsort(a, n, sizeof(int), asc);
	int d[100005];
	for (i = 0; i < m; i++)
		d[i] = i;
	qsort(d, m, sizeof(int), asc2);
	int j = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] < c[d[j]])
		{
			a[i] = c[d[j]];
			b[d[j]]--;
			if (b[d[j]] == 0)
				j++;
			if (j == m)
				break;
		}
	}
	long long int ans = 0;
	for (i = 0; i < n; i++)
		ans += (long long int)a[i];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2164
n,c,k,*t=map(int,open(0).read().split())
t.sort()
totalbus=1
bus=0
time=t[0]
for i in range(n):
    bus+=1
    if t[i]>time+k or bus>c:
        time=t[i]
        totalbus+=1
        bus=1
print(totalbus)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, x;
    while(cin >> n >> x) {
        int ans = 0;
        if (n == 0 && x == 0) break;
        for(int i = 1; i <= n; i++) {
            for(int j = i+1; j <= n; j++) {
                for(int k = j+1; k <= n; k++) {
                    if(i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
using namespace atcoder;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

long long pows[200'010];

struct S { long long val; int sz; };
struct F { long long d;};

S op(S x, S y) {
  long long val = mod(x.val * pows[y.sz]  + y.val);
  int sz = x.sz + y.sz;
  return S{val, sz};
}
S e() { return S{0, 0}; }
S mapping(F f, S s) {
  if(f.d == 0) return s;
  int sz = s.sz;
  int d = f.d;
  long long val = mod(mod(pows[sz] - 1) * inv_mod(9, i_7) * d);
  return S{val, sz}; 
}
F composition(F f, F g) {
  if(f.d == 0) return g;
  return f;
}
F id() { return F{0}; }

int main(){
  //using namespace std;
  
  int n, q;
  cin>>n>>q;
  int l[q], r[q], d[q];
  REP(i, q){
    cin>>l[i]>>r[i]>>d[i];
    l[i]--; r[i]--;
  }
  
  for(int i = 0; i <= 200'000; i++){
    if(i == 0){
      pows[i] = 1;
      continue;
    }
    pows[i] = mod(10 * pows[i - 1]);
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(n);
  REP(i, n){
    S now = {1, 1};
    seg.set(i, now);
  }
  REP(i, q){
    seg.apply(l[i], r[i] + 1, F{d[i]});
    long long ans = seg.all_prod().val;
    cout << ans << endl;
  }
  return 0;
}

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

int main()
{
	ll K;
	cin >> K;
	int ans = 1;
	if (7 % K == 0)
	{
		cout << ans << endl;
		return 0;
	}
	int temp = 7 % K;
	rep(i,K+10)
	{
		temp = (temp * 10 + 7) % K;
		ans++;
		if (temp == 0)
		{
			cout << ans << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(void){
    // Here your code !
    int n;
    cin >> n;
    vector<string> a(1001);
    bool run[30]={false, false, false};
    int out=0, e=0;
    int point[500] = {};
    int j=0;
    int k=0;
    while(cin >> a[j]) {
        if(a[j]=="HIT") {
            if(run[2]) {
                point[e]++;
                run[2] = false;
            }
            if(run[1]) {
                run[2] = true;
                run[1] = false;
            }
            if(run[0]) {
                run[1] = true;
                run[0] = false;
            }
            run[0] = true;
        } else if(a[j]=="OUT") {
            out++;
            if(out==3) {
                out = 0;
                run[0] = false;
                run[1] = false;
                run[2] = false;
                e++;
            }
        } else {
            k=0;
            if(run[0]) k++;
            if(run[1]) k++;
            if(run[2]) k++;
            run[0] = false;
            run[1] = false;
            run[2] = false;
            REP(i,k) {
                point[e]++;
            }
            point[e]++;
        }
        j++;
    }
    REP(i,n) {
        cout << point[i] << endl;
    }
 
}

Measured memory_bytes: 3020
#include<iostream>
#include<string>
using namespace std;
int main(){
 string s;
 cin>>s;
 int ans;
 for(char moji='a';moji<='z';moji++){
  int j=0;
  for(int i=0;i<s.size();i++){
   if(s[i]==moji)j++;
  }
  if(moji=='z'&&j!=0){
    cout<<"None"<<endl;
    break;
  }
  if(j==0){
   cout<<moji<<endl;
   break;
  }
  else continue;
} 
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll a, b; std::cin >> a >> b;
  ll aa = a + (a & 1), bb = b - !(b & 1);
  ll cnt = (bb - aa + 1) / 2, ans = -1;
  if (cnt > 0) {
    ans = (cnt & 1 ? 1 : 0);
    if (aa != a) ans ^= a;
    if (bb != b) ans ^= b;
  } else if (a != b) ans = a ^ b;
  else ans = a;
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string s1, s2, s3;
   cin >> s1 >> s2 >> s3;
   char tmp1 = s1[0] - 32;
   char tmp2 = s2[0] - 32;
   char tmp3 = s3[0] - 32;
   cout << tmp1 << tmp2 << tmp3 << endl;
   return 0;
}


Measured memory_bytes: 256
N = int(input())
s_list = []
t = []
for i in range(N):
    a, n = input().split()
    s_list.append(a)
    t.append(int(n))
X = input()

times = 0
flag = False
for i, s in enumerate(s_list):
    if flag:
        times += t[i]
    if X == s:
        flag = True

print(times)


Measured memory_bytes: 3060
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  if(strcmp(fmt, "char*")) return "%s";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);
#define PS(...)   _FCN(_P, char*, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RI(N, X);
  vector<i32> m;
  REP(N) { RI(t); m.push_back(t); }
  sort(m.begin(), m.end());
  X -= accumulate(m.begin(), m.end(), 0);
  PI(N + X / m[0]);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <pair <string, pair <int, int>>> a(n);
    forn (i, 0, n) 
        cin >> a[i].fs >> a[i].sc.fs, a[i].sc.sc = i;
    sort(all(a), [&](pair <string, pair <int, int>> a, pair <string, pair <int, int>> b){
        if (a.fs == b.fs)
            return a.sc.fs > b.sc.fs;
        return a.fs < b.fs;
    });
    forn (i, 0, n) 
        cout << a[i].sc.sc + 1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    char s[n];
    scanf("%s", s);
    if (n % 2 == 0){
        for(int i = 0; i < n / 2; i++){
            if (s[i] != s[i + n / 2]) {
                puts("No");
                return 0;
            }
        }
        
    }
    else {
        puts("No");
        return 0;
    }
    puts("Yes");
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static List<int>[] sl;
    static decimal result;
    static int N,K,Q;
    //StringBuilder strresult= new StringBuilder("");//Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read4();
Read2();
      for(int i=0;i<N;i++){pr.Add(-s[i],s[i]);}
      //一番高いのに割引券適用して/2して再整列。10^5回繰り返せばＯＫ。
      int tmp=0;
      for(int i=0;i<K;i++)
      {
        //ソートするんじゃなく、取り出しては突っ込む。
        tmp=pr.Dequeue().Value;
        tmp=tmp/2;
       pr.Add(-tmp,tmp);
      }
      for(int i=0;i<N;i++){result+=pr.Dequeue().Value;}
      
      Console.WriteLine(result.ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
        sl = new List<int>[N];
        for (int i = 0; i < N; i++) {
            sl[i] = new List<int>();
            string[] tmp = Console.ReadLine().Split(' ');
            for (int j = 0; j < K; j++) {
                sl[i].Add(int.Parse(tmp[j]));
            }
        }

    }
}


class PriorityQueue<TKey, TValue>
{
    SortedDictionary<TKey, Queue<TValue>> dict = new SortedDictionary<TKey, Queue<TValue>>();
    int count = 0;

    public int Count
    {
        get
        {
            return count;
        }
    }

    public void Add(TKey key, TValue value)
    {
        if (!dict.ContainsKey(key))
        {
            dict[key] = new Queue<TValue>();
        }

        dict[key].Enqueue(value);
        count++;
    }

    public KeyValuePair<TKey, TValue> Dequeue()
    {
        var queue = dict.First();
        if (queue.Value.Count <= 1)
        {
            dict.Remove(queue.Key);
        }
        count--;
        return new KeyValuePair<TKey, TValue>(queue.Key, queue.Value.Dequeue());
    }
}


Measured memory_bytes: 42868
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll n, a[100001] = {0};
  string ans;
  cin >> n;
  REP(i, n) cin >> a[i];
  ll evenCount = 0, oddCount = 0;
  REP(i, n) {
    if (a[i] % 2 == 1) {
      oddCount++;
    } else {
      evenCount++;
    }
  }
  ll oddPair = oddCount / 2;
  oddCount -= 2 * oddPair;
  evenCount += oddPair;
  if (evenCount > 0 && oddCount > 0) {
    ans = "NO";
  } else if (evenCount > 0 && oddCount == 0) {
    ans = "YES";
  } else if (evenCount == 0 && oddCount > 0) {
    ans = "YES";
  } else if (evenCount == 0 && oddCount == 0) {
    ans = "NO";
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h; 
    for(int i=0; i<n; ++i){
        int height;
        cin >> height;
        h.push_back(height);
    }

    int max_ = 0, curr = 0;
    for(int i=0; i<n-1; ++i){
        if(h[i+1] <= h[i]){
            curr++;
            max_ = max(max_, curr);
        }else{
            curr = 0;
        }
    }
    cout << max_ << endl;
}


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

int main() {
  int n;cin>>n;
  vector<ll> vec(90);
  vec[0]=2;
  vec[1]=1;
  for(int i=2;i<=n;i++){
    vec[i]=vec[i-1]+vec[i-2];
  }
  cout<<vec[n]<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
   cin >> vec.at(i);
  }
  
  int ans = 0;
  
  for(int i = 0; i < N; i++){
   if(vec.at(i) < K - vec.at(i)){
     ans += 2*vec.at(i);
   }else{
     ans += 2*(K-vec.at(i));
   }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    long[] x = new long[m];
    for(int i = 0; i < m; i++) {
      x[i] = sc.nextLong();
    }
    Arrays.sort(x);
    long[] sa = new long[m - 1];
    for(int i = 0; i < (m - 1); i++) {
      sa[i] = x[i + 1] - x[i];
    }
    Arrays.sort(sa);
    long t = 0;
    if(n >= m) {
      System.out.println(0);
    } else {
      for(int i = m - 2; i >= m - n; i--) {
        t += sa[i];
      }
      System.out.println(x[m - 1] - x[0] - t);
    }
  }
}

Measured memory_bytes: 62728
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.H = inpt[0];
        this.W = inpt[1];

        for (int i = 0; i < this.H; i++) {
            string row = Reader.ReadLine();
            map.Add(row.ToList());
        }

        bool IsRemoved = true;

        while(IsRemoved) {
            IsRemoved = false;
            if(this.map.Count > 0) {
                for (int i = this.map.Count - 1; i >= 0; i--)
                {
                    if (map[i].All(a=>a=='.'))
                    {
                        map.RemoveAt(i);
                        IsRemoved = true;
                    }
                }
            }

            for (int i = this.map[0].Count - 1; i >= 0; i--) {
                List<char> tmp = new List<char>();
                for (int j = 0; j < this.map.Count; j++) {
                    tmp.Add(this.map[j][i]);
                }
                if(tmp.All(a=>a=='.')) {
                    for (int j = 0; j < this.map.Count; j++)
                    {
                        this.map[j].RemoveAt(i);
                    }
                    IsRemoved = true;
                }
            }
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < this.map.Count; i++) {
            ans.AppendLine(string.Join("", map[i]));
        }
        Console.Write(ans.ToString());

    }

    private int H;
    private int W;

    private List<List<char>> map = new List<List<char>>();

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



7 6
......
....#.
.#....
..#...
..#...
......
.#..#.



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13524
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
tc=sum(abs(a[i]-a[i+1]) for i in range(n+1))
for i in range(1,n+1):
    print(tc-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]))

Measured memory_bytes: 13920
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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; }

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int K; cin >>K;

  string s="";
  rep(i,0,K) {
    s+="ACL";
  }

  cout <<s <<'\n';
  return 0;
}


Measured memory_bytes: 3592
def count_necessary_num_of_track(baggages, capacity)
  num_of_track = 1
  baggage_index = 0
  loaded_weight = 0
  num_of_baggage = baggages.count
  while baggage_index < num_of_baggage
    loaded_weight += baggages[baggage_index]
    if loaded_weight > capacity
      num_of_track += 1
      loaded_weight = 0
      next
    else
      baggage_index += 1
    end
  end
  return num_of_track
end


def calc_minimum_capacity(baggages, k)
  max_weight = baggages.max
  return (max_weight..10000*100000).bsearch{|candidate_for_capacity|
    count_necessary_num_of_track(baggages, candidate_for_capacity) <= k}
end

n, k = gets.chomp.split.map(&:to_i)
baggages = Array.new
n.times do
  baggages.push(gets.chomp.to_i)
end
puts calc_minimum_capacity(baggages, k)

Measured memory_bytes: 9712
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


signed main() {
	double n, m, d;
	cin >> n >> m >> d;
	//差がdなる順列の個数をc
	double c = d==0 ? n-d : (n-d)*2;

	//cout  << c * (m - 1) / (n*n) << "\n";
	cout << fixed << setprecision(1000000) << c*(m-1)/(n*n) << "\n";

	return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

ll gcd(ll n, ll k)
{
    if (k == 0)
	return n;
    ll mod = n % k;
    return gcd(k, mod);
}

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

    vector<int> a(n);
    rep (i, 0, n)
	cin >> a[i];

    int l_gcd[n + 1];
    int r_gcd[n + 1];
    l_gcd[0] = 0;
    r_gcd[n] = 0;

    rep (i, 1, n) {
	l_gcd[i] = gcd(l_gcd[i - 1], a[i - 1]);
	r_gcd[n - i] = gcd(r_gcd[n - i + 1], a[n - i]);
    }

    int res = 0;
    rep (i, 0, n)
	res = max(res, (int)gcd(l_gcd[i], r_gcd[i + 1]));

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define MAXN 105
using namespace std;



int main(void)
{
    int N;
    cin >> N;
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a, a+N);
    vector<int> vi;
    int cnt,cur;
    for(int i=0; i<N; ){
        cnt = 0;
        cur = a[i];
        while(i < N && a[i] == cur){
            cnt++;
            i++;
        }
        if(cnt%2==1) vi.push_back(1);


    }
    cout << vi.size();
    return 0;
}


Measured memory_bytes: 1276