akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef long long unsigned int ll;


int main(){
    int ans=0;
    int n,m;
    int a[100],b[100];
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
    }
    int v[10];
    for(int i=0;i<n;i++){
        v[i]=i+1;
    }
    
    do{
        if(v[0]!=1){
            break;
        }
        int is[10]={0};//v[i]からv[i+1]へ辺があれば1
        for(int i=0;i<n-1;i++){
            //v[i]からv[i+1]にいく辺があるか探す
            for(int j=0;j<m;j++){
                if(v[i]==a[j]&&v[i+1]==b[j]){
                    is[i]=1;
                }else if(v[i]==b[j]&&v[i+1]==a[j]){
                    is[i]=1;
                }
            }
            
        
        }
        
        int c=1;
        for(int i=0;i<n-1;i++){
            c*=is[i];
        }
        
        if(c==1) ans++;
    }while(next_permutation(v,v+n));
    
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll s;

ll a, b, c, d, e, f;

int main(void) {
  // Here your code !
  scanf("%lld", &s);

  e = 0LL;
  f = 0LL;

  a = (ll)(1e9);
  c = 1LL;

  ll div = s / a;
  ll mod = s % a;

  if (mod == 0LL) {
    d = div;
    b = 0LL;
  } else {
    d = div + 1LL;
    b = a - mod;
  }

  printf("%lld %lld %lld %lld %lld %lld\n", a, b, c, d, e, f);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  int i,j,l,k;
  for(i=0;i<n;i++){
    cin >> k;
    for(j=0;j<k;j++){
      cin >> l;
      a[l-1] +=1;
    }
  }int ans=0;
  for(i=0;i<m;i++){
    if(a[i] == n)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.HashSet;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int r=sc.nextInt();
        int g=sc.nextInt();
        int b=sc.nextInt();
        int sum=100*r+10*g+b;
        if(sum%4==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
        
        

        }
       
        
    }

Measured memory_bytes: 22996
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    long double l; cin >> l;
    l /= 3;
    cout << fixed << setprecision(12) << l*l*l;

    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.rstrip

mx = 0
1.upto(n - 1) do |i|
  a = s[0..i]
  b = s[i+1..-1]

  cnt = 0
  ("a".."z").each do |x|
    cnt += 1 if a.include?(x) and b.include?(x)
  end

  mx = [cnt, mx].max
end

p mx


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	ll a, b, x; cin >> a >> b >> x;
	ll left = a / x, right = b / x;
	ll ans;
	if(a % x == 0) left--;
	ans = right - left;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <deque>
#include <queue>
#include <string>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define V vector

map<ll, int> add, sub;
int N;
ll t;
map<ll, int>::iterator iter;


void solve() {
    ll res = 0;
    map<ll, int>::iterator addIt = add.begin();
    while( addIt != add.end()) {
        ll t = addIt -> first;
        res += add[t] * sub[t];
        addIt++;
    }
    cout << res;
    return;
}

int main() {
    cin >> N;
    REP(i, 0, N) {
        cin >> t;
        add[t+i]++;
        sub[i-t]++;
    }
    solve();
    return 0;
}



Measured memory_bytes: 37488
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;
using XY = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &v: a)
        cin >> v;
    vector<int> d(n + 1);
    int prise = 0;
    int prev = 0;
    forin(i, 0, n) {
        d[i] = abs(a[i] - prev);
        prise += d[i];
        prev = a[i];
//        cerr << prise << endl;
    }
    d[n] = abs(a[n - 1]);
    prise += d[n];
    forin(i, 0, n) {
        auto p = prise;
        p -= d[i] + d[i + 1];
        auto t = (i == n - 1) ? 0 : a[i + 1];
        auto f = (i == 0) ? 0 : a[i - 1];
        p += abs(t - f);
        cout << p << endl;
    }
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    REP(i, 5){
        ll a; cin >> a;
        if (a == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n,k;    cin >> n >> k;
    vector<int>p(n);
    rep(i, n)   cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k)   ans += p[i];
    cout << ans << endl;
}


Measured memory_bytes: 3628
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn is_sorted(xs: &Vec<usize>) -> bool {
    for i in 1..xs.len() {
        if xs[i-1] > xs[i] {
            return false;
        }
    }
    true
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut xs: Vec<usize> = (0..n).map(|_| sc.cin()).collect();
    let mut ans = "NO";
    if is_sorted(&xs) {
        ans = "YES";
    }
    for i in 0..n {
        for j in 0..i {
            let tmp = xs[i];
            xs[i] = xs[j];
            xs[j] = tmp;
            if is_sorted(&xs) {
                ans = "YES";
            }
            let tmp = xs[j];
            xs[j] = xs[i];
            xs[i] = tmp;
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m % n);
}//gcd

ll lcm(ll m, ll n) {
	return m / gcd(m, n) * n;
}

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

	ll n;
	cin>>n;
	Array a(n,0);
	ll num=1;
	REP(i,n){
		cin>>a[i];
		if(num==a[i]){
			num++;
		}
	}

	if(num==1){
		cout<<-1<<endl;
	}else{
		cout<<n-num+1<<endl;
	}
	return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int a[n];
    REP(i, n) {
        cin >> a[i];
    }
    int idx = 0;
    int c[h][w];
    REP(i, h) {
        REP(j, w) {
            if (a[idx] <= 0)
                idx++;
            if (i % 2 == 0) {
                c[i][j] = idx + 1;
            } else {
                c[i][w - j - 1] = idx + 1;
            }
            a[idx]--;
        }
    }
    REP(i, h) {
        REP(j, w) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

const ll V = 100000;
using P = pair<ll, ll>;
vector<P> G[V];	//pair<辺の距離, 行き先の頂点>
vector<ll> dist(V); //dist[i]はsから頂点iへの最短距離が入る
vector<bool> used(V);

void dijkstra(ll s) {	//s : 始点
						//初期化
	fill(dist.begin(), dist.end(), INF);
	fill(used.begin(), used.end(), false);

	priority_queue<P, vector<P>, greater<P>> q;
	q.push(P(0, s));
	while (!q.empty()) {
		ll d;	//d : sからの距離
		ll t;	//t ; 行き先
		tie(d, t) = q.top();
		q.pop();
		if (used[t]) {	//もう探索済みか
			continue;
		}
		used[t] = true;
		dist[t] = d;
		for (P e : G[t]) {
			if (dist[e.second] <= d + e.first) {	//枝刈り
				continue;
			}
			q.push(P(d + e.first, e.second));
		}
	}
}

signed main() {
	ll n, u, v, w;

	cin >> n;

	vector<ll> ans(n, 0);

	REP(i, n - 1) {
		cin >> u >> v >> w;
		G[u - 1].push_back(make_pair(w, v - 1));
		G[v - 1].push_back(make_pair(w, u - 1));
	}

	dijkstra(0);

	FOR(i, 1, n) {
		if (dist[i] % 2 == 0) {
			continue;
		}

		ans[i] = 1;
	}

	REP(i, n) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
  
int main(){
    ll n, m; cin >> n >> m;
    ll l = min(n, m / 2);
    ll ans = l;
    n -= l, m -= l * 2;
    ans += m / 4;
    m = m % 4;
    cout << ans << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[1005];
ll B[1005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N;
    memset(A, -1, sizeof(A));
    memset(B, -1, sizeof(B));
    REP(i, N) {
        cin >> A[i];
    }
    cin >> M;
    REP(i, M) {
        cin >> B[i];
    }

    REP(i, std::max(N, M)) {
        if (A[i] < B[i]) {
            cout << 1 << endl;
            return 0;
        }
        if (A[i] > B[i])
            break;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3172
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

x = []
y = []
c = []

cand = []
for i in range(M):
    lx, ly, lc = map(int, input().split())
    x.append(lx)
    y.append(ly)
    c.append(lc)

cand.append(min(a)+min(b))
for i in range(M):
    cand.append(a[x[i]-1] + b[y[i]-1] - c[i])

ans = min(cand)
print(ans)


Measured memory_bytes: 90732
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;


int main(){
  long double a,b,c;
  cin >> a >> b >> c;
  long double aa,bb,cc;

  long double eps=1.0E-14;

  aa=sqrtl(a);
  bb=sqrtl(b);
  cc=sqrtl(c);
  if(aa+bb+eps<cc){
    puts("Yes");
  }else{
    puts("No");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

const int mod = 1000000007;
struct ModInt {
    lint x;
    ModInt (lint a) : x((a % mod + mod) % mod) {}
    ModInt operator - () const {
        return ModInt(-x);
    }
    ModInt &operator += (const ModInt &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator -= (const ModInt &a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    ModInt &operator *= (const ModInt &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator + (const ModInt &a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator - (const ModInt &a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator * (const ModInt &a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(lint t) const {
        if (!t) return 1;
        ModInt a = pow(t / 2);
        a *= a;
        if (t % 2) a *= *this;
        return a;
    }
    ModInt inv() const {
        return pow(mod - 2);
    }
    ModInt &operator /= (const ModInt &a) {
        return (*this) *= a.inv();
    }
    ModInt operator / (const ModInt &a) const {
        ModInt res(*this);
        return res /= a;
    }
    friend ostream &operator << (ostream &os, const ModInt &a){
        os << a.x;
        return os;
    }
};

vector<ModInt> fact;
ModInt P(int n, int r) {
    if (n < r) return ModInt{0};
    else return fact[n] / fact[n - r];
}

struct Edge {int to;};
using Graph = vector<vector<Edge>>;
Graph G;
vector<int> dist, cnt;
void dfs(int v) {
    for (auto e : G[v]) {
        if (dist[e.to] == -1) {
            dist[e.to] = dist[v] + 1;
            dfs(e.to);
            ++cnt[v];
        }
    }
}

int main() {
    int N, K;
    cin >> N >> K;
    G = Graph(N);
    dist = vector<int>(N, -1);
    cnt = vector<int>(N, 0);
    ModInt M(1);
    fact.push_back(M);
    for (int i = 1; i < K; ++i) {
        ModInt m(i);
        M *= m;
        fact.push_back(M);
    }
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(Edge{b});
        G[b].push_back(Edge{a});
    }
    dist[0] = 0;
    dfs(0);
    ModInt ans(K);
    rep(i, N) {
        if (dist[i] == 0) ans *= P(K - 1, cnt[i]);
        else ans *= P(K - 2, cnt[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  int sum=x+y;
  int mean;
  if(0==sum%2){
    mean=sum/2;
  }else{
    mean=sum/2+1;
  }
  cout<<mean;
  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

vector<vector<ll>> soinsu(ll a){
  if(a<=0) return {};
  if(a==1) return {{1,1}};
  vector<ll> f;
  ll b=a;
  for(ll i=2;i*i<=a;i++){
    if(b%i==0){
      f.push_back(i);
      b=b/i;
      i--;
    }
  if(b==1)break;
  }
  if(b!=1)f.push_back(b);

  vector<vector<ll>> u;
  ll p=f[0];
  ll c=1;
  for(ll i=1;i<f.size();i++){
    if(f[i]==p)c++;
    else{
      u.push_back({p,c});
      p=f[i];
      c=1;
    }
  }
  u.push_back({p,c});

  return u;
}

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

int main(){

  ll n;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++)cin >> a[i];

  vector<ll> s(1000010);
  vector<ll> t;

  for(ll i=0;i<n;i++){
    vector<vector<ll>> v=soinsu(a[i]);
    for(ll i=0;i<v.size();i++){
      if(s[v[i][0]]==0)t.push_back(v[i][0]);
      s[v[i][0]]=max(s[v[i][0]],v[i][1]);
    }
  }

  //lcm mod 10^9+7を求める
  ll l=1;
  for(ll i=0;i<t.size();i++){
    l*=powmod(t[i],s[t[i]],mod);
    l%=mod;
  }
  ll S=0;

  //cout << l << endl;

  for(ll i=0;i<n;i++){
    vector<vector<ll>> v=soinsu(a[i]);
    ll b=l;
    for(ll i=0;i<v.size();i++){
      ll c=modinv(powmod(v[i][0],v[i][1],mod),mod);
      b*=c;
      b%=mod;
    }
    S+=b;
    S%=mod;
  }

  cout << S << endl;


  
  

}

Measured memory_bytes: 11364
#include<stdio.h>
int main(void){
    int a,b,c;
    while(scanf("%d%d",&a,&b)!=EOF){
        while((a%b)!=0){
            c=b;
            b=(a%b);
            a=c;
        }
        printf("%d\n",b);
    }
    return 0;
}

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

public class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Reader.ReadLine());
        long[] input = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        long[] total = new long[itemCount];

        total[0] = input[0];
        for (int i = 1; i < itemCount; i++) {
            total[i] = total[i - 1] + input[i];
        }

        Dictionary<long, long> cnt = new Dictionary<long, long>();
        total.ToList().ForEach(a =>
        {
            if (cnt.ContainsKey(a))
            {
                cnt[a]++;
            }
            else
            {
                cnt.Add(a, 1);
            }
        });

        long ans = 0;
        foreach(KeyValuePair<long, long> item in cnt) {
            if(item.Key == 0) {
                ans += item.Value * (item.Value + 1) / 2;                
            } else {
                ans += item.Value * (item.Value - 1) / 2;
            }
        }
        Console.WriteLine(ans);
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


7
1 -1 1 -1 1 -1 1




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 47120
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int k, n, i;
    cin >> k >> n;
    long int a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    long int mx = min(a[n-1]-a[0], a[i] + (k-a[1]));
    for(i=1; i<n-1; i++)
        mx = min(min((k-a[i]) + a[i-1], a[i] + (k-a[i+1])), mx);
    mx = min(min((k-a[n-1]) + a[n-2], a[n-1] - a[0]), mx);
    cout << mx << '\n';
    return 0;
}


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

int main()
{
    int n;
    vector<int> a(10);

    for (int i = 0; i < 4; i++)
    {
        cin >> n;
        a[n]++;
    }
    
    if (a[1] && a[4] && a[7] && a[9])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	ll argA, argB, argX;
	cin >> argA >> argB >> argX;

	ll resA = argA % argX == 0 ? argA / argX - 1 :  argA / argX ;
	ll resB = argB / argX;
	
	cout << max(resB - resA, 0LL) << endl;
}

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


int n,k;
long long h[3][100005];
long long f[3][100005];

int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<3;j++) cin>>h[j][i];

    }

    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<3;j++)
            for(int z=0;z<3;z++)
            if (z!=j)
            f[j][i]=max(f[j][i],h[j][i]+f[z][i-1]);
    }
    long long ans=0;
    for (int i=0;i<3;i++) ans=max(ans,f[i][n]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){

	string s,t;
	cin>>s>>t;

	ll ans=0;
	for(ll i =0;i<s.size();i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}

	cout<<ans<<endl;
}


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


Measured memory_bytes: 3856
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
  
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  string ans = "No";
  if(A == B){
    if(A != C){
      ans = "Yes";
    }
  }
  if(B == C){
    if(B != A){
      ans = "Yes";
    }
  }
  if(C == A){
    if(C != B){
      ans = "Yes";
    }
  }
  
      
    
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int n; cin >> n;
    vector<int> s(n);
    for(int i=0;i<n;i++){
        cin >>s.at(i);
    }
    int q; cin >> q;
    vector<int> t(q);
    for(int i=0;i<q;i++){
        cin >>t.at(i);
    }
    int cnt, x;
    for(int i=0;i<q;i++){
        x = t.at(i);
        if(binary_search(s.begin(),s.end(),x)){
            cnt++;
        }
    }
    cout << cnt << endl;
}



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

int main() {
  int month,day,day1,day10;
  int count = 0;
  
  std::cin >> month;
  std::cin >> day;
  
  for(int i = 1; i <= month; i++){
    for(int j = 2; j <= day; j++){
      day1 = j % 10;
      if(day1 == 1){
        continue;
      }
      day10 = j / 10;
      if(day10 == 1){
          continue;
      }
      if(i == day1 * day10)
      	count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t;
        int n;
        int s,f,sum;

        while((t = sc.nextInt())!=0){
            n = sc.nextInt();
            sum=0;
            for(int i=0;i<n;i++){
                s = sc.nextInt();
                f = sc.nextInt();
                sum += (f-s);
            }
            if(sum>=t){System.out.println("OK");}
            else{System.out.println(t-sum);}
        }
    }
}


Measured memory_bytes: 31760
import math
n,m = map(int,input().split())

def make_divisors(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

divisor_ls = make_divisors(m)

ans = 1
for divisor in divisor_ls:
    if m // divisor < n:
        break
    else:
        ans = divisor

print(ans)

Measured memory_bytes: 3064
main = do
  s <- getLine
  print $ solve $ init s

ev :: String -> Bool
ev str = even n && l == r
  where n = length str
        m = n `div` 2
        (l,r) = splitAt m str

solve :: String -> Int
solve [] = 0
solve str = max res (solve st)
  where res = if ev str then length str else 0
        st = init str

Measured memory_bytes: 892
use std::io;
use std::str::FromStr;
use std::collections::HashMap;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.chars().collect()
}

fn main() {
    let n: u64 = input();
    let mut count: HashMap<String, u64> = HashMap::new();
    
    for _ in 0..n {
        let s: String = input();
        let n = count.entry(s).or_insert(0);
        *n += 1;
    }

    let mut max = 0;
    for c in &count {
        if *c.1 > max {
            max = *c.1;
        }
        // println!("{:?}", c);
    }

    let mut ans: Vec<String> = Vec::new();
    for c in &count {
        if *c.1 == max {
            ans.push(c.0.to_string());
        }
    }
    ans.sort();
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 26804
#include <bits/stdc++.h>
#define fi first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#ifdef CURIOUSCAT
#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
#else
#define Pr(f,...) ;
#endif

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e6+50;

int P;
int mul(int a,int b){ return 1ll*a*b%P; }
//int add(int a,int b){ a+=b; return a>=P?a-P:a; }
void upd(int &a,int b) { a=a+b>=P?a+b-P:a+b; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }


int n; string s; vector<pair<int,int>> ans;
void add(int msk,int inv){
	Pr("add %d,%d\n",msk,inv); 
	int lsb=msk&-msk;
	if(lsb==msk){
		int x=31-__builtin_clz(msk); 
		Pr("x=%d\n",x);
		rep(i,0,x)ans.eb(i,0); 
		Pr("ans.size()=%d\n",(int)ans.size()); 
		if(inv){
			ans.eb(x,1);
			ans.eb(x+1,1);
			ans.eb(x+1,0);
		}else{
			ans.eb(x+1,0);
			ans.eb(x+1,1); 
			ans.eb(x,1); 
		}
		dec(i,x,1)ans.eb(i,0);
	}else{
		if(!inv){
			add(msk^lsb,0);
			add(lsb,0);
			add(msk^lsb,1);
			add(lsb,1);
		}else{
			add(lsb,0); 
			add(msk^lsb,0);
			add(lsb,1);
			add(msk^lsb,1); 
		}
	}
}
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	cin>>n>>s; 
	lop(i,0,(1<<n))lop(j,0,n)if(i>>j&1&&s[i]=='1'&&s[i^1<<j]=='0'){
		cout<<"Impossible"<<endl; 
		return 0; 
	}
	cout<<"Possible"<<endl;

	lop(i,0,1<<n)if(s[i]=='0')add(i,0); 
	ans.eb(0,0); 
	cout<<(int)ans.size()-1<<endl;
	for(auto x:ans)cout<<x.fi<<" "<<x.sc<<endl;
	return 0; 
}


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

int main(){

    array<int, 3> candy;
    cin >> candy[0] >> candy[1] >> candy[2];

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

    if(candy[2] == candy[0] + candy[1])cout << "Yes\n";
    else cout << "No\n";

    return 0;

}

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


int main(int argc, const char * argv[]) {
    int a, b;
    
    cin >> a >> b;
    
    if(a < b){
        cout << "a < b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else if (a == b){
        cout << "a == b" << endl;
    }
    
    return 0;
}



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

int gcd(int x, int y){
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main(){
    int a, b;
    cin >> a >> b;
    cout << (long long)a * b / gcd(a, b) << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			if i*j == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;

	if (s.find('C') != -1 && s.rfind('F') != -1 && s.find('C') < s.rfind('F')) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int C[128];

int main() {
  C['J'] = 0;
  C['O'] = 1;
  C['I'] = 2;
  for(int H, W; cin >> H >> W;) {
    vector<string> G(H);
    for(int i = 0; i < H; ++i) cin >> G[i];
    vector<string> F(2);
    for(int i = 0; i < 2; ++i) cin >> F[i];

    vector<vector<int> > A(H, vector<int>(W, 0));
    vector<vector<vector<int> > > B(H, vector<vector<int> >(W, vector<int>(3, 0)));
    int S = 0;
    for(int i = 0; i+2 <= H; ++i) {
      for(int j = 0; j+2 <= W; ++j) {
        vector<int> pi, pj, pc;
        for(int a = 0; a < 2; ++a) {
          for(int b = 0; b < 2; ++b) {
            if(G[i+a][j+b] != F[a][b]) {
              pi.push_back(i+a);
              pj.push_back(j+b);
              pc.push_back(C[(int)F[a][b]]);
            }
          }
        }
        if(pi.empty()) {
          S += 1;
          A[i][j] = 1;
        } else if(pi.size() == 1) {
          B[pi[0]][pj[0]][pc[0]] += 1;
        }
      }
    }
    int res = S;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        for(int k = 0; k < 3; ++k) {
          int T = S + B[i][j][k] - A[i][j];
          if(i) T -= A[i-1][j];
          if(j) T -= A[i][j-1];
          if(i && j) T -= A[i-1][j-1];
          res = max(res, T);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

    #define ll long long
    #define pb push_back
    #define mod 1000000007

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

      ll n;
      cin>>n;
      cout<<n*(n-1)/2;

      return 0;
      
      }

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0
m = 0
l, r = 0, 0
while l < n:
    if a[r] ^ m == a[r] + m:
        m += a[r]
        if r == n - 1:
            break
        r += 1
    else:
        ans += r - l
        m -= a[l]
        l += 1
print(ans + (r - l + 1) * (r - l + 2) // 2)

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

#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;
using lint = long long;

int main(void)
{
    lint k;
    cin >> k;

    vector<lint> x;
    queue<lint> q;
    rep(i, 9){
        q.push(i+1);
        x.push_back(i+1);
    }

    while(x.size() < 100000){
        lint num = q.front();
        q.pop();
        lint c = num % 10;
        if(c != 0){
            q.push(num * 10 + c-1);
            x.push_back(num * 10 + c-1);
        }
        q.push(num * 10 + c);
        x.push_back(num * 10 + c);

        if(c != 9){
            q.push(num * 10 + c+1);
            x.push_back(num * 10 + c+1);
        }
    }
    cout << x[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
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; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

void y(bool c) {
	if (c)print("Yes");
	else print("No");
}
void solve() {

	int X, K; cin >> X >> K;
	if (X >= K) {
		int cnt = (X / K);
		X -= cnt * K;

	}
	while (true) {
		int nxt = abs(X - K);
		if (nxt >= X)break;
		else X = nxt;
	}
	print(X);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(x,v) memset(x,v,sizeof(x)) 
#define go(i,a,b)  for (int i = a; i <= b; i++)
#define og(i,a,b)  for (int i = a; i >= b; i--)
#define MID(a,b) (a + b) >> 1
#define lson now << 1
#define rson now << 1 | 1
#define low(x) (x & (-x))
using namespace std;
typedef long long LL;
const double EPS = 1e-10;
const int INF = 1e9+100;
const int N = 1e6+10;
int a[N],b[N],c[N];
LL f[N];
int n,tt;
void Add(int x){
	while(x <= 5*n){
		f[x] += 1;
		x += low(x);
	}
}
int Query(int x){
	int ans = 0;
	while(x > 0) ans += f[x], x -= low(x);
	return ans; 
}
bool find(int k){
	mem(f,0);
	LL Ans = 0;	b[0] = 0;
	go(i,1,n) if (a[i] >= c[k]) b[i] = b[i-1] + 1; else b[i] = b[i-1];
	go(i,0,n) {
		b[i] = 2*b[i] - i + n + 1;
		Ans += Query(b[i]);
		Add(b[i]);
	}
	LL t = (1LL * n * (n + 1)) / 2;
	if (Ans >= (t+1)/2) return 1; 
	return 0;
}

int main(){
	scanf("%d",&n);
	int l = 1, r = n;
	go(i,1,n){
		scanf("%d",&a[i]);
		c[i] = a[i];
	}
	sort(c+1,c+n+1);
	int ans = 0;
	while(l <= r){
		int mid = MID(l,r);
		if (find(mid)) l = mid+1,ans = c[mid]; else r = mid - 1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14592
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    h, w, k = map(int, input().split())
    a = []
    for __ in range(h):
        a += [[k for k in input()]]
    ans = 0
    for ch1 in range(2**h):
        for ch2 in range(2**w):
            rowchosen = binary(ch1, h)
            colchosen = binary(ch2, w)
            count = 0
            for i in range(h):
                for j in range(w):
                    if rowchosen[i] != '1' and colchosen[j] != '1' and a[i][j] == '#':
                        count += 1
            if count == k:ans+=1
    print(ans)

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

int main() {
    int64_t a, b;
    cin >> a >> b;
    auto f = [&](int64_t n, int64_t d) {
        int64_t mod = 1ll << d;
        int64_t n01 = (n+1) / (mod*2), s = (n+1) % (mod*2);
        return n01 * mod + (s > mod ? s - mod : 0);
    };
    int64_t ans = 0;
    for(size_t i = 0; i < 50; i++) {
        int64_t af = f(a-1, i), bf = f(b, i);
        ans += ((bf - af) % 2 != 0 ? 1ll << i : 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s;
int k;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s >> k;
	int sz = s.size();
	FOR(i, sz) {
		if (s[i] == 'a') continue;
		if ('z' - s[i] < k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
		if (!k) break;
	}
	if (k) {
		k %= 26;
		if ('z' - s[sz-1] >= k) {
			s[sz-1] = (char)(s[sz-1] + k);
		}
		else s[sz-1] = (char)('a' + k - 'z' + s[sz-1] - 1);
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 592