akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 101000
using namespace std;
struct point{
	int a, b, num;
	bool operator<(const point &p)const {
		return a != p.a?a<p.a:b>p.b;
	}
}w[N_];
int A[N_], B[N_];
vector<int>E[N_];
long long SB[N_], M[N_], mmm;
int UF[N_], chk[N_];
int n, m, v[N_];
int Find(int a) {
	if (a == UF[a])return a;
	return UF[a] = Find(UF[a]);
}
struct TT {
	long long sb, m;
	bool operator <(const TT &p)const {
		return sb - m < p.sb - p.m;
	}
};
long long G[N_], BB[N_], EE[N_];
void Go(int a, vector<int> &T) {
	chk[a] = 1;
	if (T.empty()) {
		SB[a] = B[a];
		M[a] = max(A[a], B[a]);
		return;
	}
	int sz = T.size();
	vector<TT> U(sz);
	mmm = A[a];
	int c = 0;
	for (auto &t : T) {
		UF[t] = a;
		U[c++] = { SB[t], M[t] };
	}
	sort(U.begin(), U.end());
	long long mm = 0, sb = 0;
	int i;
	for (i = 0; i < sz; i++) {
		mm = max(mm, sb + U[i].m);
		G[i] = sb + U[i].m;
		sb += U[i].sb;
	}
	mm = max(mm, sb + max(A[a], B[a]));
	for (i = 0; i < sz; i++) {
		if (i == 0 || G[i] > BB[i - 1])BB[i] = G[i];
		else BB[i] = BB[i - 1];
	}
	for (i = sz - 1; i >= 0; i--) {
		if (i == sz - 1 || G[i] > EE[i + 1])EE[i] = G[i];
		else EE[i] = EE[i + 1];
	}
 
	for (i = 0; i < sz; i++) {
		long long t = sb - U[i].sb + B[a] + U[i].m;
		t = max(t, sb - U[i].sb + max(A[a], B[a]));
		if (i != 0)t = max(t, BB[i - 1]);
		if (i != sz - 1)t = max(t, EE[i + 1] - U[i].sb);
		mm = min(mm, t);
	}
 
	sb += B[a];
	M[a] = mm;
	SB[a] = sb;
}
int main() {
	int i, a, b;
	scanf("%d%d",&n,&m);
	for (i = 1; i <= n; i++) {
		scanf("%d%d", &w[i].a, &w[i].b);
		A[i] = w[i].a, B[i] = w[i].b;
		UF[i] = i;
		w[i].num = i;
	}
	sort(w + 1, w + n + 1);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
	for (i = 1; i <= n; i++) {
		int a = w[i].num;
		vector<int>T;
		for (auto &x : E[a]) {
			if (!chk[x])continue;
			int t = Find(x);
			if (!v[t]) {
				T.push_back(t);
				v[t] = 1;
			}
		}
		for (auto &t : T)v[t] = 0;
		Go(a, T);
	}
	printf("%lld\n",M[w[n].num]);
}

Measured memory_bytes: 12920
N = int(input())
X = list(map(int,input().split()))

Y = sorted(X)

Y_mid_left,Y_mid_right = Y[N//2-1],Y[N//2]

for i in range(N):
    if X[i] <= Y_mid_left:
        print(Y_mid_right)
    else:
        print(Y_mid_left)


Measured memory_bytes: 26772
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
// #include <unordered_set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

//unordered_set<pair<int,int>> blacks;
set<pair<int,int>> blacks;

int main(void)
{
    cin.sync_with_stdio(false);
    int H, W, N;
    cin >> H >> W >> N;

    REP(n,N) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        blacks.insert(mp(a,b));
    }

    vector<ll> appear(10);
    vector<vector<char>> mini(5, vector<char>(5));
    for(auto&e: blacks) {
        auto cy = e.first;
        auto cx = e.second;

        REP(y1,5) {
            REP(x1,5) {
                auto y = cy + y1 - 2;
                auto x = cx + x1 - 2;
                if (0 <= y && y < H && 0 <= x && x < W) {
                    mini[y1][x1] = blacks.count(mp(y,x));
                }
                else {
                    mini[y1][x1] = -100;
                }
            }
        }

        // cout << endl;
        // cout << "mini:" << endl;
        // REP(y1,5) {
        //     REP(x1,5) {
        //         cout << (int)mini[y1][x1] << "\t";
        //     }
        //     cout << endl;
        // }

        REP(y1,3) {
            REP(x1,3) {
                int tmp = 0;
                REP(y,3) {
                    REP(x,3) {
                        tmp += mini[y1+y][x1+x];
                    }
                }
                if (tmp >= 0) {
                    ++appear[tmp];
                    // cout << "found " << tmp << endl;
                }
            }
        }
    }

    ll zero_cnt = (ll)(W-2) * (H-2);
    FOR(x,1,10) {
        zero_cnt -= appear[x] / x;
    }
    cout << zero_cnt << endl;
    FOR(x,1,10) {
        cout << appear[x] / x << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
X, Y, A, B, C = map(int,input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
s = P[:X]+Q[:Y]+R
s.sort(reverse=True)
        
print(sum(s[:X+Y]))

Measured memory_bytes: 22560
var
	i,j:integer;
    arr:array[1..1000] of integer;
    n,k,d,input:integer;
begin
	readln(n,k);
    for i:=1 to n do arr[i]:=0;
    for i:=1 to k do begin
    	readln(d);
        for j:=1 to d do begin
        	read(input);
            inc(arr[input]);
        end;
    end;
    input:=0;
    for i:=1 to n do begin
    	if arr[i]=0 then input:=input+1;
    end;
    writeln(input);
end.

Measured memory_bytes: 1384
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const i64 MOD = 1e9 + 7;

int main()
{
  i64 N;
  cin >> N;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  i64 sum = 0;
  for (i64 i = 0; i < N; i++)
    sum += A[i];
  i64 ans = 0;
  for (i64 i = 0; i < N; i++)
  {
    sum -= A[i];
    (ans += sum % MOD * A[i]) %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4776
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
  
 int main()
 {
   multiset<string> kk;
   int max=0;
   int fre=-100000000;
   string str;
   string str_max;
   string str_fre;
   multiset<string>::iterator iter; 
   while(cin>>str)
   {
     if(str.length()>max) 
     {
       max=str.length();
       str_max=str;                     
     }             
     kk.insert(str);      
   }              
   for(iter = kk.begin();iter!= kk.end(); iter++)  
   {  
     string str=*iter;
     int num=kk.count(str);
     if(num>fre) 
     {
       fre=num;
       str_fre=str;                
     }
   }  
   cout<<str_fre<<" "<<str_max<<endl;
   //while(1);     
   return 0;  
 }
 

Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  int N = S.size();

  char list[N + 10];
  ll ans = 0;
  int ac = 0;

  for (int i = 0; i < N; ++i) {
    list[i] = S[i];

    if (list[i] == 'A') {
      ++ac;
    }

    /*
    for (int j = 0; j <= i; ++j) {
      cout << list[j] << " ";
    }
    cout << endl;
    */

    if (i < 2) continue;
    if (list[i - 1] == 'A') {
      if (list[i] == 'C') {
        ac = 0;
      }
    }
    if (list[i - 1] == 'B') {
      if (list[i] == 'A') {
        ac = 1;
      } else if (list[i] == 'B') {
        ac = 0;
      }
    }
    if (list[i - 1] == 'C') {
      if (list[i] == 'A') {
        ac = 1;
      } else {
        ac = 0;
      }
    }
    if (list[i - 2] != 'A' || list[i - 1] != 'B' || list[i] != 'C') continue;

    ans += ac;

    /*
    cout << ac << endl;
    */

    list[i] = 'A';
  }

  cout << ans << endl;

  return 0;
}


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

ll modpow(ll a, ll n)
{
  ll res=1;
  while (n>0) {
    if (n&1) res = res*a % mod;
    a = a*a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++){
    cin >> A[i];
  }

  ll ans = 0;
  ll maxd = 0;
  for (int j=0; j<=60; j++) {
    for (int i=0; i<N; i++) {
      ll t = (A[i]>>j)&1;
      if (t==1) {
        maxd = j;
        break;
      }
    }
  }
  for (int j=0; j<=maxd; j++) {
    vector<ll> d(N, 0);
    for (int i=N-1; i>=0; i--) {
      int t = (A[i]>>j)&1;
      if (i==N-1) {
        d[i] = t;
        continue;
      }
      d[i] = d[i+1] + t;
    }
    for (int i=0; i<N-1; i++) {
      ll t = (A[i]>>j)&1;
      if (t==0) ans = (ans + (modpow(2,j) * d[i+1] % mod)) % mod;
      else ans = (ans + (modpow(2,j) * (N-1-i-d[i+1]) % mod)) % mod;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	int n, m, x, y,z1,z2;
	cin >> n >> m >> x >> y;
	if (y-1<=x) {
		cout << "War";
		abort();
	}
	else {
		z1 = x + 1;
		z2 = y - 1;
	}
	vector<int>xl(n+1), yl(m+1);
	for (int i = 0; i < n; i++) {
		cin >> xl.at(i);
	}
	sort(xl.begin(), xl.end());
	reverse(xl.begin(), xl.end());
	
	for (int u = 0; u < m; u ++) {
		cin >> yl.at(u);
	}	
	sort(yl.begin(), yl.end());
	//for (int i = 0; i < n + 1; i++) {
	//	cout << xl.at(i) << " ";
	//}
	//cout << endl;
	//for (int u = 0; u < m+1; u++) {
	//	cout << yl.at(u) << " ";
	//}
	int x1 = xl.at(0);
	if (x1 == 0) {
		x1  = xl.at(1);
	}

	int y1 = yl.at(0);
	if (y1  == 0) {
		y1  = yl.at(1);
	}
	//cout << endl;
	//cout << x1 << endl << y1  << endl;
	if (x1  >= y1) {
		cout << "War";
	}
	else if (y1 > x1) {
		if (z1 <= x1 + 1&&x1+1<=z2 ) {
			cout << "No War";
		}
		else {
			cout << "War";
		}
	}
}

Measured memory_bytes: 256
const MOD: usize = 1e9 as usize + 7;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut indices = vec![];
    for i in 1.. {
        if i * i > n {
            break;
        }
        indices.push(i);
        indices.push(n / i);
    }
    indices.sort();
    indices.dedup();

    let n = indices.len();
    let mut dp = vec![0; n];
    dp[0] = 1;
    for i in 1..n {
        let prev_index = indices[i - 1];
        let index = indices[i];
        dp[i] = index - prev_index;
    }

    for _ in 1..k {
        let mut next = vec![0; n];

        let mut sum = 0;
        for i in 0..n {
            sum += dp[i];
            sum %= MOD;

            let count = if n - 1 - i == 0 {
                1
            } else {
                let prev = indices[n - 1 - i - 1];
                let index = indices[n - 1 - i];
                index - prev
            };
            next[n - 1 - i] = (sum * count) % MOD;
        }
        dp = next;
    }

    println!("{}", dp.into_iter().sum::<usize>() % MOD);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main()
{
  int k;
  cin >> k;
  
  int odd = k / 2;
  if (k % 2 != 0) odd ++;
  
  int even = k / 2;
  
  cout << odd * even << endl;
  
  return 0;
}

// [1, k]の中の奇数と偶数１個ずつの組み合わせの数=奇数の個数*偶数の個数

Measured memory_bytes: 256
from collections import Counter, deque
from bisect import *
alphabets = list("abcdefghijklmnopqrstuvwxyz")
s = input()
t = input()
cs = Counter(list(s))
ct = Counter(list(t))
for char in alphabets:
    if ct[char] > 0 and cs[char]==0:
        print(-1)
        exit()

l_s = len(s)
l_t = len(t)
ss = list(s+s)
c2loc = {char: [] for char in alphabets}
for i in range(l_s*2):
    c2loc[ss[i]].append(i)

ans = 0
now = -1
for i in range(l_t):
    target = t[i]
    target_idxes = c2loc[target]
    idx = bisect_right(target_idxes, now)
    ans += target_idxes[idx] - now
    now = target_idxes[idx]%l_s
print(ans)

Measured memory_bytes: 99332
fn main() {
    let (n, k, c): (usize, usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let s: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let mut left = vec![0; k];
    let (mut li, mut lj) = (0, 0);
    while li < n && lj < k {
        if s[li] == 'o' {
            left[lj] = li;
            li += c;
            lj += 1;
        }
        li += 1;
    }

    let mut right = vec![0; k];
    let (mut ri, mut rj) = (0, 0);
    while ri < n && rj < k {
        if s[n - 1 - ri] == 'o' {
            right[k - 1 - rj] = n - 1 - ri;
            ri += c;
            rj += 1;
        }
        ri += 1;
    }

    for i in 0..k {
        if left[i] == right[i] {
            println!("{}", left[i] + 1);
        }
    }
}

Measured memory_bytes: 5712
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
using namespace std;
int a[1010],b[1010],dp[11000];
int main(){
	int n,h,i;
	scanf("%d%d",&h,&n);
	for(i=1;i<=n;i++)
	scanf("%d%d",&a[i],&b[i]);
	int j;
	dp[0]=0;
	for(i=1;i<=h;i++){
		dp[i]=199999999;
		for(j=1;j<=n;j++){
			int temp=dp[i];
			if(i>=a[j])
			dp[i]=dp[i-a[j]]+b[j];
			else
			dp[i]=b[j];
			dp[i]=min(dp[i],temp);
		}
	}
	printf("%d\n",dp[h]);
	
}

Measured memory_bytes: 256
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for j in range(n)]
ab.sort(key=lambda x:x[0])
#print(ab)
ans,i = 0,0

while(m>0):
  num = min(ab[i][1],m)
  ans += ab[i][0]*num
  #print(ans,num)
  m -= num
 #print(m)
  i += 1
print(ans)

Measured memory_bytes: 28408
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
if b<c:
	print(0)
else:
	print(10)
#print("{} {}".format(a+b+c, s))

Measured memory_bytes: 2940
import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl read <*> getl (map read . words) >>= print

solve :: Int -> [Int] -> Int
solve n xs
  | even (length $ filter (==2) ys) = length ys
  | otherwise = length ys - 1
  where
    ys = map (\l -> f (length l)) . group . sort $ xs
    f x | even x = 2
        | otherwise = 1

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 31612
#include<stdio.h>
int main()
{
    int t,a,b,c,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d%d%d",&a,&b,&c);
        if(a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2076
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

bool compare(vector<int> a, vector<int> b) {
    return a.at(1) < b.at(1);
}

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ab;
    int a,b;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        ab.push_back({a, b});
    }
    sort(ab.begin(), ab.end());
    int pos = n;
    int ans = 1;
    for(int i = 0; i < m; i++){
        if(ab.at(i).at(0) >= pos){
            ans++;
            pos = ab.at(i).at(1);
        }
        else{
            pos = min(pos, ab.at(i).at(1));
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6964
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  char s[10];
  puts("0"); fflush(stdout);
  scanf("%s", s);
  if (*s == 'V') return 0;
  char first = *s;
  int l = 0, r = n;
  while (r - l > 1)
  {
    int mid = l + (r - l) / 2;
    printf("%d\n", mid); fflush(stdout);
    scanf("%s", s);
    if (*s == 'V') return 0;
    if ((mid & 1) != (l & 1))
    {
      if (*s != first) { l = mid; first = *s; }
      else r = mid;
    }
    else
    {
      if (*s == first) l = mid;
      else r = mid;
    }
  }
  printf("%d\n", r); fflush(stdout);
  scanf("%s", s);
  if (*s == 'V') return 0;
}


Measured memory_bytes: 760
function main()
   function gcd(x, y)
        if x%y == 0
            return y
        else
            return gcd(y,x%y)
        end
    end
    
    K = parse(Int,readline())
    A = 0
    for a in 1:K
        for b in 1:K
            for c in 1:K
                A += gcd(gcd(a,b),c)
            end
        end
    end
    
    println(A)
end
main()

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
  int x;
  ci >> x;

  int sum = 0;

  for(int i = 1; i <= x; i++) {
    sum += i;
    cnt++;

    if(sum >= x) break;
  }
  
  co << cnt << en;
  
  return 0;
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n){
    	cin >> a[i];
    }
    set < ll > s;
    ll ans = 0;
    rep(i, n){
    	s.ins(a[i]);
    	if(a[i] == *s.begin()){
    		ans++;
    	}
    }
    cout << ans <<endl;
    
}

int main(){
    IOS;
   // io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 

Measured memory_bytes: 11264
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> 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(begin(ret), end(ret));
    return (ret);
}

const ll MAX = 510000;
// const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve()
{
    string s;
    cin >> s;
    string ans = "";
    ll cnt = 0;
    for(int i=0; i < s.length(); i++){
        if(s[i] == '0'){
            ans += "0";
        }else if(s[i] == '1'){
            ans += "1";
        }else{
            if(ans != ""){
                ans.erase(--ans.end());
            }
            
        }
    }

    cout << ans << endl;

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 1000000;

  for (char c : {'0', '1'}) {
    int tmp = 0;
    const char c2 = 1 - (c - '0') + '0';
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0 && s[i] != c) {
        ++tmp;
      } else if (i % 2 == 1 && s[i] != c2) {
        ++tmp;
      }
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
###############################################################################\
s=input()
bool=True
for i in range(len(s)):
    if i%2==0:
        if s[i]=="R" or s[i]=="U" or s[i]=="D":
            continue
        else:
            bool=False
            break
    else:
        if s[i]=="L" or s[i]=="U" or s[i]=="D":
            continue
        else:
            bool=False
            break

if bool is True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int X[101][101];

int main(){
  int N,D;
  cin>>N>>D;
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin>>X[i][j];
    }
  }

  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      double res=0;
      for(int k=0;k<D;k++){
        res+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      double z=sqrt(res);
      if(floor(z)==ceil(z)) ans++;
    }
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

namespace ALDS1_6_A {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] A = new int[n + 1];
            int[] B = new int[n + 1];
            int[] C = new int[10001];

            for (int i = 1; i <= n; i++) {
                int temp = int.Parse(input[i - 1]);
                A[i] = temp;
                C[temp]++;
            }

            for (int i = 1; i < 10001; i++) {
                C[i] += C[i - 1];
            }

            for (int i = n; i > 0; i--) {
                int temp = A[i];
                B[C[temp]] = temp;
                C[temp]--;
            }

            StringBuilder sb = new StringBuilder();
            foreach (int b in B.Skip(1))
                sb.AppendFormat(" {0}", b);
            Console.WriteLine(sb.ToString().TrimStart());
        }
    }
}

Measured memory_bytes: 258128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        StringBuilder strb = new StringBuilder();
        String[] data;
        int h = 0;
        int w = 0;
        while (true) {
            data = br.readLine().split(" ");
            h = Integer.parseInt(data[0]);
            w = Integer.parseInt(data[1]);
            if (h == 0 && w == 0) {
                break;
            }
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    strb.append("#");
                }
                strb.append("\n");
            }
            strb.append("\n");
        }
        System.out.print(strb);
    }
}

Measured memory_bytes: 25560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


ll F(ll A, ll B){
    ll f = 0;
    for(ll i = 0, q = 1; i < 40; i++, q <<= 1){
        ll a = 0;
        if(A){
            a = (A-1)/(q*2)*q;
            a += max(0LL, (A-1)%(q*2) - q + 1);
        }
        ll b = B/(q*2)*q;
        b += max(0LL, B%(q*2) - q + 1);
        if((b - a)%2)f += q;
    }
    return f;
}

int main(){

    ll A, B;
    cin >> A >> B;
    cout << F(A, B) << endl;

    return 0;
}


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

signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,i,ans;
    cin>>n;

    ans=0;
    int val=0;
    i=0;
    while(i<10000000)
    {
        if(val<n)
        {
            val*=10;
            val+=7;
            ans++;
        }
        else
        {
            val%=n;
            if(val==0)
            {
                cout<<ans<<endl;
                return 0;
            }

        }
         i++;     
    }


    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 3632
#-*- coding: utf-8 -*-

#関数は気持ち上に書いておきたい
def check_num():
    for i in range(N):
        if A[i] % 2 != 0:
            return False
        else:
            A[i] = A[i] / 2
    return True

if __name__ == '__main__':
    N = int(input())

    A = list(map(int, input().split()))
    ans = 0 #counterと同じ

    #check_num == Trueの間実行する
    while True:
        if check_num() == False:
            break
        ans += 1

    print(str(ans))



Measured memory_bytes: 3060
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        s:chars
    }

    let len = s.len();
    let mut ans = true;
    for i in 0..len {
        if i % 2 == 0 {
            if s[i] == 'L' {
                ans = false;
            }
        } else {
            if s[i] == 'R' {
                ans = false;
            }
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#define ll long long
#define re register
using namespace std;
struct ios{
	inline char fchar(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	}
//	#define getchar fchar
	template <typename ty> inline ios& operator >> (ty &x)
	{
		register int f=1;x=0;register char c=getchar();
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
		for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
		x*=f;return *this;
	}
	template <typename ty>  inline ios& operator << (ty x)
	{
		if(x<0) x=-x,putchar('-');
		if(x>9) *this << x/10;
		putchar(x%10+48);
		return *this;
	}
	inline ios& operator << (char x){putchar(x);return *this;}
}io;
const int N = 6e4+5;

int n;
int a[1005];
double inv[1005];
int main()
{
	io >> n;
	for(int i=1;i<=n;i++) io >> a[i],inv[i] = 1.0/a[i];
	double sum = 0;
	for(int i=1;i<=n;i++) sum+=inv[i];
	printf("%.5lf",1.0/sum);
	return 0;
} 

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

int main(){
  int n;
  cin >> n;
  for (int i=0;i<n+1;i++){
     int x=i*108/100;
     if (x==n){
       cout << i << endl;
       return 0;
     }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

int gcd(int a, int b){
    if(a < b){
        swap(a, b);
    }

    int r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

signed main(){
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;

    int g = gcd(n, m);
    int lcm = n * m / g;

    map<int, char> mm;
    rep(i, n){
        mm[lcm / n * i] = s[i];
    }

    bool ok = true;
    rep(i, m){
        if(mm.find(lcm / m * i) == mm.end()){
            continue;
        }

        if(mm[lcm / m * i] != t[i]){
            ok = false;
        }
    }

    if(ok){
        cout << lcm << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}


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

char alphas[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

 
int main(){
    string s;
    cin >> s;
    int ans = 1000;
    int siz = s.size();
    for(int i=0;i<27;i++){
        int now = 0;
        int ansnow = 0;
        for(int j=0;j<s.size();j++){
            if(s[j]==alphas[i]){
                if(now!=0){
                    if(s[j]==s[j-1]){
                        now++;
                    }else{
                        ansnow = max(ansnow,j-now);
                        now = j+1;
                    }
                }else{
                    ansnow = max(ansnow,j-now);
                    now = j+1;
                }
            }
        }
        ansnow = max(ansnow,siz-now);
        ans = min(ans,ansnow);
    }

    cout << ans << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef vector<int> vi;

int main()
{
    int n;
    while(cin >>n,n)
    {
        //schedule
        int s[50][31]={0};

        rep(i,n)
        {
            int f;
            cin >>f;
            rep(j,f)
            {
                int d;
                cin >>d;
                s[i][d]=1;
            }
        }

        int ans=-1;
        vector<vi> v(n,vi(n,0));

        rep(i,n) v[i][i]=1;

        //i-th day
        for(int i=1; i<=30; ++i)
        {
            vi G[50];
            rep(j,n)rep(k,j)
            {
                if(s[j][i] && s[k][i])
                {
                    G[j].pb(k);
                    G[k].pb(j);
                }
            }

            //root-j BFS
            vi vv(n);
            rep(j,n)
            {
                if(vv[j]) continue;

                vi vis(n);
                vis[j]=1;
                queue<int> que;
                que.push(j);
                while(!que.empty())
                {
                    int now=que.front();
                    que.pop();
                    rep(k,G[now].size())
                    {
                        int nx=G[now][k];
                        if(!vis[nx])
                        {
                            que.push(nx);
                            vis[nx]=1;
                        }
                    }
                }

                vi p(n);
                rep(k,n)
                {
                    if(vis[k])
                    {
                        rep(l,n) p[l]|=v[k][l];
                    }
                }

                rep(k,n)
                {
                    if(vis[k])
                    {
                        rep(l,n) v[k][l]|=p[l];
                    }
                }

                rep(k,n) vv[k]|=vis[k];
            }

            rep(j,n)
            {
                int ct=0;
                rep(k,n) ct+=v[j][k];
                if(ct==n)
                {
                    ans=i;
                    break;
                }
            }

            if(ans>0) break;
        }

        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3216
import std.stdio;

void main() {
  long n;
  readf("%d\n", &n);
  auto isEven = n % 2 == 0;
  if (isEven) {
    writeln(0.5);
  } else {
    writeln((cast(double) (n / 2 + 1)) / n);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100100;
int a[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int n;
	scanf("%d", &n);
	while(n--) {
		int x;
		scanf("%d", &x);
		a[x]++;
	}
	int ans = 0;
	for (int i = 1; i < N - 1; i++) {
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
bool digit[10];
int a[5] = { -1 };

int main(void) {
	ll n, m;
	cin >> n >> m;
	cout << (1900 * m + 100 * (n - m))*pow(2, m) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const long long int MAX=1e3;
map<long long int , long long int >cnt;
long long int prime[MAX]={1};
void compute(){
	long long int i ,j,k;
	for(i=1;i<MAX;i++)
		prime[i]=1;
	for(i=2;i*i<MAX;i++){
		if(prime[i]){
			for(j=2*i;j<MAX;j+=i)
				prime[j]=0;
		}
	}
}
int main(){
	long long int a  ,b ,c ,n ,i ,j;
	cin>>n;
	c=n;
	compute();
//	cout<<"\n";
	cout<<n<<':';
	for(i=2;i*i<=n;i++){
		while(n%i==0){
			cout<<" "<<i;
//			cnt[n/i]++;
			n=n/i;
		}
	}
	if(n!=1)
		cout<<" "<<n;
	cout<<"\n";
}


Measured memory_bytes: 3104
# ABC071 B - Not Found
S = input()

ABC = 'abcdefghijklmnopqrstuvwxyz'

for s in S:
    if s in ABC:
        ABC = ABC.replace(s,'')

if len(ABC) == 0:
    ans = 'None'
else:
    ans = ABC[0:1]

print(ans)

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

int main() {
  int moneyToPay, oneYenCoinsNum;
  cin >> moneyToPay >> oneYenCoinsNum;
  
  // 500で割った余りが1円玉で支払う金額
  moneyToPay %= 500;
  
  // 持ってるコインの方が支払額より多かったら払える
  if(oneYenCoinsNum >= moneyToPay)
    cout << "Yes" << endl;
  // 足りないので払えない
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vec a(n);
  REP(i,n) cin >> a[i];

  sort(a.begin(),a.end());

  int ans = accumulate(a.begin(),a.end(),0LL);
  int id = 0, cur = ans;
  while(id < n-1){
    cur -= (a[id]+a[id+1])*2;
    ans = max(cur,ans);
    id += 2;
  }

  cout << ans << endl;

  return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int calc(int a, int k) {
  if (k == 2) {
    return (a + 1) % 2;
  } else if (1 <= k && k <= 3) {
    if (a == 0) return 2;
    return a % 2;
  }
  return a;
}

signed main() {
  int N;
  cin >> N;
  int a[N + 2];
  for (int i = 1; i <= N; i++) cin >> a[i];
  a[N + 1] = 0;

  int dp[N + 2][5];
  fill(dp[0], dp[1], 0);
  fill(dp[1], dp[N + 2], INF);

  for (int i = 1; i <= N + 1; i++) {
    for (int k = 0; k < 5; k++) {
      int m = INF;
      for (int j = 0; j < k + 1; j++) {
        chmin(m, dp[i - 1][j]);
      }

      dp[i][k] = m + calc(a[i], k);
    }
  }

  cout << dp[N + 1][4] << endl;
  return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,br=0;
    long long d,d1,g,x,y;
    cin >> n >> d;
    d1=d*d;
    for (int i=0;i<n;i++)
    {
        cin >> x >> y;
        if(x*x+y*y<=d1)
            br++;
    }
    cout << br;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		String m = n.substring(n.length() - 1);
		Integer o = Integer.parseInt(m);
		switch(o) {
		case 3:
			System.out.println("bon");
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
		}
	}
}

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

typedef long long int ll;
const int N_MAX = 3005;
const int S_MAX = 3005;
const long long int MOD = 998244353;

ll dp[N_MAX][S_MAX];
int A[N_MAX];

int main(){
    int n, s;
    cin >> n >> s;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= s; j++){
            if (j < A[i]){
                dp[i][j] = dp[i-1][j] * 2;
            }
            else{
                dp[i][j] = dp[i-1][j] * 2 + dp[i-1][j-A[i]];
            }
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 74200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  string S, T;
  cin >> S >> T;
  bool A = true;
  if(S.size() != T.size()-1) A = false;
  string B = T.substr(0,S.size());
  if(S != B) A = false;
  if(A) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  string N;
  cin >> N;
  int sn = 0;
  for (auto c : N) {
    sn += c - '0';
  }
  if (stoi(N) % sn == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;    
    
    vvl G(n-1+m);  // 辺の重みがすべて1のグラフ
    vl indeg(n);  // indeg[v] : 頂点vの入次数
    rep(i, n-1+m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        indeg[b]++;
    }
    
    // BFS。計算量はO(V+E)
    queue<ll> Q;
    vl ans(n);  // ans[v] : 頂点vの親の頂点番号
    rep(v, n) {
        if(indeg[v] == 0) {
            ans[v] = -1;
            Q.push(v);
        }
    }
    
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(auto u : G[v]) {
            indeg[u]--;
            if(indeg[u] == 0) {
                ans[u] = v;
                Q.push(u);
            }
        }
    }

    rep(v, n) {
        out(ans[v] + 1);
    }
    
    re0;
}

Measured memory_bytes: 7808