akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] q = new int[M][2];
		for (int i = 0; i < M; ++i) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			q[i][0] = A;
			q[i][1] = B;
		}

		Arrays.sort(q, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				if (o1[0] != o2[0])
					return Integer.compare(o1[0], o2[0]);
				else
					return Integer.compare(o1[1], o2[1]);
			}
		});
		long cur = 0, late = Long.MAX_VALUE / 3, time = Long.MAX_VALUE / 3;
		// 左を塗る
		for (int i = 0; i < M; ++i) {
			int j = i;
			while (j + 1 < M && q[j][1] == q[j + 1][1])
				++j;
			if (time <= q[j][0]) {
				late = Long.MAX_VALUE / 3;
			}
			// 左を選択
			long ncur = cur + 1;
			if (time > q[j][0]) {
				ncur = Math.min(ncur, late + 1);
			}
			if (time > q[j][1]) {
				time = q[j][1];
			}
			if (cur < late || (cur == late && time == q[j][1])) {
				time = q[j][1];
				late = cur;
			}
			cur = ncur;
			// 無視
			i = j;
		}
		pw.println(cur);
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 25952
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N = 0
A = []


def set_inputs():
    global N, A
    N = get_int()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    ans = 0
    for a in A:
        while a % 2 == 0:
            a //= 2
            ans += 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4784
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    if K == 1:
        print(0)
    else:
        print(N-K)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstdlib>

#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <tuple>

using namespace std;

using ii = pair < int, int >;
using ti = tuple < int, int, int>;
using lint = long long;

const int N = 2 * 1e5 + 5;

int a[N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		a[x] = i;
	}
	set < int > s1, s2;
	s1.insert(0);
	s1.insert(n + 1);
	s2.insert(0);
	s2.insert(-n - 1);
	lint ans = 0;
	for (int i = 1; i <= n; i++) {
		s1.insert(a[i]);
		s2.insert(-a[i]);
		int up = *s1.lower_bound(a[i] + 1);
		int down = -(*s2.lower_bound(-a[i] + 1));
		lint diff1 = up - a[i];
		lint diff2 = a[i] - down;
		ans = ans + diff1 * diff2 * i;
	}
	printf("%lld\n", ans);
	return 0;
}


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

int main(){
    int k,a,b;cin>>k>>a>>b;
    for(int i=k;i<1001;i+=k){
        if(a<=i && i<=b){cout << "OK" << endl;return 0;}
    }
    cout << "NG" << endl ;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;	

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define test() ll t;cin>>t;for(ll test = 1;test<=t;test++)
#define f first
#define s second
#define pb push_back
#define nl cout<<"\n"
#define MOD(x) ((x%P)+P)%P
#define vec(v) loop(i,0,v.size()) cout<<v[i]<<" "; nl
const int N = 100005;
const ll P = 1000000007;
const double eps = 1e-6;


void addself(ll&a, ll b)
{
	a += b;
	if(a>=P)
		a -= P;
} 
ll dp[1LL<<21] = {};
int main()
{
	fastio();
	
	int n; cin>>n;

	int can[n][n];
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>can[i][j];

	dp[0] = 1;

	for(ll mask=0; mask<((1LL<<n)-1); mask++)
	{
		int a = __builtin_popcount(mask);
		for(ll b=0; b<n; b++)
		{
			if(can[a][b] && !(mask&(1LL<<b)))
				addself(dp[mask^(1LL<<b)], dp[mask]);
		}
		// cout<<dp[mask]<<" ";
	}

	cout<<dp[(1LL<<n)-1],nl;



//	cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
	return 0;
}

Measured memory_bytes: 16640
fn read_one<T : std::str::FromStr>() -> T {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().parse().ok().unwrap()
}

fn main() {
    let input : i32 = read_one();
    let mut answer = 0;
    for i in 1..(input + 1) {
        if (i.to_string().len() % 2) != 0 {
            answer += 1;
        }
    }
    println!("{}", answer);
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	X := nextInt()
	A := nextInt()
	if X < A {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(){
	std::string buf;

	std::getline(std::cin, buf);
 
   for(int i=0;buf[i] != '\0';i++){
     if(i >= 4 && buf[i] == 'e' && buf[i-1] == 'l' && buf[i-2] == 'p' &&
               buf[i-3] == 'p' && buf[i-4] == 'a'){
           buf[i-4] = 'p';
           buf[i-3] = 'e';
           buf[i-2] = 'a';
           buf[i-1] = 'c';
           buf[i] = 'h';
       }else if(i >= 4  && buf[i] == 'h' && buf[i-1] == 'c' && buf[i-2] == 'a' &&
               buf[i-3] == 'e' && buf[i-4] == 'p'){
           buf[i-4] = 'a';
           buf[i-3] = 'p';
           buf[i-2] = 'p';
           buf[i-1] = 'l';
           buf[i] = 'e';
       }
   }
 
   printf("%s\n",buf.c_str());
 
    return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<algorithm>
#include<iomanip>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <new>
#include <cmath>
#include<fstream>
using namespace std;
#define Precision(i) cout << fixed << setprecision(i)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
const ll N = 1e5 + 100, MOD = 1e9 + 7, INF = 1e17, SQ = 350, LOG = 20;
ll n, m, x1, x2, d, z , t, sum,y, maxi,mini, ans, ptr, x, q, a[N], b[N], k;
map <ll, int> mp;
int main()  
{
	//ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		mp[a[i]] = i % 2;
	}
	for (int i = 0; i < n; i++)
	{
		if (mp[b[i]] != i % 2) ans++;
	}
	cout << ans / 2;
}


Measured memory_bytes: 8192
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vll cnt(n,1) ;
	vb red(n,false) ;
	red.at(0) = true ;
	for(int i=0;i<m;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		cnt.at(a)-- ;
		cnt.at(b)++ ;
		if(red.at(a)){
			red.at(b) = true ;
			if(cnt.at(a)==0) red.at(a) = false ;
		}
	}
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		if(cnt.at(i)>0&&red.at(i)) ans++ ;
	}
	cout << ans << endl ;
}


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

using namespace std;

int exgcd(int a, int b, int &x, int &y) {
	if(b == 0) {
		x = 1; y = 0; 
		return a; 
	}
	int dx, dy; 
	int d = exgcd(b, a%b, dx, dy);
	x = dy;
	y = dx - (a/b) * dy; 
	return d; 
}

bool check(int ans, int a, int b) {
	int x, y; 
	int d = exgcd(a, b, x, y);
	if(ans % d != 0) return 0; 
	x = x * ans / d; 
	y = y * ans / d; 
	int D = a * b / d; 
	x = (x % (D / a) + (D / a)) % (D / a);
	y = (ans - x * a) / b; 
	return x >= 0 && y >= 0; 
}

int main() {
	
	int a, b, c, d, e, f, fm, fz; 
	
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f); 
	
	fm = fz = 0; 
	for(int i=100; i<=f; i+=100)
		if(check(i/100, a, b)) 
			for(int j=0; j<=f-i; ++j) 
				if(check(j, c, d)) {
					if(fz == 0 && fm == 0) { fz = j; fm = (i+j); continue; }
					if(100 * j > i * e) continue; 
					if((i+j) * fz >= j * fm) continue; 
					fz = j; 
					fm = (i+j); 
					
				}	 
	
	printf("%d %d\n", fm, fz);  
	
	return 0; 
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,j,k) for(int i=(int)j;i<=(int)k;i++)
#define per(i,j,k) for(int i=(int)j;i>=(int)k;i--)
using namespace std;
typedef long long LL;
const int N=510000;
char a[N];int n;
int fail[N];
int df[N];
int pre(int x){
    if(!fail[x])return 1;
    return x%(x-fail[x])>0;
}
int suf(int x){
    if(!df[x])return 1;
    return x%(x-df[x])>0;
}
int main(){
    scanf("%s",a+1);
    n=strlen(a+1);
    rep(i,2,n){
        int x=fail[i-1];
        while(x&&a[x+1]!=a[i])x=fail[x];
        if(a[x+1]==a[i])fail[i]=x+1;
    }
    rep(i,2,n){
        int x=df[i-1];
        while(x&&a[n+1-x-1]!=a[n+1-i])x=df[x];
        if(a[n+1-x-1]==a[n+1-i])df[i]=x+1;
    }
    if(fail[n]&&(n%(n-fail[n])==0)){
        if(n-fail[n]==1){
            printf("%d\n%d\n",n,1);
        }
        else{
            printf("2\n");
            int ans=0;
            rep(i,1,n-1)if(pre(i)&&suf(n-i))++ans;
            printf("%d\n",ans);
        }
    }
    else printf("1\n1\n");
    return 0;
}






Measured memory_bytes: 4736
def num(x):
	if x == 1:
		return 2
	elif x == 2:
		return 5
	elif x == 3:
		return 5
	elif x == 4:
		return 4
	elif x == 5:
		return 5
	elif x == 6:
		return 6
	elif x == 7:
		return 3
	elif x == 8:
		return 7
	elif x == 9:
		return 6

n, m = map(int, input().split())
a = list(map(int, input().split()))

num_to_dig = [0 for _ in range(9)]
for i in a:
	num_to_dig[num(i)] = max(num_to_dig[num(i)], i)

dp = [-float("inf")] * (n+1)
dp[0] = 0
for i in range(1, n+1):
	for j in range(9):
		if num_to_dig[j] > 0 and i >= j:
			dp[i] = max(dp[i], dp[i-j] * 10 + num_to_dig[j])
print(dp[n])

Measured memory_bytes: 14412
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll a,b;cin>>a>>b;
	cout<<max(a-2*b,0ll);
}

Measured memory_bytes: 256
N=parse(readline())
function get_num(N)
  for i in 1:1:sqrt(N)
    if N%i==0
      global a = i
    end
  end
  return a
end

a=get_num(N)
b=div(N,a)
a=Int64(a)
b=Int64(b)
println((a-1)+(b-1))


Measured memory_bytes: 113988
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<unordered_set>
#include<string.h>
#include<unordered_map>
#include<numeric>
#include <iomanip>
#include<string.h>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FOR(i,N) for(int i=0;i<N;i++)

ll mod=1e9+7;


int main() {
    string s;
    cin>>s;
    if(s.substr(0,4)=="YAKI"){
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, C;
    cin >> N >> C;
    vector<int> s(N), t(N), c(N);
    vector<vector<ll>> A(C, vector<ll>(pow(10, 5) + 10));
    vector<ll> B(pow(10, 5) + 10);
    rep(i, N) {
        cin >> s[i] >> t[i] >> c[i];
        c[i]--, s[i]--, t[i]--;
        A[c[i]][s[i]]++;
        A[c[i]][t[i]]--;
    }

    ll ans = 0;

    rep(i, pow(10, 5) + 9) {
        rep(j, C) {
            if (A[j][i] == 1)
                B[i]++;
            if (A[j][i] == -1)
                B[i + 1]--;
        }
    }

    rep(i, B.size() - 1) {
        B[i + 1] += B[i];
        ans = max(ans, B[i + 1]);
    }

    cout << ans << endl;
}

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b;

  a = a+b;
  
  if(a < 24){
    printf("%d\n", a);
  }
  else printf("%d\n", a-24);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    rep(i,N)cin>>A.at(i);

    int count = 0;
    rep(i,N){
        if((i+1)%2==1 && A.at(i)%2==1){
            count++;
        }

    }
    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  string s="Christmas";
  rep(i,25-n) s+=" Eve";
  pr(s);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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


using LL = long long int;

LL get_times(LL min_val, const std::vector<int>& v) {
    LL sum = 0;
    for (int i=0; i<v.size(); ++i) {
        sum += v.end() - lower_bound(v.begin(), v.end(), min_val-v[i]);
    }

    return sum;
}

LL score(LL min_val, const std::vector<int>& v, const LL& m) {
    LL used = 0;
    std::vector<LL> rui(v.size()+1,0);
    for (int i=v.size()-1; i>=0; --i) {
        rui[i] = rui[i+1] + v[i];
    }
    LL sum = 0;
    for (int i=0; i<v.size(); ++i) {
        int l = lower_bound(v.begin(), v.end(), min_val-v[i]) - v.begin();
        int num = v.end() - lower_bound(v.begin(), v.end(), min_val-v[i]);
        sum += rui[l] + (LL)v[i]*num;
        used += num;
    }

    return sum -(used - m)*min_val;
}

signed main(){
    LL n,m;
    std::cin>>n>>m;
    std::vector<int> v;

    for (int i=0; i<n; ++i) {
        int tmp;
        std::cin >> tmp;
        v.emplace_back(tmp);
    }

    std::sort(v.begin(), v.end());

    LL l = 0, r = 300000;
    while( r-l>1 ){
        LL mid = (r+l)/2;

        LL times = get_times(mid, v);
        if (times < m) {
            r = mid;
        }else{
            l = mid;
        }
    }

    std::cout << score(l, v, m) << std::endl;

}


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

int main(){
    string s;
    cin >> s;
    int t=0;
    for (int i=1;i<s.size();i++){
        if (s.at(i)==s.at(i-1)) t=1;
    }
    if (t==1) cout << "Bad" << endl;
    else cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

int N;
int c;

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		int a;
		scanf("%d" , &a);
		c += a % 2;
	}
	printf("%s\n" , c % 2 == 0 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <stdio.h>
#include <fstream>
#include <time.h>
using namespace std;
const double PI = 3.14159265358979323846;

struct UnionFind {
    vector<int> parent;

    UnionFind(int N) : parent(N) {
        for (int i = 0; i < N; i++) {
            parent[i] = -1;
        }
    }

    int root(int i) {
        if (parent[i] < 0) {
            return i;
        }
        return (parent[i] = root(parent[i]));
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx != ry) {
            parent[ry] += parent[rx];
            parent[rx] = ry;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int treeSize(int x) {
        

        return -parent[root(x)];
    }
};

int main() {


    int N, M, K;
    cin >> N >> M >> K;
    auto unionFind = UnionFind(N);

    vector<int> notSuggestList(N);


    for (int i = 0; i < M; i++) {
        int A, B;
        scanf("%d %d", &A, &B);
        //cin >> A >> B;
        A--;
        B--;
        unionFind.unite(A, B);
        notSuggestList[A]++;
        notSuggestList[B]++;
    }


    for (int i = 0; i < K; i++) {
        int C, D;
        scanf("%d %d", &C, &D);
        //cin >> C >> D;
        C--;
        D--;
        if (unionFind.same(C, D)) {
            notSuggestList[C]++;
            notSuggestList[D]++;
        }
    }


    printf("%d", unionFind.treeSize(0) - notSuggestList[0] - 1);
    for (int i = 1; i < N; i++) {
        printf(" %d", unionFind.treeSize(i) - notSuggestList[i] - 1);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<string>S(N);
  for(int i=0;i<N;i++){
    vector<char>C(10);
    string A; cin>>A;
    for(int j=0;j<10;j++)C[j]=A.at(j);
    sort(C.begin(),C.end());
    for(int j=0;j<10;j++)A.at(j)=C[j];
    S[i]=A;
  }
  sort(S.begin(),S.end());
  long long ans=0;
  int count=1;
  for(int i=1;i<N;i++){
    if(S[i]==S[i-1]){ans+=count;count++;}
    else count=1;
  }
  cout<<ans<<endl;
}

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

int main() {
    long long int A, B, N;
    cin >> N >> A >> B;

    if (A != B && N == 1) {
        cout << 0 << endl;
    } else if (B < A) {
        cout << 0 << endl;
    } else {
        cout << ( A + B * ( N - 1 ) ) - ( A * ( N - 1 ) + B - 1) << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
	int n;

	cin >> n;

	int A[n];
	int left;
	int right;
	int mid;
	int answer;

	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	int q;
	cin >> q;
	int k;

	for (int i = 0; i < q; i++) {
		cin >> k;
		answer = 0;
		left = 0;
		right = n;

		while (left <= right) {
			mid = (left + right) / 2;
			if (A[mid] == k) {
				answer = 1;
				break;
			}
			else if (A[mid] < k) {
				left = mid + 1;
			}
			else {
				right = mid - 1;
			}
		}
		cout << answer << endl;	
	}
}


Measured memory_bytes: 3488
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

bool valid(vi& v)
{
  for (int i = 1; i < 10; i++) {
    if (v[i] > 4)
      return false;
  }
  return true;
}

bool zero(vi& v)
{
  for (int i = 1; i < 10; i++) {
    if (v[i]) return false;
  }
  return true;
}

bool check(vi& v)
{
  if (zero(v))
    return true;
  for (int i = 1; i < 10; i++) {
    if (v[i] >= 3) {
      v[i] -=3;
      if (check(v))
        return true;
      v[i] +=3;
    }
  }
  for (int i = 1; i <= 7; i++) {
    if (v[i] && v[i+1] && v[i+2]) {
      v[i]--; v[i+1]--; v[i+2]--;
      if (check(v))
        return true;
      v[i]++; v[i+1]++; v[i+2]++;
    }
  }
  return false;
}

void Puzzle(vi& v)
{
  vi res;
  for (int i = 1; i < 10; i++) {
    vi u(10, 0);
    u[i]++;
    for (auto ii : v) {
      u[ii]++;
    }
    if (!valid(u))
      continue;
    for (int j = 1; j < 10; j++) {
      if (u[j] < 2)
        continue;
      u[j] -= 2;
      if (check(u)) {
        res.pb(i);
        break;
      }
      u[j] += 2;
    }
  }
  if (sz(res)) {
    rep (i, sz(res)) {
      cout << (i?" ":"") << res[i];
    }
    cout << endl;
  } else {
    cout << 0 << endl;
  }
}

vi s2vi(string& s)
{
  vi v;
  for (auto& c : s) {
    v.pb(c - '0');
  }
  return v;
}

int main(int argc, char **argv)
{
  string s;
  while (getline(cin, s)) {
    vi v = s2vi(s);
    Puzzle(v);
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  rep2(i, 1, 1e4) {
    ll k = a * i;
    if(k % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

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

int main() {
    int a, b;
    while (~scanf("%d%d", &a, &b)) {
        int c = b-a;
        int aa = c*(c-1)/2;
        int bb = (c+1)*c/2;
        if (bb - b == aa-a) {
            printf("%d\n", aa-a);
        } else {
            int lo = 1;
            int hi = c;
            while (lo < hi) {
                int mid = (lo+hi) / 2;
                if (mid*(mid-1)/2+c < b) {
                    lo = mid+1;
                } else if (mid*(mid-1)/2+c == b) {
                    break;
                } else {
                    hi = mid-1;
                }
            }
            printf("%d\n", lo*(lo+1)/2-a);
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#define INF 10000000
using namespace std;
typedef pair<int,int> p;
vector<int> V[101];
int cost[101];

void dijkstra(int s,int d,int v1) {
  priority_queue<p,vector<p>, greater<p> > que;
  for(int i=0;i<101;i++) {
    cost[i] = INF;
  }
  cost[s] = 1;
  que.push(p(0,s));

  while(!que.empty()) {
    p v = que.top();que.pop();
    int P = v.second;
    if(cost[P] < v.first) continue;
    for(unsigned int i=0;i<V[P].size();i++) {
      int to = V[P][i];
      if(cost[to] > cost[P] + 1) {
        cost[to] = cost[P] + 1;
        que.push(p(cost[to],to));
      }
    }
  }
  if(v1 - cost[d] >= 0)
    cout << cost[d] << endl;
  else
    cout << "NA" << endl;
}

int main() {
  int n,t,k,r,p,s,d,v;
  string str;
  while(cin >> n) {

    for(int i=0;i<n;i++) {
      cin >> r >> k;
      for(int j=0;j<k;j++) {
        cin >> t;
        V[r].push_back(t);
      }
    }

    cin >> p;
    for(int i=0;i<p;i++) {
      cin >> s >> d >> v;
      dijkstra(s,d,v);
    }
  }
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int maxm=1e5+10;
int to[maxm<<1],beg[maxm<<1],nex[maxm<<1],col[maxn][2];
int e=0;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
inline void add(int x,int y){
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
}
void dfs(int x,bool p){
	int i;
	col[x][p]=1;
	for(i=beg[x];i;i=nex[i])
		if(!col[to[i]][p^1])
			dfs(to[i],p^1);
}
int main(){
	int i,j,k,m,n;
	n=read();m=read();
	for(i=1;i<=m;i++){
		int x,y;
		x=read();y=read();
		add(x,y);add(y,x);
	}
	dfs(1,0);
	int cnt0,cnt1,cnt2;
	cnt0=cnt1=cnt2=0;
	for(i=1;i<=n;i++){
		if(col[i][0] && col[i][1])cnt0++;
		else if(col[i][0])cnt1++;
		else if(col[i][1])cnt2++;
	}
	ll ans=1ll*(1ll*cnt1*cnt2+1ll*cnt0*cnt2+1ll*cnt0*cnt1+1ll*cnt0*(cnt0-1)/2-m);
	printf("%lld\n",ans);
	return 0;
}

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

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        M: usize,
        A: [chars; N],
        B: [chars; M],
    }
    let len = N-M+1;
    for i in 0..len{
        for j in 0..len{
            let mut ans = true;
            for ii in 0..M{
                for jj in 0..M{
                    if A[i+ii][j+jj] != B[ii][jj]{
                        ans = false;
                    }
                }
            }
            if ans{
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    string mat[n];
    for (int i = 0;i<n;i++)
        cin >> mat[i];

    long long dp[n][m];
    dp[0][0]=1;

    for (int i = 1;i<m;i++)
        if (mat[0][i]=='#')
            dp [0][i]=0;
        else
            dp[0][i]=dp[0][i-1];

    for (int i = 1;i<n;i++){
        if (mat[i][0]=='#')
            dp [i][0]=0;
        else
            dp[i][0]=dp[i-1][0];
    }

    for (int i = 1;i<n;i++)
        for (int j = 1;j<m;j++){
            if (mat[i][j]=='#')
                dp [i][j]=0;
            else
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007 ;
        }
    cout << dp[n-1][m-1];
}



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

int main(){
    ll N, L;
    cin >> N >> L;
    ll sum = 0;
    rep(i, 1, N+1) sum += L + i -1;
    ll diff = 1e18, pos = 1;
    rep(i, 1, N+1){
        if(diff > abs(L + i -1)){
            diff = abs(L + i -1);
            if(L + i -1 < 0) pos = -1; 
        }
    }
    cout << sum - pos * diff << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    
    count = 0

    flag = True
    while flag:
        flag = False
        for j in range(n-1, 0, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                flag = True
                count += 1
    
    print(*a)
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5608
n = gets.to_i
h = gets.split.map(&:to_i)

(1..(n-1)).each do |i|
  if h[i-1] > h[i]
    puts 'No'
    exit
  end
  if h[i] > h[i-1]
    h[i] -= 1
  end
end

puts 'Yes'

Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int N;
	long long int dp[100001][2];
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	dp[0][0] = 0;
	dp[0][1] = numeric_limits<long long int>::min() / 2; //what's this.
	for (int i = 0; i < N; i++)
	{
		dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i]);
		dp[i+1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i]);
	}
	cout << dp[N][0] << endl;
	return 0;
}

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

int main(){
  int N, M, score, max_score=0, str_exist;
  string b;
  cin >> N;
  vector<string> b_card(N), list;
  rep(i,N){
    cin >> b;
    b_card.at(i) = b;
    str_exist = 0;
    rep(j,list.size()){
      if (list.at(j) == b) {str_exist = 1;break;}
    }
    if (str_exist == 0) list.push_back(b);  
  }
  cin >> M;
  vector<string> r_card(M);
  rep(i,M){cin >> r_card.at(i);}

  rep(i,list.size()){
    b = list.at(i);
    score=0;
    rep(j,b_card.size()){if(b_card.at(j) == b) score++;}
    rep(j,r_card.size()){if(r_card.at(j) == b) score--;}
    if(score > max_score) max_score = score;
  }
  cout << max_score << endl;  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string S , T ;
    int cnt = 0 ;
    cin >> S >> T ;
    int sz = S.size();
    for(int i = 0 ; i < sz ; ++i)
    {
        if(S[i] != T[i])
            cnt++;
    }
    cout << cnt ;
    return 0;
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin >> b;
  if(b == "A"){
  	cout << "T" << endl;
  }
  else if(b == "T"){
    cout << "A" << endl;
  }
  else if(b == "G"){
    cout << "C" << endl;
  }
  else if(b == "C"){
    cout << "G" << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  for(int i = 0; i < n; i++){
    while(a[i] % 2 == 0){
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3668
N = int(input())

ans = 0

def mkdivisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

for i in range(1, N+1):
    if i % 2 != 0:
        if len(mkdivisors(i))==8:
            ans += 1
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<limits.h>
#include <stdlib.h>
#include<string.h>
#include<stdbool.h>

#define		BUILDINGS	(4)
#define		FLOOR		(3)
#define		ROOMS		(10)

void printApartment(void);
void ApartInOut(int b,int f,int r,int v);

static int Apart[BUILDINGS][FLOOR][ROOMS]={0};

int main(){
	int n=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int b,f,r,v;
		b=f=r=v=0;
		scanf("\n%d %d %d %d",&b,&f,&r,&v);
		ApartInOut(b,f,r,v);
	}
	printApartment();
	return 0;
}

void printApartment(void){
	for(int i=0;i<BUILDINGS;i++){
		for(int j=0;j<FLOOR;j++){
			for(int k=0;k<ROOMS;k++){
				printf(" %d",Apart[i][j][k]);
			}
			puts("");
		}
		if(i+1!=BUILDINGS)puts("####################");
	}
}
void ApartInOut(int b,int f,int r,int v){
	Apart[--b][--f][--r]+=v;
}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;

const int maxn = 1100;
ll X[maxn]; ll Y[maxn]; int N;
ll ABS(ll x) { return (x >= 0) ? x : -x; }
ll d[50];

void solve(int k,int pos)
{
	ll XX = X[k]; ll YY = Y[k];
	ll x = 0; ll y = 0;
	for (int i = pos - 1; i >= 0; i--)
	{
		if (ABS(XX - x) > ABS(YY - y))
		{
			if (XX > x) { cout << 'R'; x += d[i]; }
			else if (XX < x) { cout << 'L'; x -= d[i]; }
		}
		else if(ABS(XX-x)<ABS(YY-y))
		{
			if (YY > y) { cout << 'U'; y += d[i]; }
			else if (YY < y) { cout << 'D'; y -= d[i]; }
		}
		else
		{
			if (XX >= x) { cout << 'R'; x += d[i]; }
			else if (XX < x) { cout << 'L'; x -= d[i]; }
		}
	}
	cout << endl;
}

int main()
{
	cin >> N;
	int flag0 = 0; int flag1 = 0; ll pmax = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> X[i] >> Y[i];
		if ((X[i] + Y[i]) % 2 == 0)flag0 = 1;
		else flag1 = 1;
		pmax = max(pmax, ABS(X[i]) + ABS(Y[i]));
	}
	if (flag0 == 1 && flag1 == 1)
	{
		cout << -1 << endl;
		return 0;
	}
	ll sum = 0; int pos = 0;
	if (flag0 == 1) { d[pos++] = 1; sum += 1; }
	for (ll k = 0; k < 50; k++)
	{
		sum += (1 << k);
		d[pos++] = (1 << k);
		if (sum >= pmax)break;
	}
	cout << pos << endl;
	for (int i = pos - 1; i >= 0; i--)
		cout << d[i] << ' ';
	cout << endl;
	
	for (int i = 1; i <= N; i++)
		solve(i, pos);
	return 0;
}

Measured memory_bytes: 888
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = -1;
    for(int t = 1; t <= 1000; t++) {
      int c = (((int)8 * t) / (int)100);
      int d = (((int)10 * t) / (int)100);
      if((a == c) && (b == d)) {
        ans = t;
        break;
      }
    }
    System.out.println(ans);
  }
}

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

typedef long long int ll;

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

    ll A, B, K, i;

    cin >> A >> B >> K;

    if (K > A) {
        K = K - A;
        A = 0;
        
        if (K > B) {
            B = 0; 
        }
        else {
            B = B - K;
        }
    }
    else {
        A = A - K;
    }

    cout << A << " " << B << '\n';
    
    return 0;
}


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

namespace ABC_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long c = 0;
            foreach (long i in a)
            {
                long t = i;
                while (t % 2 == 0)
                {
                    t /= 2;
                    c++;
                }
            }

            Console.WriteLine(c);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vi a(n);
    cin>>a;
    deque<int> b;
    REP(i,n) {
        if(i%2==0) {
            b.push_back(a[i]);
        }
        else {
            b.push_front(a[i]);
        }
    }
    if(n%2==1) reverse(ALL(b));
    REP(i,n) {
        cout<<b[i];
        if(i!=n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}


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

int main(){
  int n,m,i,j,k;
  cin>>n;
  double x[n];
  string u[n];
  for(i=0;i<n;i++){
    cin>>x[i];
    cin>>u[i];
  }
  double sum=0;
  for(i=0;i<n;i++){
    if(u[i]=="JPY")sum+=x[i];
    else sum+=380000*x[i];
  }
  printf("%.10lf",sum);
}

Measured memory_bytes: 256
INF=float("inf")
def c2i(c): return ord(c)-ord("a")

def main():
    S=list(map(c2i, input()))
    N=len(S)
    T=list(map(c2i, input()))
    S*=2
    Next=[[INF]*26 for _ in range(N*2)]
    for i in range(N*2-2,-1,-1):
        for j in range(26):
            Next[i][j] = 1 if S[i%N]==j else Next[i+1][j]+1
    ans=0
    i=0
    for t in T:
        x=Next[i][t]
        if x==INF:
            print(-1)
            exit()
        i+=x
        i%=N
        ans+=x
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
	int n, m;
	std::cin >> n >> m;
	std::vector<int> vec;
	for(int i=1;i<=n*2;i++)
		vec.push_back(i);
	for(int i=0;i<m;i++){
		int k;
		std::cin >> k;
		std::vector<int> _vec = vec;
		if(k > 0){
			for(int i=0;i<n*2;i++){
				int index;
				if(i < 2*n-k)
					index = k + i;
				else
					index = i - (n*2 - k);
				vec[i] = _vec[index];
			}
		}else{
			if(n == 1){
				vec[0] = _vec[1];
				vec[1] = _vec[0];
			}else{
				for(int i=0;i<n*2;i++){
					int index;
					if(i % 2 == 0)
						index = i / 2;
					else{
						index = n + (i - 1) / 2;
					}
					vec[i] = _vec[index];
				}
			}
		}
	}
	for(int i=0;i<n*2;i++)
		std::cout << vec[i] << std::endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
# define    all(a)              a.begin(), a.end()
#define forn(i, a, b) for (int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD int(1e9+7)
using namespace std;

typedef long long int ll;

bool cmp(int a, int b) {
    return a < b;
}

void printV(vector<int> nums) {
    for (int i: nums) {
        printf("%d ", i);// << " ";
    }
    printf("\n");
}

// void printV(vector<ll> nums) {
//     for (ll i: nums) {
//         printf("%lld ", i);// << " ";
//     }
//     printf("\n");
// }



int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

bool valid(int i, int j, int n, int m) {
    if (i >= 0 && i < n && j >=0 && j < m)
        return true;
    else 
        return false;
}

int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    ll res = 0;
    // set<pair<int, int>> pr;
    for (int i=1; i<=n-1; i++) {
        for (int j=1; j*j<=i; j++) {
            if (i%j == 0) {
                int x = i/j;
                if (x!=j)
                    res++;
                res++;
                // pr.insert(mp(i, j));
                // pr.insert(mp(j, i));
            }
        }
    }
    // cout << pr.size() << endl;
    cout << res << endl;
    return 0;
}      

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N =  1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(8);
  }
}IO;

int32_t main(){
 int h, a;
 cin >> h >> a;
 cout << (h + a - 1) / a << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl
using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    a[0] = -1;
    for (int i = 1; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }
    // A_i is the parent of i
    int b[n] = {0};
    for (int i = 1; i < n; ++i) {
        b[a[i]]++;
    }
    for (int i = 0; i < n; ++i)
        cout << b[i] << "\n";

}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T;
    T = 1;
    // cin >> T;
    for (int t = 1; t <= T; t++){
        // cout << "Case #" << t << ": ";
        solve();
    }
	return 0;
}


Measured memory_bytes: 4772
#include <iostream>
#include <cmath>

#define SIZE 200000

// OMG OMG OMG OMG 
using namespace std;

int main() {
    unsigned long long int A,C,D,i,j,k,N,M,K,Q,X,dix;
    double B,B2;
  //  long long int A[100][100];

 cin >> A >> B;

if ((A == 0) || (B == 0))
  cout << 0 << endl;
else {
 B2 = round(B*100);
 C = A*(unsigned long long int) B2;
 D = C/100;

 cout << D << endl;
}
  return 0;

}

Measured memory_bytes: 3776
#include<iostream>
using namespace std;
long ans;
string s,t="";
long calc(const string&t)
{
	long ret=0,a=0;
	for(int i=0;i<t.size();i++)
	{
		if(t[i]=='A')a++;
		else ret+=a;
	}
	return ret;
}
main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A')t+='A';
		else if(i+1<s.size()&&s[i]=='B'&&s[i+1]=='C')t+='B',i++;
		else ans+=calc(t),t="";
	}
	cout<<ans+calc(t)<<endl;
}


Measured memory_bytes: 776