akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long t,a,b,c,ans;
inline long long read()
{
   long long sum=0,x=1;
   char ch=getchar();
   while (ch<'0'||ch>'9')
   {
       if (ch=='-')
	     x=-1;
	   ch=getchar();
   }
   while (ch>='0'&&ch<='9')
   {
   	   sum=sum*10+ch-'0';
	   ch=getchar();
   }
   return sum*x;
}
inline void write(long long x)
{
    if (x<0)
	{
        putchar('-');
        x=-x;
    }
    if (x>9)
      write(x/10);
    putchar(x%10+'0');
    return;
}
int main()
{	
	t=read();
	while (t--)
	{
		ans=0;
		a=read();b=read();
		if (a>b)
		  swap(a,b);
        c=sqrt(a*b);
        c-=(c*c==a*b);
        if (a==b||a==b+1)
		  ans=2*a-2;else
		if (c*(c+1)>=a*b)
		  ans=2*c-2;else
		  ans=2*c-1;
       	write(ans);
       	putchar('\n');
	}	
	return 0;
}

Measured memory_bytes: 3532
#!/usr/bin/env python

s = raw_input()

s1 = []
for x in s:
	if not s1:
		s1.append(x)
		continue
	if x == 'T' and s1[-1] == 'S':
		# s1 = s1[:-1]
		del s1[-1]
	else:
		s1.append(x)

print len(s1)


Measured memory_bytes: 4456
#include <bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define INF 10000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
const ll N = 100001;
bool v[N];
vector<int> adj[N][2];
ll d[N][2];

void dfs(ll x, bool c)
{
    v[x] = 1;
    for(auto i:adj[x][c])
    {
        if(!v[i]) dfs(i, c);
        d[x][c] = max(d[i][c] + 1, d[x][c]);
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 0, y = 0, ans = 0;
        cin >> n >> m;
        for(int i = 0; i < m; i++)
        {
            cin >> x >> y;
            adj[x][0].push_back(y);
            adj[y][1].push_back(x);
        }
        for(int i = 1; i <= n; i++)
        {
            if(!v[i])
            {
                dfs(i, 0);
            }
        }
        memset(v, 0, sizeof v);
        for(int i = 1; i <= n; i++)
        {
            if(!v[i])
            {
                dfs(i, 1);
            }
        }
        for(int i = 1; i <= n; i++) ans = max(d[i][1] + d[i][0], ans);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 18944
#include<stack>
#include<cstdio>
std::stack<int>stk;char str[5007],ans[2];
int ask(int a,int b){return printf("? %d %d\n",a-1,b-1),fflush(stdout),scanf("%s",ans),ans[0]=='Y';}
int main()
{
    int n,a,b;scanf("%d%d",&a,&b),n=a+b;
    if(a<=b) return puts("Impossible"),0;
    for(int i=1;i<=n;++i) stk.empty()||ask(stk.top(),i)? stk.push(i):stk.pop();
    for(int i=1;i<=n;++i) str[i]=ask(stk.top(),i)+'0';
    printf("! %s",str+1);
}


Measured memory_bytes: 724
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

bool ismonth(int x){
	return 1<=x && x<=12;
}
bool isyear(int x){
	return 0<=x && x<= 99;
}

int main()
{
	string s;
	cin>>s;
	int x = stoi(s);
	int a = x/100;
	int b = x%100;

	if(isyear(a) && ismonth(b)){
		if(ismonth(a) && isyear(b))
			cout<<"AMBIGUOUS"<<endl;
		else
			cout<<"YYMM"<<endl;
	}else if(ismonth(a) && isyear(b)){
		if(isyear(a) && ismonth(b))
			cout<<"AMBIGUOUS"<<endl;
		else
			cout<<"MMYY"<<endl;
	}else{
		cout<<"NA"<<endl;
	}

	return 0;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  string s, t;
  cin >> s >> t;
  string tt = t.substr(0,s.size());
  if(s == tt) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3604
N = int(input())
T = [0] + list(map(int, input().split()))
M = int(input())
ans = []
for i in range(M):
    Pi, Xi, = map(int, input().split())
    tmp = T[:]
    tmp[Pi] = Xi
    ans.append(sum(tmp))
print(*ans, sep="\n")


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

using namespace std;

typedef int ll;
typedef vector<ll> vl;

ll m,n;
ll dp[1005][1005];
ll dp1[1005][1005];
ll dp2[1005][1005];
ll vis[1005][1005];
ll p[1000001];
ll si = 502,sj = 502;
ll dx[] = {0, 1, 0, -1};
ll dy[] = {1, 0, -1, 0};
ll sx,sy;
ll idx[1005][1005];


void dfs(ll x, ll y){
  if(vis[y][x]) return;
  // cerr << x << " " << y << endl;

  vis[y][x] = 1;
  dp1[y][x] = 0;
  dp2[y][x] = 0;
  vl ret = vl({0, 0});
  for(ll i = -1;i <= 1;i++){
    if(idx[y+1][x+i]){
      dfs(x+i,y+1);
      ret = max(ret,vl({dp1[y+1][x+i],dp2[y+1][x+i]}));
    }
  }
  if(dp[y][x] == 1){
    if(ret[0] == 0) ret[1] = idx[y][x];
    ret[0] += 1;

  }
  dp1[y][x] = ret[0];
  dp2[y][x] = ret[1];
  return;
}

void solve(ll m,ll n){
  ll x = si;
  ll y = sj;
  for(ll i = 0;i < 1005;i++){
    for(ll j = 0;j < 1005;j++){
      dp[i][j] = -1;
      dp1[i][j] = 0;
      dp2[i][j] = 0;
      vis[i][j] = 0;
      idx[i][j] = 0;
    }
  }
  ll d = 0;

  // cerr << m << endl;
  for(ll i = 1;i <= m;i++){
    if(i == n){
      sx = x;
      sy = y;
    }
    idx[y][x] = i;
    idx[y][x] = i;
    if(p[i]) dp[y][x] = 0;
    else dp[y][x] = 1;
    if(dp[y+dy[(d+1)%4]][x+dx[(d+1)%4]] < 0) d = (d+1)%4;
    x += dx[d];
    y += dy[d];
  }
  // for(ll i = si - 5;i <= si+5;i++){
  //   for(ll j = sj - 5;j <= sj+5;j++){
  //     cerr << dp[i][j] << " ";
  //   }
  //   cerr << endl;
  // }
  dfs(sx,sy);
  cout << dp1[sy][sx] << " " << dp2[sy][sx]<< endl;
  // for(ll i = si - 5;i <= si+5;i++){
  //   for(ll j = sj - 5;j <= sj+5;j++){
  //     cerr << dp[i][j] << " ";
  //   }
  //   cerr << endl;
  // }
  // cerr << endl;
  // for(ll i = si - 5;i <= si+5;i++){
  //   for(ll j = sj - 5;j <= sj+5;j++){
  //     cerr << dp1[i][j] << " ";
  //   }
  //   cerr << endl;
  // }

}

int main(){
  p[0] = p[1] = 1;
  for(ll i = 2;i <= 1000000;i++){
    if(p[i] == 0){
      for(ll j = 2;j*i <= 1000000;j++){
        p[i*j] = 1;
      }
    }
  }
  while(cin >> m >> n){
    if(m == 0 && n == 0) return 0;
    solve(m,n);

  }
}



Measured memory_bytes: 26936
n, m, l = map(int,input().split())
a = list()
b = list()

for i in range(n):
    a_col = list(map(int,input().split()))
    a.append(a_col)
for i in range(m):
    b_col = list(map(int,input().split()))
    b.append(b_col)

# 計算
c = list()
for a_line in a:
    c_line = [0 for num in range(l)]
    for i in range(m):
        for j in range(l):
            c_line[j] += a_line[i] * b[i][j]
# c.append(c_line)
    c_line = [str(c_num) for c_num in c_line]
    print(' '.join(c_line))



Measured memory_bytes: 6244
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

string shuffle(string str, int h){
    string head = str.substr(0,h);
    string tail = str.substr(h,str.size()-h);
    return tail + head;
}

int main(){
    string cards;
    int m,h;

    while(1){
        cin >> cards;
        if(cards=="-") break;

        cin >> m;
        for(int i=0; i<m; i++){
            cin >> h;
            cards = shuffle(cards,h);
        }
        cout << cards << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007

#define SZ 100005
using namespace std;
int main()
{
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0; i<n; i++) cin>>arr[i];
    cout<<*max_element(arr, arr+n) - *min_element(arr, arr+n)<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()

print(s[::2])

Measured memory_bytes: 3316
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let (n,m) = read!(i64,i64);
	let ans = n*(n-1)/2 + m*(m-1)/2;
	println!("{}", ans);
}

fn run() {
    solve();
}


Measured memory_bytes: 8572
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc  = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] d = new int[n];
      	int[] mochi = new int[101];
      	for(int i = 0 ; i < n; i++){
        	d[i] = sc.nextInt();
          	mochi[d[i]]++;
        }
      	int count = 0;
      	for(int i = 0; i <= 100; i++){
        	if(mochi[i] > 0) count++;
        }
      	System.out.println(count);
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) cout << "a < b" << endl; 
  else if (a == b) cout << "a == b" << endl; 
  else cout << "a > b" << endl; 
}


Measured memory_bytes: 3084
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 18 17:04:29 2017

@author: goto
"""

int1,int2,int3=map(int, input().split())

t=int1*int2

if t<int3:
    minmoji=t
else:
    minmoji=int3
    

print(minmoji)    



Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    map<string,int> s; 
    for(int i=0;i<n;i++)
    {
        string t;
        cin>>t;
        if(s[t]==0)
        {
            ans++;
            s[t]++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 19180
a, b, c, d, e, f = gets.split.map(&:to_i)

cntA = f / (100 * a)
cntB = f / (100 * b)
maxNodo = 0
maxWater = 0
maxSugar = 0

for numA in 1..cntA
	for numB in 0..cntB
		break if (100*a*numA + 100*b*numB) > f
		cntC = (a*numA+b*numB)*e / c
		cntD = (a*numA+b*numB)*e / d
		for numC in 0..cntC
			for numD in 0..cntD
				sugar = c*numC + d*numD
				break if sugar > e*(a*numA+b*numB)
				water = 100*a*numA + 100*b*numB
				break if (water + sugar) > f
				temp = 100.0*sugar/(water+sugar)
				if maxNodo <= temp
					maxNodo = temp
					maxWater = water
					maxSugar = sugar
					if maxSugar == e*(a*numA+b*numB)
						print(maxWater+maxSugar, " ", maxSugar, "\n")
						exit(0)
					end
				end
			end
		end
	end
end

print(maxWater+maxSugar, " ", maxSugar, "\n")

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   int d,t,s;
   cin>>d>>t>>s;
   cout<<(s*t>=d?"Yes":"No")<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 3628
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]


n = inN()
s = input()


r = s.count('R')
b = s.count('B')
g = s.count('G')
cnt = 0

for i in range(n):
    for j in range(i+1,n):
        k = 2*j - i
        if k < n:
            if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
                cnt += 1
print(r*g*b - cnt)

Measured memory_bytes: 73520
import math
(n, d) = list(map(int, input().split()))
d = pow(d, 2)
points = []
c = 0
for i in range(n):
  (x, y) = list(map(int, input().split()))
  if (pow(x, 2) + pow(y, 2)) <= d:
    c += 1
print(c)

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

template<typename T> using V = vector<T>;

// borrowed from neal's code
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    double r; cin >> r;
    cout << fixed << setprecision(10);
    cout << 2 * 3.14159 * r;
}

Measured memory_bytes: 3828
H, W = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(H)]
ans = []
flg = False
for i in range(H):
    for k in range(W):
        if i % 2 != 0:
            k = W - 1 - k
        if i % 2 == 0:
            if k == W - 1:
                if i == H - 1:
                    continue
                next_i = i + 2
                next_k = k + 1
            else:
                next_i = i + 1
                next_k = k + 2
        else:
            if k == 0:
                if i == H - 1:
                    continue
                next_i = i + 2
                next_k = k + 1
            else:
                next_i = i + 1
                next_k = k
        if grid[i][k] % 2 == 1:
            if flg:
                flg = False
                continue
            flg = True
            ans.append((i+1,k+1,next_i,next_k))
        elif flg:
            ans.append((i+1,k+1,next_i,next_k))
print(len(ans))
for i in ans:
    print(i[0],i[1],i[2],i[3])

Measured memory_bytes: 26704
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }
	public static void printArrayB(byte[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	static final byte LEFT = 1;
	static final byte TOP = 2;
	static final byte TOP_LEFT = 3;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();

		byte[][] dirs = new byte[S.length + 1][T.length + 1];
		int[][] value = new int[S.length + 1][T.length + 1];
		for (int y = 1; y <= S.length; y++) {
			dirs[y][0] = TOP;
		}
		for (int x = 1; x <= T.length; x++) {
			dirs[0][x] = LEFT;
		}
		for (int y = 1; y <= S.length; y++) {
			for (int x = 1; x <= T.length; x++) {
				int nextValue;
				byte dir;
				if (value[y-1][x] >= value[y][x-1]) {
					nextValue = value[y-1][x];
					dir = TOP;
				} else {
					nextValue = value[y][x-1];
					dir = LEFT;
				}
				if (S[y - 1] == T[x - 1]) {
					if (value[y-1][x-1] + 1 > nextValue) {
						nextValue = value[y-1][x-1] + 1;
						dir = TOP_LEFT;
					}
				}
				value[y][x] = nextValue;
				dirs[y][x] = dir;
			}
		}
		// for (int y = 0; y <= S.length; y++) {
		// 	printArrayB(dirs[y]);
		// }
		{
			ArrayList<Character> chars = new ArrayList<>();
			int y = S.length;
			int x = T.length;
			while (y > 0 || x > 0) {
				byte d = dirs[y][x];
				if (d == TOP) {
					y--;
					continue;
				}
				if (d == LEFT) {
					x--;
					continue;
				}
				if (d == TOP_LEFT) {
					y--;
					x--;
					chars.add(S[y]);
					continue;
				}
				throw new RuntimeException("unreachable: (x=" + x + ", y=" + y + ")");
			}
			StringBuilder sb = new StringBuilder();
			for (int i = chars.size() - 1; i >= 0; i--) {
				sb.append(chars.get(i));
			}
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 87116
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){
    ll n,m; cin>>n>>m;
  vl h(n); 
  lp(i,0,n) cin>>h[i];
  ll ans=0;
  map<ll,vl> ma;
  lp(i,0,m){
    ll x,y; cin>>x>>y;
    ma[x].pb(y);
    ma[y].pb(x);
  }
  lpd(x,ma){
    if(x.y.size()==0) ans++;
    bool f=0;
    //cout<<x.F<<" ";
    lpd(j,x.y){
      //cout<<j<<" ";
      if(h[j-1]>=h[x.x-1]){
        f=1; break;
      }
    }
    if(!f){ ans++;
    }
  }
  lp(i,1,n+1)
  if(ma[i].size()==0) ans++;
  cout<<ans;
  return 0;
}

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 15340
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

enum struct Type
{
	ROOT,
	INTERNAL,
	LEAF
};

struct OwnNode
{
	int id;
	int parent;
	int depth;
	int height;
	int sibling;
	Type type;
	int left;
	int right;
};

OwnNode tree[100001];
bool isChild[100001];
const string typeStr[] = { "root","internal node","leaf" };

int TrackTree(int parentid,int id, int depth)
{
	/*int height = 0;
	tree[id].parent = parentid;
	tree[id].depth = depth;
	for (int i = 0; i != tree[id].children.size(); i++)
	{
		height = max(height, TrackTree(id, tree[id].children[i], depth + 1));
	}
	if (tree[id].children.size() == 2)
	{
		tree[tree[id].children[0]].sibling = tree[tree[id].children[1]].id;
		tree[tree[id].children[1]].sibling = tree[tree[id].children[0]].id;
	}
	tree[id].height = height;
	return height + 1;*/
	return 0;
}

void PreOrder(int id)
{
	printf(" %d", id);
	if (tree[id].left!=-1)
	{
		PreOrder(tree[id].left);
	}
	if (tree[id].right!=-1)
	{
		PreOrder(tree[id].right);
	}
}

void InOrder(int id)
{
	if (tree[id].left != -1)
	{
		InOrder(tree[id].left);
	}
	printf(" %d", id);
	if (tree[id].right != -1)
	{
		InOrder(tree[id].right);
	}
}

void PostOrder(int id)
{
	if (tree[id].left != -1)
	{
		PostOrder(tree[id].left);
	}
	if (tree[id].right != -1)
	{
		PostOrder(tree[id].right);
	}
	printf(" %d", id);
}

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

	for (int i = 0; i < n; i++)
	{
		int id,left,right;
		scanf("%d %d %d", &id, &left, &right);

		tree[id].id = id;
		tree[id].depth = 0;
		tree[id].sibling = -1;
		tree[id].parent = -1;
		tree[id].left = left;
		tree[id].right = right;

		if (left != -1)
		{
			isChild[left] = true;
		}
		if (right != -1)
		{
			isChild[right] = true;
		}
	}

	int rootID = -1;
	for (int i = 0; i < n; i++)
	{
		if (!isChild[i])
		{
			rootID = i;
			break;
		}
	}

	/*TrackTree(-1, rootID, 0);

	for (int i = 0; i < n; i++)
	{
		if (tree[i].parent == -1)
		{
			tree[i].type = Type::ROOT;
		}
		else if (tree[i].children.size() == 0)
		{
			tree[i].type = Type::LEAF;
		}
		else
		{
			tree[i].type = Type::INTERNAL;
		}
	}

	for (int i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", tree[i].id, tree[i].parent, tree[i].sibling,tree[i].children.size(),tree[i].depth, tree[i].height,typeStr[(int)tree[i].type].c_str());
	}*/

	printf("Preorder\n");
	PreOrder(rootID);
	printf("\nInorder\n");
	InOrder(rootID);
	printf("\nPostorder\n");
	PostOrder(rootID);
	printf("\n");

	return 0;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    ll M = 1;
    while( N > 0 ){
        if(N / 10 == 0){
            break;
        }
        N /= 10;
        M++;
    }
    return M;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}


// ---------------------------------------------

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

    ll ans = 0;
    ll flag = p[0];
    for(ll i=0;i<n;++i){
        if(flag >= p[i]){
            flag = p[i];
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int N, M;
ll dist[100][100];
ll cost[100][100];

void warshall_floyd() {
  for (int k = 0; k < N; k++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        continue;
      dist[i][j] = cost[i][j] = INFLL;
      dist[j][i] = cost[j][i] = INFLL;
    }
  }

  int a, b, c;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    dist[a-1][b-1] = cost[a-1][b-1] = c;
    dist[b-1][a-1] = cost[b-1][a-1] = c;
  }

  warshall_floyd();

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j || cost[i][j] == INFLL)
        continue;
      cnt += (cost[i][j] > dist[i][j]);
    }
  }

  cout << cnt / 2 << endl;
  return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double W, H, X, Y;
    cin >> W >> H >> X >> Y;
    cout << fixed << setprecision(10);
    cout << (W * H) / 2 << ' ';
    if (X == W / 2 && Y == H / 2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    string s;
    cin >> s;
    if(s=="AAA"||s=="BBB"){
        cout << "No" <<endl;
        return 0;
    }
    cout << "Yes" <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

int main(int argc, char** argv)
{
    std::string S;
    std::cin >> S;
    int counter1=0;
    int counter2=0;
    int L = S.length();

    for(int i=0;i<L;i++)
    {
        if(i % 2 ==0)
        {
            if(S.substr(i,1) == "1"){counter1++;}
            if(S.substr(i,1) == "0"){counter2++;}
        }
        else
        {
            if(S.substr(i,1) == "0"){counter1++;}
            if(S.substr(i,1) == "1"){counter2++;}
        }
    }
    int Ans = counter1 < counter2 ? counter1 :counter2;

    std::cout << Ans;
    
    return 0;
}

Measured memory_bytes: 512
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vi(v)        vector<int>v;
#define   vl(v)        vector<ll>v;
#define   vs           vector<string>v
#define   rslt(x)      cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          rslt("YES");
#define   no           cout<<"NO"<<endl;
#define   srt(v)       sort(v.begin(),v.end())
#define   rvs(v)       reverse(v.begin(),v.end());
#define   AR           ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   max          1000007
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
int main()
{

    ll x;
    cin>>x;
    if(x>=30)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(void){
    char input[1001];
    int sum;
    int i;
    
    while(cin >> input){
//    cout << input << endl;
    if(input[0] == '0' && input[1] == '\0') break;
    
    sum = 0;
    for(i = 0; input[i] != '\0'; i++){
        sum += static_cast<int>(input[i] - '0');
    }
    
    cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>

int calc(const std::vector<std::string> &s, size_t &idx, size_t indent=0) {
    if (!(idx < s.size() && indent < s[idx].length()))
        return -1;

    if (isdigit(s[idx][indent]))
        return s[idx++][indent] - '0';

    if (s[idx][indent] == '*') {
        int res=1;
        ++idx;
        while (idx < s.size()) {
            if (indent+2 == s[idx].length()) {
                int tmp=calc(s, idx, indent+1);
                if (tmp < 0) break;

                res *= tmp;
            } else {
                break;
            }
        }

        return res;
    }

    if (s[idx][indent] == '+') {
        int res=0;
        ++idx;
        while (idx < s.size()) {
            if (indent+2 == s[idx].length()) {
                int tmp=calc(s, idx, indent+1);
                if (tmp < 0) break;

                res += tmp;
            } else {
                break;
            }
        }

        return res;
    }

    return -2;
}

int solve_testcase() {
    size_t n;
    scanf("%zu", &n);

    if (n == 0)
        return 1;

    std::vector<std::string> s(n);
    for (size_t i=0; i<n; ++i) {
        char buf[1024];  // enough?
        scanf("%s", buf);
        s[i] = buf;
    }

    size_t idx=0;
    printf("%d\n", calc(s, idx));
    return 0;
}

int main() {
    while (!solve_testcase()) {}

    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    
    ll ans = 0;
    for (ll i = 1;i <= n;i++) {
        ll y = n / i;
        ans += y * (y + 1) * i / 2;
    }

    cout << ans << endl;

    return 0;
}


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

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

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <utility>
#include <iterator>
#include <sstream>
#include <fstream>
#include <functional>
#include <ctime>
#include <cassert>
#include <limits>

using namespace std;

#define SyncFalse ios::sync_with_stdio(0); cin.tie(0)
#define MEM(a, v) memset(a, v, sizeof(a))
#define CLRV(a, sz, v) a.clear(); a.resize(sz, v)
#define CLR(a, sz) a.clear(); a.resize(sz)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.end(), a.begin()
#define MP make_pair
#define FI first
#define SE second
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define SZ(a) (int)a.size()
#define LNG(a) (int)a.length()
#define LPI 3.141592653589793238462643383279502884L
#define SI(n) scanf("%d", &n)
#define SL(n) scanf("%lld", &n)
#define SD(n) scanf("%lf", &n)
#define SLD(n) scanf("%llf", &n)
#define SC(n) scanf(" %c", &n)
#define SS(n) scanf("%s", n)
#define FR(i, n) for (int i = 0; i < n; i++)
#define RFR(i, n) for (int i = n - 1; i >= 0; i--)
#define FR1(i, n) for (int i = 1; i <= n; i++)
#define RFR1(i, n) for (int i = n; i >= 1; i--)
#define FOREACH(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<ld> VLD;
typedef vector<double> VD;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;

const double PI = acos(-1.0);
const double EPS = numeric_limits<double>::epsilon();
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int MOD = (int) 1e9 + 7;

//------------------------------------------------------------------------

int main() {
	int n, m, t = 0;
	SI(n), SI(m);
	MII dp[2];
	dp[t][0] = 0;
	FR(i, n) {
		t ^= 1;
		dp[t].clear();
		int v, w;
		SI(w), SI(v);
		FOREACH(it, dp[t ^ 1]) {
			int va = it->second, wt = it->first;
			dp[t][wt] = max(dp[t][wt], va);
			if (wt + w <= m) {
				dp[t][wt + w] = max(dp[t][wt + w], va + v);
			}
		}
	}
	int ans = 0;
	FOREACH(it, dp[t]) {
		ans = max(ans, it->second);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 2000

void change(char*, char *,int ,int );
int co(char*, char*, int, int);

int main()
{
	char s[MAX];
	char t[MAX];
	char search[MAX];
	int min, c;
	int count = 0;
	int cu=0;

	scanf("%s", s);
	scanf("%s", t);

	if(strcmp(s,t)!=0) {
		min = strlen(s);
		for (int i = 0; i < strlen(s) - strlen(t) + 1; i++) {
			change(search, s, i, strlen(t));
			count = co(search, t, 0, strlen(search));
			if (count < min) 
				min = count;
		}

		count = min;

	}

	printf("%d\n", count);

	return 0;
}

int co(char* search, char* s, int start, int length)
{
	int count = 0;

	for (int i = 0; i < length; i++) {
		if (s[start + i] != search[i])
			count++;
	}

	return count;
}

void change(char* search, char* s,int start,int length)
{
	int i;

	search[0] = '\0';

	for (i = 0; i < length; i++) 
		search[i] = s[start + i];

	search[i] = '\0';

}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N, M; cin >> N >> M;
	if (N == M) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#define N 2000000
int A[N];
int B[N];
int C[N];
main(){
  int i,j,k=0,len;
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];
  }
  for(i=0;i<=k;i++)
    C[i]=0;
  for(i=0; i<len; i++)
    C[A[i]]++;
  for(i=1; i<=k; i++)
    C[i]=C[i]+C[i-1];
  for(j=len; j>=0; j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }  
  for(i=0;i<len;i++){
    printf("%d",B[i]);
    if(i !=len-1)
      printf(" ");
    else
      printf("\n");
  }
  return 0;
  
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, a, b;

bool ask(int a, int b) {
    cout << "? " << a << ' ' << b << endl;
    string ans;
    cin >> ans;
    return ans[0] == 'Y';
}

string ans;

int main() {
    cin >> a >> b;
    if (a <= b) {
        cout << "Impossible" << endl;
        return 0;
    }
    n = a + b;
    vector<int> v;
    forn(i, n) if (v.empty()) {
        v.pb(i);
    } else if (ask(v.back(), i)) {
        v.pb(i);
    } else {
        v.pop_back();
    }
    int cur = v.back();
    ans = string(n, '0');
    ans[cur] = '1';
    forn(i, n) if (i != cur) {
        if (ask(cur, i)) {
            ans[i] = '1';
        }
    }
    cout << "! " << ans << endl;
    return 0;
}


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

int main(){
  ll n;cin >> n;
  vector<ll> a(n+1,1);

  for(ll i=1;i<=n/2;++i){
    for(ll j=i+i;j<=n;j+=i){
      ++a.at(j);
    }
  }
  //for(ll i=1;i<=n;++i) cout << a.at(i) << endl;
  ll ans = 0;
  for(ll i=1;i<=n;++i){
    ans += i*a.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 81412
#include<stdio.h>
#include<string.h>

char a[ 256 ] ,b[ 256 ] ,c[ 256 ] ;
int len_a ,len_b ;

int main()
{
	scanf( "%s %s %s" ,a ,b ,c ) ;

	len_a = strlen( a ) - 1 ;
	len_b = strlen( b ) - 1 ;

	if( a[ len_a ] == b[ 0 ] && b[ len_b ] == c[ 0 ] )
	{
		printf( "YES\n" ) ;
	}
	else
	{
		printf( "NO\n" ) ;
	}

	return 0 ;
}

Measured memory_bytes: 128
#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>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n); rep (i, n) cin >> a[i];
    ll sum = 0;
    map<ll, int> m; m[0]++;
    rep (i, n) {
        sum += a[i]; m[sum]++;
    }
    ll ans = 0;
    for (auto i : m) ans += (ll)i.second * (i.second - 1) / 2LL;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 13568
//{{{
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

int n;
int a[N], b[N];

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> n)
    {
        for (int i = 1; i <= n; ++i) cin >> a[i];
        for (int i = 1; i <= n; ++i) cin >> b[i];

        reverse(b + 1, b + 1 + n);

        int c = -1;
        int l = -1, r = -1;
        for (int i = 1; i <= n; i++)
        {
            if (a[i] == b[i])
            {
                c = a[i];
                l = i;
                break;
            }
        }

        for (int i = n; i >= 1; i--)
        {
            if (a[i] == b[i] && a[i] == c)
            {
                r = i;
                break;
            }
        }

        if (l != -1)
        {
            for (int i = 1; i <= n; i++)
            {
                if (l > r) break;
                if (l <= i && i <= r) continue;
                if (a[i] == c || b[i] == c) continue;
                swap(b[i], b[l]);
                l++;
            }
        }

        if (l != -1 && l <= r)
        {
            // assert(0);
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
            for (int i = 1; i <= n; ++i)
            {
                assert(b[i] != a[i]);
                cout << b[i] << " \n"[i == n];
            }
        }
    }

    return 0;
}

Measured memory_bytes: 5192
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main()
{
  int a,b,c,d;cin>>a>>b>>c>>d;
  string ans = "Yes";
  if(abs(a-b)>d||abs(b-c)>d)ans="No";
  if(abs(a-c)<=d)ans="Yes";
  cout<<ans<<endl;
}

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

int main(){
	int N, T, A;
	cin>>N;
	cin>>T>>A;
	int place;
	double difference;
	for(int i=0;i<N;i++){
		int height ;
		cin>>height;
		double temperature=T-0.006*height;
		if(i==0){
			difference = fabs(temperature-A);
			place = 1;
		}
		if(i!=0 && difference > fabs(temperature-A)){
			difference = fabs(temperature-A);
			place = i+1;
		}
	}
	cout<<place;
	return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        Integer a[] = new Integer[N];
        
        for (int i= 0; i < N ;i++) {
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a, Comparator.reverseOrder());
        
        int A = 0;
        int B = 0;
        
        for (int i = 0; i < N; i+=2) {
            A += a[i];
        }
        
        for (int i = 1; i < N; i+=2) {
            B += a[i];
        }
        
        System.out.println(A - B);
    }
}


Measured memory_bytes: 22608
import heapq
n=int(input())
A=list(map(int,input().split()))
que_left,que_right=[],[]
left,right=[-float("inf")]*(3*n),[float("inf")]*(3*n)
for i in range(n):
    heapq.heappush(que_left,A[i])
    if i==0:
        left[i]=A[i]
    else:
        left[i]=left[i-1]+A[i]
for i in range(n,2*n):
    heapq.heappush(que_left,A[i])
    tmp=heapq.heappop(que_left)
    left[i]=left[i-1]+A[i]-tmp
for i in range(2*n,3*n)[::-1]:
    heapq.heappush(que_right,-A[i])
    if i==3*n-1:
        right[i]=A[i]
    else:
        right[i]=right[i+1]+A[i]
for i in range(n,2*n)[::-1]:
    heapq.heappush(que_right,-A[i])
    tmp=heapq.heappop(que_right)
    right[i]=right[i+1]+A[i]+tmp
ans=-float("inf")
for i in range(n-1,2*n):
    ans=max(ans,left[i]-right[i+1])
print(ans)

Measured memory_bytes: 39488
s = input().strip()
c1,c2 = 0,0
for i in range(len(s)):
  if i % 2 == 0 and s[i] != '0':
    c1 +=1
  if i%2 != 0 and s[i] != '1':
    c1 += 1
for i in range(len(s)):
  if i % 2 != 0 and s[i] != '0':
    c2 +=1
  if i%2 == 0 and s[i] != '1':
    c2 += 1
print(min(c1,c2))

Measured memory_bytes: 3188