akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int n;
	cin >> n;
	REP(i, n + 1){
		if (!(i % 3)){
			if (i) cout << " " << i;
		}
		else {
			string s = to_string(i);
			int len = s.size();
			REP(j, len){
				if (s[j] == '3'){
					cout << " " << i;
					break;
				}
			}
		}
	}
	cout << endl;
}



Measured memory_bytes: 3276
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let (n, k) = (io.read::<usize>(), io.read::<i64>());
    let x = io.readn::<i64>(n);
    let mut ans = 0;
    for x in x.iter() {
        ans += min(x * 2, (x - k).abs() * 2);
    }
    io.writeln(ans);
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2172
#include <stdio.h>

int main(void)
{
  int w, h, n, x, y, a, rx, ry, lx, ly;
  scanf("%d %d %d", &w, &h, &n);

  rx = w; ry = h; lx = 0; ly = 0;
  while(n--){
    scanf("%d %d %d", &x, &y, &a);
    if(a == 1){
      if(x >= lx) lx = x;
    }else if(a == 2){
      if(x <= rx) rx = x;
    }else if(a == 3){
      if(y >= ly) ly = y;
    }else if(a == 4){
      if(y <= ry) ry = y;
    }
    if((rx-lx) < 0 || (ry-ly) < 0){
      printf("0\n");
      return 0;
    }
  }
  printf("%d\n", (ry-ly)*(rx-lx));
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i%2==0){
            if(a%2){
                a--;
            }
            a /= 2;
            b += a;
        }
        else{
            if(b%2){
                b--;
            }
            b /= 2;
            a += b;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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

int main() {
	int D, N; cin >> D >> N;

	int S = 1; for (int i = 0; i < D; i++)
	S *= 100;
	if (N <= 99) {
		cout << S * N << endl;
	}
	else {
		cout << S * 101 << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

int dp[51][51][2525];

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

    int N, A;
    cin >> N >> A;
    vi x(N);
    rep(i, N) cin >> x[i];

    dp[0][0][0] = 1;
    rep(i, N) {
        rep(j, N) {
            rep(k, 2525) {
                dp[i + 1][j][k] += dp[i][j][k];
                if (k - x[i] >= 0) {
                    dp[i + 1][j + 1][k] += dp[i][j][k - x[i]];
                }
            }
        }
    }

    int ans = 0;
    rep2(j, 1, N + 1) {
        ans += dp[N][j][A * j];
    }
    cout << ans << endl;
}


Measured memory_bytes: 50560
while 1:
    try:
        be = float(input())
        sum = be
        for i in range(2, 11):
            if i % 2 == 0:
                be *= 2
                sum += be

            if i % 2 == 1:
                be /= 3
                sum += be
        print(sum)
    except:
        break



Measured memory_bytes: 5576
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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


int solve( int x ){
    if( x == 0 )return 1;
    if( x < 0 )return 0;

    rep(i,6){
        return solve( x - 100 - i );
    }
}

int dp[ 100000 ];
int main(){
    int n;
    cin >> n;

    VEC(int , p , n);
    int res = 0;
    
    rep(i , n-2){
        if( p[i+1] < p[i+2] && p[i+1] > p[i] )res++;
        if( p[i+1] > p[i+2] && p[i+1] < p[i] )res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end
s = gets_s

upcase = ("A".."Z").to_a
downcase = ("a".."z").to_a

if upcase.include?(s)
  puts("A")
else
  puts("a")
end

Measured memory_bytes: 14504
uses math;
var i, n : longint;
    h, dp : array[1..100005] of longint;
const inf = 2000000000;
 
begin
    readln(n);
    for i := 1 to n do 
    begin
        read(h[i]);
        dp[i] := inf;
    end;
    dp[1] := 0;
    for i := 2 to n do
    begin
        dp[i] := min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 2) then dp[i] := min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    end;
    writeln(dp[n]);
end.

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n = 1,x = 1,m = 0;
	while(1){
		cin>>n>>x;
		if(n == 0 && x == 0){
			break;
		}
		for(int a = 1;a <= n;a++){
			for(int b = a;b <= n;b++){
				for(int c = b;c <= n;c++){
					if(a + b + c == x && a != b && b != c && c != a){
						m++;
						break;
					}
				}
			}
		}
		cout<<m<<endl;
		m = 0;
	}
	return 0;
}


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int n,p;

//使用する関数
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 (a > b) { a = b; return 1; }
	return 0;
}

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

	cin >> n;
	int nmin = n + 1;
	int ans = 0;
	REP(i, n) {
		cin >> p;
		if (chmin(nmin, p))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k,sum=0,ar[100][100],b[10000],r,c;
    while(scanf("%d%d",&r,&c)!=EOF)
    {
        for(i=0;i<r;i++)
        {
            for(j=0;j<c;j++)
            {
                cin>>ar[i][j];
            }
        }

        for(i=0;i<c;i++)
        {
            cin>>b[i];
        }
         for(i=0;i<r;i++)
        {
            for(j=0;j<c;j++)
            {
                sum=sum+ar[i][j]*b[j];
            }
                    cout<<sum<<endl;
                    sum=0;

        }
       // cout<<sum<<endl;

    }
}



Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c)
{
    stack<int> S;

    S.push(r);
    color[r] = c;
    while (!S.empty()) {
        int u = S.top(); S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main()
{
    int s, t, m, q;
    int i;

    cin >> n >> m;

    for (i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for (i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8992
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    int n;cin >>n;
    int arr[n];
    fo(s,n){
        cin >> arr[s];
    }
    int cnt = 0,i = 0;
    while(i<n){
        if(i==n-1){
            cout << cnt +1;return 0;
        }
        else if(arr[i+1]==arr[i]){
            ++i;
        }
        else if(arr[i+1]<arr[i]){
            for(int j=i+1;j<n;++j){
                if(j==n-1&&arr[j]<=arr[j-1]){
                    cout << cnt +1;return 0;
                }
                else if(arr[j]<=arr[j-1]){
                    continue;
                }
                else{
                    ++cnt;
                    i = j;break;
                }
            }
        }
        else if(arr[i+1]>arr[i]){
            for(int k=i+1;k<n;++k){
                if(k==n-1&&arr[k]>=arr[k-1]){
                    cout << cnt + 1;return 0;
                }
                else if(arr[k]>=arr[k-1]){
                    continue;
                }
                else{
                    ++cnt;
                    i = k;break;
                }
            }
        }
    }
}

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

int main(){
  int N;
  long long D;
  int cnt = 0;
  cin >> N >> D;
  for (int i=0; i<N; i++){
    long long X,Y;
    cin >> X >> Y;
    if (sqrt(X*X+Y*Y) <= D){
      cnt ++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3680
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


map<int, bool> used;

int main(int argc, const char * argv[]) {
#ifdef __APPLE__
    freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    //freopen("/Users/danya.smelskiy/Documents/Danya/Danya/output.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int x;
    cin >> x;
    used[x] = true;
    int res = 1;
    while (true) {
        ++res;
        if (x % 2 == 0) x /= 2;
        else x = 3 * x + 1;
        if (used[x]) {
            cout << res << '\n';
            return 0;
        }
        used[x] = true;
    }
    return 0;
}



Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter  
from collections import defaultdict
def main():
    n, m = map(int, readline().split())
    cities = []
    for i in range(m):
        p, y = map(int, readline().split())
        cities.append((i+1, p, y))
    cities.sort(key=itemgetter(2))
    dd = defaultdict(int)
    ansdd = defaultdict(str)
    for i in range(m):
        cid, p, y = cities[i]
        dd[p] += 1
        x = dd[p]
        ansdd[cid] = '{:0=6}'.format(p)+'{:0=6}'.format(x)
    for i in range(1, m+1):
        print(ansdd[i])
if __name__ == '__main__':
    main()


Measured memory_bytes: 44160
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

class union_find {
    vector<int> p;
    vector<int> r;
    vector<int> s;

public:
    union_find(int n) {
        p = vector<int>(n);
        r = vector<int>(n);
        s = vector<int>(n);

        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 0;
            s[i] = 1;
        }
    }

    int root(int a) {
        if (p[a] != a) {
            p[a] = this->root(p[a]);
        }

        return p[a];
    }

    void unite(int a, int b) {
        int ra = this->root(a);
        int rb = this->root(b);

        if (ra == rb) {
            return;
        }

        if (r[ra] < r[rb]) {
            p[ra] = rb;
            s[ra] = s[rb] = s[ra] + s[rb];
        } else {
            p[rb] = ra;
            s[ra] = s[rb] = s[ra] + s[rb];

            if (r[ra] == r[rb]) {
                r[ra]++;
            }
        }
    }

    int size(int a) {
        s[a] = s[this->root(a)];
        return s[a];
    }
};

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

    union_find uf(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        uf.unite(a - 1, b - 1);
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        res = max(res, uf.size(i));
    }

    cout << res << endl;
}


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

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define repinv(i, st, n) for (int i = ((n)-1); i >= (st); --i)
#define MEM(a, b) memset(a, b, sizeof(a));
#ifdef LOCAL
#define debug(x) std::cerr << #x << ": " << x << endl
#else
#define debug(x) 860111
#endif
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileIO(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

//mt19937 mrand(random_device{}());
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
pii operator+(const pii&x, const pii&y) { return mp(x.X+y.X, x.Y+y.Y);}
pii operator-(const pii&x, const pii&y) { return mp(x.X-y.X, x.Y-y.Y);}
//INT_MAX, ULLONG_MAX, LLONG_MAX or numeric_limits<int>::min()

inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}

//------------------------------------------------------------------------//
int T;
const int maxn = 2e5+7;
int a, b, m;
int as[maxn];
int bs[maxn];

//check T
void solve()
{
	cin >> a >> b >> m;
	int ma = INT_MAX, mb = INT_MAX;
	rep(i, 1, a+1) cin >> as[i], ma = min(ma, as[i]);
	rep(i, 1, b+1) cin >> bs[i], mb = min(mb, bs[i]);
	int x, y, ci;
	int ans = ma+mb;
	rep(i, 0, m)
	{
		cin >> x >> y >> ci;
		ans = min(ans, as[x]+bs[y]-ci);
	}
	cout << ans << endl;
  return;
}


signed main()
{
  fastIO();
  T = 1;
  //cin >> T; //this
  while(T--) solve();
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int Hamming(int N, char A[], char B[]){
  int i;
  int res = 0;
  for(i=(0);i<(N);i++){
    if(A[i] != B[i]){
      res++;
    }
  }
  return res;
}
int SS;
int TT;
char S[1002];
char T[1002];
int main(){
  int i;
  int res = 1073709056;
  SS = rd(S);
  TT = rd(T);
  for(i=(0);i<(SS-TT+1);i++){
    chmin(res, Hamming(TT, S+i, T));
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200813-1 [beta]

// --- original code ---
// int Hamming(int N, char A[], char B[]){
//   int i, res = 0;
//   rep(i,N) if(A[i] != B[i]) res++;
//   return res;
// }
// 
// int SS, TT;
// char S[1002], T[1002];
// 
// {
//   int res = int_inf;
//   rd(S@SS, T@TT);
//   rep(i,SS-TT+1) res <?= Hamming(TT, S+i, T);
//   wt(res);
// }


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define orta ((bas+son)/2)
#define sol k+k
#define sag k+k+1
#define N 1000005
using namespace std;
typedef long long ll;

ll n, mod, dp[N], ans[N], seg[4*N];
vector < ll > g[N];

void up(ll k, ll bas, ll son, ll x, ll y){
	if(bas == son){
		seg[k] = y;
		return;
	}
	if(x <= orta)
		up(sol, bas, orta, x, y);
	else
		up(sag, orta + 1, son, x, y);
	seg[k] = seg[sol]*seg[sag]%mod;
}

ll qu(ll k, ll bas, ll son, ll x, ll y){
	if(bas >= x and son <= y)
		return seg[k];
	if(bas > y or son < x)
		return 1;
	return qu(sol, bas, orta,x , y)*qu(sag, orta + 1, son, x, y)%mod;
}

void dfs(ll node, ll par, ll ust){
	// cout << node << " -> " << dp[node] << " " << ust << endl;
	ans[node] = dp[node]*( (ust + 1)%mod )%mod;

	for(ll i = 0; i < g[node].size(); i++){
		if(g[node][i] == par){
			up(1, 1, n, i + 1, 1);
			continue;
		}
		up(1, 1, n, i + 1, (dp[g[node][i]] + 1)%mod );
		// cout << "AMK" << node << " -> " << i  << " " << g[node][i]<<  " = " << (dp[g[node][i]] + 1)%mod << endl;
	}
	// cout << qu(1, 1, n, 1, 1) << endl;
	vector < ll > git;
	git.resize((int)g[node].size());
	for(ll i = 0; i < g[node].size(); i++){
		if(g[node][i] == par)
			continue;
		ll sl = qu(1, 1, n, 1, i);
		ll sg = qu(1, 1, n, i + 2, (int)g[node].size());
		// cout << node << " tooo " << g[node][i] << " " << sl << " " << sg << endl;
		git[i] = ((sl*sg%mod)*( (ust + 1)%mod )%mod)%mod;
		// dfs(g[node][i], node, ((sl*sg%mod)*(ust + 1)%mod) );
	}
	for(ll i = 0; i < g[node].size(); i++){
		if(g[node][i] == par)
			continue;
		dfs(g[node][i], node, git[i] );

	}
}

void bul(ll node, ll par){
	dp[node] = 1;
	for(ll i = 0; i < g[node].size(); i++)
		if(g[node][i] != par){
			bul(g[node][i], node);
			dp[node] = dp[node]*( (dp[g[node][i]] + 1)%mod )%mod;
		}
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&n ,&mod);
	for(ll i = 1; i < n; i++){
		ll u, v;
		scanf("%lld %lld",&u ,&v);
		g[u].pb(v);
		g[v].pb(u);
	}
	bul(1, 0);
	dfs(1, 0, 0);
	for(ll i = 1; i <= n; i++)
		printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 44288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
const int INF = 1 << 30;

struct Edge{
    int to;
    int cost;
    int from; // from ????????????????????¨?????????
    Edge(int to, int cost, int from = -1):to(to), cost(cost), from(from) {}
};

using EdgeList = vector<vector<Edge>>;

struct State {
    int index, cost, left;
    bool operator > (const State &r) const { return cost > r.cost; }
};

// O(ElogV)
vector<int> dijkstra(const EdgeList &G, const set<int> &frozen_city, int start, int M) {
    priority_queue<State, vector<State>, greater<State>> que;
    vector<vector<int>> dp(G.size(), vector<int>(M + 1, INF));
    que.push(State{start, 0, M});
    dp[start][M] = 0;
    while(not que.empty()){
        State now = que.top(); que.pop();
        for(Edge e : G[now.index]){
            if(now.left >= e.cost) {
                State nxt = State{ e.to, now.cost + e.cost, now.left - e.cost };
                if(frozen_city.count(e.to)) nxt.left = M;
                if(dp[e.to][nxt.left] > now.cost + e.cost) {
                    dp[e.to][nxt.left] = nxt.cost;
                    que.push(nxt);
                }
            }
        }
    }
    vector<int> dist(G.size(), INF);
    rep(i, G.size()) rep(j, M + 1) {
        set_min(dist[i], dp[i][j] + max(0, dp[i][j] - M));
    }
    return dist;
}

class Solver {
  public:
    bool solve() {
        int N, M, L, K, A, H; cin >> N >> M >> L >> K >> A >> H;
        if(N == 0) return false;
        set<int> froze_city;
        rep(i, L) {
            int a; cin >> a;
            froze_city.insert(a);
        }
        EdgeList E(N);
        rep(i, K) {
            int a, b, c; cin >> a >> b >> c;
            E[a].push_back(Edge(b, c));
            E[b].push_back(Edge(a, c));
        }
        int ans = dijkstra(E, froze_city, A, M)[H];
        if(ans < INF) cout << ans << endl;
        else cout << "Help!" << endl;
        return true;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(Solver().solve());
    return 0;
}

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int n, k;
    int d[110];
    int a[110][110];
    cin >> n >> k;
    rep(i,k){

        cin >> d[i];
        rep(j,d[i]){

            cin >> a[i][j];
        }
    }

    int ans[110] = {0};

    rep(i, k){
        rep(j, d[i]){
            ans[a[i][j]]++;
        }

    }

    int cnt = 0;

    rep(i, n+1){
        if(ans[i] == 0){
            cnt++;
        }
    }

    cout << cnt-1 << endl;



return 0;
}

Measured memory_bytes: 3648
N,K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
for i in range(N):
    P[i] = (P[i] + 1) / 2
P = [0] + P
for i in range(N):
    P[i+1] += P[i]
ans = 0
for i in range(N-K+1):
    tmp = P[i+K] - P[i]
    if tmp > ans:
        ans = tmp
print(ans)

Measured memory_bytes: 24516
#include<iostream>
#include<algorithm>
#include<vector>
 
using namespace std;
 
int main()
{
  string S;
  
  cin >> S;
 
  if(S[0]=='7'||S[1]=='7'||S[2]=='7')
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))

def sell(money,stock,price):
  money += price*stock
  stock = 0
  return money, stock

def buy(money,price):
  stock,money = divmod(money,price)
  return money,stock

money = 1000
stock = 0
for i in range(N):
  money, stock = sell(money,stock,A[i])
  if i<N-1 and A[i]<A[i+1]:
    money, stock = buy(money,A[i])
print(money)

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

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int out = 0;
	out+=(n*(n-1))/2;
	out+=(m*(m-1))/2;
	cout<<out<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;
int x, y, s;
int ans;
int main(){
	while(1){
		cin >> x >> y >> s;
		if(x == 0) return 0;
		ans = 0;
		for(int i=1;i<=s;i++){
			for(int j=1;j<=s;j++){
				if(i+j+i*x/100+j*x/100 == s){
					ans = max(i+j+i*y/100+j*y/100,ans);
				}
			}
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3072
lst = [0] * 5

for i in range(5):
  lst[i] = int(input())

s = 0
for i in range(5):
  s += (lst[i]+9) // 10 * 10
  
ans = s
for i in range(5):
  if lst[i] % 10:
  	ans = min(ans, s-10+lst[i]%10)
  
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
int main(){
    cout << fixed << setprecision(10);
    int n;
    int a,b;
    cin >> n >> a >> b;
    int c1 = 0,c2 = 0,c3 = 0;
    rep(i,n){
        int x;
        cin >> x;
        if(x <= a) c1++;
        else if(x > a && x <= b) c2++;
        else c3++;
    }
    cout << min({c1,c2,c3}) << endl;
    return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

#define forl(i,a,b) for (ll i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin>>n>>k;
    unordered_map <ll,ll> a;
    ll t;
    forl(i,1,n+1) {
        cin>>t;
        a[i] = t;
    }
    map <ll,bool> visited;
    vector <ll> rset;
    if(k<=n) {
        ll j=1;
        forl(i,1,k+1) {
            j = a[j];
        }
        cout<<j<<"\n";
    }
    else {
        ll j=1;
        forl(i,1,k+1) {
            if(!visited[j]) {
                visited[j] = true;
                j = a[j];
            }
            else {
                k -= i;
                t = j;
                j = a[j];
                while(j!=t) {
                    rset.pb(j);
                    j = a[j];
                }
                rset.pb(j);
                k = k % (rset.size());
                cout<<rset[k]<<"\n";
                break;
            }
        }
    }
}

Measured memory_bytes: 22188
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

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

pii l[100005];
int loc[100005];
int xorval[100005];
int par[100005];

int find(int x) {
  return par[x] == x ? x : (par[x] = find(par[x]));
}
bool merge(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return false;
  par[x] = y;
  return true;
}

vector<pii> edges[100005];
int n;
bool seen[100005];
int singular[100005];

set<int> ret;
void dfs(int curr, int par, int parid) {
  assert(!seen[curr]);
  seen[curr] = true;
  for(pii out: edges[curr]) {
    if(out.first == par) continue;
    dfs(out.first, curr, out.second);
  }
  if(xorval[curr]) {
    if(par == -1) {
      if(singular[curr] >= 0) {
        ret.insert(singular[curr]);
        xorval[curr] ^= 1;
        return;
      }
      cout << "-1\n";
      exit(0);
    }
    xorval[curr] ^= 1;
    xorval[par] ^= 1;
    ret.insert(parid);
  }
}

void solve() {
  int m;
  cin >> n >> m;
  for(int i = 1; i <= n; i++) cin >> l[i].first >> l[i].second;
  n++;
  sort(l, l+n);
  loc[0] = l[0].first;
  xorval[0] = l[0].second;
  for(int i = 1; i < n; i++) {
    par[i] = i;
    loc[i] = l[i].first;
    xorval[i] = l[i-1].second ^ l[i].second;
  }
  memset(singular, -1, sizeof(singular));
  for(int i = 1; i <= m; i++) {
    int lhs, rhs;
    cin >> lhs >> rhs;
    int idx = lower_bound(loc, loc+n, lhs) - loc;
    int a = -1;
    int b = -1;
    if(loc[idx] <= rhs && idx < n) {
      assert(idx > 0);
      a = idx;
    }
    idx = upper_bound(loc, loc+n, rhs) - loc;
    idx--;
    if(loc[idx] >= lhs) {
      if(idx + 1 < n) b = idx + 1;
    }
    if(a < 0 && b < 0) continue;
    if(a >= 0 && b >= 0) {
      assert(a != b);
      if(merge(a, b)) {
        edges[a].push_back({b, i});
        edges[b].push_back({a, i});
      }
      continue;
    }
    assert(a >= 0 || b >= 0);
    if(a >= 0) {
      singular[a] = i;
    }
    else {
      singular[b] = i;
    }
  }
  for(int i = 0; i < n; i++) {
    if(!seen[i] && singular[i] >= 0) dfs(i, -1, -1);
  }
  for(int i = 0; i < n; i++) {
    if(!seen[i]) dfs(i, -1, -1);
  }
  cout << sz(ret) << "\n";
  for(auto out: ret) cout << out << " "; cout << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 11392
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N;
    sll(N);
    if(N%1000 == 0){
        cout << 0 <<endl;
    }else{
        cout << 1000 - N % 1000<<endl;
    }

}

int main(){
    Main();
}

Measured memory_bytes: 3256
#include <iostream>

using namespace std;

int main()
{
    int t,x,c=0,ans=1000000000;
    cin>>t;
    while(t--){
        cin>>x;
        c=0;
        while(x%2==0){
            x/=2;
            c++;
        }
        ans=min(c,ans);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n; cin >> n;
	cout<<(n*(n+1))/2;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("op.txt","w",stdout);
    #endif

    ll n;
    cin>>n;
    //ll ar[n];
    map<ll,ll> mp;
    mp[1]=0;
    rep(i,2,n+1)
    {
        ll ele;
        cin>>ele;
        // cin>>ar[i];
        mp[ele]++;
    }
    rep(i,1,n+1)
    {
        cout<<mp[i]<<endl;
    }
}//Goodbye...

Measured memory_bytes: 16164
#import<bits/stdc++.h>
using namespace std;
int i,j,m,n,s,t,u,v,k[11],p[11],b[11][11];
int Y()
{
	int w=0;
	for(j=0;j<k[i];j++)w+=((1<<b[i][j]-1)&s)>0;
	return w%2==p[i];
}
main()
{
	scanf("%d%d",&n,&m);
	for(;i<m;i++)for(scanf("%d",k+i),j=0;j<k[i];j++)scanf("%d",&b[i][j]);
	for(i=0;i<m;i++)scanf("%d",p+i);
	for(t=1<<n;s<t;s++)
	{
		for(i=v=0;i<m;i++)v+=Y();
		u+=v==m;
	}
	printf("%d",u);
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((b1[:, :], i8, i8, i8, i8), cache=True)
def main(wall, Sx, Sy, Tx, Ty):
    INF = 1 << 30
    H, W = wall.shape
    S = Sx * W + Sy
    T = Tx * W + Ty
    dist = np.full(H * W, INF, np.int64)
    deq = np.empty(2 * H * W + 100, np.int64)
    dist[S] = 0
    deq[H * W], l, r = S, H * W, H * W + 1
    while l < r:
        v, l = deq[l], l + 1
        vx, vy = divmod(v, W)
        # そのままあるく
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            wx, wy = vx + dx, vy + dy
            if not (0 <= wx < H):
                continue
            if not (0 <= wy < W):
                continue
            if wall[wx, wy]:
                continue
            w = wx * W + wy
            if dist[w] <= dist[v]:
                continue
            dist[w] = dist[v]
            deq[l - 1], l = w, l - 1
        # ワープする
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                wx, wy = vx + dx, vy + dy
                if not (0 <= wx < H):
                    continue
                if not (0 <= wy < W):
                    continue
                if wall[wx, wy]:
                    continue
                w = wx * W + wy
                if dist[w] <= dist[v] + 1:
                    continue
                dist[w] = dist[v] + 1
                deq[r], r = w, r + 1
    ans = dist[T]
    if ans == INF:
        ans = -1
    return ans

H, W = map(int, readline().split())
Sx, Sy = map(lambda x: int(x) - 1, readline().split())
Tx, Ty = map(lambda x: int(x) - 1, readline().split())
wall = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'#'

print(main(wall, Sx, Sy, Tx, Ty))

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

int main() {

  int N;
  cin >> N;
  
  int ans;
  if( 360 % N == 0){
    ans = 360/N;
  }else{
    int n=1;
    while( N * n % 360 != 0){
      n++;
    }
    ans = n;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3632
#include <stdio.h>
#define REP(i,n) for (int i=0;i<(n);++i)
const int INF = 1e9;

int N;

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

    int digit = N / 100;
    int abc = digit * 100 + digit * 10 + digit;
    if(N > abc) {
        printf("%d\n",(digit+1) * 100 + (digit+1) * 10 + (digit+1));
    } else {
        printf("%d\n",abc);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll> > a(n);  rep(i, 0, n) cin >> a[i].first >> a[i].second;
  sort(all(a));
  
  ll drink = m;
  ll money = 0;
  rep(i, 0, n) {
    if(drink <= a[i].second) {
      money += drink*a[i].first;
      break;
    }
    else {
      money += a[i].first*a[i].second;
      drink -= a[i].second;
    }
  }
  cout << money << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  int k, x, mini, maxi;
  cin >> k >> x;

  mini = max(x - k + 1, -1000000);
  maxi = min(x + k - 1, 1000000);
  for (int i = mini; i <= maxi; i++)
  {
    cout << i << " ";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int res = 0;
    res += min(a, k);
    k -= min(a, k);
    if (k)
        k -= min(b, k);
    if (k)
        res -= min(c, k);
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 3616
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int ans = max(0, C - (A - B));
    cout << ans << endl;
}


Measured memory_bytes: 256
//C - One Quadrillion and One Dalmatians

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	string ans ="";
	while(n>0) {
	   	n--;
	   	ans.insert(ans.begin(), 'a'+n%26);
	   	n /= 26;
	}
	cout<<ans<<endl;
	return 0;
}


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


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

    int temp;
    if (b > a){
        temp = a;
        a = b;
        b = temp;
    }

    while (b != 0){
        return gcd(b, a%b);
    }
}


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

    ll ans = 0;
    rep(i, n) rep(j, n) rep(k, n) ans += gcd(i, gcd(j, k));

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
const double PI=3.14159265358979323846;
 
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)

void changeNum(int& a, int& b) {
	int tmp;
	tmp = a;
	a = b;
	b = tmp;
}

int main() {

	int x, y, z;

	cin >> x >> y >> z;

	changeNum(x, y);
	changeNum(x, z);

	cout << x << ' ' << y << ' ' << z << endl;
}



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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<pair<int, int>> robots(N);
	for (auto& it : robots) { cin >> it.first >> it.second; it.second += it.first; }

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

	vector<int> dp(N+1);
	dp[N] = 1;
	vector<int> furthest(N);
	for (int i = N-1; i >= 0; i--) {
		furthest[i] = i+1;
		while (furthest[i] < N && robots[furthest[i]].first < robots[i].second) {
			furthest[i] = furthest[furthest[i]];
		}
		dp[i] = dp[i+1] + dp[furthest[i]];
		if (dp[i] >= 998244353) dp[i] -= 998244353;
	}
	cout << dp[0] << '\n';

	return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;

// https://atcoder.jp/contests/abc140/tasks/abc140_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();

		int ans = 0;

		for(int i=1;i<=N/2;i++) {
			if(i!=(N-i)) {
				ans = ans + 1;
			}
		}


		System.out.println(ans);

	}
}


Measured memory_bytes: 21972