akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n, m, l, m_a[110][110], m_b[110][110];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m >> l;
    rep(i, 0, n) rep(j, 0, m) cin >> m_a[i][j];
    rep(i, 0, m) rep(j, 0, l) cin >> m_b[i][j];
    rep(i, 0, n) {
        rep(j, 0, l) {
            ll sum = 0;
            rep(k, 0, m) {
                sum += m_a[i][k] * m_b[k][j];
            }
            printf("%lld", sum);
            if (j != l-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;

int N, ans;
int A[220];

int main(){
    scanf("%d", &N);
    for (int i=1; i<=2*N; i++) scanf("%d", &A[i]);
    sort(A+1, A+2*N+1);
    for (int i=1; i<=N; i++) ans += A[2*i-1];
    printf("%d\n", ans);
    return 0;
}


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

const int MAXN = 1000010;

int suffix_one[MAXN];
int suffix_zero[MAXN];

int main() {
	string s;
	cin >> s;
	int suffix_0 = 0;
	int suffix_1 = 0;
	for (int i = s.size(); i > 0; i--) {
		suffix_one[i] = suffix_1;
		suffix_zero[i] = suffix_0;
		if (s[i - 1] == '1') {
			suffix_1++;
			suffix_0--;
		}
		else if (s[i - 1] == '0') {
			suffix_1--;
			suffix_0++;
		}
		else {
			suffix_1--;
			suffix_0--;
		}
		suffix_1 = max(suffix_1, 0);
		suffix_0 = max(suffix_0, 0);
	}
	int left = 0, right = s.size();
	while (left < right) {
		bool flag = true;
		int mid = (left + right) / 2;	
		int allowed_1 = mid;
		int allowed_0 = mid;
		for (int i = 0; flag && i < s.size(); i++) {
			if (s[i] == '1') {
				if (allowed_1 <= 0) {
					flag = false;
				}
				allowed_1--;
				allowed_0++;
			}
			else if (s[i] == '0') {
				if (allowed_0 <= 0) {
					flag = false;
				}
				allowed_1++;
				allowed_0--;
			}
			else {
				int capacity_1 = allowed_1 - suffix_one[i + 1];
				int capacity_0 = allowed_0 - suffix_zero[i + 1];
				if (allowed_1 > 0 && allowed_1 - 1 >= suffix_one[i + 1] && (capacity_1 > capacity_0 || capacity_1 == capacity_0 && allowed_1 > allowed_0)) {
					allowed_1--;
					allowed_0++;
				}
				else if (allowed_0 > 0 && allowed_0 - 1 >= suffix_zero[i + 1]) {
					allowed_1++;
					allowed_0--;
				}
				else {
					flag = false;
					break;
				}
			}
			allowed_1 = min(allowed_1, mid);
			allowed_0 = min(allowed_0, mid);
		}
		if (flag) {
			right = mid;
		}
		else {
			left = mid + 1;
		}
	}
	cout << left << endl;
}

Measured memory_bytes: 11816
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

const P: i64 = 1_000_000_007;

pub fn pow(x: i64, n: i64) -> i64 {
    let (mut x, mut y, mut n) = (x % P, 1_i64, n);
    while n > 0 {
        if n % 2 != 0 {
            y = (y * x) % P;
            n -= 1;
        }

        x = (x * x) % P;
        n /= 2;
    }
    y
}

pub struct ChooseFn {
    fact: Vec<i64>,
    fact_inv: Vec<i64>,
}

impl ChooseFn {
    pub fn new(m: usize) -> Self {
        let mut fact = vec![0; m];
        fact[0] = 1;
        fact[1] = 1;
        for i in 2..m {
            fact[i] = (i as i64) * fact[i - 1] % P;
        }

        let mut fact_inv = vec![0; m];
        fact_inv[m - 1] = pow(fact[m - 1], P - 2);
        for i in (1..m).rev() {
            fact_inv[i - 1] = (i as i64) * fact_inv[i] % P;
        }

        ChooseFn { fact, fact_inv }
    }

    pub fn call(&self, n: usize, r: usize) -> i64 {
        if n < r {
            return 0;
        }

        let mut t = self.fact[n];
        t *= self.fact_inv[n - r];
        t %= P;
        t *= self.fact_inv[r];
        t % P
    }
}

fn main() {
    let mut scan = Scan::new();

    let K = scan.word::<usize>();
    let S = scan.word::<String>();

    let choose = ChooseFn::new(K + S.len() + 1);

    let mut total = 0;

    for k in 0..=K {
        let mut n = pow(26, (K - k) as i64);
        n *= pow(25, k as i64);
        n %= P;
        n *= choose.call(S.len() + k - 1, k);

        total += n % P;
        total %= P;
    }

    println!("{}", total);
}


Measured memory_bytes: 36216
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;

char s[MAXN];
int a[MAXN];

int c(int n,int m){ return (n|m)==n;}

int main(void)
{
	int n;
	scanf("%d%s",&n,s+1);
	for(int i=1; i<=n; ++i) a[i]=s[i]-'1';
	
	bool flag=1;
	for(int i=1; i<=n; ++i)
		if(a[i]==1){ flag=0; break;}
	
	if(flag)
	{
		for(int i=1; i<=n; ++i)
			a[i]>>=1;
	}
	else
	{
		for(int i=1; i<=n; ++i)
			a[i]&=1;
	}
	
	int ans=0;
	for(int i=1; i<=n; ++i)
		ans ^= a[i]&c(n-1,i-1);
	if(flag) ans<<=1;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    ll L,R;
    cin>>L>>R;
    ll ans=2*100100100;
    R=min(R, L+2019);
    for(ll i=L;i<=R;i++){
        for(ll j=i+1;j<=R;j++){
            if(i==j)continue;
            ans=min(ans, (i*j)%2019);
            if(ans==0){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<queue>
#include<vector>

using Weight = long long;
using Vertex = int;
struct Edge {Vertex from, to; Weight weight;};
using Graph = std::vector<std::vector<Edge>>;

// ???????§???????????????? O(|E| + |V| log |V|)
// ????????????????????°????????????????????????
std::vector<Weight> Dijkstra(const Graph& G, Vertex s) {
  std::vector<Weight> d(G.size(), -1);
  std::priority_queue<Edge, std::vector<Edge>, std::function<bool(Edge,Edge)>> q([](Edge lhs, Edge rhs){return lhs.weight > rhs.weight;});
  q.push({s, s, 0});
  while(!q.empty()) {
    auto cur = q.top();
    q.pop();
    if(d[cur.to] != -1) continue;
    d[cur.to] = cur.weight;
    for(const auto& nex: G[cur.to]) if(d[nex.to] == -1) q.push({cur.to, nex.to, cur.weight + nex.weight});
  }
  return d;
}

#include<bits/stdc++.h>
using namespace std;

int main() {
  int V, E, r;
  cin >> V >> E >> r;
  Graph G(V);
  for(int i = 0; i < E; ++i) {
    Vertex s, t; Weight d;
    cin >> s >> t >> d;
    G[s].push_back({s, t, d});
  }
  for(const auto& d: Dijkstra(G, r)) {
    if(d == -1) cout << "INF" << endl;
    else        cout << d << endl;
  }
}

Measured memory_bytes: 21612
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int num[500005];
int main()
{
	int n;
	scanf("%d",&n);
	int i=0;
	if(n==0)
	{
		printf("0");
	}
	else
	{
		while(n)
		{
			if(n%2!=0)
			{
				num[i++]=1;
				n=(n-1)/(-2);
			}
			else
			{
				num[i++]=0;
				n=n/(-2);
			}
		}
		for(int j=i-1;j>=0;j--)
		{
			printf("%d",num[j]);
		}
	}
	return 0;
	

   return 0;
 } 
 



Measured memory_bytes: 256
#include <iostream>

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

  for (int i = 1; i <= 9; ++i) {
    if (N % i == 0 && N / i >= 1 && N / i <= 9) {
      std::cout << "Yes";
      return 0;
    }
  }
  std::cout << "No";
  return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int n;
string s1, s2;
char n1[80], n2[80], sum[80];

int main() {
	scanf("%d", &n);
	rep(i,n) {
		memset(n1, 0, sizeof(n1));
		memset(n2, 0, sizeof(n2));
		memset(sum, 0, sizeof(sum));

		cin>>s1>>s2;
		int l1 = s1.size();
		int l2 = s2.size();
		if(max(l1,l2) > 80) {
			printf("overflow\n");
			continue;
		}

		rep(k,l1) n1[k] = s1[l1-k-1] - '0';
		rep(k,l2) n2[k] = s2[l2-k-1] - '0';

		char a = 0;
		rep(i,80) {
			char c = n1[i] + n2[i] + a;
			a = c / 10;
			sum[i] = c % 10;
		}

		if(a != 0) {
			printf("overflow\n");
			continue;
		}

		bool start = false;
		repd(i,79,0) {
			if(sum[i] != 0) start = true;
			if(!start && sum[i] == 0) continue;
			printf("%d", sum[i]);
		}
		if(!start) printf("0");
		printf("\n");
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

int gcd(int X, int Y) {
	if (X < Y) gcd(Y, X);
	int r;
    if(Y == 0) return X;
	while (r = X % Y) {
		X = Y;
		Y = r;
	}
	return Y;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vector<int> A(N);

    REP(i,N){
        cin >> A[i];
        if(K == A[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    sort ALL(A);
    if(N == 1){
        if(K == A[0]) cout << "POSSIBLE" << endl;
        else cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if(A[N-1] < K){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int I = gcd(A[0],A[1]);
    if(I == 1){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    REP(i,N){
        if(A[i] % I != 0){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if(K % I == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

typedef long long ll;

std::vector<ll> enum_div(ll n)
{
	static std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
  ret.push_back(n);
	return ret;
}

int main() {
  ll N;
  std::cin >> N;

  static std::vector<ll> v = enum_div(N);

  ll ans = 0;
  for(ll x : v) {
    if(x != 1 and N / (x - 1) == N % (x - 1)) ans += x - 1;
  }

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


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

int ndm(int y, int m) {
    if(y%3==0||m%2==1) return 20;
    else return 19;
}

int calc(int y, int m, int d) {
    int days = ndm(y, m) - d;
    for(int i=m+1; i<=10; ++i) days += ndm(y, i);
    for(int i=y+1; i<=999; ++i) days += (i%3)?195:200;
    days++;
    return days;
}

int main()
{
    int n;
    cin >> n;
    rep(i,n) {
        int y, m, d;
        cin >> y >> m >> d;
        cout << calc(y,m,d) << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <stdio.h>
#include <string.h>
#define S 1000000
#define H 12
#define len 14

int find(char *);
int insert(char *);
long long change1(char *);
int change2(char);
int h1(int);
int h2(int);

char array[S][H];

int main()
{

  int n,i;
  char c[len],ord[7];

  for(i=0;i<S;i++){
    array[i][0]='\0';
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",ord,c);

  if(ord[0]=='i'){
    insert(c);
  }
  else{
    if(find(c)){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  }
  return 0;
}

int insert(char c[])
{
  long long key,i,h;
  key=change1(c);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%S;
    if(strcmp(array[h],c)==0) return 1;
    else if(strlen(array[h])==0){
      strcpy(array[h],c);
      return 0;
    }
  }
  return 0;
}

int find(char c[])
{
  long long key,i,h;
  key=change1(c);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%S;
    if(strcmp(array[h],c)==0) return 1;
    else if(strlen(array[h])==0) return 0;
  }
  return 0;
}

long long change1(char c[])
{
  long long point=1,i,sum=0;
  for(i=0;i<strlen(c);i++)
    {
      sum+=point*(change2(c[i]));
      point*=5;
    }
  return sum;
}

int change2(char c)
{
  if(c=='A') return 1;
  else if(c=='C') return 2;
  else if(c=='G') return 3;
  else if(c=='T') return 4;
  else return 0;
}

int h1(int key)
{
  return key%S;
}

int h2(int key)
{
  return 1+(key%(S-1));
}


      

Measured memory_bytes: 12324
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	vector<ll> a(4);
	rep(i, 4) cin >> a[i];
	ll ans = -1e18;
	rep(i, 2) rep(j, 2) ans = max(ans, a[i] * a[j + 2]);
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3648
class UnionFind:
    def __init__(self, n):
        self.ps = [-1] * (n + 1)

    def find(self, x):
        if self.ps[x] < 0:
            return x
        else:
            self.ps[x] = self.find(self.ps[x])
            return self.ps[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.ps[x] > self.ps[y]:
            x, y = y, x
        self.ps[x] += self.ps[y]
        self.ps[y] = x
        return True

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

    def size(self, x):
        x = self.find(x)
        return -self.ps[x]


n, m, k = map(int, input().split())


uf = UnionFind(n)

friends = [0] * (n + 1)
chain = [0] * (n + 1)

for _ in range(m):
    a, b = map(int, input().split())
    friends[a] += 1
    friends[b] += 1
    uf.union(a, b)

for _ in range(k):
    c, d = map(int, input().split())
    if uf.same(c, d):
        friends[c] += 1
        friends[d] += 1

ans = []
for i in range(1, n + 1):
    ans.append(uf.size(i) - friends[i] - 1)

print(*ans)

Measured memory_bytes: 19288
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	int N, M;
	cin >> N >> M;

	vector<int> vk(M);
	vector<vector<int> > vs(M);
	rep(i, M) {
		cin >> vk[i];
		rep(j, vk[i]) {
			int tmp;
			cin >> tmp;
			vs[i].push_back(tmp);
		}
	}

	vector<int> vp(M);
	rep(i, M) cin >> vp[i];

	int npattern = pow(2, N);
	long ans = 0;
	for (int i = 0; i != npattern; ++i) {
		bool bOK = true;
		for (int j = 0; j != M; ++j) {
			int cnt = 0;
			for (int k = 0; k != vs[j].size(); ++k) {
//				int tmp = pow(2, vs[j][k]);
				int tmp2 = pow(2, vs[j][k]-1);
				int comp = i / tmp2;
				comp = comp % 2;
				if (comp == 1) {
					cnt++;
				}
			}
			if (cnt % 2 != vp[j]) {
				bOK = false;
				break;
			}
		}
		if (bOK) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>

#define MAX 100005
P p[MAX];
	
signed main(){
	vector<int> ve[MAX];
	int n,m; cin>>n>>m;
	
	for(int i=0; i<m; i++){
		cin>>p[i].first>>p[i].second;
		ve[p[i].first].push_back(p[i].second);
	}
	
	for(int i=0; i<=n; i++) sort(ve[i].begin(), ve[i].end());
	for(int i=0; i<m; i++){
		int fir=p[i].first,sec=lower_bound(ve[fir].begin(), ve[fir].end(), p[i].second)-ve[fir].begin()+1;
		int a=log10(fir)+1;
		for(int i=0; i<6-a; i++) cout<<0;
		cout<<fir;
		a=log10(sec)+1;
		for(int i=0; i<6-a; i++) cout<<0;
		cout<<sec<<en;
	}
}
	
	
	

Measured memory_bytes: 9088
instr = list(str(input()))
num = int(input())
for i in range(num):
    comm = list(input().split())
    if str(comm[0]) =='replace':
        instr[int(comm[1]):int(comm[2])+1]=str(comm[3])
    elif str(comm[0]) =='reverse':
        instr[int(comm[1]):int(comm[2])+1]=list(reversed(instr[int(comm[1]):int(comm[2])+1]))
    elif str(comm[0]) =='print':
        print("".join(instr[int(comm[1]):int(comm[2])+1]))


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t,x,a[500],tt=0;
    cin>>n;
    k=n-1;set<ll> se;
    for(i=1;i<=sqrt(k);i++)
    {
        if(k%i==0)
        {
            se.insert(i);
            se.insert(k/i);
        }
    }
    for(i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            s=n;
            while(s%i==0&&i!=1)
            {
                s/=i;
            }
            if(s%i==1&&i!=1)
            se.insert(i);

            s=n;
            j=n/i;
            while(s%j==0&&j!=1)
            {
              s/=j;
            }
            if(s%j==1&&j!=1)
            se.insert(j);
        }
    }
    if(*(se.begin())==1)
    se.erase(*se.begin());
    cout<<se.size()<<endl;
    return 0;
}
    

Measured memory_bytes: 256
import collections

N, M = map(int, input().split())
li = []
for i in range(M):
    a, b = map(int, input().split())
    li.append(a)
    li.append(b)

counter = collections.Counter(li)
for i in range(N):
    print(counter[i + 1]) if i + 1 in counter else print(0)


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int getmin(int bit)
{
	return __builtin_ctz(~bit);
}
int getmax(int bit)
{
	return 31-__builtin_clz(~bit&1023);
}

int solve(int* c,int* z,int M,int sum,int bit)
{
	int depth=__builtin_popcount(bit);
	if(depth==M)
		return sum==0;
	
	// } è
	if(sum>0){
		int s=sum,b=bit;
		for(int i=depth;i<M;i++){
			int j=c[i]>0?getmin(b):getmax(b);
			b|=1<<j;
			s+=c[i]*j;
		}
		if(s>0)
			return 0;
	}
	if(sum<0){
		int s=sum,b=bit;
		for(int i=depth;i<M;i++){
			int j=c[i]>0?getmax(b):getmin(b);
			b|=1<<j;
			s+=c[i]*j;
		}
		if(s<0)
			return 0;
	}
	
	int res=0;
	for(int i=z[depth];i<10;i++){
		if(bit&1<<i) continue;
		res+=solve(c,z,M,sum+c[depth]*i,bit|1<<i);
	}
	return res;
}

int main()
{
	int d[9]={1};
	for(int i=1;i<9;i++)
		d[i]=d[i-1]*10;
	
	for(int N;cin>>N,N;){
		string n[12];
		for(int i=0;i<N;i++)
			cin>>n[i];
		
		map<char,int> m;
		for(int i=0;i<N;i++)
			for(int j=0;j<n[i].size();j++)
				if(m.find(n[i][j])==m.end())
					m.insert(make_pair(n[i][j],m.size()));
		int M=m.size();
		
		int c[10]={},z[10]={}; // c:W, z:0ðèÄÄæ¢©Ç¤©
		for(int i=0;i<N;i++){
			if(n[i].size()>1)
				z[m[n[i][0]]]=1;
			reverse(n[i].begin(),n[i].end());
			for(int j=0;j<n[i].size();j++)
				c[m[n[i][j]]]+=i==N-1?-d[j]:d[j];
		}
		
		// WÌâÎlÌ~Å\[g
		for(int i=0;i<M;i++)
			for(int j=M-1;j>i;j--)
				if(abs(c[j-1])<abs(c[j])){
					swap(c[j-1],c[j]);
					swap(z[j-1],z[j]);
				}
		
		cout<<solve(c,z,M,0,0)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 940
N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
f = False
for x in range(101):
    for y in range(101):
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for i in range(N):
            if xyh[i][2] == 0 and H - abs(xyh[i][0]-x) - abs(xyh[i][1]-y) > 0:
                break
            if xyh[i][2] != 0 and H != abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]:
                break
        else:
            f = True
            break
    if f:
        break
print(x,y,H)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"



signed main()
{
    FAST;
    int t;
    t=1;
    
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        vector<pair<int,int>> vect;
        for(i=1;i<=5;i++)
        {
            cin>>temp;
            if(!temp) 
            {
                cout<<i<<endl;
                return 0;
            }
        }
        
        
        
        
    }
        
    
    
    
    
}

Measured memory_bytes: 3640
n, m = gets.chomp.split(" ").map(&:to_i)
divisor = []
i = 1
while i * i <= m
    if m % i == 0 then
        divisor << i
        tmp = m / i
        divisor << tmp if tmp != i
    end
    i += 1
end
divisor.sort!
ans = -1
divisor.each do |e|
    break if m/n < e
    ans = e
end

puts ans

Measured memory_bytes: 3836
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();

		sc.close();
		if( a.equals(b) ){
			System.out.println("H");
		} else {
			System.out.println("D");
		}

	}

}

Measured memory_bytes: 23252
N,M = [int(e) for e in input().split(' ')]
As = [int(e) for e in input().split(' ')]

cnt=0 
epsilon=sum(As)/(4*M)

for Ai in As:
    if Ai >= epsilon:
        cnt += 1

if cnt >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b;
int h, w;
char field[100][100];

int main()
{
	cin >> a >> b;

	for (int i = 0;i < 50;i++)
		for (int j = 0;j < 100;j++) {
			field[i][j] = '#';
		}

	for (int i = 50;i < 100;i++)
		for (int j = 0;j < 100;j++) {
			field[i][j] = '.';
		}

	int r = 0;
	int c = 0;

	for (int k = 1;k < a;k++) {
		field[r][c] = '.';
		c += 2;
		if (c >= 100) {
			r+=2;
			if (r % 2) c = 1;
			else c = 0;
		}
	}

	r = 51;
	c = 0;

	for (int k = 1;k < b;k++) {
		field[r][c] = '#';
		c += 2;
		if (c >= 100) {
			r+=2;
			if (r % 2) c = 1;
			else c = 0;
		}
	}

	cout << 100 << " " << 100 << endl;

	for (int i = 0;i < 100;i++) {
		for (int j = 0;j < 100;j++) {
			cout << field[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h1,m1,h2,m2,k;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        if(s[i]=='?') s[i]='D';
    cout<<s<<endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

bool sosuu(int num) {
	if (num < 2)return false;
	else if (num == 2)return true;
	else if (num % 2 == 0)return false;

	long double b = num;
	long double a = sqrt(b);
	for (int i = 3; i <= a; i += 2) {
		if (num % i == 0)
			return false;
	}
	return true;
}

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

	string S;
	cin >> S;
	int cnt[3] = { 0 };
	REP(i, S.size()) {
		cnt[S[i] - 'a']++;
	}
	int ans = max(cnt[0] - cnt[1], cnt[1] - cnt[2]);
	ans = max(ans, cnt[0] - cnt[2]);
	ans = max(ans, cnt[1] - cnt[0]);
	ans = max(ans, max(cnt[2] - cnt[0], cnt[2] - cnt[1]));

	if (ans > 1) 
		cout << "NO" << endl;
	
	else
		cout << "YES" << endl;
	return 0;
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int X, Y, Z; scanf("%d %d %d", &X, &Y, &Z);
  int ans = (X - Z) / (Y + Z);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

long long inf = 1e9+7;

int main(void){
    long long n;
    cin >> n;
    vector<long long> a(n), b(n), d(n);
    vector<pair<long long, long long>> bridge(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        d[i] = a[i] - b[i];
        bridge[i] = make_pair(a[i] + b[i], i);
    }
    
    sort(bridge.begin(), bridge.end());
    
    long long ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (i % 2 == (n - 1) % 2) ans += a[bridge[i].second];
        else ans -= b[bridge[i].second];
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, k, i, j;
	cin >> n >> k;
	int arr[n + 1], dp[n + 1];
	foe(i, 1, n)
	cin >> arr[i];
	foe(i, 0, n + 1)
	dp[i] = INT_MAX;
	dp[1] = 0;
	dp[2] = abs(arr[2] - arr[1]);
	
	foe(i, 3, n)
	{
		fo(j, max(i - k, 1), i)
		dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
	}
	cout << dp[n];
}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29
int main(){

int n;
cin >> n ;

int a[n],b[n];

for(int i=0;i<n;i++){
cin >> a[i];
b[i]=a[i];
}
sort(b,b+n);
int flag=0;
if(b[n-1]==b[n-2]){
flag=1;
}

if(flag==0){
for(int i=0;i<n;i++){
if(a[i]==b[n-1])cout << b[n-2]<<"\n";
else cout << b[n-1]<<"\n";
}

}else{
for(int i=0;i<n;i++){
cout << b[n-1]<<"\n";
}

}




}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

// [1, n] の範囲の素数を vector に格納して返す
// O(n log log n)
vector<int> Sieve(int n) {
    vector<int> ret;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = false;
    for(int i = 2; i <= n; ++i) {
        if(isPrime[i]) {
            ret.push_back(i);
            for(int j = 2 * i; j <= n; j += i) { isPrime[j] = false; }
        }
    }
    return ret;
}

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

    int N;
    cin >> N;
    auto res = Sieve(100005);
    for(auto& p : res) {
        if(p >= N) {
            printf("%lld\n", p);
            return 0;
        }
    }

    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  vi dist(26,-1);
  for(char a = 'a'; a <= 'z'; a++){
    int cnt = 0;
    rep(i,s.size()){
      if(s[i] == a){
        chmax(dist[a-'a'],cnt);
        cnt = 0;
      }else cnt++;
    }
    chmax(dist[a-'a'],cnt);
  }
  // rep(i,26) cout << char('a'+i) << ":" << dist[i] << endl;
  int ans = 1001001001;
  rep(i,26) chmin(ans,dist[i]);
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3612
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;
vi a;

int main() {
    fastio();

    cin >> n;
    a = vi(n);

    forn(i, n) cin >> a[i];

    ll total = 0;
    for (int i = 1; i < n; i++) {
        int d = max(0, a[i - 1] - a[i]);
        total += d;
        a[i] += d;
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3908
N = int(input())
fbsum = 0
for i in range(1, N+1):
    if i % 15 == 0:
        # print("Fizz Buzz!")
        pass
    elif i % 3 == 0:
        # print("Fizz!")
        pass
    elif i % 5 == 0:
        # print("Buzz!")
        pass
    else:
        # print(i)
        fbsum += i
print(fbsum)


Measured memory_bytes: 9160
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    string s;cin>>s;
    ll ans=0;
    for(ll i=0;i<s.length()/2;++i){
        if(s[i]!=s[s.length()-1-i])++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
A,B,H,M=map(float,input().split())
import math
rad_min =2.0*math.pi*M/60
rad_hour = 2.0*math.pi*H/12.0+math.pi/6.0*M/60.0
rad=abs(rad_min-rad_hour)
l=math.sqrt(A**2+B**2-2.0*A*B*math.cos(rad))
print(l)

Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    string op;
    while(1){
        cin >> a >> op >> b;
        if(op == "+"){
            cout << a + b << endl;
        }else if (op == "-"){
            cout << a - b << endl;
        }else if(op == "*"){
            cout << a * b << endl;
        }else if(op == "/"){
            cout << a / b << endl;
        }else{
            break;
        }
    }
}


Measured memory_bytes: 3160
#include<stdio.h>

int main(){

  int n, max, min, i, a[10000];
  long int sum = 0;
  
  scanf("%d", &n);
  scanf("%d", &a[0]);

  max = a[0];
  min = a[0];
  sum = a[0];
  for ( i = 1; i < n; i++){
    scanf("%d", &a[i]);
    sum = sum + a[i];
    if ( max < a[i] ){
      max = a[i];
    }
    if ( min > a[i] ){
      min = a[i];
    }
  }

  printf("%d %d %ld\n", min, max, sum);

  return 0;
}
  

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

#define FOR(i, n) for(int i=0;i<n;i++)
#define FORM(i, n) for(int i=1;i<=n;i++)
#define ll long long
using namespace std;

const long long mod = 1000000007;

long long pow(long long a, long long b){
    long long ret=1;
    long long apow=a;
    while(b!=0){
        if(b%2==1)
            ret = (ret*apow)%mod;
        apow = (apow*apow)%mod;
        b/=2;
    }
    return ret;
}

long long mult(long long a, long long b){
    return (a*b)%mod;
}

long long divi(long long a, long long b){
    return (a * pow(b, mod-2))%mod;
}

long long nCk(long long n, long long k){
    if(k>n-k)
        return nCk(n, n-k);
    else{
        long long ret = 1;
        for(long long i=0;i<k;i++)
            ret = divi(mult(ret, n-i), i+1);
        return ret;
    }
}

int main(void){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int x, y;
    cin>>x>>y;
    if((2*x-y)%3!=0 or (2*y-x)%3!=0 or 2*x<y or 2*y<x){
        cout<<0;
        return 0;
    }
    int a = (2*x-y)/3, b = (2*y-x)/3;
    cout<<nCk(a+b, a);
}

Measured memory_bytes: 256
import sys

int1 = lambda x: int(x) - 1
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int1, readline().split()))
prn = lambda x: print(*x, sep='\n')

n, k = nm()
m = 64
a = nl()
table = list()
table.append(a)
for _ in range(m-1):
    f = table[-1]
    g = [f[f[i]] for i in range(n)]
    table.append(g)
crt = 0
for i in range(m):
    if k & 1:
        crt = table[i][crt]
    k >>= 1
print(crt + 1)


Measured memory_bytes: 117380
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,w;
	cin>>w>>a>>b;
	if(a<=b+w&&b<=a+w)cout<<0<<endl;
	else cout<<max(b-a-w,a-b-w)<<endl;
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  
    int n = ri();
    cout << (n*(n+1))/2 << endl;
  
  return 0;
}

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int n, f;
    cin >> n >> f;
    if(n <= f)  cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static FastScanner sc = new FastScanner();
    public static void main(String[] args) {
        int n=sc.nextInt();
        int k=sc.nextInt();
         int a[]=new int[n];
         for (int i=0;i<n;i++){
             a[i]=sc.nextInt();
         }
         int min=1,max=(int)1e9+100;
         while (min!=max){
             int mid=(min+max)/2;
             if (possible(mid,a,k)){
                 max=mid;
             }
             else{
                 min=mid+1;
             }
         }
        System.out.println(min);
    }
    static boolean possible(int ans,int a[],int k){
        for (int i:a){
            if (i<=ans)continue;
            k-=(i+ans-1)/ans-1;
        }
        return k>=0;

    }

        static void sortint(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sort(long[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (long i : a) l.add((int) i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

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

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





Measured memory_bytes: 55456
/* RMQ：[0,n-1] について、区間ごとの最小値を管理する構造体
    set(int i, T x), build(): i番目の要素をxにセット。まとめてセグ木を構築する。O(n)
    update(i,x): i 番目の要素を x に更新。O(log(n))
    query(a,b): [a,b) での最小の要素を取得。O(log(n))
    find_rightest(a,b,x): [a,b) で x以下の要素を持つ最右位置を求める。O(log(n))
    find_leftest(a,b,x): [a,b) で x以下の要素を持つ最左位置を求める。O(log(n))
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)

/* RMQ：[0,n-1] について、区間ごとの最小値を管理する構造体
    update(a,b,x): 区間[a,b) の要素を x に更新。O(log(n))
    query(a,b): [a,b) での最小の要素を取得。O(log(n))
*/
template <typename T>
struct RMQ
{
    ll INF = pow(2, 31) - 1;
    int n;
    vector<T> dat, lazy;
    RMQ(int n_) : n(), dat(n_ * 4, INF), lazy(n_ * 4, INF)
    {
        int x = 1;
        while (n_ > x)
            x *= 2;
        n = x;
    }

    /* lazy eval */
    void eval(int k)
    {
        if (lazy[k] == INF)
            return; // 更新するものが無ければ終了
        if (k < n - 1)
        { // 葉でなければ子に伝搬
            lazy[k * 2 + 1] = lazy[k];
            lazy[k * 2 + 2] = lazy[k];
        }
        // 自身を更新
        dat[k] = lazy[k];
        lazy[k] = INF;
    }

    void update(int a, int b, T x, int k, int l, int r)
    {
        eval(k);
        if (a <= l && r <= b)
        { // 完全に内側の時
            lazy[k] = x;
            eval(k);
        }
        else if (a < r && l < b)
        {                                               // 一部区間が被る時
            update(a, b, x, k * 2 + 1, l, (l + r) / 2); // 左の子
            update(a, b, x, k * 2 + 2, (l + r) / 2, r); // 右の子
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(int a, int b, T x) { update(a, b, x, 0, 0, n); }

    T query_sub(int a, int b, int k, int l, int r)
    {
        eval(k);
        if (r <= a || b <= l)
        { // 完全に外側の時
            return INF;
        }
        else if (a <= l && r <= b)
        { // 完全に内側の時
            return dat[k];
        }
        else
        { // 一部区間が被る時
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }

    /* debug */
    inline T operator[](int a) { return query(a, a + 1); }
    void print()
    {
        for (int i = 0; i < 2 * n - 1; ++i)
        {
            cout << (*this)[i];
            if (i != n)
                cout << ",";
        }
        cout << endl;
    }
};
int main()
{
    ll n, q;
    vector<ll> A;

    cin >> n >> q;
    RMQ<ll> data(n);
    rep(i, q)
    {
        int a, b, c;
        cin >> a >> b >> c;
        c++;
        if (a == 1)
        {
            cout << data.query(b, c) << endl;
        }
        else
        {
            ll x;
            cin >> x;
            data.update(b, c, x);
        }
    }
}


Measured memory_bytes: 9176
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

constexpr i64 S(const i64 n) {
  return n == 0 ? 0 : n % 10 + S(n / 10);
}

int main() {
  i64 N;
  std::cin >> N;
  std::cout << (N % S(N) == 0 ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256