akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int>> st(10);
  
  for (int i = 0; i < n; i++) st[s[i] - '0'].insert(i);
  
  int res = 0;

  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      for (int k = 0; k <= 9; k++) {
        int p = -1;

        if (st[i].upper_bound(p) == st[i].end()) continue;
        p = *(st[i].upper_bound(p));
        
        if (st[j].upper_bound(p) == st[j].end()) continue;
        p = *(st[j].upper_bound(p));
        
        if (st[k].upper_bound(p) == st[k].end()) continue;
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> a(n),b(n),c(m),d(m);
  vector<ll> v;
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];

  int ans = 0;
  rep(i,n){
    ll mn = 1e9;
    rep(j,m){
      if(mn > abs(a[i]-c[j])+abs(b[i]-d[j])){
        mn = abs(a[i]-c[j])+abs(b[i]-d[j]);
        ans = j+1;
      }
    }
    v.pb(ans);
  }
  rep(i,v.size()){
    cout << v[i] << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

class node {
public:
	int Hcover;
	int Lcover;
	int min;
	node *parent;
	node *left;
	node *right;
	node() {
		parent = NULL;
		left = NULL;
		right = NULL;
	}

	node(int l, int h, int m) {
		Hcover = h;
		Lcover = l;
		min = m;
		parent = NULL;
		left = NULL;
		right = NULL;
	}

	bool between(int a) {
		return (Lcover <= a) && (a <= Hcover);
	}

};

node **table;

node* cousei(node *n, int l, int h, int m) {
	node *mob = new node(l, h, m);
	mob->parent = n;
	if (h > l) {
		mob->left = cousei(mob, l, (h + l) / 2, m);
		mob->right = cousei(mob, (h + l) / 2 + 1, h, m);
	}
	if (h == l)table[h] = mob;
	return mob;
}

int find(node *n, int l, int h) {
	if (n->Lcover == l&&n->Hcover == h)return n->min;

	if (n->left->between(l) && n->left->between(h)) {
		return find(n->left, l, h);
	}
	else if (n->right->between(l) && n->right->between(h)) {
		return find(n->right, l, h);
	}
	else {
		return find(n->left, l, n->left->Hcover) + find(n->right, n->right->Lcover, h);
	}
}

void update(node *n, int p, int x) {
	for (node *it = n; it != NULL; it = it->parent) {
		it->min = it->left->min + it->right->min;
	}
}

int main(void) {
	node *root;
	root = new node();
	table = new node*[100000];
	int n, q;
	scanf("%d %d", &n, &q);
	root->Hcover = n;
	root->Lcover = 1;
	root->parent = NULL;
	root->left = cousei(root, 1, (n + 1) / 2, root->min);
	root->right = cousei(root, (n + 1) / 2 + 1, n, root->min);
	for (int XXX = 0; XXX < q; XXX++) {
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
		if (com == 0) {
			int m = table[x]->min;
			table[x]->min += y;
			update(table[x]->parent, x, y);
		}
		else {
			printf("%d\n", find(root, x, y));
		}
	}
}

Measured memory_bytes: 12848
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print('Yes' if len([1 for a in range(26) for b in range(26) if 4*a+7*b == N]) > 0 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let a = it.next().unwrap().parse::<i64>().unwrap();
    let b = it.next().unwrap().parse::<i64>().unwrap();
    let c = it.next().unwrap().parse::<i64>().unwrap();
    let k = it.next().unwrap().parse::<i64>().unwrap();
    println!("{}", if k%2 == 0 { a-b } else { b-a });
}


Measured memory_bytes: 4352
import java.util.Scanner;
class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        System.out.println(d + " " + r + " " + String.format("%.5f", f));
    }
}


Measured memory_bytes: 26532
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());
		int[][] s = new int[h + 2][w + 2];
		for(int i = 0 ; i < h + 2 ; i++) Arrays.fill(s[i] , 0);
		for(int i = 0 ; i < h ; i++){
			String sss = sc.next();
			for(int j = 0 ; j < w ; j++){
				if(sss.charAt(j) == '#') s[i + 1][j + 1] = -1;
			}
		}
		sc.close();
		for(int i = 1 ; i < h + 1 ; i++){
			for(int j = 1 ; j < w + 1 ; j++){
				if(s[i][j] != -1){
					for(int pp = i - 1 ; pp <= i + 1 ; pp++){
						for(int qq = j - 1 ; qq <= j + 1 ; qq++){
							if(s[pp][qq] == -1) s[i][j]++;
						}
					}
				}
			}
		}
		for(int i = 1 ; i < h + 1 ; i++){
			for(int j = 1 ; j < w + 1 ; j++){
				if(s[i][j] == -1) ou.print("#");
				else ou.print(s[i][j]);
			}
			ou.println();
		}
		ou.flush();
	}
}

Measured memory_bytes: 35820
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int ans = 999999999;
    string s;
    cin >> s;
    for(int i = 0;i < 2;i++)
    {
        int count = 0;
        for(int j = 0;j < s.size();j++)
        {
            if(s[j] - '0' != (i + j) % 2){count++;}
        }
        ans = min(ans,count);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

string s,t;
cin >> s >> t;
string tt=t.substr(0,s.size());
if(s==tt) cout << "Yes" << endl;
else cout << "No" << endl;

}

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

using namespace std;

vector <int> D[100001];
int Dp[100001], n;

void dfs(int d, int p)
{
    Dp[d] = 0;
    int k = 0, s=0;
    for (int i = 0; i < D[d].size(); i++)
    {
        int a = D[d][i];
        if (a != p)
        {
            s++;
            dfs(a, d);
            if (Dp[a] != 0)
            {
                k++;
            }
            Dp[d] += Dp[a];
        }
    }
    if (k < s-1)
    {
        Dp[d] += s-1-k;
    }
}

int main()
{
    int a, b, M=0;
    cin >> n;
    for (int i = 0; i < n-1; i++)
    {
        cin >> a >> b;
        D[a].push_back(b);
        D[b].push_back(a);
    }
    for (int i = 0; i < n; i++)
    {
        if (D[i].size() > M)
        {
            M = D[i].size();
            a = i;
        }
    }
    dfs(a, -1);
    if (Dp[a] == 0)
    {
        Dp[a] = 1;
    }
    cout << Dp[a];
    return 0;
}


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

int main(void){
    long long n, T, t[200000], count = 0;
    cin >> n >> T;
    for(int i = 0; i < n; ++i) cin >> t[i];
    int resttime = T, i = 1, now = 0;
    while(i <= n-1){
        now++;
        if(resttime){
            count++;
            resttime--;
        }
        if(now == t[i]){
            i++;
            resttime = T;
        } 
    }
    cout << (count+T) << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N =scan.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int num = 0;

		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
			B[i] = scan.nextInt();
		}

		sort(A, 0, N-1);
		sort(B, 0, N-1);

		if (N % 2 == 0) {
			num = B[N/2] + B[N/2-1] - A[N/2] - A[N/2-1] + 1;
		} else {
			num = B[(N-1)/2] - A[(N-1)/2] + 1;
		}

		System.out.println(num);
	}

	public static void sort(int[] x, int left, int right) {
		if (left >= right) {
			return;
		}

		int p = x[(left + right) / 2];
		int l = left;
		int r = right;
		int temp;

		while (l <= r) {
			while (x[l] < p) { l++; }
			while (x[r] > p) { r--; }
			if (l <= r) {
				temp = x[l];
				x[l] = x[r];
				x[r] = temp;
				l++;
				r--;
			}
		}

		sort(x, left, r);
		sort(x, l, right);
	}

}

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

int main() {
int N,L,i,x=0;
cin>>N;
for(i=1;i<=N;i++)
{
    cin>>L;
    if(i%2!=0)
    {
        if(L%2!=0)
        x++;
    }
}
cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3468
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;
int main()
{
    
    string p;
    cin >> p;

    string a = p.substr(0, 2);
    string b = p.substr(2, 2);
    int x = 0, y = 0;
    if (a >= "01" && a <= "12")x = 1;
    if (a > "12")x = 2;

    if (b >= "01" && b <= "12")y = 1;
    if (b > "12")y = 2;
    
    if (!x && !y)cout << "NA" << endl;
    else if (x == 2 && y == 2)cout << "NA" << endl;
    else if (x == 1 && y == 1)cout << "AMBIGUOUS" << endl;
    else if (x == 1 && y == 2)cout << "MMYY" << endl;
    else if (x == 1 && y == 0)cout << "MMYY" << endl;
    else if (x == 0 && y == 2)cout << "NA" << endl;
    else if (x == 2 && y == 1)cout << "YYMM" << endl;
    else if (x == 0 && y == 1)cout << "YYMM" << endl;
    else if (x == 2 && y == 0)cout << "NA" << endl;


    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define PB(x) push_back(x)
#define SIZE(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
	
return 0;
}


Measured memory_bytes: 256
d={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
while True:
    try:
        s=[d[i] for i in raw_input()]
    except EOFError:
        break
    i,m=0,0
    while i<len(s)-1:
        if s[i]<s[i+1]:
            m+=s[i+1]-s[i]
            s[i],s[i+1]=0,0
            i+=2
        else:
            i+=1
    print sum(s)+m

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;


int main()
{
    idfc;
    int n;
    cin>>n;
    int p= n/1000;
    if(n%1000)p++;
    int ans= (p*1000)-n;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
                using namespace std;
                #define int long long
                #define fi first
                #define se second
                #define pi pair<int,int>  
                #define pb push_back

                // dont forget to initialize global variables inside main() ;
                int mod = 1e9 + 7;

                int f=0;

                void dfs(int s,vector<vector<int>>&v,vector<int>&vis){
                    vis[s]=1;
                    f++;
                    for(int i=0;i<v[s].size();i++){
                        if( vis[v[s][i]]==0 )
                            dfs(v[s][i],v,vis);
                    }

                }

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

                int tt=1;//;cin>>tt; 
                
                
                while( tt-- ){

                    int n,m;cin>>n>>m;
                    vector<vector<int>> v(n);
                    for(int i=0;i<m;i++){
                        int x,y;cin>>x>>y;
                        x--;y--;
                        v[x].pb(y);
                        v[y].pb(x);
                    }

                    int ans=0;
                    vector<int > vis(n,0);
                    for(int i=0;i<n;i++){
                        f=0;
                        if( vis[i]==0 ){
                            dfs(i,v,vis);
                        }
                        ans = max(ans,f);
                    }
                    cout<<ans<<endl;
                }
                return 0;
            }

                        


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

int main(void){
    map<int, vector<ll>> city;
    int c, m;

    cin >> c >> m;

    pair<int, ll> input[m];
    rep(i, m){
        cin >> input[i].first >> input[i].second;
        city[input[i].first].push_back(input[i].second);
    }

    map<ll, int> id;

    int count = 0;
    for(auto v: city){
        sort(v.second.begin(), v.second.end());
        rep(i, v.second.size()){
            id[v.second[i]] = i + 1;
        }
    }

    rep(i, m){
        printf("%06d%06d\n", input[i].first, id[input[i].second]);
    }
}



Measured memory_bytes: 20224
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int H, R;
  cin >> H >> R;
  if (H == - R) {
    cout << 0 << endl;
  } else if (H < -R) {
    cout << -1 << endl;
  } else {
    cout << 1 << endl;
  }
}



Measured memory_bytes: 3220
#ABC 100C
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
#A.sort(reverse=True)

def calc(a):
    cnt =0
    while True:
        if a %2==0:
            cnt+=1
            a = a//2
        else:
            return cnt
            break

ans =0
for a in A:
    ans +=calc(a)

print(ans)

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

using ll = long long;

const int MAXN = 3e5;
const int MAXM = 3e5;
int N, M;
int A[MAXM], B[MAXM];
int par[MAXN], sz[MAXN];

ll ans[MAXN];

int getpar(int a) {
	return par[a] == -1 ? a : (par[a] = getpar(par[a]));
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	for (int e = 0; e < M; e++) {
		cin >> A[e] >> B[e]; A[e]--, B[e]--;
	}

	for (int i = 0; i < N; i++) {
		par[i] = -1;
		sz[i] = 1;
	}

	ans[M-1] = ll(N) * (N-1) / 2;
	for (int e = M-1; e >= 1; e--) {
		ans[e-1] = ans[e];
		int a = getpar(A[e]);
		int b = getpar(B[e]);
		if (a != b) {
			ans[e-1] -= ll(sz[a]) * sz[b];
			par[a] = b;
			sz[b] += sz[a];
		}
	}

	for (int e = 0; e < M; e++) {
		cout << ans[e] << '\n';
	}

	return 0;
}


Measured memory_bytes: 6272
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn result<'a>(x: u64, y: u64) -> u64{
    if y > 1 { x + result(x, y-1)*10 } else {x}
}

fn main(){
    input!{
        a:chars,
        b:chars
    }
    for i in b {
        print!("{}", i)
    }
    for i in a {
        print! ("{}", i)
    }
}


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

using namespace std;

int main(){
long long N; cin >> N;
  vector<long long > H(N);
  
  for(int i = 0; i < N; i++){ cin >> H[i];}
  
  if( N == 1){ cout << "Yes" << endl; return 0;}
  
  for(int i = 0; i < N - 1; i++){
    if( i == 0){ H[0]--;}
    else{
      if( H[i] > H[i-1]){  H[i]--;}}
  }
  
  bool flag = true;
  
  for(int i = 0; i < N - 1; i++){
    if( H[i] > H[i+1]){ flag = false;}}
  
  if( flag){ cout << "Yes" << endl;}
  else{ cout << "No" <<endl;}
  return 0;}

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

int main(){
    long long i,n;
    cin >> n;
    cout << n << ":" ;
    i=2;
    while(i*i<=n){
        if(n%i==0){
            n/=i;
            cout << " " << i;
        }else{
            i++;
        }
    }
    cout << " " << n;
    cout << endl;
}


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

ans = 0
for num in range(1, N + 1):
  count = 0
  if not num % 2:
    continue
  
  for i in range(1, num + 1):
    if not num % i:
      count += 1
    if count == 8:
      ans += 1
      continue
      
print(ans)

Measured memory_bytes: 2940
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e3 + 10;
LL check(vector<int> v, int o = 1)
{
	for (auto& x : v) x *= o;
	LL sum = 0;
	LL ans = 0;
	for (int i = 0; i < v.size(); i++)
	{
		sum += v[i];
		if (i % 2 == 0)
		{
			LL o = max(0LL, 1 - sum);
			sum += o;
			ans += o;
		}
		else
		{
			LL o = max(0LL, sum + 1);
			sum -= o;
			ans += o;
		}
	}
	return ans;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> v(n);
	for (auto& x : v) cin >> x;
	cout << min(check(v, 1), check(v, -1)) << endl;
	return 0;
}

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

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

    string S;
    cin >> S;
    vector<string> v;
    v.push_back("dream");
    v.push_back("dreamer");
    v.push_back("erase");
    v.push_back("eraser");
    bool flag;
    for (int i = 0; i < S.size(); i++) {
        if (v.empty()) {
            cout << "NO" << endl;
            return 0;
        }
        auto itr = v.begin();
        while (itr != v.end()) {
            if (S[i] == itr->at(0)) {
                itr->erase(itr->begin());
                itr++;
            } else {
                itr = v.erase(itr);
            }
        }
        flag = false;
        itr = v.begin();
        while (itr != v.end()) {
            if (itr->empty()) {
                flag = true;
                itr = v.erase(itr);
            } else {
                itr++;
            }
        }
        if (flag) {
            v.push_back("dream");
            v.push_back("dreamer");
            v.push_back("erase");
            v.push_back("eraser");
        }
    }

    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 512
def merge_jibun(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]

    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

# def merge_hoka(A, left, mid, right):
#     global count
#     inf = 10 ** 9
#     L = A[left:mid] + [inf]
#     R = A[mid:right] + [inf]
 
#     i = 0
#     j = 0
#     for k in range(left, right):
#         count += 1
#         # print(L)
#         # print(R)
#         if L[i] <= R[j]:
#             A[k] = L[i]
#             i += 1
#         else:
#             A[k] = R[j]
#             j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge_jibun(A, left, mid, right)
        # merge_hoka(A, left, mid, right)

n = int(input())
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print(' '.join(list(map(str, A))))
print(count)


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

int main(){
  int N; cin >>N;
  int c[N] = {0};
  int s[N] = {0};
  int f[N] = {0};
  REP(i,N-1){cin >> c[i] >> s[i] >> f[i];}
  REP(i,N){
    int t = 0;
    for(int j=i;j<N;j++){
      if(t>=s[j]){
        int fj = f[j];
        if(fj){t += (fj-t%fj)%fj + c[j];}
        else{ t += c[j]; }  
      }else{
        t = s[j]+c[j];
      }
    }
    printf("%d\n",t);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(void)
{
   int N;
   cin >> N;
   int p[N];
   int p_max = 0;
   int p_sum =0;
   for (int j=0 ; j<N;j++)
   {
       cin >>p[j]; 
       if(p[j] > p_max)
       {
           p_max = p[j];
       }
       p_sum += p[j];
       
   }
   p_sum -= p_max/2;
   
   
    cout << p_sum << endl;
    return 0;
}

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

int main(){
        int n;
        cin >> n;
        if (n == 25) {
                cout << "Christmas";
        }
        if (n == 24) {
                cout<< "Christmas Eve";
        }
        if (n == 23) {
                cout << "Christmas Eve Eve";
        }
        if (n == 22) {
                cout << "Christmas Eve Eve Eve";
        }
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int s=b+c;
    int res=a/s*b;
    a%=s;
    res+=min(a,b);
    cout<<res<<endl;
}

Measured memory_bytes: 256
from collections import deque
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

K = read_int()[0]

q = deque()
for i in range(1, 10):
    q.append(i)

def solve():
    for _ in range(K - 1):
        x = q.popleft()
        if x % 10 != 0:
            q.append(10 * x + (x % 10 - 1))
        q.append(10 * x + (x % 10))
        if x % 10 != 9:
            q.append(10 * x + + (x % 10 + 1))
    return q.popleft()

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 12384
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>

int main() {
	int ta, tb, ra, rb; std::cin >> ta >> tb >> ra >> rb;
	if (ra == -1 || rb == -1) {
		if (ta < tb) std::cout << "Alice\n";
		else if (tb < ta) std::cout << "Bob\n";
		else std::cout << "Draw\n";
	}
	else {
		if (ra > rb) std::cout << "Alice\n";
		else if (rb > ra) std::cout << "Bob\n";
		else std::cout << "Draw\n";
	}
}



Measured memory_bytes: 3100
A,B,C,X = [int(input()) for _ in range(4)]
X = X//50

ans = 0

for i in range(min(A, X//10) + 1):
    Y = X - 10*i
    for j in range(min(B, Y//2) + 1):
        ans += Y - 2*j <= C

print(ans)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    if(n%2) cout<<b[n/2]-a[n/2]+1<<endl ;
    else cout<<b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1<<endl;
    return 0;
}


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

using namespace std;

long long solve(int N, int P, string S)
{
	long long ans = 0;
	vector<int> r(N);
	r[N - 1] = (S[N - 1] - '0') % P;
	int d = 1;
	for (int i = N - 2; i >= 0; --i) {
		d *= 10;
		d %= P;
		r[i] = ((S[i] - '0') * d + r[i + 1]) % P;
	}

	vector<int> h(P, 0);
	for (auto x : r) {
		++h[x];
	}
	for (int i = 0; i < N; ++i) {
		if (r[i] == 0) {
			ans += h[r[i]];
			--h[r[i]];
		}
		else {
			--h[r[i]];
			ans += h[r[i]];
		}
		
	}
	return ans;
}

long long solve_2_or_5(int N, int P, string S)
{
	long long ans = 0;

	vector<int> h(10, 0);
	for (auto c : S) {
		++h[c - '0'];
	}
	for (int i = 0; i < N; ++i) {
		int x = S[i] - '0';
		if (x % P == 0) {
			for (int k = 0; k < 10; k += P) {
				ans += h[k];
			}
			--h[x];
		}
		else {
			--h[x];
			for (int k = 0; k < 10; k += P) {
				ans += h[k];
			}
		}
	}
	return ans;
}

int main()
{
	int N, P;
	string S;
	cin >> N >> P >> S;

	if (P == 2 || P == 5) {
		cout << solve_2_or_5(N, P, S) << endl;
	}
	else {
		cout << solve(N, P, S) << endl;
	}
}


Measured memory_bytes: 1540
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
# include <map>
# include <string>
# include <functional>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> students;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		students.emplace_back(a);
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j < n - 1; j++) {
			if (students[j] % i > students[j + 1] % i) {
				swap(students[j], students[j + 1]);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << students[i] << endl;
	}
}

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

using namespace std;

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

    int cntOdd = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a % 2 == 1) cntOdd++;
    }

    long long ans;
    if (cntOdd == 0) {
        ans = (p == 0) ? (1LL << n) : 0;
    } else {
        ans = 1LL << (n - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,string> p1,pair<ll,string> p2){
return p2.fi>p1.fi;
}
void cycle(ll p[],ll fi,ll si,ll ti){
swap(p[fi],p[ti]);
swap(p[si],p[ti]);
}
void solve(){
ll a,b,c,k;
cin>>a>>b>>c>>k;
if(k<=a+b){
    cout<<min(k,a)<<endl;
    return;
}
else{
    k-=a;
    k-=b;
    cout<<a-k<<endl;
}
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int s,w; cin>>s>>w;
    if(s<=w)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}





Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
using namespace std;
int a, b;
int main () {
	scanf ("%d%d", &a, &b);
	if (a <= 0 && b >= 0) printf ("Zero\n");
	else if (a > 0) printf ("Positive\n");
	else printf ((b - a + 1) & 1 ? "Negative\n" : "Positive\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define gc getchar
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)
#define reb(i,u,z) for(rint i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

inline int readint(){
	int rt=0,sign=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){
		if(ch=='-')sign=-1;
	    ch=gc();
	}
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt*sign;
}
int main(){
	int R,C,r,c;
	R=readint(),C=readint(),r=readint(),c=readint();
	printf("%d",R*C-r*C-c*(R-r));
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val (n, a, b) = readLine()!!.split(" ").map { it.toInt() }
	val values = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
	values.sort()
	values.reverse()
	val sum = (0..(a - 1)).fold(0L) { acc, i -> acc + values[i] }
	val ans = sum.toDouble() / a.toDouble()
	println("%.6f".format(ans))
	val v = values[a - 1]
	var r = (0..(a - 1)).fold(0) { acc, i -> if (values[i] == v) { acc + 1 } else { acc } }
	val num = (0..(n - 1)).fold(0) { acc, i -> if (values[i] == v) { acc + 1 } else { acc } }
	var prv = 1L
	for (i in 1..r) {
		prv = (prv * (num - i + 1)) / i
	}
	var total = prv
	if (r != a) {
		println(total)
		return
	}
	for (i in (r + 1)..(r + b - a)) {
		val pattern = (prv * (num - i + 1)) / i
		prv = pattern
		total += pattern
	}
	println(total)
}


Measured memory_bytes: 37904
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A!=B&&B!=C&&C!=A){
    cout << "No" << endl;
  }
  else if(A==B&&B==C){
cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define ll long long
int main()
{
    string x , y;
    cin >> x >> y;
  //  cout << x << " " << y << endl;
    ll m = x.size();
    ll n = y.size();

    ll g[m+1][n+1];
    memset(g , 0 , sizeof(g));

    for(ll i = 1 ; i <= m ; i++)
    {
        for(ll j = 1 ; j <= n ; j++){
            if(x[i-1] == y[j-1])
            {
                g[i][j] = 1+g[i-1][j-1];
            }
            else
            {
                g[i][j] = max(g[i-1][j] , g[i][j-1]);
            }
        }
    }
    string ans;
    ll i = m  ,j = n;
    while(i >0 && j >0)
    {
        if(x[i-1] == y[j-1])
        {
            ans.push_back(x[i-1]);
            i--;
            j--;
        }
        else
        {
            if(g[i-1][j] > g[i][j-1])
            {
                i--;
            }
            else 
            {
                j--;
            }
        }
    }

    for(ll i = ans.size()-1; i >= 0 ; i--){
        cout << ans[i] ;
    }
    

}


Measured memory_bytes: 70656
#include<iostream>
#include<vector>
using namespace std;
int main(){
  vector<vector<char>> a(3,vector<char>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>a.at(i).at(j);
    }
  }
  cout<<a.at(0).at(0)<<a.at(1).at(1)<<a.at(2).at(2)<<endl;
}

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


int main()
{
  string s;
  std::cin >> s;
  int os = count(begin(s), end(s), 'p');
  int ms = s.size() / 2 ;
  int ans = ms - os;
  cout << ans << endl;
}

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

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

    if( A == 1 ) A+=13;
    if( B == 1 ) B+=13;

    if( A > B ){
        cout << "Alice" << endl;
    }else if( A == B ){
        cout << "Draw" << endl;
    }else if( A < B ){
        cout << "Bob" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  int N,K; cin>>N>>K;
  ll ans=0;
  while(N){
    N/=K;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


signed main() {
	int y, x;
	while (1) {
		cin >> x >> y;
		if (y + x == 0) break;
		int d[20][20];
		rep(i, 0, 20) rep(j, 0, 20) d[i][j] = 1;
		rep(i, 0, y) {
			rep(j, 0, x) {
				cin >> d[i][j];
			}
		}
		int dp[20][20] = { 0 };
		rep(i, 0, x) {
			if (d[0][i] == 0) dp[0][i] = 1;
		}
		rep(i, 0, y) {
			rep(j, 0, x) {
				if (d[i][j] == 2 && d[i + 2][j] != 1) {
					dp[i + 2][j] += dp[i][j];
				}
				else if (d[i][j] == 0) {
					rep(k, -1, 2) {
						if (0 <= j + k && j + k < x && d[i + 1][j + k] == 0) {
							dp[i + 1][j + k] += dp[i][j];
						}
					}
					if (d[i + 1][j] == 2) {
						dp[i + 1][j] += dp[i][j];
					}
				}
			}
		}
		/*cout << endl;
		rep(i, 0, y + 2) {
			rep(j, 0, x) {
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}*/
		int ans = 0;
		rep(i, 0, x) {
			ans += dp[y - 1][i];
			if (d[y - 2][i] == 2) {
				ans += dp[y - 2][i];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
const ll MOD=1000000007,INF=1e18;

int N,M,A,B;
string s,t;
int a[100010],b[100010],c[100010];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>A>>B;
    if(B%A)cout<<B-A<<endl;
    else cout<<B+A<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
cnt = [1] * n
has_red = [False] * n
has_red[0] = True
for i in range(m):
    a, b = list(map(int, input().split()))
    has_red[b - 1] = has_red[b - 1] or has_red[a - 1]
    if cnt[a - 1] == 1:
        has_red[a - 1] = False
    cnt[a - 1] -= 1
    cnt[b - 1] += 1
print(has_red.count(True))


Measured memory_bytes: 76036
#include <cstdio>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if((a + b == c) || (a + c == b) || (b + c == a))
    {
        printf("Yes");
    }
    else 
    {
        printf("No");
    }
}


Measured memory_bytes: 1736
require 'prime'

def divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

n, m = gets.split.map(&:to_i)
puts divisors(Prime.prime_division(m), 0).select{ |k| k if m >= n * k }.max


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

using namespace std;

int white[200005], black[200005];

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

    int n, k; string s;

    cin >> n >> s >> k; k--;

    char temp = s[k];
    for(auto &i : s) if(i != temp) i = '*';
    cout << s;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

typedef long long int64;
const int inf = (int)1e9;

int main()
{
	int w, h, n;
	vector<pair<int, int> > pos;
	
	scanf("%d%d%d", &w, &h, &n);
	pos.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%d%d", &pos[i].first, &pos[i].second);
	
	vector<pair<int, int> > x, y;
	vector<pair<int64, pair<int, int> > > ans;
	
	for(int i = 0; i < n; ++i) {
		x.push_back(make_pair(pos[i].first, i));
		x.push_back(make_pair(pos[i].first, i));
		y.push_back(make_pair(pos[i].second, i));
		y.push_back(make_pair(pos[i].second, i));
	}
	
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	
	for(int i = 0; i < 2 * n; ++i) {
		pos[x[i].second].first = i;
		pos[y[i].second].second = i;
	}
	
	int x1 = n - 1, x2 = n, y1 = n - 1, y2 = n;
	int64 x1cost = 0, x2cost = 0, y1cost = 0, y2cost = 0;
	
	for(int i = 0; i < 2 * n; ++i) {
		x1cost += abs(x[i].first - x[x1].first);
		x2cost += abs(x[i].first - x[x2].first);
		y1cost += abs(y[i].first - y[y1].first);
		y2cost += abs(y[i].first - y[y2].first);
	}
	
	for(int i = 0; i < n; ++i) {
		
		int ix = pos[i].first;
		int dx = x[ix].first;
		int iy = pos[i].second;
		int dy = y[iy].first;
		
		int64 cost = 0;
		
		if(ix >= n)
			cost += x1cost - abs(dx - x[x1].first);
		else
			cost += x2cost - abs(dx - x[x2].first);
		
		if(iy >= n)
			cost += y1cost - abs(dy - y[y1].first);
		else
			cost += y2cost - abs(dy - y[y2].first);
		
		int sx = ix >= n ? x[x1].first : x[x2].first;
		int sy = iy >= n ? y[y1].first : y[y2].first;
		
		ans.push_back(make_pair(cost, make_pair(sx, sy)));
		
	}
	
	sort(ans.begin(), ans.end());
	
	printf("%lld\n%d %d\n", ans[0].first, ans[0].second.first, ans[0].second.second);
	
	return 0;
}

/* ハラスメントに負けず */
/* 0完太陽にも負けず */
/* はやく人権を獲得したい */
/* nullmineralが書きましたが */
/* 責任はまったくとりません */

Measured memory_bytes: 7884
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;


class Program
{
	//mod（10^9 + 7）
	static readonly long mod = 1000000007;

	//Main
	static void Main(string[] args)
	{
		int S = int.Parse(Console.ReadLine());

		//dp記憶用
		long[] dp = new long[S+1];
		//累積和
		long[] accum = new long[S+1];
		if(S >= 3){
			dp[3] = 1;
			accum[3] = 1;
		}

		for(int i=4; i<S+1; i++){
			//i単体の場合、1通り
			dp[i] ++;

			//単体ではない場合、今までのケツに玉を加えるイメージ
			//対象は、3 <= j <= i-3までの和
			/*
			3つ前の並びのケツに3つ玉を加え、
			4つ前のケツに4個加え etc...
			*/
			if(3 <= i-3){
				long sum = accum[i-3] - accum[2];
				dp[i] += sum;
				dp[i] %= mod;
			}

			//累積和に反映
			accum[i] = accum[i-1] + dp[i];
			accum[i] %= mod;
		}

		long ans = dp[S];

		if(ans < 0){
			ans += mod;
		}
		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 17508
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;


class Program
{
	//繰り返し２乗法
	//N^Pをmodで割った余りを計算
	static long PowMod(long N, long P, long mod){
		//0乗の場合
		if(P == 0){
			return 1;
		}
		//指数が偶数の場合
		else if(P % 2 == 0){
			//指数を半分にして計算したもの同士を掛け合わせる
			long half = PowMod(N, P/2, mod);
			return half * half % mod;
		}
		//奇数の場合
		else{
			//指数を一つ減らしたものに、Nをかける
			long before = PowMod(N, P-1, mod);
			return N * before % mod;
		}
	}

	//Main
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());

		long mod = 1000000007;

		//全て0~9の組み合わせの数
		long ans = PowMod(10, N, mod);

		//うち、0がない組み合わせ（9がないのも数は同じ）
		long non1 = PowMod(9, N, mod);

		//うち、0も9もない組み合わせ
		long non2 = PowMod(8, N, mod);

		ans -= non1;
		ans %= mod;
		ans -= non1;
		ans %= mod;
		ans += non2;
		ans %= mod;

		if(ans < 0){
			ans += mod;
		}

		Console.WriteLine(ans);
	}
}



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

int main() {
	ll n,cnt=0;
	cin>>n;
	vector<ll>a(n+1),b(n);
	for(ll i=0;i<n+1;i++)cin>>a.at(i);
	for(ll i=0;i<n;i++){
		cin>>b.at(i);
		if(a.at(i)<b.at(i)){
			cnt+=a.at(i);
			b.at(i)-=a.at(i);
			a.at(i)=0;
		}else{
			cnt+=b.at(i);
			a.at(i)-=b.at(i);
			b.at(i)=0;
		}
		if(a.at(i+1)<b.at(i) ){
			cnt+=a.at(i+1);
			a.at(i+1)=0;
			b.at(i)-=a.at(i+1);
		}else if(a.at(i+1)>=b.at(i) ){
			cnt+=b.at(i);
			a.at(i+1)-=b.at(i);
			b.at(i)=0;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############
X,A = inputIL()

if X<A:
  print(0)
  exit()
print(10)


Measured memory_bytes: 63980
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b;
	cin>>a>>b;
	if(b%a!=0)
		cout<<b-a<<endl;
	else
		cout<<a+b<<endl;
	return 0;
}


Measured memory_bytes: 256