akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define siz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define endl '\n'
typedef pair<int,int> pii;
typedef unsigned long long ull;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e15;
const int Mod=1e9+9;
const int base=228;
typedef long long ll;
typedef long double ld;
int maxt[100005<<2],mint[100005<<2];
int a[100005];
int k;
void up(int rt) {
	maxt[rt]=max(maxt[rt<<1],maxt[rt<<1|1]);
	mint[rt]=min(mint[rt<<1],mint[rt<<1|1]);
}
void Build(int l,int r,int rt) {
	int mid=l+r>>1;
	maxt[rt]=0;mint[rt]=100000007;
	if(l==r) {
		maxt[rt]=a[l];
		mint[rt]=a[l];
		return ;
	}
	Build(lson);Build(rson);
	up(rt);
}
int querya(int L,int R,int l,int r,int rt) {
	if(L<=l && r<=R) return maxt[rt];
	int mid=l+r>>1;
	if(R<=mid) return querya(L,R,lson);
	else if(L>mid) return querya(L,R,rson);
	else return max(querya(L,mid,lson),querya(mid+1,R,rson));
}
int queryi(int L,int R,int l,int r,int rt) {
	if(L<=l && r<=R) return mint[rt];
	int mid=l+r>>1;
	if(R<=mid) return queryi(L,R,lson);
	else if(L>mid) return queryi(L,R,rson);
	else return min(queryi(L,mid,lson),queryi(mid+1,R,rson));
}
struct Solver {
	int n;
	void solve(){
		iossy;
		cin>>n>>k;
		For(i,1,n) cin>>a[i];
		sort(a+1,a+1+n);
		Build(1,n,1);
		int ans=1000000007;
		For(i,1,n-k+1) {
			int l=i,r=l+k-1;
			if(r>n) continue;
			int minn=queryi(l,r,1,n,1);
			int maxx=querya(l,r,1,n,1);
			ans=min(ans,maxx-minn);
		}
		cout<<ans<<endl;
	}
};
int main(){
//	p[0]=1;
//	For(i,1,500005) p[i]=p[i-1]*base;
//	while(scanf("%d",&n)!=EOF) solve();
	int t=1;
	Solver solver;
	solver.solve();
	return 0;
}


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

int main(){
	int n; cin>>n;
	int a[n+1]={};
	int b[n]={};
	int c[n]={};
	a[n]=-1;
	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	rep(i,n-1) cin>>c[i];
	int ans=0;
	//cout<<ans<<endl;
	rep(i,n){
		ans+=b[a[i]-1];
		//cout<<ans<<endl;
		if(a[i]+1==a[i+1]){
			ans+=c[a[i]-1];
		}
			//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}
		

Measured memory_bytes: 3584
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a < b && a < c){
		if(b < c){
			printf("%d %d %d\n",a,b,c);
		}
		else{
			printf("%d %d %d\n",a,c,b);
		}
	}
	else if(b < c && b < a){
		if(c < a){
			printf("%d %d %d\n",b,c,a);
		}
		else{
			printf("%d %d %d\n",b,a,c);
		}
	}
	else{
		if(a < b){
			printf("%d %d %d\n",c,a,b);
		}
		else{
			
		printf("%d %d %d\n",c,b,a);
		}
	}
	return 0 ;
}

Measured memory_bytes: 2696
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut abl = vec![];
    let mut abr = vec![];
    let mut stack: Vec<char> = vec![];
    for _ in 0..n {
        let p = it.next().unwrap();
        for pi in p.chars() {
            if stack.len() > 0 && stack[stack.len() - 1] == '(' && pi == ')' {
                stack.pop();
            } else {
                stack.push(pi);
            }
        }
        let a = stack.iter().filter(|c| **c == ')').count() as i64;
        let b = stack.iter().filter(|c| **c == '(').count() as i64;
        if a <= b {
            abl.push((a, b));
        } else {
            abr.push((a, b))
        }
        stack.clear();
    }
    abl.sort();
    abr.sort_by_key(|x| -x.1);
    let mut cur = 0;
    for (a, b) in &abl {
        cur += a;
        if cur > 0 {
            println!("No");
            return;
        }
        cur -= b;
    }
    for (a, b) in &abr {
        cur += a;
        if cur > 0 {
            println!("No");
            return;
        }
        cur -= b;
    }
    if cur == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 19796
import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int X = sc.nextInt();
      int Y = sc.nextInt();

      int cost = Integer.MAX_VALUE;
      // ABセット（C*2）の枚数に基づいてA,Bの枚数を求める。
      for (int i = 0; i <= 100000; i++) {
        int tmp = i * (2 * C) + Math.max(0, X - i) * A + Math.max(0, Y - i) * B;
        cost = Math.min(tmp, cost);
      }

      System.out.println(cost);
    }
  }
}


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

int n, s, a[205];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n * 2; i++) scanf ("%d", &a[i]);
	sort(a, a + n * 2);
	for (i = 0; i < n * 2; i += 2)  s += a[i];
	cout <<s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "local_debug.h"
using namespace std;
#define endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e2 + 5;
ll n, a[MAXN], b[MAXN], c[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		for (ll i = 1; i <= n; ++i) cin >> a[i];
		for (ll i = 1; i <= n; ++i) cin >> b[i];
		for (ll i = 2; i <= n; ++i) cin >> c[i];
		ll ans = 0, last = -1;
		for (ll i = 1; i <= n; ++i)
		{
			ans += b[a[i]];
			if (a[i] == last + 1)
				ans += c[a[i]];
			last = a[i];
		}
		cout << ans << endl;
	}
}
/*
3
3 1 2
2 5 4
3 6

4
2 3 4 1
13 5 8 24
45 9 15

2
1 2
50 50
50
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
const int MOD = 1e9+7, N = 1e7 + 10;

int main(){
    int a,b;
    sd(a);
    sd(b);
    int s = a+b;
    int m = a-b;
    int M = a*b;
    int ans;
    if(M >= s && M>=m)
        ans = M;
    else
    {
        if(s>=m)
            ans = s;
        else
            ans = m;
    }
    pd(ans);
    return 0;    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    string n;
    cin >> n;
    int ans=0;
    char st = 'g';
    rep(i, n.length()){
        if(n[i]!=st){
            st=n[i];
            ans++;
        }
    }
    pri(ans-1);
    
    return 0;
}



Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  vector<ll> a(n + 2), diffs(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  ll sum = 0;
  for (int i = 1; i <= n + 1; i++) {
    diffs[i-1] = abs(a[i] - a[i-1]);
    sum += diffs[i-1];
  }

  rep(i, n) outl(sum - diffs[i] - diffs[i+1] + abs(a[i] - a[i+2]));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
  int N;
  cin >> N;
  
  vector<double> val(N);

  
  for(int i=0; i<N; i++){
	cin >> val.at(i);
  }  
  sort(val.begin(),val.end());
  
  for(int i=0; i<N-1; i++){
	val.at(i+1) = (val.at(i)+val.at(i+1))/2;
  }
  printf("%.6f",val.at(N-1));
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if(a > b)
    {
        d = a;
        a = b;
        b = d;
    }
    if(b > c)
    {
        d = b;
        b = c;
        c = d;
    }
    if(a > b)
    {
        d = a;
        a = b;
        b = d;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}

Measured memory_bytes: 596
//-----Rashish-----//
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define endl '\n'
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());




int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  int t;
  t = 1;
  //cin>>t;
  while (t--) {
    string s;
    cin >> s;
    ll s1 = 0;
    ll n = s.size();
    for (ll i = 0; i < n; ++i)
    {
      s1 += (s[i] - '0');
      /* code */
    }
    // cout << s1 << endl;
    if (s1 % 9 == 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }



  }

  return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




ll dp[303][303];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, k;
    cin >> n >> k;
    if (n == k) { cout << 0 << endl; return 0; }
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    
    const ll INF = 1e18;
    rep(i, 303) rep(j, 303) dp[i][j] = INF;
    // x番目は削除しない
    // 初期値は項数1以上
    rep(x, n) {
        dp[x][1] = h[x];
    }
    
    rep3(y, 2, n + 1) rep(x, n) {
        rep(i, x) {
            if (dp[i][y - 1] == INF) continue;
            chmin(dp[x][y], dp[i][y - 1] + max(0, h[x] - h[i]));
        }
    }
    ll ans = INF;
    rep(i, n) chmin(ans, dp[i][n - k]);
    cout << ans << endl;
}




Measured memory_bytes: 1024
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
int main() {
    scanf("%d",&n);
    if(n == 1) {
        putchar(49);
    } else {
        const int sqrtN = sqrt(n);
        ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int a = n / i;
            ans += ((long long)i * (i + a) * (a + 1 - i));
        }
        printf("%lld",ans);
    }
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
int a[21];
int b[21];
int c[21];
int n, ans;

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++)
	{
		cin >> b[i];
	}
	for(int i = 1; i <= n-1; i++)
	{
		cin >> c[i];
	}
	
	for(int i = 1; i <= n; i++)
	{
		ans += b[a[i]];
		if(a[i-1]==a[i]-1)
		{
			ans += c[a[i-1]];
		}
	}
	
	cout << ans;
	
	return 0;
}

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

int main() {
  int A, B, C, X;
  int count = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		for j,vol in enumerate(val):
			if tmp == vol:
				ans.append(random.randint(1, 26))
				break

	for i in range(D):
		print(ans[i])

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 78364
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//


int main() {
	int H, W, K;
	cin >> H >> W >> K;
	K--;
	
	if (W == 1) {
		cout << 1 << endl;
		return 0;
	}
	
	ll dp[101][8] = {};
	dp[0][0] = 1;
	
	REP(i, H) {
		REP(bit, 1<<(W - 1)) {
			bool ok = true;
			FOR(j, 1, W - 1) if ((bit >> j-1 & 1) && (bit >> j & 1)) ok = false;
			if (!ok) continue;
			
			REP(k, W) {
				if (k != W - 1 && (bit >> k & 1)) (dp[i + 1][k + 1] += dp[i][k]) %= MOD;
				if (k != 0 && (bit >> k-1 & 1)) (dp[i + 1][k - 1] += dp[i][k]) %= MOD;
				if (!(k != W - 1 && (bit >> k & 1) || k != 0 && (bit >> k-1 & 1))) (dp[i + 1][k] += dp[i][k]) %= MOD;
			}
		}
	}
	
	cout << dp[H][K] << endl;
	
	return 0;
}


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

int main(){
    int N ;
    long long sum = 0;
    cin >> N;
    for(int i = 1 ; i <= N ; ++i){
        if( i%3 != 0 && i%5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int k; cin>>k;
    string s,a; cin>>s;
    for(int i=0; (i<k and i < s.size()); i++) cout<<s[i];
    if( k < s.size()){
        string b="...";
        cout<<b<<endl;

    }
    //cout<<a<<endl;
}

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int N,res=0,cr=0;
  string S;

  cin >> N;
  cin >> S;

  REPI(S.size())
  {
    if (S[i] == 'I')
      cr++;
    else
      cr--;
    
    res = max(res,cr);    
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3620
def main():
    n=input()
    kushi=map(int,raw_input().split())
    print answer(n,kushi)

def answer(n,kushi):
    kushi.sort()
    kushi.reverse()
    sums=0
    for i in range(1,2*n,2):
        sums+=kushi[i]
    return sums
        

if __name__=='__main__':
    main()

Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < 10000; i++) {
		if (floor(double(i) * 0.08) == a && floor(double(i) * 0.1) == b) {
			cout << i << endl;
			getchar();
			getchar();
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

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

    return gcd(b, a % b);
}

signed main()
{
int n;
std::cin >> n;
std::vector<int> a;
int onef = 0;
int sum = 0;
int turn = 1;
for(int i = 0; i < n; i++){
    int temp;
    std::cin >> temp;
    a.push_back(temp);
    sum += temp - 1;
    if(temp == 1){
        onef = 1;
    }
}
int flag = 0;

if(onef){
    flag = (sum%2 == 0)? -1:1;
}else {
while(flag == 0){
    int tempsum = 0;
    int temp = 0;
    int ecounter = 0;
    int ocounter = 0;
    int odd = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == 1){
            onef = 1;
        }
        tempsum += a[i] - 1;
        if(a[i] % 2 == 0){
            ecounter++;
        } else {
            ocounter++;
            odd = i;
        }
    }
    if(onef){
        flag = (tempsum%2 == 0)? -1*turn:1*turn;
        break;
    }
    if(ecounter % 2 == 1){
        flag = 1*turn;
        break;
    } else {
        if(ocounter >= 2){
            flag = -1*turn;
            break;
        } else {
            int g = a[0];
            a[odd]--;
            for(int i = 1; i < n; i++){
                g = gcd(g,a[i]);
            }
            for(int i = 0; i < n; i++){
                a[i] = a[i]/g;
            }
            turn *= -1;
        }
    }
}
}

if(flag == 1){
    std::cout << "First" << std::endl;
} else {
    std::cout << "Second" << std::endl;
}

return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	int c=a*b;
	if (c%2==0) cout<<"Even";
	else cout<<"Odd";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i = 0,j= 0;
	for(i = 0; i<9; i++){
		for(j = 0;j<9;j++){
			printf("%dx%d=%d\n",i+1,j+1,(j+1)*(i+1));
		}
	}
    return 0;
}

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

int main(void){
    int a, b, k, result = 0;

    cin >> a >> b;

    if(a > b){
        /* aの方が大きい */
        for(int i = 0; i < 1000000000; i++ ){
            if((a - i) == ((b-i)*(-1))){
                result = i;
                break;
            }
        }
    }else{
        /* bの方が大きい */
        for(int i = 0; i < 1000000000; i++ ){
            if((a - i)*(-1) == (b-i)){
                result = i;
                break;
            }
        }
    }

    if(result == 0){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << result << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fact(ll n)
{
    return (n <= 1) ? 1 : n * fact(n - 1);
}

// A utility function to count smaller characters on right
// of arr[low]
ll findSmallerInRight(string str, ll low, ll high)
{
    ll countRight = 0, i;

    for (i = low + 1; i <= high; ++i)
        if (str[i] < str[low])
            ++countRight;

    return countRight;
}

// A function to find rank of a string in all permutations
// of characters
ll findRank(string str)
{
    ll len = str.length();
    ll mul = fact(len);
    ll rank = 1;
    ll countRight;

    ll i;
    for (i = 0; i < len; ++i) {
        mul /= len - i;

        // count number of chars smaller than str[i]
        // fron str[i+1] to str[len-1]
        countRight = findSmallerInRight(str, i, len - 1);

        rank += countRight * mul;
    }

    return rank;
}

int main()
{
    ll n;
    cin>>n;
    ll arr[n],brr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    for(int i=0;i<n;i++)
        cin>>brr[i];
    string s1,s2;
    for(int i=0;i<n;i++)
        s1+=('0'+arr[i]);
    for(int i=0;i<n;i++)
        s2+=('0'+brr[i]);
    cout<<abs(findRank(s1)-findRank(s2))<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int x,n;
  cin >> x >> n;
  vi p(105,0);
  rep(i,n) {
    int y;
    cin >> y;
    p.at(y) = 1;
  }

  int d = 10010;
  ll ans = 500;
  rep(i,105) {
    if(!p.at(i)) {
    int a = abs(x-i);
    if(a < d) {
      d = a;
      ans = i;
    } else if ( a== d) {
      ans = min(ans,i);
      }
    }

    int b = abs(x+i);
    if(b < d) {
      d = b;
      ans = -i;
    } else if ( b== d) {
      ans = min(ans,-i);
    }

  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<unordered_map>
#include<climits>
using namespace std;

int main()
{
    string s; cin >> s;
    int count_0 = 0;
    int count_1 = 0;
    for(int i = 0; i < s.size(); ++i){
        if( s[i] == '0') ++count_0;
        else if( s[i] == '1') ++count_1;
    }

    int ans = 2 * min(count_0, count_1);
  
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
use std::io;
use std::collections::HashSet;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n: i32 = match buf.trim().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let mut set: HashSet<String> = HashSet::new();
	for num in 0..n {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		buf = buf.trim().to_string();
		set.insert(buf);
	}
	println!("{}", set.len());
}

Measured memory_bytes: 15260
MOD=10**9+7
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self //value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

class Combination:
    def __init__(self,max_n):
        self.max_n=0
        self.fact=[Fp(1)]
        self.ifact=[Fp(1)]
        self.make_fact_list(max_n)
    def C(self,n,k):return self.fact[n]*self.ifact[k]*self.ifact[n-k] if 0<=k<=n else 0
    def H(self,n,k):return self.C(n+k-1,k) if n or k else 1
    def P(self,n,k):return self.fact[n]*self.ifact[n-k] if 0<=k<=n else 0
    def make_fact_list(self,max_n):
        if max_n<=self.max_n: return
        self.fact+=[Fp(0)]*(max_n-self.max_n)
        self.ifact+=[Fp(0)]*(max_n-self.max_n)
        for i in range(self.max_n+1,max_n+1):
            self.fact[i]=self.fact[i-1]*i
            self.ifact[i]=self.ifact[i-1]//i
        self.max_n=max_n

def main():
    N,*X=map(int, open(0).read().split())
    f=Combination(N)
    ans=Fp(0)
    acc=Fp(0)
    for i,(x,y) in enumerate(zip(X,X[1:]),1):
        acc+=f.fact[N-1]//i
        ans+=acc*(y-x)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 22368
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    
    int H[N+1];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    H[N] = 1000000001;
    
    int cnt = 0,ans = 0;
    for(int i=0;i<N;i++){
            if(H[i]<H[i+1]){
                ans = max(ans,cnt);
                cnt = 0;
            }else{
                cnt++;
            }
        }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 640
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;
//ex
void solve(){
	LL H,W;
	cin >> H >> W;

	LL ans = LINF;
	LL MIN = LINF;
	LL MAX = -LINF;
	LL A,B,C;
	LL Left,Right;

	Left = W*(H/2)/(H+(H/2));
	Right = W*(H-(H/2))/(2*H-(H/2));
	if( Left < Right ){
		swap(Left,Right);
	}
	Left = max(Left-1,(LL)0);
	Right = min( Right+1,W);
	for(LL w=Left;w<=Right;++w){
		vector<LL> temp(3);
		temp[0] = (W-w)*(H/2);
		temp[1] = (W-w)*(H-(H/2));
		temp[2] = w*H;
		sort(temp.begin(), temp.end());
		ans = min( ans, temp[2]-temp[0]);

		temp[0] = H*((W-w)/2);
		temp[1] = H*((W-w)-((W-w)/2));
		temp[2] = w*H;
		sort( temp.begin(), temp.end() );
		ans = min(ans,temp[2]-temp[0]);
	}
		
	swap(H,W);
	Left = W*(H/2)/(H+(H/2));
	Right = W*(H-(H/2))/(2*H-(H/2));
	if( Left < Right ){
		swap(Left,Right);
	}
	Left = max(Left-1,(LL)0);
	Right = min( Right+1,W);
	for(LL w=Left;w<=Right;++w){
		vector<LL> temp(3);
		temp[0] = (W-w)*(H/2);
		temp[1] = (W-w)*(H-(H/2));
		temp[2] = w*H;
		sort(temp.begin(), temp.end());
		ans = min( ans, temp[2]-temp[0]);

		temp[0] = H*((W-w)/2);
		temp[1] = H*((W-w)-((W-w)/2));
		temp[2] = w*H;
		sort( temp.begin(), temp.end() );
		ans = min(ans,temp[2]-temp[0]);
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(3);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  char a,b;

  cin>>a>>b;

  if(a==b){
    cout<<'H'<<endl;
  }else{
    cout<<'D'<<endl;
  }
  
  return 0;

}




Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static final void solve() {
		try (Scanner cin = new Scanner(System.in)) {
			int length = cin.nextInt();
			int[] array = new int[length];

			for (int i = 0; i < length; i++) {
				array[i] = cin.nextInt();
			}

			Arrays.sort(array);
			int ans = 1;
			int num = array[0];
			int index = 0;
			int nextIndex = 0;

			for (int i = 0; i < length; i++) {

				if (nextIndex == 0 && array[i] != num) {
					nextIndex = i;
				}

				if (array[i] > num + 2) {
					if (i - index > ans) {
						ans = i - index;
					}
					i = nextIndex;
					index = nextIndex;
					num = array[nextIndex];
					nextIndex = 0;
				}

				if (i == length - 1) {
					if (i - index + 1 > ans) {
						ans = i - index + 1;
					}
				}
			}

			System.out.println(ans);
		} finally {
		}
	}

}


Measured memory_bytes: 50440
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    c = collections.Counter(S())
    if c['R'] > c['B']:
        return 'Yes'

    return 'No'


print(main())




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

int main() {

int a = 0;
cin>>a;
  bool can=false;
for (int i = 0; i < 200; i++){
  if(can){break;}
	for (int j = -200 ; j < i; j++){
	if(a == i*i*i*i*i-j*j*j*j*j){
	cout<<i<<' '<<j<<endl;
      can=true;
	break;}
	}
}
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    String str1 = str.substring(0,5);
    String str2 = str.substring(6,13);
    String str3 = str.substring(14,19);
    System.out.println(str1+' '+str2+' '+str3);
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //char s[] = new char[3];
        String input = scanner.nextLine();
        int count=0;
        for (int i = 0; i < 3; i++) {
            //s[i]=input.charAt(i);
            if(input.charAt(i)=='1'){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        do {
        	int[] ice = new int[10];
        	for(int i = 0;i < n;i++){
        		ice[sc.nextInt()]++;
        	}
        	for(int a : ice){
        		for(int i = 0;i < a;i++){
        	    	System.out.print('*');
         	   }
        	    if(a <= 0){
        	    	System.out.println('-');
        	    }else{
         		   	System.out.println();
        	    }
        	}
        } while((n = sc.nextInt()) != 0);
    }
}


Measured memory_bytes: 64260
import java.util.Scanner;

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

        String S = sc.next();
        int zeroCount = 0;
        int oneCount = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) == '1') {
                zeroCount++;
            } else {
                oneCount++;
            }
        }

        int notDeletedCount = Math.abs(zeroCount - oneCount);
        int res = S.length() - notDeletedCount;

        System.out.println(res);
    }
}


Measured memory_bytes: 25300
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
	int a =sc.nextInt();
	int b =sc.nextInt();
	int c =sc.nextInt();
	if((a==b) && (b==c)){
	System.out.println("1");
	}else if((a==b && b!=c) || (b==c && b!=a) ||(a==c && b!=a)){
	System.out.println("2");
	}else{
	System.out.println("3");
	}
	}
	}

Measured memory_bytes: 23892
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd



int main() {
	ll a[5];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	ll b[5];
	ll max = 0;
	ll total = 0;
	for (int i = 0; i < 5; i++) {
		if (a[i] %10 != 0) {
			b[i] = a[i] / 10;
			b[i] *= 10;
			b[i] += 10;
			if (b[i] - a[i] > max)max = b[i] - a[i];
		}
		else {
			b[i] = a[i];
		}
		total += b[i];
	}
	total -= max;

	cout << total;
	return 0;
}


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

int main(){
  //ちょうどＮ円を支払えるかどうか 1円玉はA枚
  int N, A;
  cin >> N >> A;
  int a;
  a = N % 500;
  if(A >= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const long long INF = (long long)(1e18) + 1;
int main() {
	int N;
	string X;
	cin >> N >> X;
	vector<int>tmp0(N);
	tmp0[0] = 0;
	for (int n = 1; n < N; ++n) {
		if (1 == n % 2) {
			tmp0[n] = tmp0[n / 2] + 1;
		}
		else {
			tmp0[n] = tmp0[n / 2];
		}
	}
	vector<int>tmp1(N);
	tmp1[0] = 0;
	for (int n = 1; n < N; ++n) {
		if (0 == n % tmp0[n]) {
			tmp1[n] = 1;
		}
		else {
			tmp1[n] = tmp1[n % tmp0[n]] + 1;
		}
	}
	int d = 0;
	for (int n = 0; n < N; ++n) {
		if ('1' == X[n]) {
			d++;
		}
	}

	vector<int>D1(N);
	int sumD1 = 0;
	{
		int num = 1;
		for (int n = 0; n < N; ++n) {
			D1[N - 1 - n] = num;
			if ('1' == X[N-1-n]) {
				sumD1 += num;
				sumD1 %= (d + 1);
			}
			num *= 2;
			num %= (d + 1);
		}
	}
	vector<int>D2(N); 
	int sumD2 = 0;
	{
		int num = 1;
		if (1 != d) {
			for (int n = 0; n < N; ++n) {
				D2[N - 1 - n] = num;
				if ('1' == X[N - 1 - n]) {
					sumD2 += num;
					sumD2 %= (d - 1);
				}
				num *= 2;
				num %= (d - 1);
			}
		}
	}
	//cout << d<< endl; 
	//cout << sumD1 << endl; 
	//cout << sumD2 << endl;

	for (int n = 0; n < N; ++n) {
		int dcopy = d;
		int sumDcopy = 0;
		string Xcopy =X;
		if ('0' == Xcopy[n]) {
			Xcopy[n] = '1';
			dcopy++;
			sumDcopy = sumD1 + D1[n];
			sumDcopy %= (dcopy);
		}
		else {
			Xcopy[n] = '0';
			dcopy--;
			if (0 == dcopy) {
				cout << 0 << endl;
				continue;
			}
			sumDcopy = sumD2 + (dcopy)-D2[n];
			sumDcopy %= (dcopy);
		}
		//cout << sumDcopy<<"_";
		if(0 == sumDcopy){
			cout << 1 <<endl;
		}
		else {
			cout << tmp1[sumDcopy] + 1 <<endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 6872
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"

using namespace std;
typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;
  ll h[100100];
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  sort(h, h + n);
  ll min = 1234567890;
  for (int i = 0; i < n - k + 1; i++)
  {
    if (min > (h[i + k - 1] - h[i]))
    {
      min = (h[i + k - 1] - h[i]);
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

const ll MX = ll(1e18);

int cnt(int a1, int b1, int a2, int b2) {
    if (b1 >= a2) return b2 - a1 + 1;
    else return (b1 - a1) + 1 + (b2 - a2) + 1;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll mxa = 0, mib = MX;
    rep(i,n) {
        cin >> a[i] >> b[i];
        chmax(mxa, a[i]);
        chmin(mib, b[i]);
    }
    ll mib2 = MX, mxa2 = 0;
    rep(i,n) {
        if(b[i] >= mxa) chmin(mib2, b[i]);
        if(a[i] <= mib) chmax(mxa2, a[i]);
    }
    vector<ll> sa = a, sb = b;
    ssort(sa);
    ssort(sb);
    int ans = 0;
    if (n % 2 == 1) {
        ans = cnt(sa[(n-1)/2], mib2, mxa2, sb[(n-1)/2]);
    } else {
        ans = cnt(sa[n/2-1] + sa[n/2],2 * mib2, 2 * mxa2, sb[n/2-1] + sb[n/2]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 9596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (Math.abs(arr[i] - arr[j]) % (n - 1) == 0) {
                    System.out.println(arr[i] + " " + arr[j]);
                    return;
                }
            }
        }
    }
}



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

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define SORT(v) sort(v.begin(), v.end())
typedef long long ll;

int main()
{
    int w, s;

    cin >> s >> w;

    //vector<int> v(/*size*/);
    if (w >= s)
        cout << "unsafe";
    else
        cout << "safe";
}


Measured memory_bytes: 3620
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/
 
 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */
 
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
    fast;
    read(n);
    read(k);
    int s;
    cin>>s;
    vector<int> v;
   
    for(int i=0;i<k;i++)
    v.pb(s);
    loop(i,n-k){
     if(s==1000000000)
    v.pb(s-1);
    else
    v.pb(s+1);

    }
    loop(i,n)
    cout<<v[i]<<" "; 
    return 0;
}

Measured memory_bytes: 2292