akhauriyash/Code-Regression huggingface dataset:
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter, Binary};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

fn main() {
    loop {
        let_all!(d: usize, e: f64);
        if d == 0 {
            return
        }
        let mut min_diff = std::f64::MAX;
        for i in 0 .. d {
            let diff = (((i * i + (d - i) * (d - i)) as f64).sqrt() - e).abs();
            if diff < min_diff {
                min_diff = diff;
            }
        }
        println!("{:.*}", 10, min_diff);
    }
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, t;
    cin >> n >> t;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());

    vector<int> d(t, INT_MIN); // d[i] = max вкусность ко времени i
    d[0] = 0;

    int res = 0;
    for (int i = 0; i < n; i++) {
        //d[j + a] = max(d[j + a], d[j] + b)
        for (int j = t - 1; j >= 0; j--) {
            if (d[j] == INT_MIN) continue;
            int aa = a[i].first;
            int bb = a[i].second;
            res = max(res, d[j] + bb);
            if (j + aa < t) {
                d[j + aa] = max(d[j + aa], d[j] + bb);
            }
        }
    }
    cout << res;

    return 0;
}

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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int lcost=0, rcost=0;
  for(int i=0; i<m; i++){
    int tmp;
    cin >> tmp;
    if(tmp<x)lcost++;
    else rcost++;
  }
  cout << min(lcost, rcost);
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
num = 0
for i in range(1, 10):
    for j in range(10):
        for k in range(10):
            x = 10000 * i + 1000 * j + 100 * k + 10 * j + i
            if a <= x <= b:
                num += 1
print(num)

Measured memory_bytes: 3060
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	s = '$' + s;
	vvint vv;
	initvv(vv, s.size(), 26);
	vint pre(26,-1);
	for(int i=s.size()-1; i>=0; i--){
		vv[i] = pre;
		if(i) pre[s[i]-'a'] = i;
	}
	vint p(s.size(),-1);
	vint now(1,0);
	string ans;
	while(1){
		vint next;
		for(int x: now){
			rep(i,26){
				if(vv[x][i]==-1){
					ans += char(i+'a');
					// cout<<x<<" "<<i<<" "<<vv[x][i]<<endl;
					int pos = x;
					while(pos>=0){
						ans += s[pos];
						pos = p[pos];
					}
					reverse(ALL(ans));
					// cout<<ans<<endl;
					cout<<ans.substr(1)<<endl;
					return;
				}
				else{
					if(p[vv[x][i]]>=0) continue;
					p[vv[x][i]] = x;
					next.PB(vv[x][i]);
				}
			}
		}
		now = next;
	}
	cout<<"hoge"<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 27856
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> l(n);
    rep(i, n)cin >> l[i];
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                int a[3] = {l[i], l[j], l[k]};
                sort(a, a+3);
                if(a[0] != a[1] && a[1] != a[2] && a[0]+a[1] > a[2])ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c + max(a, max(b, c)) * 9 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin >>k;
  int a,b;
  cin >> a >> b;
  for(int i = a;i <= b;i++){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(c - (a - b) <= 0){
		cout << 0 << endl;
	}else{
		cout << c - (a - b) << endl;
	}
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {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 a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    vi a(n);
    vi b(n-1);
    a[0]=1E6;
    FOR(i,n-1)cin>>b[i];
    FOR(i,n-1){
        a[i]=min(a[i],b[i]);
        a[i+1]=b[i];
    }
    int ans=a[0];
    for(int i=1;i<n;++i) ans += a[i];
    cout << ans;

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

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

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

char arr[105][105];
int col[105], row[105];
int main() {
    //freopen("262144.in","r",stdin);
    //freopen("262144.out","w",stdout);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> arr[i][j];
        }
    }
    for (int i = 1; i <= n; i++) {
        int ok = 1;
        for (int j = 1; j <= m; j++) {
            if (arr[i][j] == '#') {
                ok = 0;
                break;
            }
        }
        if (ok == 1) {
            col[i] = 1;
        }
    }
    for (int i = 1; i <= m; i++) {
        int ok = 1;
        for (int j = 1; j <= n; j++) {
            if (arr[j][i] == '#') {
                ok = 0;break;
            }
        }
        if (ok == 1) {
            row[i] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        if (col[i] == 1) continue;
        for (int j = 1; j <= m; j++) {
            if (row[j] == 1) continue;
            cout << arr[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	vector<int> a(n);
	vector<string> s(n);
	fo(i,n)
	{
		// string s;
		cin>>s[i];
		cin>>a[i];
	}
	int ans=0;
	string x;
	cin>>x;
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]==x)
			break;
		ans+=a[i];
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 256
N, M = map(int, input().split())  # N軒の店舗, M本欲しい
# 1本Ai円のドリンクをBi本まで買うことができる
ans = 0

# shop_list = [list(map(int, input().split())) for _ in range(N)]

# print(shop_list)

shop_list = []
for _ in range(N):
    hoge = {}
    A, B = map(int, input().split())
    hoge['price'] = A
    hoge['amount'] = B
    shop_list.append(hoge)
    hoge = {}

shop_list.sort(key=lambda x: x['price'])
# print(shop_list)
quontity = 0
money = 0
for i in range(N):
    money += shop_list[i]['price']*shop_list[i]['amount']
    # print('money = ', money)
    quontity += shop_list[i]['amount']
    # print('quontity = ', quontity)
    if quontity >= M:
        money -= shop_list[i]['price']*(quontity-M)
        break

print(money)


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

int main(){
    int n,ma=0,ans=0;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p.at(i);
    }
    ma=p.at(0);
    for(int i=0;i<n;i++){
        if(ma>=p.at(i)){
            ans++;
        }
        ma=(min(ma,p.at(i)));
    }
    cout << ans << endl;
    
}

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


int main(){   
    int a,b,c;
    cin >> a >> b >> c;
    if(a-b==0){
        if(a != c) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else if(a-c==0){
        if(b != a) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else if(b-c==0){
        if(a != b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else cout << "No" << endl;
}


Measured memory_bytes: 256
n = gets.to_i
w = gets.chomp.split.map(&:to_i)
all_sum = w.inject(&:+)
part_sum = 0
ans = 0xffffffff

0.upto(w.size - 2) do |i|
  part_sum += w[i]
  ans = [ans, (all_sum - 2 * part_sum).abs].min
end

puts ans

Measured memory_bytes: 3836
import sys
input = sys.stdin.readline

from math import *
# from collections import deque

def linput(_t=int):
    return list(map(_t, input().split()))

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():

    A,B,H,M = linput()
    # res = 0
    # print(N)

    ta = M / 60 * 2 * pi
    tb = (H * 60 + M) / (12 * 60) * 2 * pi

    xa = A * sin(ta)
    ya = A * cos(ta)

    xb = B * sin(tb)
    yb = B * cos(tb)

    res = sqrt((xa-xb)**2 + (ya-yb)**2)

    print("{:.14f}" .format(res))
    # print(res)
    # print(("No","Yes")[res%2])


main()


Measured memory_bytes: 9420
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    string s[n];
    set<string> cnt;
    for(int i=0;i<n;i++){
        cin >> s[i];
        cnt.insert(s[i]);
    }
    if(cnt.size()<n){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(s[i].back()!=s[i+1].front()){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string n;
int main() {
	cin>>n;
	int len=n.size();
	for(int i=0; i<len; i++)
		if(n[i]=='C') {
			int j=i+1;
			while(j<len)
				if(n[j++]=='F') {
					cout<<"Yes"<<endl;
					return 0;
				}
		}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
k = int(input())

def rec(d, n, array):
    array.append(n)

    if d == 10:
        return
    
    for i in [-1, 0, 1]:
        add = n % 10 + i
        if 0 <= add <= 9:
            rec(d + 1, 10 * n + add, array)


array = []
for i in range(1, 10):
    rec(1, i, array)

s_array = sorted(array)
ans = s_array[k - 1]
print(ans)

Measured memory_bytes: 84144
d,g = list(map(int,input().split()))
lis = []
for i in range(d):
    lis.append(list(map(int,input().split())))
ans = 10000000
for bit in range(2**d):
    price = 0
    count = 0
    use = [0]* d
    for j in range(d):
        if (bit >> j) & 1:
            use[d-1-j] = 1
    for i in range(d):
        if use[i] == 1:
            if price < g:
                price += (i+1)*100*lis[i][0] + lis[i][1]
                count += lis[i][0]
    if price < g:

        for k in reversed(range(d)):
            if use[k] == 0:
                for m in range(lis[k][0]):
                    if price < g:
                        price += (k+1)*100
                        count += 1

    if count < ans:
        ans = count

print(ans)



Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
void solve(){
    int x;
    cin >> x;
    while(true){
        bool ck = false;
        bool ans = false;
        if(x == 1 || x == 2){
            cout << 2 << endl;
            break;
        }
        for(int i = 2; i < sqrt(x) + 1; i++){
            if(x % i == 0){
                ck = true;
                break;
            }
            if(i > sqrt(x)){
                ans = true;
                break;
            }
        }
        if(ck){
            x++;
            continue;
        }
        if(ans){
            cout << x << endl;
            break;
        }
    }
}

int main(){
    solve();
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Iterator;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		long[] NK = readLineLong();
		long N = NK[0];
		long K = NK[1];
		print(Math.min(N%K,(N%K-K)*(-1)));
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static long[] readLineLong(){
		try{
			String[] s = readLine();
			long[] ints = new long[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Long.parseLong(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 21588
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
long long x,y;
int main(){
	cin>>x>>y;
	if(x==1||y==1)return cout<<1,0;
	if(x*y%2==0)cout<<x*y/2;
	else cout<<(x*y+1)/2;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int,input().split())))
L = []
for i in range(N-1):
    if A[i] == A[i+1]:
        L.append(A[i])
        A[i]=0
        A[i+1]=0
    
if len(L)<=1:
    print(0)
else:
    print(L[-1]*L[-2])

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int T,A,B,x;
  cin >> T >> A >> B;
  if(A * T >= B){
    x = B;
    cout << x << endl;
  }else if(A * T < B){
    x = A * T;
    cout << x << endl;}
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<ll,ll> ii;

ll  f[40][40][40][40];
ll  h[40][40][40][40];

int adj[40][40];

ii  cal(int a,int b,int c,int d)    {
    if (a > b && c > d)
        return  ii(1,1);
    if (a > b)  return  ii(0,0);
    if (c > d)  return  ii(0,0);

    ll &F = f[a][b][c][d];
    ll &H = h[a][b][c][d];

    if (F >= 0) return  ii(F,H);

    F = 0;
    H = 0;

    for(int i = a ; i <= b ; ++i)
    for(int j = c ; j <= d ; ++j)
        F += cal(a,i - 1,i + 1,b).Y * cal(c,j - 1,j + 1,d).Y * adj[i][j];

    for(int i = a ; i <= b ; ++i)
    for(int j = c ; j <= d ; ++j)
        H += cal(a,i,j,d).X * cal(i + 1,b,c,j - 1).Y;

    return  ii(F,H);
}

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

    int n;  cin >> n;   n *= 2;

    for(int i = 0 ; i < n ; ++i)
    for(int j = 0 ; j < n ; ++j)    {
        char x; cin >> x;
        adj[i][j] = x - '0';
    }

    memset(f,-1,sizeof f);
    memset(h,-1,sizeof h);

    ll  ans = 0;

    for(int i = 1 ; i < n ; ++i)    if (adj[0][i])
        ans += cal(1,i - 1,i + 1,n - 1).Y;

    cout << ans << endl;
}

Measured memory_bytes: 40320
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int R, G;
    cin >> R >> G;

    cout << 2*G-R << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 12;
const int M = 1e3;

int n;
int m;
int cost[M];
int unlocks[M];
int mem[M][1 << N];

int go(int idx , int mask){
    if(mask == (1 << n) - 1)
        return 0;
    if(idx == m)
        return 1e9;
    if(~mem[idx][mask])
        return mem[idx][mask];
    int mn = go(idx + 1 , mask);
    mn = min(mn , go(idx + 1 , mask | unlocks[idx]) + cost[idx]);
    return mem[idx][mask] = mn;
}

int main(){
    scanf("%d%d" , &n , &m);
    for(int i = 0; i < m; i++){
        int x;
        scanf("%d%d" , &cost[i] , &x);
        int mask = 0;
        for(int j = 0; j < x; j++){
            int y;
            scanf("%d" , &y);
            y--;
            mask ^= 1 << y;
        }
        unlocks[i] = mask;
    }
    memset(mem , -1 , sizeof mem);
    int ans = go(0 , 0);
    if(ans >= 1e9){
        puts("-1");
    } else {
        printf("%d\n" , ans);
    }
}

Measured memory_bytes: 16384
#include<iostream>
#include<cstdio>
using namespace std;
int a[200005],b[200005];
int main()
{
	int n,m,x,y,j=1,k=1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		if(x==1) a[y]=1;
		if(y==n) b[x]=1;
	}
	for(int i=1;i<=n;i++)
	 {
	 	if(a[i]&&b[i])
	 	{
	 		printf("POSSIBLE");
	 		return 0;
	 	}
	 }
	printf("IMPOSSIBLE");
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2000+10,INF=0x3f3f3f3f,dx[]={1,1},dy[]={-1,1};
int a,b,n;
int main()
{
    while(~scanf("%d%d%d",&n,&a,&b)){
        int sum=0;
        for(int i=1;i<=n;i++){
            int x=i,sam=0;
            while(x){
                sam+=(x%10);
                x/=10;
            }
            if(sam>=a&&sam<=b){
                sum+=i;
            }
        }
        printf("%d\n",sum);
    }

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int cnt[10][10]={};
  for(Int i=1;i<=n;i++){
    string s=to_string(i);
    cnt[s.front()-'0'][s.back()-'0']++;
  }

  Int ans=0;
  for(Int i=0;i<10;i++)
    for(Int j=0;j<10;j++)
      ans+=cnt[i][j]*cnt[j][i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
x,y,z = map(int,input().split())

n = int(x/(y+z))
res = 0
total = 0
for i in range(n):
    if i  ==  0:
        total += z*2+y
    else:
        total += z+y
    if total <= x:
        res += 1
    else:
        break
print(res)

Measured memory_bytes: 38512
N=int(input())
S=input()
L=[[0 for j in range(10)]for i in range(N+1)]
R=[[0 for j in range(10)]for i in range(N+1)]
for i in range(N):
    for j in range(10):
        L[i+1][j]=L[i][j]
    L[i+1][int(S[i])]=1
for i in range(N-1,-1,-1):
    for j in range(10):
        R[i][j]=R[i+1][j]
    R[i][int(S[i])]=1
ans=[[[0 for k in range(10)]for j in range(10)] for i in range(10)]
num=[0 for k in range(10)]
for t in range(N):
    X=[]
    Y=[]
    k=int(S[t])
    if num[k]==100:
        continue
    for x in range(10):
        if L[t][x]==1:
            X.append(x)
    for y in range(10):
        if R[t+1][y]==1:
            Y.append(y)
    for i in X:
        for j in Y:
            if ans[i][j][k]==0:
                ans[i][j][k]=1
                num[k]+=1
print(sum(num))


Measured memory_bytes: 15732
import itertools

def seven_five_five(n):
    s = list(str(n))
    len_s = len(s)
    semi_753 = []
    for j in range(3,len_s+1):
        for i in itertools.product(['3','5','7'],repeat=j):
            l = ''.join(i)
            #print l
            semi_753.append(l)

    target = [i for i in semi_753 if int(i) > 356 and int(i) <= n]
    #print target
    count = 0
    for i in target:
        v = str(i)
        flag = [False,False,False]
        for j in list(v):
            if j == '7':
                flag[0] = True
            elif j == '5':
                flag[1] = True
            elif j == '3':
                flag[2] = True
            else:
                break

            if flag[0] and flag[1] and flag[2]:
                #print i
                count += 1
                break
    print count
if __name__ == '__main__':
    n =  int(raw_input())
    seven_five_five(n)

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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,k; cin>>n>>m>>k;
    int a=__gcd(n,m);
    for(int i=a;i>=1;i--)
    {
        if(a%i==0)
        k--;
        if(k==0)
        {
            cout<<i;
            break;
        }
        
    }
    return 0;
}


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

int main() {
  int A, B; cin >> A >> B;
  int i;

  for (i = 1; i < 1250; i++) {
    int a = i * 8 / 100;
    int b = i * 10 / 100;
    if (a == A && b == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<int> divisors(n + 1);
    for(int i=1; i <= n; i++) {
        for(int j=i; j <= n; j+=i) {
            divisors[j]++;
        }
    }
    ll res = 0;
    for(int i=1; i <= n; i++) {
        res += ((ll) i * divisors[i]);
    }
    cout << res;
}

Measured memory_bytes: 42340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin() , v.end()
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)

#define n 10000001
bool markd[n] ;
vector<ll>v ;
void sieve()
{
    ll i , j ;
    for(i = 2 ; i < n ; i+=2)
    {
        if(i > 2) markd[i] = 1 ;
    }
    for(i = 3 ; i * i < n ; i+=2)
    {
        if(markd[i] != 1)
        {
            for(j = i * i ; j < n ; j = j + i + i)
            {
                markd[j] = 1 ;
            }
        }
    }
    for(i = 2 ; i < n ; i++)
    {
        if(markd[i] != 1)
        {
            v.pb(i) ;
        }
    }
}

int main()
{
    fast;
    sieve() ;
    ll s ;
    cin >> s ;
    auto it = lower_bound(all(v) , s) ;
    if(it != v.end())
    {
        cout << *it << "\n" ;
    }

    return 0;
}


Measured memory_bytes: 20332
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

double P,E,T;
double rec(int K,double L,double R){
    double H = (L+R)/2;
    if(K == 0){
        return (double)(abs(T-H)<E);
    }
    if(R < T-E || T+E < L){
        return 0;
    }else if(T-E<=L && R <= T+E){
        return 1;
    }
    if(H <= T){
        return P * rec(K-1,L,H) + (1-P)*rec(K-1,H,R);
    }else{
        return (1-P) * rec(K-1,L,H) + P *rec(K-1,H,R);

    }
}
template<class Type>
Type solve(Type res = Type()){
    int K; double R,L;
    cin >> K >> L >> R;
    cin >> P >> E >> T;
    res = rec(K,L,R);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}



Measured memory_bytes: 3296
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B, C;
  cin>>A>>B>>C;
  bool ans = false;
  for(int i=1;i<=B;++i){
    if(i*A%B==C) ans = true;
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
    int n,k,x,y,i,l=0;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(k>n) i=n*x;
    else i=k*x;
    if(n-k > 0) l=(n-k)*y;
    printf("%d",i+l);
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  ll n; cin >> n;
  vl a(n); ina(a,n);
  ll ans = 0;
  if (a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  REP(i,1,n) {
    if (a[i] - a[i-1] > 1) {
      cout << -1 << endl;
      return 0;
    }
    ans += (a[i]==a[i-1]+1) ? 1 : a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    input! {
    a:usize,
    c:[usize;a],
    }
    let mut b=[0;1000000];
    for i in 0..a {
        b[c[i]]+=1;
        b[c[i]+1]+=1;
        b[c[i]+2]+=1;
    }
    println!("{}",b.iter().max().unwrap())
}

Measured memory_bytes: 7244
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
  int q,t,x;
  string k;
  map<string,int,less<>> a;

  cin >> q;
  for (int i = 0; i < q; i++){
    cin >> t;
    cin >> k;
    auto itr = a.find(k);
    if (t == 0){
      cin >> x;
      if (itr == a.end()){
        a.insert(make_pair(k, x));
      }else{
        a[itr->first]=x;
      }
    }else if(t == 1){
      if (itr != a.end()){
        cout << itr->second << endl;
      }else{
        cout << "0" << endl;
      }
    }else{
      a.erase(k);
    }
  }

  return 0;
}



Measured memory_bytes: 27832
#include<stdio.h>
#include<string.h>
typedef struct i{char f[21];int s,w;} i;
i g[10];
int n,t[10],f[10],ans[10],max;
void rec(int d)
{
	int i,w=0,G=0;
	if(d==n)
	{
		for(i=0;i<n;i++)
		{
			if(w>g[t[i]].s)
				return;
			w+=g[t[i]].w;
			G+=g[t[i]].w*(i+1);
		}
		if(max<G)
		{
			max=G;
			memcpy(ans,t,40);
		}
	}
	else
	{
		for(i=0;i<n;i++)
		{
			if(!f[i])
			{
				f[i]=1;
				t[d]=i;
				rec(d+1);
				f[i]=0;
			}
		}
	}
}

int main()
{
	int i;
	for(;;)
	{
		memset(ans,0,40);
		memset(f,0,40);
		max=0;
		scanf("%d",&n);
		if(!n)
			return 0;
		for(i=0;i<n;i++)
			scanf("%s %d%d",g[i].f,&g[i].w,&g[i].s);
		rec(0);
		while(-- n>=0)
			puts(g[ans[n]].f);
	}
	return 0;
}

Measured memory_bytes: 1012
import sys
from collections import deque
from collections import  Counter
import statistics
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
s = input()
c = Counter(s)
li = list(c.keys())
ans = -1
for i in range(n-1):
    ct = 0
    for c in li:
        if c in s[:i+1] and c in s[i+1:]:
            ct += 1
    ans = max(ans, ct)
print(ans)


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

int cnt = 0;
void Selection_sort(int a[], int n){
	for(int i = 0; i < n-1; i++){
		int min = i;
		for(int j = i+1; j < n; j++)
		{
			if(a[j] < a[min]){
				min = j;
			}
		}
		int t = a[i]; a[i] = a[min]; a[min] = t;
		if(min != i)	cnt++;
	}
}
int main()
{
	int a[101], n;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	Selection_sort(a, n);
	for(int j = 0; j < n; j++){
		if(j)
			cout<<" "<<a[j];
		else
			cout<<a[j];
	}
	cout<<endl<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var X = cin.ReadDoubleArray(4);
            var dx = X[2] - X[0];
            var dy = X[3] - X[1];
            Console.WriteLine(Math.Sqrt(dx * dx + dy * dy));
        }
        
    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



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

int main(){
    while(true){
        int n, x, a, i, j, k;
        a = 0;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        
        for(i = 0; i < n; i++){
            for(j = 0; j < i; j++){
                for(k = 0; k < j; k++){
                    if(i + j + k == x-3) a = a + 1;
                }
            }
        }
        cout << a << endl;
    }
}


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

#define SZ(x) ((int(x.size())))

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 100*1000+10;
int n, x[maxn], y[maxn], t, T, X, Y;
bool bad;

int ABS (int a)
{
	if (a < 0)
		return -a;
	return a;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t >> x[i] >> y[i];
		if (ABS (x[i] - X) + ABS (y[i] - Y) > t - T || ((t - T - ABS (x[i] - X) - ABS (y[i] - Y)) & 1))
			bad = 1;
		X = x[i];
		Y = y[i];
		T = t;
	}
	if (bad)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long sum = 0;
        for(int i = 1; i <= n; i++){
            if(i % 3 != 0 && i % 5 != 0){
                sum += i;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 35876
#include<iostream>
#include<vector>

using namespace std;

class UnionFind{

private:
    vector<int> rank,p;

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

  public:
      UnionFind(){};
      UnionFind(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i = 0; i < size; i++){
          makeSet(i);
        }
      }

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

    void unite(int x, int y){
      link(find(x), find(y));
    }

    int find(int x){
      if(x != p[x]) p[x] = find(p[x]);
      return p[x];
    }

private:
    void link(int x, int y){
      if(rank[x] > rank[y]){
        p[y] = x;
      }else{
        p[x] = y;
        if(rank[x] == rank[y]) rank[y]++;
      }
    }

};

int main(){
    int n, a, b, q;
    int t;

    cin >> n >> q;
    UnionFind uf = UnionFind(n);

    for(int i = 0; i < q; i++){
      cin >> t >> a >> b;
      if(t == 0){
        uf.unite(a,b);
      }else{
        if(uf.same(a,b))cout << 1 << endl;
        else cout << 0 << endl;
      }
    }
    return 0;
}



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

int main(){
string S;
  cin >> S;
  
  int count =0;
  for(int i=0;i<3;i++){
      if(S.at(i)=='o'){
      count++; 
       }
  }

  cout << 700 + count*100 <<endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		int x = sc.nextInt();
		int y = sc.nextInt();

		if ((x + y) % 3 != 0) {
			System.out.println(0);
			return;
		}

		int n = (2 * y - x) / 3;
		int m = y - 2 * n;

		if (n < 0 || m < 0) {
			System.out.println(0);
			return;
		}

		long[] fac = new long[n + m + 1];
		fac[0] = 1;
		for (int i = 1; i < fac.length; i++) {
			fac[i] = (fac[i - 1] * i) % mod;
		}

		long answer = fac[n + m];
		answer = (answer * modpow(fac[n], mod - 2, mod)) % mod;
		answer = (answer * modpow(fac[m], mod - 2, mod)) % mod;

		System.out.println(answer);
	}

	public static long modpow(long a, long n, long p) {
		long x = 1;
		while (n > 0) {
			if ((n & 1) == 1) x = (x * a) % p;
			n /= 2;
			a = (a * a) % p;
		}
		return x;
	}

}


Measured memory_bytes: 27476
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> pa(a), pb(b), pc(c);
  for(int i=0; i < a; i++) scanf("%i", &pa[i]);
  for(int i=0; i < b; i++) scanf("%i", &pb[i]);
  for(int i=0; i < c; i++) scanf("%i", &pc[i]);

  sort(pa.rbegin(), pa.rend());
  sort(pb.rbegin(), pb.rend());

  for(int i=0; i < x; i++) {
    pc.push_back(pa[i]);
  }
  for(int i=0; i < y; i++) {
    pc.push_back(pb[i]);
  }

  sort(pc.rbegin(), pc.rend());
  
  long long ans = 0;
  for (int i=0; i < x + y; i++) {
    ans += pc[i];
  }

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

Measured memory_bytes: 2552
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

int cnt[26];
char str[105];
int main () {
    scanf("%s", str);
    int len = strlen(str);
    bool flag = true;
    for(int i = 0; i < len; i++) {
        cnt[str[i] - 'a']++;
    }
    for(int i = 0; i < 26; i++) {
        if(cnt[i] % 2) {
            flag = 0;
        }
    }
    if(flag) {
        printf("Yes");
    }
    else {
        printf("No");
    }
}


Measured memory_bytes: 256