akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
char a[101][105],vis[101][105];
int n,m,len[105];
int main() {
    scanf("%d",&n);
    for(int i=1; i<=n; i++)scanf("%s",a[i]+1);
    for(int i=1; i<=n; i++) {
        len[i]=strlen(a[i]+1);
    }
    for(int I=1; I<=10000; I++) {
        bool bb=0;
        for(int J=1; J<=26; J++) {
            int t=J+'a'-1;
            bool b=1;
            for(int i=1; i<=n; i++) {
                bool cc=0;
                for(int j=1; j<=len[i]; j++) {
                    if(a[i][j]==t&&!vis[i][j]) {
                        cc=1;
                        break;
                    }
                }
                if(cc==0)b=0;
            }
            if(b) {
                bb=1;
                
                for(int i=1; i<=n; i++) {
                    for(int j=1; j<=len[i]; j++) {
                        if(a[i][j]==t&&!vis[i][j]) {
                        	vis[i][j]=1;
                            break;
                        }
                    }
                }
                printf("%c",t);
                break;
            }
        }
		if(!bb)break;
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 888
import fractions

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

A, B, C, D = map(int, input().split())
total = B - A + 1
CD = lcm(C, D)

C_count = B//C - (A-1)//C
D_count = B//D - (A-1)//D
CD_count = B//CD - (A-1)//CD

result = total - C_count - D_count + CD_count

print(result)


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

struct data{
    bool used[10];
    long long int count;
    int n;
    data(){
        for(int i=0; i<10; i++){
            used[i] = false;
        }
        count = 0;
        n = 0;
    }
};

int main() {

    int d;
    long long int g;

    cin >> d >> g;

    vector<int> p;
    vector<long long int> c;

    for(int i=0; i<d; i++){
        int ip;
        long long int ic;

        cin >> ip >> ic;

        p.push_back(ip);
        c.push_back(ic);

    }

    data start;

    queue<data> q;

    q.push(start);

    int ans = 10000000;

    while(!q.empty()){

        data now = q.front();
        q.pop();


        for(int i=0; i<d; i++){
            data tmpnow = now;
            if(!tmpnow.used[i]){
                int tmpcount;
                if((i+1)*100*p[i] + tmpnow.count >= g){
                    tmpcount = static_cast<int>((g-tmpnow.count))/((i+1)*100);
                    if((g-tmpnow.count)%((i+1)*100) > 0){
                        tmpcount++;
                    }
                    ans = min(ans,tmpnow.n+tmpcount);
                }
                else{
                    tmpnow.count += (i+1)*100*p[i] + c[i];
                    tmpnow.n += p[i];

                    if(tmpnow.count >= g){
                        ans = min(ans,tmpnow.n);
                    }
                    else{
                        tmpnow.used[i] = true;
                        q.push(tmpnow);
                    }
                }
            }

        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 121236
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let x: usize = read();
    let mut arr = vec![x];
    for _ in 0..n {
        arr.push(read());
    }
    arr.sort();
    let mut ans = arr[1] - arr[0];
    for i in 1..=n {
        ans = gcd(ans, arr[i] - arr[i - 1]);
    }
    println!("{}", ans);
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 3144
#include <cstdio>
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cctype>
#define fs first
#define sc second
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
D inf=1e50,eps=1e-10;
inline D dot(P a,P b){
	return real(conj(a)*b);
}
inline D cro(P a,P b){
	return imag(conj(a)*b);
}
inline P perp(L l,P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
inline P refl(L l,P p){
	return p+2.0*(perp(l,p)-p);
}
inline P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
string s;
P ran=P(1024,1024);
double num(int &it){
	bool neg=false;
	if(s[it]=='-') neg=true,it++;
	double x=0;
	while(isdigit(s[it])){
		x*=10;
		x+=(s[it]-'0');
		it++;
	}
	if(neg) x=-x;
	return x;
}
L point(int& it){
	it++;
	double x=num(it);
	it++;
	double y=num(it);
	it++;
	return L(P(x,y),ran);
}
L expr(int& it){
	L ret;
	if(s[it+1]=='('){
		it++;
		ret=expr(it);
		it++;
	}else{
		ret=point(it);
	}
	while(s[it]=='@'){
		it++;
		L l;
		if(s[it+1]=='('){
			it++;
			l=expr(it);
			it++;
		}else{
			l=point(it);
		}
		if(ret.sc==ran&&l.sc==ran){
			ret=L(ret.fs,l.fs);
		}else if(ret.sc==ran&&l.sc!=ran){
			P p=ret.fs;
			ret=L(refl(l,p),ran);
		}else if(ret.sc!=ran&&l.sc==ran){
			P p=l.fs;
			ret=L(refl(ret,p),ran);
		}else{
			ret=L(intLL(ret,l),ran);
		}
	}
	return ret;
}
int main(){
	while(true){
		cin>>s;
		if(s[0]=='#') break;
		int it=0;
		L l=expr(it);
		P p=l.fs;
		printf("%.12f %.12f\n",p.real(),p.imag());
	}
}

Measured memory_bytes: 1248
fun main(args: Array<String>) {
    val sc = System.`in`.bufferedReader()
    val n = Integer.parseInt(sc.readLine())
    val list = LinkedList()

    repeat(n) {

        val (command, key) = run {
            val s = sc.readLine().split(' ')
            if (s.size == 1) {
                Pair(s[0], -1)
            } else {
                Pair(s[0], Integer.parseInt(s[1]))
            }
        }

        when (command) {
            "insert" -> list.insert(key)
            "delete" -> list.delete(key)
            "deleteFirst" -> list.deleteFirst()
            "deleteLast" -> list.deleteLast()
        }
    }

    println(list)
}

private class LinkedList {

    private val nil: Node = Node(null)

    fun insert(key: Int) {
        val x = Node(key)

        x.next = nil.next
        nil.next?.prev = x
        nil.next = x
        x.prev = nil
    }

    private fun deleteNode(node: Node?) {
        if (node == nil) {
            return
        }
        node?.prev?.next = node?.next
        node?.next?.prev = node?.prev
    }

    fun delete(key: Int) {
        var cur = nil.next
        while (cur != nil && cur?.key != key) {
            cur = cur?.next
        }
        deleteNode(cur)
    }

    fun deleteFirst() {
        deleteNode(nil.next)
    }

    fun deleteLast() {
        deleteNode(nil.prev)
    }

    override fun toString(): String {
        val sb = StringBuilder()
        var cur = nil.next
        while (cur != nil) {
            sb.append(cur?.key).append(' ')
            cur = cur?.next
        }
        sb.deleteCharAt(sb.lastIndex)
        return sb.toString()
    }

}

private class Node(val key: Int?) {

    var next: Node? = this

    var prev: Node? = this

}



Measured memory_bytes: 331788
#include<stdio.h>
int main(void){
int n,i;
long a,sum=0,min=1000000,max=-1000000;

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

}
printf("%ld %ld %ld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 1844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AOJALDS12B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var strlist = new List<string>();
            strlist.AddRange(Console.ReadLine().Split(' ').ToList());
            var numlist = strlist.ConvertAll(int.Parse);

            var flag = 0;
            for (int i = 0; i < n-1; i++)
            {
                var mini = i;
                for (int j = i; j < n; j++)
                {
                    if (numlist[j]<numlist[mini])
                    {
                        mini = j;
                    }
                }
                var temp = numlist[mini];
                numlist[mini] = numlist[i];
                numlist[i] = temp;
                if (i != mini)
                {
                    ++flag;
                }
            }

            for (int i = 0; i < numlist.Count; i++)
            {
                Console.Write("{0}", numlist[i]);
                if (i != numlist.Count - 1)
                {
                    Console.Write(" ");
                }
                else
                {
                    Console.Write("\n");
                }
            }

            Console.WriteLine("{0}", flag);
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 18320
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string s, v;
int main() {
	cin >> s; v = s;
	for (int i = 7; i < s.size(); i++) {
		string t = s.substr(i - 7, 8);
		sort(t.begin(), t.end());
		if (t == "AADINNUY") v.replace(v.begin() + i - 7, v.begin() + i + 1, "AIZUNYAN");
	}
	cout << v << endl;
	return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<iterator>
#include<queue>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class Graph{
    public:
    typedef struct Edge{
        ll from, to, cost;
        Edge(ll f, ll t, ll c): from(f),to(t),cost(c){}
    } Edge;

    bool isDirected;
    ll INF = 1LL << 62;
    ll v; // 頂点数
    std::vector<Edge> edges;  // 辺のリスト
    std::vector<std::vector<std::pair<ll,ll>>> list;  // 隣接リスト
    //std::vector<std::vector<ll>> matrix; // 隣接行列

    Graph(ll n, bool isDirected=false) : isDirected(isDirected) { init(n); }
    void init(ll n){
        v=n;
        edges.clear();
        list.assign(n, std::vector<std::pair<ll,ll>>());
        //matrix.assign(n, std::vector<ll>(n, INF));
    }
    void connect(ll from, ll to){
        con(from, to, 1);
        if(!isDirected) con(to, from, 1);
    }
    void connect(ll from, ll to, ll cost){
        con(from, to, cost);
        if(!isDirected) con(to, from, cost);
    }
    void con(ll from, ll to, ll cost){
        edges.push_back(Edge(from,to,cost));
        list[from].push_back(std::make_pair(to, cost));
        //matrix[from][to] = cost;
    }
};

class StronglyConnectedComponents{  // 強連結成分分解
    public:
    std::vector<std::vector<ll>> list, rlist;
    Graph G;
    std::vector<ll> order; // 帰りがけ順の並び
    std::vector<ll> used;
    std::vector<ll> cmp;   // 属する強連結成分のトポロジカル順序
    ll node_num;

    StronglyConnectedComponents(Graph G) : G(G){
        list.assign(G.v, std::vector<ll>());
        rlist.assign(G.v, std::vector<ll>());
        order.clear();
        used.assign(G.v, 0);
        cmp.assign(G.v, -1);
    }

    void make_list(){
        for(auto i : G.edges){
            list[i.from].push_back(i.to);
            rlist[i.to].push_back(i.from);
        }
    }
    void dfs(ll idx){
        if(used[idx])return;
        used[idx]=true;
        for(ll to : list[idx]) dfs(to);
        order.push_back(idx);
    }
    void rdfs(ll idx, ll cnt){
        if(cmp[idx] != -1) return;
        cmp[idx] = cnt;
        for(ll to : rlist[idx]) rdfs(to, cnt);
    }
    void build(){
        make_list();
        for(ll i=0; i<list.size(); i++) dfs(i);
        std::reverse(order.begin(), order.end());
        ll ptr=0;
        for(ll i : order)if(cmp[i]==-1) rdfs(i,ptr++);
        node_num = ptr;
    }
    ll operator[](ll k){
        return cmp[k];
    }
};

int main(){
    ll v,e,s,t;
    cin >> v >> e;
    Graph G(v, true);
    REP(i,e){
        cin >> s >> t;
        G.connect(s,t);
    }
    StronglyConnectedComponents scc(G);
    scc.build();
    //for(auto i : scc.cmp)cout << "###" << i << endl;
    //cout << "##" << scc.node_num << endl;
    if(v == scc.node_num) cout << "0" << endl;
    else cout << "1" << endl;
    return 0;
}


Measured memory_bytes: 3300
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 H = 100005;
i64 n;
vector<vector<i64>> g;
vector<i64> vis;

tuple<i64, i64, i64> dfs(i64 u) {
  if (vis[u]) return {};
  vis[u] = true;
  i64 c = u < H, r = u >= H, e = 0;
  for (i64 v : g[u]) {
    auto t = dfs(v);
    i64 cv, rv, ev;
    tie(cv, rv, ev) = t;
    c += cv;
    r += rv;
    e += ev + 1;
  }
  return make_tuple(c, r, e);
}

int main() {
  init_n(g, 2 * H);
  cin >> n;
  for (i64 i = 0; i < n; ++i) {
    i64 x, y;
    cin >> x >> y;
    g[x].push_back(H + y);
    g[H + y].push_back(x);
  }
  init_n(vis, 2 * H);

  i64 ans = 0;
  for (i64 i = 0; i < 2 * H; ++i) {
    auto t = dfs(i);
    i64 c, r, e;
    tie(c, r, e) = t;
    ans += c * r - e / 2;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 15488
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) rep(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;

int K, X, Y, Z;
ll A[1005], B[1005], C[1005];
vector<ll> D, E;

int main(void) {
    scanf("%d %d %d %d", &X, &Y, &Z, &K);
    
    rep(i, 0, X) scanf("%lld", &A[i]);
    rep(i, 0, Y) scanf("%lld", &B[i]);
    rep(i, 0, Z) scanf("%lld", &C[i]);
    
    rep(i, 0, X) {
      rep(j, 0, Y) {
        D.push_back(A[i]+B[j]);
      }
    }
    sort(D.bg, D.en, greater<ll>());
    
    int n = min(3000, (int)D.size());
    rep(i, 0, n) {
      rep(j, 0, Z) {
        E.push_back(D[i]+C[j]);
      }
    }
    sort(E.bg, E.en, greater<ll>());
    
    n = min(K, (int)E.size());
    rep(i, 0, n) printf("%lld\n", E[i]);
    return 0;
}


Measured memory_bytes: 43236
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll freq[100001];
    memset(freq,0,sizeof(freq));
    for(ll i=0;i<n;i++){cin>>a[i];freq[a[i]]++;}
    ll q;
    cin>>q;ll s=0;
    for(ll i=1;i<100001;i++){
          s+=(freq[i]*i);
      }
    while(q--){
        ll b,c;
        cin>>b>>c;
        s-=(c*freq[c]);
         s-=(b*freq[b]);
        freq[c]+=freq[b];
        s+=(c*freq[c]);
        freq[b]=0;
        cout<<s<<"\n";
        
    }
  
   // cout<<s<<"\n";
}


Measured memory_bytes: 5192
def main():
    from collections import Counter as ct
    n = int(input())

    def soinsuu(a):
        yy, j = [], 2
        y = yy.append
        while(a > 1):
            for i in range(j, int(a**0.5)+1):
                if a % i == 0:
                    y(i)
                    a, j = a//i, i
                    break
            else:
                y(a)
                break
        yy.sort()
        return yy
    s = ct(soinsuu(n))
    cnt = 0
    for i, j in s.items():
        for k in range(1, 10**5):
            if j >= k:
                j -= k
                cnt += 1
            else:
                break
    print(cnt)


main()

Measured memory_bytes: 9720
#include<iostream>
#include<cmath>
#include<string>
#include<utility>
#include<vector>
#include<array>

using namespace std;
const int INF=100000000;


int main(){
    int N,M,X;
    cin >> N >> M >> X;
    int C[N],A[N][M],gain[M],cost,check,ans=INF;
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++){
            cin >> A[i][j] ;
        }
    }
    for(int i=1;i<1<<N;i++){
        check=1;
        cost=0;
        for(int j=0;j<M;j++){
            gain[j]=0;
        }
        for(int j=0;j<N;j++){
            bool a=i & 1<<j;
            if(a){
                cost+=C[j];
                for(int k=0;k<M;k++){
                    gain[k] += A[j][k];
                }
            }
        }
        for(int j=0;j<M;j++){
            if(gain[j]<X) {
                check=0;
                break;
            }
        }
        if(check==1) {
            ans=min(ans, cost);
        }
    }
    if(ans==INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3168
use proconio::input;

fn main() {
    input! {
        n: u64,
        talls: [u64; n]
    }

    let mut before = talls[0];
    let mut sum = 0;

    for mut tall in talls {
        if before > tall {
            sum += before - tall;
            tall += before - tall;
        }

        before = tall;
    }

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


Measured memory_bytes: 5644
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, N, M);
    vector<int> cnt(N, 1);
    vector<bool> p(N);
    p[0] = true;

    rep(i, 0, M) {
        var(int, x, y);
        --x, --y;
        --cnt[x];
        ++cnt[y];
        p[y] = p[y] | p[x];

        if (cnt[x] == 0) {
            p[x] = false;
        }
    }

    print(count(all(p), true));

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
ll a[maxn],x[maxn],y[maxn];
int n,tot;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	std::sort(a+1,a+n+1);
	int k=1;
	while(k<=n&&a[k]<0)++k;
	if(k==1){
		for(int i=1;i<n-1;i++){
			x[i]=a[1]; y[i]=a[i+1];
			a[1]-=a[i+1];
		}
		x[n-1]=a[n]; y[n-1]=a[1];
		a[n]-=a[1];
		writeln(a[n]);
		for(int i=1;i<n;i++)
			writesp(x[i]),writeln(y[i]);
	}
	else if(k>n){
		for(int i=1;i<n;i++){
			x[i]=a[n]; y[i]=a[i];
			a[n]-=a[i]; 
		}
		writeln(a[n]);
		for(int i=1;i<n;i++)
			writesp(x[i]),writeln(y[i]);
	}
	else{
		tot=0;
		for(int i=k;i<n;i++){
			x[++tot]=a[1]; y[tot]=a[i];
			a[1]-=a[i];
		}
		for(int i=1;i<k;i++){
			x[++tot]=a[n]; y[tot]=a[i];
			a[n]-=a[i];
		}
		writeln(a[n]);
		for(int i=1;i<n;i++)
			writesp(x[i]),writeln(y[i]);
	}
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  string s;
  cin>>s;

  bool ans=true;
  ll n=s.size();
  rep(i,n){
    if(i&1){
      if(s[i]=='R')ans=false;
    }
    else{
      if(s[i]=='L')ans=false;
    }
  }
  cout<<(ans?"Yes":"No")<<endl;


}


Measured memory_bytes: 256
// abc141_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> S(N);

    REP(i, Q){
        int a;
        cin >> a; a--;
        S[a]++;
    }

    REP(i, N){
        if (K - Q + S[i] > 0){
            print("Yes");
        } else {
            print("No");
        }
    }


    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**5+10)

n = int(input())
h = list(map(int, input().split()))

#aとbで小さい方を返す
def chmin(a,b):
    if a > b:
        return b
    else:
        return a

f_inf = float('inf')

dp = [f_inf] * (10**5+10)

dp[0] = 0

def rec(i):
    if dp[i] < f_inf:
        return dp[i]

    if i == 0:
        return 0

    res = f_inf
    res = chmin(res, rec(i-1) + abs(h[i] - h[i-1]))
    if i > 1:
        res = chmin(res, rec(i-2) + abs(h[i] - h[i-2]))

    dp[i] = res
    return res

ans = rec(n-1)
print(ans)


Measured memory_bytes: 93716
def main
  x, y = gets.chomp.split.map(&:to_i)

  shou = x / y

  ans1 = x - y * shou
  ans2 = (x - (y * (shou + 1))).abs

  if ans1 < ans2
    puts ans1
  else
    puts ans2
  end
end

main

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

ll a, b, c, d;
void input() { cin >> a >> b >> c >> d; }

void solve() { cout << (max({a * c, a * d, b * c, b * d})) << endl; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
  getchar();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    string s;
    cin >> s;
    int64_t k;
    cin >> k;
       int j=1;
    //cout << s[0];
    //2だとしても2^5000兆個>10^18だから、s[0]が1の時以外s[0]になるはず
    if(k==1){
        cout<<s[0]<<endl;
    }
    else if(s[0]=='1'){
        while(s[j]=='1'){
            j++;
        }
        //cout<<j<<endl;
        if(k<j+1){
        cout << s[0]<<endl;
        }
        else{
            cout<<s[j]<<endl;
        }
    }
    else{
        cout << s[0]<<endl;
    }
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;


int main() {
	
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int cnt = 0;
	for (int i = 0; i <= n / r; ++i) {
		for (int j = 0; j <= n / g; ++j) {
			if (((n - i * r - j * g) % b)  == 0 && n >= (i * r + j * g)) cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
d=[]
for i in range(n):
     d.append(list(map(int, input().split())))

count=0
ans=0
for j in range(n):
    if d[j][0]==d[j][1]:
        count+=1
        if count==3:
            ans=1
    else :
        count=0

if ans==1:
    print('Yes')
else :
    print('No')
  

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
long long i,j,n,m,mas[200005],rez;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> n;
    i=0;
    while (i<n)
    {
        cin >> mas[i];
        i++;
    }
    i=n-1;
    m=0;
    while (i>=0)
    {
        if (mas[i]!=m)
        {
            rez+=mas[i];
            m=mas[i]-1;
        }
        else
        {
            m--;
        }
        i--;
    }
    i=0;
    while (i<n)
    {
        if (mas[i]>i)
        {
            cout << "-1";
            return 0;
        }
        i++;
    }
    i=1;
    while (i<n)
    {
        if (mas[i]-mas[i-1]>1)
        {
            cout << "-1";
            return 0;
        }
        i++;
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 1792
from sys import stdin


def main() -> int:
    n = next_int()
    a = [next_int() for _ in range(n)]

    j = 1
    dic = dict()

    for i in range(n):
        dic[j] = True
        j = a[j - 1]
        if j in dic:
            break
        if j == 2:
            print(i + 1)
            return 0

    print(-1)
    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 16300
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a,b,c,n;
    string s, t;
    ll ans;

    cin  >> a >> b;

    if(a>9 || b>9) ans=-1;
    else ans = a*b;

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] main){
    Scanner scanner = new Scanner(System.in);
    int main_1 = scanner.nextInt();
    int main_2 = scanner.nextInt();
    int main_3 = main_1 * main_2;
    if(main_3 % 2 == 0){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

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

int mat[60][60], n, m, vis[60];

int dfs(int u){
    vis[u] = 1;
    for(int i=1;i<=n;i++){
        if(mat[u][i] && !vis[i]){
            dfs(i);
        }
    }
}

int main() {

    cin >> n >> m;
    vector<pair<int,int>> v;
    for(int i=0;i<m;i++){
        int u, vc;
        cin >> u >> vc;
        v.push_back({u,vc});
        mat[u][vc] = 1;
        mat[vc][u] = 1;
    }
    int cnt = 0;
    for(int i=0;i<m;i++){
        mat[v[i].first][v[i].second] = 0;
        mat[v[i].second][v[i].first] = 0;

        int cc = 0;
        memset(vis, 0,sizeof vis);
        for(int j=1;j<=n;j++){
            if(!vis[j]){
                dfs(j);
                cc++;
            }
        }
        if(cc==2) cnt++;

        mat[v[i].first][v[i].second] = 1;
        mat[v[i].second][v[i].first] = 1;
    }
    cout << cnt << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    vector<Int> M = { -1 }, S = { 0 }, C = { 0 };
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        auto it = lower_bound(begin(M), end(M), A[i]);
        if (it == M.end()) {
            M.push_back(A[i]);
            S.push_back(S.back() + A[i]);
            C.push_back(C.back() + 1);
        } else {
            int k = it - M.begin();
            M[k] = A[i];
            C[k] = i + 1;
            S[k] = S[k-1] + (C[k] - C[k-1]) * A[i];
            M.erase(begin(M) + k + 1, end(M));
            C.erase(begin(C) + k + 1, end(C));
            S.erase(begin(S) + k + 1, end(S));
        }
        ans += S.back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	bool f[11];
	for( int i = 0; i < 11; ++i ){
		f[i] = false;
	}
	int a;
	for( int i = 0; i < 4; ++i ){
		cin >> a;
		f[a] = true;
	}
	if( f[1] && f[9] && f[7] && f[4] ){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int price,change=0,res=0;
	int money[] = {500,100,50,10,5,1};
	int i;

	while (1) {
		scanf("%d", &price);
		if (price == 0)break;

		res = 0;
		change = 1000 - price;

		i = 0;
		while (change != 0) {
			if (change - money[i] >= 0) {
				change -= money[i];
				res++;
			}
			else
				i++;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define f first
//#define s second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (ll)2e5+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
 
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){	
	fast;
	int n,w;
	cin >> n >> w;
	vector<ll> dp(1e5+2,0);
	vector<ll> item;
	for(int i=0;i<n;i++ ){
		ll weight,value;
		cin >> weight >> value;
		vector<ll> new_dp = dp;
		for(int j = 0;j<w;j++){
			if(j + weight<=w){
				new_dp[j+weight] = max(dp[j]+value,new_dp[j+weight]);
			}
		}
		dp = new_dp;
	}
	cout<<*max_element(all(dp));
	return 0;
}

	


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ret = 0;
		if(S.equals("RRR")){
			ret = 3;
		}else if(S.contains("RR")){
			ret = 2;
		}else if(S.contains("R")){
			ret = 1;
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 35528
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    ll mod = 1e9 + 7, ans = 0;
    vector<ll> arr(n, 0);
    vector<ll> dp(n, 1);
    for(auto& val: arr)
        cin >> val;
    unordered_map<ll, int> pos;
    pos[arr[0]] = 0;
    for(int i = 1; i < n; i++) {
        dp[i] = dp[i-1];
        if (pos.count(arr[i]) > 0 && pos[arr[i]] != i-1) {
            dp[i] += dp[pos[arr[i]]];
        }
        dp[i] %= mod;
        pos[arr[i]] = i;
    }
    cout << dp.back() << endl;
    return 0;
}




Measured memory_bytes: 11592
from operator import mul

N,M,C = map(int,input().split())

B_list = list(map(int,input().split()))

ans = 0

for i in range(N):
  tmplist = list(map(int,input().split()))
  
  combined = list(map(mul,B_list,tmplist))

  if sum(combined)  + C > 0:
    ans += 1

print(ans)
    

Measured memory_bytes: 3060
import sys
from sys import exit
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(10**7)

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
 
    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def count(self, x):
        return -self.table[self._root(x)]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


N, M = mi()
ins = UnionFind(N)
for i in range(M):
    a, b = mi()
    a, b = a-1, b-1
    ins.union(a, b)
ans = 0
for i in range(N):
    ans = max(ans, ins.count(i))
print(ans)

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

int main() {
    int n, ans = 0, cnt = 0;
    int a[7] = {1, 2, 4, 8, 16, 32, 64};

    cin >> n;
    if (n == 1) {
        cout << a[0] << endl;
        return 0;
    }
    rep(i, 7) {
        if (a[i] > n) {
            cout << a[i - 1] << endl;
            return 0;
        } else if (a[i] == n) {
            cout << a[i] << endl;
            return 0;
        }
    }
    cout << a[6] << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  cout << N*N*N << endl;
}

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

ll dp[MAXN][MAXN];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    string s, t;
    char res[3007]{};
    cin >> s >> t;
    int m = s.length(), n = t.length();
    dp[0][0] = s[0] == t[0] ? 1 : 0;
    for (int j = 1; j != n; ++j) {
        dp[0][j] = max(dp[0][j - 1], s[0] == t[j] ? 1ll : 0ll);
    }
    for (int i = 1; i != m; ++i) {
        for (int j = 0; j != n; ++j) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    int i = m - 1, j = n - 1, idx = dp[m - 1][n - 1] - 1;
    while (idx != -1) {
        if (j > 0 && dp[i][j - 1] == dp[i][j]) {
            --j;
            continue;
        }
        if (i > 0 && dp[i - 1][j] == dp[i][j]) {
            --i;
            continue;
        }
        res[idx--] = s[i];
        --i;
        --j;
    }
    puts(res);
}

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

int main() {
    char A1,B1,C1;cin >> A1 >> B1 >> C1;
    char A2,B2,C2;cin >> A2 >> B2 >> C2;

    if (A1 == C2 && B1 == B2 && C1 == A2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;

#define pi 3.141592653589793)
#define mod 1000000007

int main(){
	string s;
	cin >> s;
	vector<int>a(s.size());
	for (int i = 0; i < s.size(); i++)a[i] = atoi(s.substr(i, 1).c_str());
	int bit = pow(2, a.size() - 1);
	llint res = 0;
	for (int i = 0; i <bit; i++) {
		llint n = 0;
		llint ans = 0;
		for (int j = 0; j < a.size()-1; j++) {
			if (i & (1 << j)) {
				ans += 10 * n + a[j];
				n = 0;
			}
			else {
				n = 10 * n + a[j];
			}
		}
		ans += 10*n+a[a.size() - 1];
		res += ans;
	}
	cout << res << endl;
	return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  if(a==1 && b==2){
    cout << "3" << endl;
  }
  if(a==1 && b==3){
    cout << "2" << endl;
  }
  if(a==2 && b==1){
    cout << "3" << endl;
  }
  if(a==2 && b==3){
    cout << "1" << endl;
  }
  if(a==3 && b==1){
    cout << "2" << endl;
  }
  if(a==3 && b==2){
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 
#define all(x) (x).begin(),(x).end()
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)
#define range(i,s,c) for(ll i=(s);i<(s+c);++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main()
{
	in(a);
	in(b);
	out(max(0LL,a-b*2));
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = B < A ? A - 1 : A;
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n,i,j;
	cin>>n;
	long long t[n], a[n],s=1,maxt=0,maxa=0;
	
	for(i=0;i<n;i++) {
		cin>>t[i];	
		if(t[i]>maxt) maxt=t[i];
	}
	for(i=0;i<n;i++) {
		cin>>a[i];	
		if(a[i]>maxa) maxa=a[i];
	}
	if(maxt==maxa){
		for(i=1;i<n-1;i++){
			if(t[i]==t[i-1]&&a[i]==a[i+1]) {
				s*=min(t[i],a[i]);
				s%=1000000007;
			} 
			if(t[i]!=t[i-1]) { if(t[i]>a[i]) { s=0; break; } }
			if(a[i]!=a[i+1]) { if(t[i]<a[i]) { s=0; break; } }
		}
	}
	else s=0;

	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define Max 			1e6
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define ppb				pop_back
#define pf				push_front
#define ppf				pop_front
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define v 				vector
#define mii             map<ll,ll>
#define pq              priority_queue<ll>
#define pqm             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define sp 				' '
#define pi 				3.14159265359
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void IO()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
void fastIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int main()
{
	fastIO();
	IO();
	ll n;
	cin >> n;
	if (n >= 1000)
	{
		ll ans = ceil((double)n / 1000);
		ans = ans * 1000;
		cout << ans - n << endl;
	}
	else
	{
		cout << 1000 - n << endl;
	}
	return 0;
}

Measured memory_bytes: 3776
S = list(input())

MOD = 10 ** 9 + 7

dp = [[0 for i in range(13)] for i in range(10**5+1)]
dp[0][0] = 1

for i in range(len(S)):
    if S[i] != "?":
        for j in range(13):
            dp[i+1][(j * 10 + int(S[i])) % 13] += dp[i][j]
    else:
        for j in range(13):
            for k in range(10):
                dp[i+1][(j * 10 + k) % 13] += dp[i][j]
    for j in range(13):
        dp[i+1][j] %= MOD

print(dp[len(S)][5])

Measured memory_bytes: 69640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define pi acos(-1)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int r;
    cin >> r;
    cout << fixed << setprecision(12) << 2*pi*r << endl;

    return 0;
}


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  
  if (S.at(K-1) == 'A') 
    S.at(K-1) = 'a';
  if (S.at(K-1) == 'B') 
    S.at(K-1) = 'b';
  if (S.at(K-1) == 'C') 
    S.at(K-1) = 'c';
 
    cout << S << endl;
}

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


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var hou = new List<int[]>[N];
            for (int i = 0; i < N; i++)
            {
                var A = ReadInt();
                hou[i] = new List<int[]>();
                for (int j = 0; j < A; j++)
                {
                    hou[i].Add(ReadArrayInt());
                }
            }
            var ans = 0;
            var max = 1 << N;
            for (int i = 1; i < max; i++)
            {
                var cnt = 0;
                var suc = true;
                for (int j = 0; j < N; j++)
                {
                    if ((i & 1 << j) != 1 << j) continue;
                    for (int k = 0; k < hou[j].Count(); k++)
                    {
                        var chk = hou[j][k][0] - 1;
                        if (hou[j][k][1] == 1)
                        {
                            if ((i & 1 << chk) != 1 << chk)
                            {
                                suc = false;
                                break;
                            }
                        }
                        else
                        {
                            if ((i & 1 << chk) == 1 << chk)
                            {
                                suc = false;
                                break;
                            }
                        }
                    }
                    if (!suc) break;
                    cnt++;
                }
                if (suc) ans = cnt > ans ? cnt : ans;
            }

            Console.WriteLine(ans);
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13524