akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, arr[100000];
int main() {
	cin >> N;
	REP(i, N) {
		cin >> arr[i];
	}
	sort(arr, arr + N);
	lint sum = 0;
	if (N % 2 == 0) {
		lint sum = 0;
		REP(i, N/2 - 1) {
			sum += arr[N - i - 1] * 2;
			sum -= arr[i] * 2;
		}
		sum += arr[N / 2];
		sum -= arr[N / 2 - 1];
		cout << sum << endl;
	}
	else {
		lint sum1 = 0, sum2 = 0;
		sum1 -= arr[N / 2] + arr[N / 2 - 1];
		REP(i, N / 2 - 1) {
			sum1 -= arr[i] * 2;
		}
		REP(i, N / 2) {
			sum1 += arr[N - i - 1] * 2;
		}

		sum2 += arr[N / 2] + arr[N / 2 + 1];
		REP(i, N / 2 - 1) {
			sum2 += arr[N - i - 1] * 2;
		}
		REP(i, N / 2) {
			sum2 -= arr[i] * 2;
		}
		cout << max(sum1, sum2);
	}
}


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


int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    vector<int> C(N);
    for (int i = 0; i < N; i++){
        cin >> h.at(i);
    }

    C.at(0) = 0;
    C.at(1) = abs(h.at(1) - h.at(0));

    for (int i = 2; i < N; i++){
        C.at(i) = min(C.at(i - 2) + abs(h.at(i) - h.at(i - 2)), C.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
    }


        cout << C.at(N - 1) << endl;
}

Measured memory_bytes: 3940
n,m=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

l=make_divisors(m)
ans=0
for i in l:
    if i<=m/n:
        ans=max(ans,i)

print(ans)


Measured memory_bytes: 39152
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;


class Pannel {
public:
  Pannel *root;
  string name;
  vector<Pannel *> v;
  int sx, sy, ex, ey;
  Pannel() {}
  Pannel(Pannel *root, string name) : root(root), name(name) {}
  ~Pannel() {
    dispose();
  }

  void init() {
    dispose();
    v.clear();
  }

  void dispose() {
    for(int i = 0; i < v.size(); ++i) {
      delete v[i];
    }
  }

  Pannel *find(int x, int y) {
    for(int i = 0; i < v.size(); ++i) {
      if(v[i]->sx > x) continue;
      if(v[i]->sy > y) continue;
      if(v[i]->ex < x) continue;
      if(v[i]->ey < y) continue;
      Pannel *tmp = v[i]->find(x, y);
      return tmp == NULL ? v[i] : tmp;
    }
    return NULL;
  }
};

string tag;
int pos;
Pannel P;


string getTag() {
  int s = pos;
  for(; pos < tag.length(); ++pos) {
    if(tag[pos] == '>') {
      return tag.substr(s, pos++ - s);
    }
  }
}

void getXY(Pannel *p) {
  int s = pos;
  for(; pos < tag.length() && tag[pos] != '<'; ++pos);
  string str = tag.substr(s, pos - s);
  sscanf(str.c_str(), "%d,%d,%d,%d", &p->sx, &p->sy, &p->ex, &p->ey);
  //cout << p->sx << " " << p->sy << " " << p->ex << " " << p->ey << endl;
}

void make() {
  Pannel *p = &P;
  pos = 0;
  while(pos < tag.length()) {
    ++pos;
    string str = getTag();
    if(str[0] == '/') {
      p = p->root;
    } else {
      Pannel *tmp = p;
      p = new Pannel(p, str);
      tmp->v.push_back(p);
      getXY(p);
    }
  }
  //cout << "cmp" << endl;
}

void solve(int x, int y) {
  Pannel *tmp = P.find(x, y);
  if(tmp != NULL) {
    cout << tmp->name << " " << tmp->v.size() << endl;
    return;
  }
  cout << "OUT OF MAIN PANEL 1" << endl;
}

main() {
  int n;
  while((cin >> n) && n) {
    P.init();
    cin >> tag;
    make();
    for(int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      solve(x, y);
    }
  }
}

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

using namespace std;
using ll = long long;


int main(){
    string s; cin >> s;
    vector<char> out;
    for(int i=0;i<s.size();i++){
        if(s[i]=='B'){
            if(out.size()==0) continue;
            out.erase(out.end()-1);
        }else{
            out.push_back((char)(s[i]));
        }
    }
    for(int j=0;j<out.size();j++){
        cout << out[j];
    }
    cout << "\n";
    return 0;
}


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

using namespace std;

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

  long long x, k, d;
  cin >> x >> k >> d;
  if (x < 0) x = -x;
  long long mn = min(k, d);
  long long mx = max(k, d);
  if (x/mx >= mn) {
    for (int i = 0; i < mn; ++i) {
      x -= mx;
    }
    cout << x << endl;
  } else {
    long long a = x / d;
    k -= a;
    x %= d;
    cout << (k%2 == 1 ? abs(x-d) : x) << endl;
  }

  return 0;
}

Measured memory_bytes: 3664
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int k, a, b;
    cin >> k >> a >> b;
    cout << (a % k && a / k == b / k ? "NG" : "OK") << "\n";
    return 0;
}

Measured memory_bytes: 3624
import math

a=int(input())

t=0

for i in range(1,a+1):
  for j in range(i,a+1):
    for k in range(j,a+1):
      
      #print(i,j,k)

      if i==j and j==k:
        t+=math.gcd(math.gcd(i,j),k)
      elif i!=j and j!=k and i!=k:
        t+=(math.gcd(math.gcd(i,j),k)*6)
      else:
        t+=(math.gcd(math.gcd(i,j),k)*3)

print(t)

Measured memory_bytes: 68000
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=200010;
const int inf=0x3f3f3f3f;
template<typename T>inline T chkmax(T A,T B){return A>B?A:B;}
template<typename T>inline T chkmin(T A,T B){return A<B?A:B;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,len,s[N];
int nxt[N][30],step[N][30],to[N][30],p[N];
char str[N];
inline bool find()
{
	int p=1;
	For(i,0,len)
	{
		p=nxt[p][s[i]];
		if(!p)return 0;
	}
	return 1;
}
inline void printans(int x,int y)
{
	For(i,1,26)
	{
		if(s[nxt[x][i]]==y)
		{
			printf("%c",'a'+i-1);
			printans(nxt[x][i],y-1);
			break;
		}
	}
}
int main()
{
	//file();
	scanf("%s",str+1);
	n=strlen(str+1);
	For(i,1,26)nxt[n+1][i]=n+1;
	s[n+1]=0;
	rFor(i,n,0)
	{
		For(j,1,26)nxt[i][j]=nxt[i+1][j];
		s[i]=inf;
		nxt[i][str[i+1]-'a'+1]=i+1;
		For(j,1,26)
		{
			step[i][j]=s[nxt[i][j]]+1;
			if(step[i][j]<s[i])
			{
				s[i]=step[i][j];
				p[i]=j;
			}
		}
	}
	printans(0,s[0]-1);
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int cnt[1001];

int main() {
  int M;
  scanf("%d", &M);
  FOR(i,1,M+1) {
    int N = i;
    FOR(j,2,1001) {
      while (N % j == 0) {
        ++cnt[j];
        N /= j;
      }
    }
  }
  LL result = 1;
  REP(j,1001) result = (result * (cnt[j]+1)) % 1000000007;
  printf("%d\n", (int)result);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    const int MAX_N = 400;
    const int64_t INF = 1e16;
    int N;
    cin >> N;
    // O(N^2)
    // (n, i) => cost
    // 左からi番目のスライムからn+1個が合体するときのコストとサイズ
    vector<int64_t> cost[MAX_N + 1];
    vector<int64_t> size[MAX_N + 1];
    for(int i = 1; i <= N; i++) {
        cost[i] = vector<int64_t>(N + 1 - i);
        size[i] = vector<int64_t>(N + 1 - i);
        for(int j = 0; j <= N - i; j++) {
            cost[i][j] = INF;
            size[i][j] = 0;
        }
    }
    for(int i = 0; i < N; i++) {
        cin >> size[1][i];
        cost[1][i] = 0;
    }
    for(int n = 2; n <= N; n++) {
        for(int i = 0; i <= N - n; i++) {
            for(int m = 1; m < n; m++) {
                size[n][i] = size[1][i] + size[n - 1][i + 1];
                cost[n][i] = min(cost[n][i], cost[m][i] + cost[n - m][i + m] + size[n][i]);
            }
        }
    }
    cout << cost[N][0] << endl;
    return 0;
}

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

int main(){

    int ans = 0;
    int a, b, c; cin >> a >> b >> c;
    int x, y; cin >> x >> y;

    //全部AB
    ans = 2*c*max(x, y);
    
    int temp = 0;

    if(x > y){
        int A = x;
        int B = y;
        temp += 2 * c * B;
        A -= B;
        temp += A * a;
    }else{
        temp = 0;
        int A = x;
        int B = y;
        temp += 2 * c * A;
        B -= A;
        temp += B * b;
    }

    ans = min(ans, temp);

    temp = 0;

    temp = a * x + b * y;
    ans = min(ans, temp);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

int n;

int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	cin >> n;
	int d;
	enum(i, 1, n)
	{
		cin >> d;
		if(d & 1)
			return cout << "first", 0;
	}
	cout << "second";
	return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




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

ll N, K, C;
string S;
vector<ll> sub(string S){

    ll last = -3e5;
    vector<ll> vec(N+1, 0);
    ll cum = 0;
    REP(i, N){
        if(i - last > C && S[i] == 'o') cum++, last = i;
        vec[i + 1] = cum;
    }

    return vec;
}

int main(){
    cin >> N >> K >> C;
    cin >> S;
    
    string T = S;
    reverse(ALL(T));

    const auto& left = sub(S);
    const auto& right = sub(T);

    bool flag = false;
    REP(i, N){
        if (S[i] == 'x') continue;
        if (left[i] + right[N-i-1] < K) cout << i + 1 << endl, flag = true;
    }

    if (!flag) cout << endl;

    return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

char s[110];

int main(){
  scanf("%s",s);
  printf("%c%d%c\n",s[0],strlen(s)-2,s[strlen(s)-1]);
}



Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let line = read_as_vec::<u64>();

    if line.iter().sum::<u64>() >= 22{
        println!("bust");
    }else{
        println!("win");
    }
}


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

int main(){
    int N;
    cin >> N;
    int nums[N];
    cin >> nums[0];
    int max_num_number = 0;
    int min_num_number = 0;
    for(int i = 1; i < N; i++){
        cin >> nums[i];
        if(nums[max_num_number] < nums[i]){
            max_num_number = i;
        }else if(nums[min_num_number] > nums[i]){
            min_num_number = i;
        }
    }
    if(nums[max_num_number] > -nums[min_num_number]){
        int count = 0;
        for(int i = 0; i < N; i++){
            if(nums[i] < 0){
                count++;
            }
        }
        cout << count + N - 1 << endl;
        for(int i = 0; i < N; i++){
            if(nums[i] < 0){
                cout << max_num_number + 1 << " " << i + 1 << endl;
                nums[i] += nums[max_num_number];
            }
        }
        for(int i = 1; i < N; i++){
            cout << i << " " << i + 1 << endl;
        }
    }else{
        int count = 0;
        for(int i = 0; i < N; i++){
            if(nums[i] > 0){
                count++;
            }
        }
        cout << count + N - 1 << endl;
        for(int i = 0; i < N; i++){
            if(nums[i] > 0){
                cout << min_num_number + 1 << " " << i + 1 << endl;
                nums[i] += nums[min_num_number];
            }
        }
        for(int i = N; i > 1; i--){
            cout << i << " " << i - 1 << endl;
        }
    }
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int col = 1;
  for(int i=1;i<N;i++){
    if(S[i]!=S[i-1]){
      col ++;
    }
  }
  cout << col << endl;
  return 0;
}

Measured memory_bytes: 512
<?php
$jud = 0;
$K = trim(fgets(STDIN));  // 入力
list($A, $B) = explode(" ", trim(fgets(STDIN)));  // スペース区切りで2つ入力
for ($i = $A; $i <= $B; $i++) {
    if ($i % $K == 0) {
        echo 'OK';
        $jud = 1;
        break;
    }
}
if ($jud == 0) {
    echo 'NG';
}


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

using namespace std;

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

  string ans;
  for (char c = 'a'; c <= 'z'; c++) {
    int num = 100;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (auto j : ss[i]) {
        if (j == c) cnt++;
      }
      num = min(num, cnt);
    }
    ans += string(num, c);
  }
  cout << ans << '\n';
  return 0;
}

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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int a[] = fs.nextIntArray(3);
		Arrays.sort(a);
		int d = a[2] - a[1];
		int ans = 0;
		if((a[2] - (a[0] + d))%2==0) {
			ans += d + (a[2] - (a[0] + d))/2;
		}
		else {
			ans += d + (a[2] - (a[0] + d)+1)/2 + 1;			
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21204
import java.util.Scanner;

class Main {
  private static void solve(int n, int[] a) {
    Integer first = null;
    Integer second = null;
    int count = 0;
    for (int val : a) {
      if (first == null || first < val) {
        second = first;
        first = val;
        count = 1;
      } else if (first == val) {
        count += 1;
      } else if (second == null || second < val) {
        second = val;
      }
    }
    int[] result = new int[n];
    for (int i = 0; i < n; i++) {
      if (a[i] != first) {
        result[i] = first;
      } else if (count > 1) {
        result[i] = first;
      } else {
        result[i] = second;
      }
    }
    for (int val : result) {
      System.out.println(val);
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.nextLine());
    }
    sc.close();
    solve(n, a);
  }
}

Measured memory_bytes: 163216
var
	N,K,i,p,q,x,tmp,get:Longint;
	ans,now,make:double;
begin
	read(N,K);
	if N>=K then begin
		ans:=(N-K+1)/N;
		q:=K-1;
	end
	else q:=N;
	make:=1;
	get:=1;
	for i:=1 to 2 do begin
		if q=0 then break;
		get:=get*2;
		make:=make*0.5;
		p:=K div get;
		if p<q then begin;
			ans:=ans+(q-p)/N*make;
			q:=p;
		end;
	end;
	for i:=q downto 1 do begin
		tmp:=(K+i-1)div i;
		x:=1;
		now:=1/N;
		while tmp>x do begin
			now:=now*0.5;
			x:=x*2;
		end;
		ans:=ans+now;
	end;
	writeln(ans:0:9);
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

typedef long long ll;

int N,M,L;
int K[2001];
int S[100001];
pair<int,int> Onpu[2001];

ll dp[2001][2001];
ll sums[100001];

ll dfs(int a,int b){
    if(a==N-1||b==N-1){
        if(a<b)swap(a,b);
        return (sums[K[a]+1]-sums[K[b]])/L;
    }
    else if(dp[a][b]!=-1)return dp[a][b];
    int nxtIdx=max(a,b)+1;
    ll tmp=(sums[K[nxtIdx]+1]-sums[K[a]])/L;
    ll res=dfs(nxtIdx,b)+tmp;
    res=min(res,dfs(a,nxtIdx)+(sums[K[nxtIdx]+1]-sums[K[b]])/L);
    return dp[a][b]=res;
}
int main(){
    cin>>N>>M>>L;
    for(int i=0;i<N;i++){
        cin>>K[i];
        K[i]--;
    }
    for(int i=0;i<M;i++){
        cin>>S[i];
        sums[i+1]=sums[i]+S[i];
    }
    for(int i=0;i<N;i++){
        Onpu[i].first=S[K[i]];
        Onpu[i].second=K[i];
    }
    //sort(Onpu,Onpu+N);
    //for(int i=0;i<N;i++)K[i]=Onpu[i].second;
    sort(K,K+N);
    memset(dp,-1,sizeof(dp));
    ll res=dfs(0,0);
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 32000
#include<iostream>
using namespace std;
#define INF 10000;
int main(){
	int n,m,a[1001],b[1001],atari=0,min=10000,ans=0,memo=0;
	bool bo=false;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		if(a[i]>=n){
			a[i]=INF;
			b[i]=INF;
			atari++;
			if(atari==m-1){
				bo=true;
			}
		}
	}
	while(1){
		for(int i=0;i<m;i++){
			if(bo){
				break;
			}
			if(min>n-a[i]&& a[i]<n){
				min=n-a[i];
				memo=i;
			}
		}
		if(bo){
			break;
		}
		ans+=n-a[memo];
		atari++;
		if(atari==m-1){
			break;
		}
		min=INF;
		b[memo]=INF;
		a[memo]=INF;
		memo=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

int main(){
	int n;

	cin >> n;
	vector<int> S(n);
	r(i, n) cin >> S[i];
	S.erase(unique(S.begin(), S.end()), S.end());

	int q, t, cnt = 0, j, l, r, size = s(S);
	cin >> q;
	r(i, q){
		cin >> t;
		l = 0, r = size;
		while(true){
			j = (r+l)/2;
			if(t == S[j]){
				cnt++;
				break;
			}else if(t < S[j]){
				r = j;
			}else{
				l = j;
			}
			if(r-l < 3){
				for(j = l; j <= r; j++){
					if(t == S[j]){
						cnt++;
						break;
					}
				}
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3112
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 12/9/2018, 10:28:17 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll N, K, X, Y;

int main()
{
  cin >> N >> K >> X >> Y;
  ll ans = 0;
  for (auto i = 0; i < N; i++)
  {
    if (i < K)
    {
      ans += X;
    }
    else
    {
      ans += Y;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s=input()
lis=[]
for i in range(len(s)):
    if s[i]=='0': lis.append('0')
    elif s[i]=='1': lis.append('1')
    elif s[i]=='B' and len(lis)==0: continue
    else: lis=lis[:-1]
print(''.join(lis))

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
//#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;


signed main() {

	fastio();
	//#define LOCAL_DEFINE	
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
		cout<<"x";
	return 0;
}





Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static int n;
	static int[] arr;
	static int[] memo;
	static boolean f = false;
	static boolean t = false;
	static int OO = (int) 1e9 + 7;
	static int k;

	static int dp(int i) {

		if (i == n - 1)
			return 0;
		if (i >= n)
			return OO;
		if (memo[i] != -1)
			return memo[i];

		int a = OO;
		for (int j = 1; j <= k && i + j < n; j++) {

			a = Math.min(Math.abs(arr[i] - arr[i + j]) + dp(i + j), a);

		}
		return memo[i] = a;

	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);

		StringTokenizer st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		k = Integer.parseInt(st.nextToken());

		st = new StringTokenizer(br.readLine());
		arr = new int[n + 1];
		for (int i = 0; i < n; i++)
			arr[i] = Integer.parseInt(st.nextToken());
		memo = new int[n + 1];
		Arrays.fill(memo, -1);
		pw.print(dp(0));
		pw.close();
	}
}


Measured memory_bytes: 48264
N = int(input())

ans = {}
m = 1
for _ in range(N):
    w = input()
    c = ans.get(w)
    # print(c)
    # print(type(c))
    if c == None:
        ans[w] = 1
    else:
        ans[w] = c + 1
        if c + 1 > m:
            m = c + 1
# print(ans)

tmp = []
for a in ans:
    if ans[a] == m:
        tmp.append(a)

tmp.sort()
for t in tmp:
    print(t)


Measured memory_bytes: 32096
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
a = [input() for i in range(h)]
ans = []
memo_x = []
memo_y = []
for i in range(h):
    cnt = 0
    for j in range(w):
        if a[i][j] == '.':
            cnt += 1
    if cnt == w:
        memo_x.append(i)
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == '.':
            cnt += 1
    if cnt == h:
        memo_y.append(i)
for i in range(h):
    if i not in memo_x:
        b = ''
        for j in range(w):
            if j not in memo_y:
                b += a[i][j]
        ans.append(b)
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
// clang-format off
#define FOR(i, n) for (int i=0; i<(int)n; ++i)
#define RFOR(i, n) for (int i=n-1; i>=0; --i)
#define OUTV(x) FOR(j,x.size()) cerr<<x[j]<<(x.size()-j-1?' ':'\n');
#define OUTM(x) FOR(i,x.size()) {OUTV(x[i])}
#define BLE cerr<<"BLE"<<endl;
#define DEBUG(x) cerr<<"DEBUG: "<<#x<<" = "<<x<<endl;
#define PB push_back
#define MP make_pair
// clang-format on
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  //  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  string s;
  cin >> s;
  int month = 10 * (int)(s[5] - '0') + (int)(s[6] - '0');
  int day = 10 * (int)(s[8] - '0') + (int)(s[9] - '0');
  if (month <= 3 or (month == 4 and day <= 30)) {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD\n";
  }

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def Y():
    print("Yes")


def N():
    print("No")


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


d, t, s = MI()
if d / s > t:
    N()
else:
    Y()


Measured memory_bytes: 9168
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    string S;
    cin >> S;
    int N = S.length();
    int c[100000] = {};
    for (int i = 0; i < N; i++) {
        c[i] = 1;
    }
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R' && S[i + 1] == 'R') {
            c[i + 2] += c[i];
            c[i] = 0;
        }
    }
    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 'L' && S[i - 1] == 'L') {
            c[i - 2] += c[i];
            c[i] = 0;
        }
    }
    for (int i = 0; i < N; i++) {
        printf("%d ", c[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 = long long;

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

ll N, M;
ll S[2010], T[2010];
mint dp[2010][2010];

int main()
{
  scanf( "%lld%lld", &N, &M );

  rep( i, N )
    scanf( "%lld", S+i );
  rep( i, M )
    scanf( "%lld", T+i );

  dp[1][1] = S[0] == T[0] ? 1 : 0;

  repi( i, 1, N+1 ) repi( j, 1, M+1 )
  {
    if( i == 1 && j == 1 )
      continue;
    
    if( S[i-1] == T[j-1] )
      dp[i][j] += dp[i-1][j-1]+1;

    dp[i][j] += dp[i][j-1];
    dp[i][j] += dp[i-1][j];
    dp[i][j] -= dp[i-1][j-1];
  }

  //rep( i, N+1 ) rep( j, M+1 )
    //printf( "dp[%lld][%lld] = %lld\n", i, j, dp[i][j].x );

  printf( "%lld\n", dp[N][M].x+1 );

  return 0;
}

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

int min( int a, int b )
{
    if( a < b )
        return a;
    else
        return b;
}

int main()
{
    int n, a, b , c;

    cin >> n;

    if( n == 2 )
    {
        cin >> a >> b;
        for( int i = 1; i <= min( a, b ); i++ )
        {
            if( a % i == 0 && b % i == 0 )
                cout << i << endl;
        }
    }
    else
    {
        cin >> a >> b >> c;
        for( int i = 1; i <= min( min( a, b ), min( b, c ) ); i++ )
        {
            if( a % i == 0 && b % i == 0 && c % i == 0 )
                cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        int H = sc.nextInt(), M = sc.nextInt();
        
        double theta = (double)2 * Math.PI * ((double)M / 60.0 - ((60.0 * (double)H + M) / 720.0));
        
        double sqr = Math.sqrt((double)(A*A + B * B) - 2 * (double)(A * B) * Math.cos(theta));
        
        System.out.println(sqr);
    }
}

Measured memory_bytes: 35924
#include<bits/stdc++.h>
#define rint register int
using namespace std;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}

namespace {
  const int mo = 1e9 + 7;
  inline int add(int x, int y) {
    if((x += y) >= mo) x -= mo;
    return x;
  }
  inline int sub(int x, int y) {
    if((x -= y) < 0) x += mo;
    return x;
  }
  inline int mul(int x, int y) {
    return 1LL * x * y % mo;
  }
}
#define VI vector<int>
const int N = 6666;
VI g[N];
int sz[N], f[N];
int n;

inline VI dfs(int u, int fat) {
  VI b = {0, 1};
  sz[u] = 1;
  for (int v : g[u]) if (v != fat) {
      VI a = dfs(v, u);
      VI ans(sz[u] + sz[v] + 1);
      for (int i = 0; i <= sz[v]; i ++)
        for (int j = 0; j <= sz[u]; j ++)
          ans[i + j] = sub(ans[i + j], mul(a[i], b[j]));
      sz[u] += sz[v];
      b = ans;
    }
  if (sz[u] % 2 == 0) {
    for (int i = 2; i <= sz[u]; i += 2)
      b[0] = sub(b[0], mul(f[i], b[i]));
  }
  // cout << u << "\n";
  // for (int i : b) cout << i << " "; puts("");
  return b;
}

main(void) {
  read(n);
  for (int i = 2; i <= n; i ++) {
    int x, y; read(x); read(y);
    g[x].push_back(y); g[y].push_back(x);
  }
  f[2] = 1;
  for (int i = 4; i <= n; i += 2)
    f[i] = mul(i - 1, f[i - 2]);

  VI ans = dfs(1, 0);

  cout << ans[0] << "\n";
}


Measured memory_bytes: 1152
#UnionFind
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x, y):
    return find(x) == find(y)

def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return

    else:
        if rank[x] < rank[y]:
            par[x] = y

        else:
            par[y] = x

            if rank[x] == rank[y]:
                rank[x] += 1

#main
n, m = map(int,input().split())
p = list(map(int,input().split()))
par = [i for i in range(n)]
rank = [0] * n

for i in range(m):
    x, y = map(int,input().split())
    unite(x - 1 , y - 1)
ans = 0
for i in range(n):
    if same(i, p[i] - 1):
        ans += 1

print(ans)


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

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define eb          emplace_back
#define	endl		'\n' 
#define max(a,b)	((a)>(b)?(a):(b))
#define min(a,b)	((a)<(b)?(a):(b))
#define vi          vector<int>
#define vii         vector<pair<int, int> >
#define mp          make_pair
#define mem1(a)     memset((a),-1,sizeof(a))
#define all(a)      (a).begin(),(a).end()
#define vs          vector<string>
#define F           first
#define S           second
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    (a)*((b)/gcd((a),(b)))
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mi          map<int,int>
#define sz(x)       (ll)(x).size()
#define rep(i,a,b)  for(int i=(a);i<(b);i++)
#define pii         pair<int,int>

int solve()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	rep(i,0,n)
	cin>>arr[i];
	int ans[n];
	ans[0]=0;
	ans[1]=abs(arr[1]-arr[0]);
	rep(i,2,n)
	{
		ans[i]=ans[i-1]+abs(arr[i-1]-arr[i]);
		for(int j=i-2;j>=0&&j>=i-k;j--)
		ans[i]=min(ans[i],ans[j]+abs(arr[j]-arr[i]));
	}
	cout<<ans[n-1];
    return 0;
}
signed main()
{
    FAST
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif 
    int t=1;
    //cin>>t;
    while(t)
    {
        solve();
        t--;
    }
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 4588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)



class SEGMENTS{
private:
    
    struct seg{
        int l,r;
        bool operator < (seg obj)const {
            if(r!=obj.r) return r<obj.r;
            else return l<obj.l;
        }
    };
    
    set<seg> dat;
    
    bool isCross(int l1,int r1,int l2,int r2){ return ( (l1<=l2 && l2<r1) || (l2<=l1 && l1<r2)); }
    bool isInclude(int li, int ri, int L, int R){ return (L<=li && ri<=R); }
    
public:
    
    void erase(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end())break;
            
            int li = it->l;
            int ri = it->r;
            if( !isCross(li,ri,l,r) )break;
            
            if( isInclude(li,ri,l,r) ) dat.erase(it);
            else{
                int tl = li, tr = ri;
                if( isInclude(l,r,li,ri) ){
                    dat.erase(it);
                    if(li!=l) dat.insert(seg{li,l});
                    if(r!=ri) dat.insert(seg{r,ri});
                }else{
                    if(li<=l&&l<ri) tr = l;
                    if(l<=li&&li<r) tl = r;
                    dat.erase(it);
                    if(tl!=tr) dat.insert(seg{tl,tr});
                }
            }
        }
    }
    
    void insert(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end())break;
            
            int li = it->l;
            int ri = it->r;
            if( !isCross(li,ri,l,r) )break;
            
            if( isInclude(li,ri,l,r) ) dat.erase(it);
            else{
                if(li<l) l = li;
                if(r<ri) r = ri;
            }
        }
        
        auto it = dat.lower_bound(seg{(int)-INF,l});
        if( it!=dat.end() && it->r == l ){
            l = it->l;
            dat.erase(it);
        }
        it = dat.upper_bound(seg{(int)INF,r});
        if( it!=dat.end() && it->l == r ){
            r = it->r;
            dat.erase(it);
        }
        
        if(l!=r)dat.insert(seg{l,r});
    }
    
    int size(){ return dat.size(); }
    
    void output(){ for(auto e:dat)cout<<e.l<<" "<<e.r<<endl;cout<<endl; }
};


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    SEGMENTS st;
    
    for(int i=0;i<n;){
        if(s[i]=='0')i++;
        else{
            int l=i;
            while(i<n && s[i]=='1') i++;
            st.insert(l,i);
        }
    }
    
    int q;
    cin>>q;
    while(q--){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
        
        if(b==0)    st.erase(l,r);
        else        st.insert(l,r);
        
        cout<<st.size()<<endl;
    }
}

Measured memory_bytes: 4272
#include <iostream>
#include <string>


   // int mokemoke,hogehoge;
   // std::cin >> mokemoke >> hogehoge;
   // std::cout << mokemoke << hogehoge << std::endl;

int main(){

    int M;
    std::cin >> M;
    std::cout << 48 - M << std::endl;



    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        input.Sort((a, b) => b - a);
        if (input[0] == input[1] + input[2])
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

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

int main(int argc, const char * argv[]) {
    int N, K;
    vector<int> h;
    
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    sort(h.begin(), h.end());
    
    vector<int> n;
    for (int i = 0; i < N - K + 1; i++) {
        n.push_back(h[i + K - 1] - h[i]);
    }
    
    int min = 1000000000;
    for (int i = 0; i < n.size(); i++) {
        if (min > n[i]) {
            min = n[i];
        }
    }
    
    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 998244353;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll n;
  cin >> n;
  n = n % 10;
  if (n == 3) cout << "bon" <<endl;
  else if (n==0||n==1||n==6||n==8) cout << "pon" <<endl;
  else cout << "hon" <<endl;
}

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
static const double pi = 3.141592653589793;
using namespace std;
int main() {
    long double A,B,H,M;
    long double mi=60;
    long double ho=12;
    cin>>A>>B>>H>>M;
    //cout<<M/60*360<<" "<<H/12*360<<endl;
    long double nDegree=abs(M/mi*360-(H/ho*360+M/mi*30));
    //if(nDegree>180)nDegree=360-nDegree;
    //cout<<nDegree<<endl;
    long double radian=nDegree*pi/180.0;
    //cout<<radian<<endl;
    long double distance=A*A+B*B-2*A*B*cos(radian);
    distance=sqrt(distance);
    cout<< fixed << setprecision(15)<<distance<<endl;
    return 0;
}

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

int main(){
  int n, a, sum=99999;
  cin >> n;
  
  for(int i=0; i < n; i++){
    int j = 0;
    cin >> a;
    while((a % 2) == 0){
      a /= 2;
      j++;
    }
    if(j < sum) sum = j;
  }
  cout << sum << endl;
}
      


Measured memory_bytes: 3452
#!/usr/bin/env python3
#三井住友信託銀行プログラミングコンテスト2019 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
for i in range(500001):
    if int(i*1.08) == n:
        print(i)
        break
else:
    print(':(')

Measured memory_bytes: 38512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
#include <bitset>
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll A, B ;
    cin >> A >> B;
    cout << ((B%A == 0)?(A+B):(B-A)) << endl;


    //cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main()
{
    int N;
    cin >> N ;
    int A, B;
    cin >> A >> B;
    vector<int> P(N);
    REP(i,N){
        cin >> P[i];
    }

    int ans[3]={};
    REP(i,N){
        if(P[i]<=A) ans[0]++;
        if(A+1<=P[i] and P[i]<=B) ans[1]++;
        if(P[i]>=B+1) ans[2]++;
    }

    cout << min(min(ans[0],ans[1]), ans[2]) << endl;

    return 0;
}

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

int main() {
    long long N; cin >> N;
    long long P, Q, m = N - 1;
    for (int i = 1; i <= sqrt(N); i++) {
        if (N % i == 0) {
            P = i;
            Q = N / i;
            m = min(m, P + Q - 2);
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200010];
map<int,bool>mp;
int main()
{
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(mp.count(a[i]))
		{
			cout<<"NO";
			return 0;
		}
		mp[a[i]]=true;
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 10368
from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))
A_count = Counter(A)
ans = 0
for i, j in A_count.items():
    ans += j * (j - 1) // 2
for k in range(1, N+1):
    n = A_count[A[k-1]]
    ans_ = ans - (n - 1)
    print(ans_)


Measured memory_bytes: 27028