akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

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

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

ll gcd(ll a, ll b){
    ll tmp;
    if(a%b == 0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}

ll a,b,c,d;
ll mem_a[2],mem_b[2],mem_sum[2],ans;

int main(){
    cin >> a >> b >> c >> d;

    mem_a[0] = (a-1)/c;
    mem_a[1] = b/c;
    mem_b[0] = (a-1)/d;
    mem_b[1] = b/d;

    ll sum_ = c*d/gcd(max(c,d),min(c,d));
  //  cout << sum_ << endl;
    mem_sum[0] = (a-1)/sum_;
    mem_sum[1] = b/sum_;

    ans = mem_a[1]+mem_b[1]-mem_sum[1];
    ans -= mem_a[0]+mem_b[0]-mem_sum[0];
    ans = b-(a-1)-ans;

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const int MAX_N=1e5;


vector<int>G[MAX_N];
int color[MAX_N];
LL N,M;
bool dfs(int v,int c){
    color[v]=c;
    REP(i,SZ(G[v])){
        if(color[G[v][i]]==c)return 0;
        if(color[G[v][i]]==0&&!dfs(G[v][i],-c))return 0;
    }
    return 1;
}
int main(){
    cin>>N>>M;
    REP(i,M){
        int A,B;
        cin>>A>>B;A--;B--;
        G[A].PB(B);
        G[B].PB(A);
    }
    CLR(color);
    bool flag=1;
    REP(i,N){
        if(color[i]==0){
            if(!dfs(i,1)){
                flag=0;break;
            }
        }
    }
    LL cnt=0;
    REP(i,N)if(color[i]==1)cnt++;
    if(!flag){
        cout<<N*(N-1LL)/2LL-M<<endl;
    }else{
        cout<<cnt*(N-cnt)-M<<endl;
    }
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(),a.end());
	ll now = a[0];
	int ans = 0;
	int cnt = 0;

	for(int i = 1; i < n; i++){
		if(2*now < a[i]){
			ans += cnt+1;
			cnt = 0;
		}
		else cnt++;
		now += a[i];
	}

	ans = n-ans;
	
	cout << ans << endl;
	return 0;
}

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

int main() {
  
  int64_t a, b, c; cin >> a >> b >> c;
  
  int64_t leftSide = 4 * a * b;
  
  int64_t tmp = c - a - b;
  
  int64_t rightSide = tmp * tmp;
  
  if (0 < tmp && leftSide < rightSide) cout << "Yes" << endl;
  
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3568
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

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

#[allow(dead_code)]
const M: i64 = 1_000_000_007;

fn eval(p: ((f64, f64), (f64, f64)), t: f64) -> (f64, f64) {
    ((p.0).0 + (p.1).0 * t, ((p.0).1 + (p.1).1 * t))
}

fn area(ps: &Vec<((f64, f64), (f64, f64))>, t: f64) -> f64 {
    let (x_, y_) = eval(ps[0], t);
    let mut x_min = x_;
    let mut y_min = y_;
    let mut x_max = x_;
    let mut y_max = y_;
    for &p in ps.iter() {
        let (x, y) = eval(p, t);
        if x_min > x { x_min = x };
        if x_max < x { x_max = x };
        if y_min > y { y_min = y };
        if y_max < y { y_max = y };
    }
    (x_max - x_min) * (y_max - y_min)
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let ps: Vec<_> = (0..n).map(|_| {
        let x: f64 = sc.cin();
        let y: f64 = sc.cin();
        let d: char = sc.cin::<String>().chars().next().unwrap();
        match d {
            'U' => ((x, y), (0., 1.)),
            'D' => ((x, y), (0., -1.)),
            'R' => ((x, y), (1., 0.)),
            'L' => ((x, y), (-1., 0.)),
            _ => ((x,y),(0.,0.))
        }
    }).collect();

    let mut left = 0.0;
    let mut right = 2000000000.0;
    for _ in 0..1000 {
        let t1 = (left + left + right) / 3.0;
        let t2 = (left + right + right) / 3.0;
        if area(&ps, t1) < area(&ps, t2) {
            right = t2;
        } else {
            left = t1;
        }
    }
    put!(area(&ps, (left + right) / 2.0));
}

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

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


Measured memory_bytes: 8444
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;
		String[] input;
		int i, j;
		int N, M;
		HashMap<Integer, Integer> D = new HashMap<Integer, Integer>();
		HashMap<Integer, Integer> T = new HashMap<Integer, Integer>();
		int max = 0;
		int ans = 0;
		int d, t;
		
		N = Integer.parseInt(br.readLine());
		buf = br.readLine();
		input = buf.split(" ");
		for(i=0;i<N;i++) {
			d = Integer.parseInt(input[i]);
			if(D.containsKey(d)) {
				D.put(d, D.get(d) + 1);
			} else {
				D.put(d,  1);
			}
		}
		M = Integer.parseInt(br.readLine());
		buf = br.readLine();
		input = buf.split(" ");
		for(i=0;i<M;i++) {
			t = Integer.parseInt(input[i]);
			if(D.containsKey(t) && D.get(t) > 0) {
				D.put(t, D.get(t) - 1);
			} else {
				System.out.println("NO");
				return;
			}
		}
		
		System.out.println("YES");
	}
}


Measured memory_bytes: 98284
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
      	int C = sc.nextInt();
      	int X = sc.nextInt();
        int total = 0;
        int count = 0;
      
      	for(int i=0; i<=A; i++){
          for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
              total = 500*i + 100*j + 50*k;
              if(total == X){
                count++;
              }
            }
          }
        }
      	System.out.println(count);
    }
}


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

using namespace std;

#define ll long long


int main(){
  int n, k;
  cin >> n >> k;
  
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  priority_queue<int> q0, q1;
  vector<int> fin(n, false);
  vector<int> seq(n, 1);
  for(int i = 0; i < k; i++){
    q0.push(p[i]);
    q1.push(-p[i]);
  }
  for(int i = n - 2; i >= 0; i--){
    if(p[i] < p[i + 1]) seq[i] = seq[i + 1] + 1;
  }
  ll s = 0;
  for(int i = 0; i < n; i++){
    if(seq[i] == k) s++;
  }
  ll count = 1;
  for(int i = 0; i + k < n; i++){
    while(fin[-q1.top()]){
      q1.pop();
    }
    ll c = 0;
    if(-q1.top() != p[i]) c = 1;
    fin[p[i]] = true;
    while(fin[q0.top()]){
      q0.pop();
    }
    q0.push(p[i + k]);
    q1.push(-p[i + k]);
    if(q0.top() != p[i + k]) c = 1;
    count += c;
  }
  
  cout << (count - max(s - (ll)1, (ll)0)) << endl;
  
  return 0;
}

Measured memory_bytes: 4468
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int isUnder(int T,int A){ // AがT以下で1,それ以外0
    if(A<=T) return 1;
    else return 0;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(N,K);
    if(K==1) cout << 0 << nn;
    else cout << N - K << nn;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[3],ans=0;
	cin>>a[0]>>a[1]>>a[2];
	if(a[0]==a[1]&&a[1]==a[2]){
	    cout<<0<<endl;
	    return 0;
	}
	while(1){
	    sort(a,a+3);
	    a[2]=a[2]-a[0];
	    a[1]=a[1]-a[0];
	    a[0]=0;
	    if(a[0]==0&&a[1]==2&&a[2]==2){
	        cout<<ans+1<<endl;
	        return 0;
	    }
	    if(a[0]==0&&a[1]==0&&a[2]==1){
	        cout<<ans+1<<endl;
	        return 0;
	    }
	    a[0]+=2;
	    ans++;
	}
	return 0;
}

Measured memory_bytes: 256
while l=gets and l!="-1 -1 -1\n"
  c,k,r=l.split(' ').map(&:to_i)
  if [c,k].include?(-1)
    puts 'F'
  else
    puts (case c+k
          when (80..100); 'A'
          when (65..79);  'B'
          when (50..64);  'C'
          when (30..49)
            r>=50 ? 'C' : 'D'
          else
            'F'
          end)
  end
end

Measured memory_bytes: 8648
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
#define MOD 1000000007

LL h, w, O[3003][3003] = {}, I[3003][3003] = {}, ans = 0;
char cell[3003][3003];

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			cell[i][j] = s[j];
		}
	}
	for (int i = h - 1; i >= 0; i--) {
		for (int j = w - 1; j >= 0; j--) {
			O[i][j] = O[i][j + 1];
			if (cell[i][j] == 'O')O[i][j]++;
			I[i][j] = I[i + 1][j];
			if (cell[i][j] == 'I')I[i][j]++;
			if (cell[i][j] == 'J')
				ans += O[i][j] * I[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n, k; cin >> n >> k;
  int towns[n];
  REP(i,n) {
    cin >> towns[i];
    --towns[i];
  }
  unordered_map<int, bool> mp;
  vector<int> shu;
  int next = 0;
  int loops = -1;
  while(!mp[next]) {
    mp[next] = true;
    shu.push_back(next);
    next = towns[next];
  }
  int loope = shu.size();
  for(int i = 0; i < shu.size(); ++i) {
    if(shu[i] == next) {
      loops = i;
      break;
    }
  }
  if(loops >= k) {
    cout << shu[k] + 1 << endl;
  } else {
    k -= loops;
    k %= loope - loops;
    cout << shu[loops+k] + 1 << endl;
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 14300
//boom diggy diggy boom boom
/*
freopen("input.txt","r",stdin);
    	freopen("output.txt","w",stdout);
    	*/
#include<bits/stdc++.h>
#define ull unsigned long long int 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define ll long long 
#define ld long double 

int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n,int r){int res=1;if(r>n-r)r=n-r;for(int i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}int max(int a,int b){int ans=a>b?a:b;return ans;}

using namespace std;

int main()
{
  int m,n;
  cin>>m>>n;
  char a[m+1][n+1];
  for (int i = 1; i <= m; ++i)
  {
  	for (int j = 1; j <= n; ++j)
  	{
  		cin>>a[i][j];
  	}
  }
  int b[m+1][n+1];
  for (int i = 0; i <= m; ++i)
  {
  	for (int j = 0; j <= n; ++j)
  	{
  		if(i==0 || j==0)
  			{
  				a[i][j]='#';
  				b[i][j]=0;
  			}
  		else
  		{
  			if(a[i][j]!='#')
  			{
	  			int x=0;
	  			if(i==1 && j==1)
	  				x=1;

  				x+=b[i-1][j];
  				x+=b[i][j-1];
	  			b[i][j]=x%mod;
	  		}
	  		else
	  			b[i][j]=0;
  		}
  	}
  }
  /*for (int i = 0; i <= m; ++i)
  {
  	for(int j =0 ; j<=n ;j++)
 		cout<<a[i][j]<<" ";
 	cout<<endl;
  }

  for (int i = 0; i <= m; ++i)
  {
  	for(int j =0 ; j<=n ;j++)
 		cout<<b[i][j]<<" ";
 	cout<<endl;
  }
  */
  cout<<b[m][n];
return 0;
}

Measured memory_bytes: 5120
def bubble(n, nums, strings)
  n.times do |i|
    a = n - 1
    i += 1
    while true do
      if a < i
        break
      end
      if nums[a] < nums[a - 1]
        tmp = nums[a]
        nums[a] = nums[a - 1]
        nums[a- 1] = tmp
        tmp_s = strings[a]
        strings[a] = strings[a - 1]
        strings[a- 1] = tmp_s
        a -= 1
      else
        a -= 1
      end
    end
  end
  return nums, strings
end

def selection(n, nums, strings)
  n.times do |nn|
    s = n - 1 - nn
    nm = nn + 1
    min = nums[nn]
    hoge = -111
    s.times do
      if min > nums[nm]
        hoge = nm
        min = nums[nm]
      end
      nm += 1
    end
    #入れ替え作業
    if hoge > 0
      tmp = nums[nn]
      nums[nn] = nums[hoge]
      nums[hoge] = tmp
      tmp_s = strings[nn]
      strings[nn] = strings[hoge]
      strings[hoge] = tmp_s
    end
  end
  return nums, strings
end

n = gets.chomp.to_i
tramps = gets.chomp.split(" ")
nums = tramps.map{|t| t.split("")[1].to_i}
strings = tramps.map{|t| t.split("")[0]}

nums_s = tramps.map{|t| t.split("")[1].to_i}
strings_s = tramps.map{|t| t.split("")[0]}

new_bubble_nums, new_bubble_strings = bubble(n, nums, strings)
new_selection_nums, new_selection_strings = selection(n, nums_s, strings_s)

bubble_result = []
selection_result = []

n.times do |a|
  bubble_result << new_bubble_strings[a] + new_bubble_nums[a].to_s
end
n.times do |b|
  selection_result << new_selection_strings[b] + new_selection_nums[b].to_s
end

puts bubble_result.join(" ")
puts 'Stable'

puts selection_result.join(" ")

if new_bubble_strings == new_selection_strings
  puts 'Stable'
else
  puts 'Not stable'
end



Measured memory_bytes: 6992
<?php
    fscanf(STDIN, "%d %d %d", $a, $b, $x);

    $a_div = $a % $x;
    $a_min = $a_div === 0 ? $a_min = $a : $a_min = $a + ($x - $a_div);
    
    $b_div = $b % $x;
    $b_max = $b - $b_div;
    $result   = ($b_max - $a_min) / $x + 1;
    
    echo $result ."\n";

Measured memory_bytes: 3576
n=int(input())
S=[]
T=[]
for i in range(n):
    s,t=input().split()
    S.append(s)
    T.append(int(t))
x=input()
y=0
for i in range(n):
  y+=T[i]
  if S[i]==x:
    print(sum(T)-y)
    break
  else:    
    i+=1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

ll n,k;
vector<long long> a;

long long solve(ll x){
  ll ret = 0;
  for(ll i = 0; i < n; i++){
    ret += (a[i]+x-1)/x-1;
    if(ret > k) break;
  }
  return ret;
}

int main(){
  cin >> n >> k;
  a.resize(n);
  int mx = 0;
  for(ll i = 0; i < n; i++){
    cin >> a[i];
    if(mx < a[i]) mx = a[i];
  }
  if(k == 0){
    cout << mx << endl;
    return 0;
  }
  ll right = mx+1,left = 0,mid;
  while(right-left > 1){
    mid = (right+left)/2;

    ll cnt = solve(mid);
    //cout << mid << " " << cnt << " " << left << " " << right << endl;
    if(cnt > k) left = mid;
    else right = mid;
  }
  cout << right << endl;
  return 0;
}

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

int main()
{
    int x;
    std::cin >> x;
    std::vector<bool> p(300000,true);
    std::vector<int> prime;
    for(int i = 2;i < 300000;i++){
        if(p[i]){
            prime.push_back(i);
            //std::cerr << i << std::endl;
            for(int j = i; j < 300000;j += i)p[j] = false;
        }
    }
    std::cout << *std::lower_bound(prime.begin(),prime.end(),x) << std::endl; 

}

Measured memory_bytes: 512
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9;
int n;
signed main(){
	scanf("%lld",&n);
	int ans=1e18;
	for(int i=1;i*i<=n;i++){
		if(n%i==0)ans=min(ans,i-1+n/i-1);
	}
	printf("%lld\n",ans);

	return 0;
}


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

a = [0] * n
b = [0] * n
c = [0] * n

a[0], b[0], c[0] = l[0][0], l[0][1], l[0][2]

for i in range(1,n):
    a[i] = max(l[i][0]+b[i-1], l[i][0]+c[i-1])
    b[i] = max(l[i][1]+a[i-1], l[i][1]+c[i-1])
    c[i] = max(l[i][2]+a[i-1], l[i][2]+b[i-1])

print(max(a[-1],b[-1],c[-1]))

Measured memory_bytes: 42308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  FOR(i, 1, n) {
    if (i % 3 == 0 || i % 5 == 0) a[i-1] = 0;
    else
      a[i-1] = i;
  }
  ll ans = 0;
  REP(i, n) {
    ans += a[i];
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

class Fenwick {
public:
  	vector<vector<int>> f;
  	string str;
  
    Fenwick(int n, char s[]) {
      	vector<vector<int>> v(n + 1, vector<int>(26));
      	swap(f, v);
      	//f.resize(n + 1);
      	str = string(s);
      	//for (int i = 0; i <= n; ++i) f[i].resize(26);
      	for (int i = 0; i < n; ++i)
          for (int j = i + 1; j <= n; j += j & (-j))
            f[j][s[i] - 'a']++;
    }
    
    void update(int n, char c) {
      	if (c == str[n-1]) return;
      	for (int i = n; i < f.size(); i += i & (-i)) {
          f[i][c - 'a']++;
          f[i][str[n-1] - 'a']--;
        }
      	str[n-1] = c;
    }
  
    void sum(int n, int arr[]) {
      	for (int i = n; i > 0; i -= i & (-i))
          for (int j = 0; j < 26; ++j)
            arr[j] += f[i][j];
    }
  
    int query(int l, int r) {
      int qa[26] = {}, qb[26] = {}, s(0);
      sum(l - 1, qa);
      sum(r, qb);
      for (int i = 0; i < 26; ++i) 
        if (qa[i] != qb[i]) s++;
      return s;
    }
};

int main() {
  int n, q, t, x, y;
  cin >> n;
  char s[n], c;
  for (int i = 0; i < n; ++i) cin >> s[i];
  Fenwick f(n, s);
  cin >> q;
  while (q--) {
    cin >> t >> x;
    if (t == 1) {
      cin >> c;
      f.update(x, c);
    } else {
      cin >> y;
      cout << f.query(x, y) << '\n';
    }
  }
  return 0;
}

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

void DFS(int v,vector<vector<int>> &g,vector<bool> &vis) 
{   vis[v] = true; 
    for(int i=0; i < g[v].size(); ++i) 
        if(!vis[g[v][i]]) 
            DFS(g[v][i],g,vis); 
} 
 
int main(){
 	int N,M;
  	cin>>N>>M;
  	vector<vector<int>> g(N);
  	for(int i=0;i<M;i++){
    	int a,b;
      	cin>>a>>b;
  		g[a-1].push_back(b-1);
      	g[b-1].push_back(a-1);
    }
  	int count=0;
  	vector<bool> vis(N,false);
	for(int i=0;i<N;i++){
     	if(vis[i]==false){
          	DFS(i,g,vis);
          	count++;
        }
    }
  	cout<<(count-1);
  	return 0;
}

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

using namespace std;



int main ()
{

int n;
cin >> n;
vector <int> a(n);
int sum  = 0;
for (int i=0; i<n; i++)
{   cin >> a[i];
    sum+=a[i];
}
//cout << sum;
double x = (float)sum/n;
//cout << x << " ";
int xx = round(x);
//cout << xx;


long long res = 0;
for (auto x:a)
    res +=  (xx-x)* (xx-x);

    cout << res;
}

/*
3
1 4 6
*/























Measured memory_bytes: 256
i=int(input())
s=[]
s.append(i)
for i in range(1000000):
    if s[i]%2==0:
        if s[i]//2 in s:
            print(i+2)
            exit(0)
        else:
            s.append(s[i]//2)
    else:
        if 3*s[i]+1 in s:
            print(i+2)
            exit(0)
        else:
            s.append(3*s[i]+1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Here your code !
    int H,W;
    cin >> H >> W;
    
    vector<vector<int> > a(H,vector<int>(W,0));
    vector<vector<int> > b(H,vector<int>(W,0));
    
    for(int i = 0; i < W; i++) a[0][i] = 1;
    
    for(int i = 0; i < W; i+=2){
        for(int j = 0; j < H-1; j++){
            a[j][i] = 1;
        }
    }
    
    for(int i = 0; i < W; i++) b[H-1][i] = 1;
    
    
    for(int i = 1; i < W; i+=2){
        for(int j = 1; j < H; j++){
            b[j][i] = 1;
        }
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char c;
            cin >> c;
            if(c == '#'){
                a[i][j] = 1;
                b[i][j] = 1;
            }
        }
    }
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(a[i][j]){
                cout << '#';
            }else{
                cout << '.';
            }
        }
        cout << endl;
    }
    cout << endl;
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(b[i][j]){
                cout << '#';
            }else{
                cout << '.';
            }
        }
        cout << endl;
    }
    cout << endl;
    
}


Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S, T;
    cin >> S >> T;

    ll ns = S.size(), nt = T.size();

    bool ans = false;

    for (ll i = ns - nt; i >= 0; i--) {
        ll now = i;
        bool check = true;
        Rep (j, nt) {
            if (S[now + j] != T[j] && S[now + j] != '?') check = false;
        }

        if (check) {
            Rep (j, nt) S[now + j] = T[j];
            ans = true;
            break;
        }
    }

    if (ans) {
        for (auto &e : S) if (e == '?') e = 'a';
        cout << S << "\n";
    }
    else cout << "UNRESTORABLE\n";
}

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

int main () {
  int N, l, r;
  int sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

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

	
	cout<<(min(B-1,N)*A/B)<<endl;
}

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

int main(){
	int N,K,x=1;
	cin >>N>>K;
	for(int i=0;i<N;i++ ){
		if(2*x<x+K)
			x*=2;
		else
			x+=K;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  const string vowel = "aeiou";

  char c;
  cin >> c;
  REP(i, 5) {
    if (c == vowel[i]) {
      cout << "vowel" << endl;
      return 0;
    }
  }

  cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

import math

ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        dist2 = sum([(Xi - Xj) ** 2 for Xi, Xj in zip(X[i], X[j])])
        dist = int(math.sqrt(dist2))
        if dist ** 2 == dist2:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define debug(x) cout << #x << " is " << x << endl;
 
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
 
ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}
 
#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

struct custom_cmp{
	bool operator()(string i,string j){
		return sz(i)>sz(j);
	}
};

const int L=128;
const string A="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
//const string A="ab"; //testing 
int len;

priority_queue<string, vector<string>, custom_cmp> pq;

bool subset(string i){
	cout<<"? "<<i<<endl;
	
	int val;
	cin>>val;
	
	return val==len-sz(i);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	for (auto &it:A){
		string query;
		
		rep(x,0,L) query+=it;
		
		cout<<"? "<<query<<endl;
		
		int val;
		cin>>val;
		
		query="";
		
		rep(x,0,L-val) query+=it;
		len+=L-val;
		
		pq.push(query);
	}
	
	string s,t;
	while (sz(pq)!=1){
		s=pq.top(),pq.pop();
		t=pq.top(),pq.pop();
		
		//add t into s character by character
		
		int pos=0;
		
		rep(x,0,sz(t)){
			while (true){
				s.insert(s.begin()+pos,t[x]);
				
				if (subset(s)){
					pos++;
					break;
				}
				else {
					s.erase(s.begin()+pos);
					pos++;
				}
			}
		}
		
		pq.push(s);
	}
	
	
	cout<<"! "<<pq.top();
}


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

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1) {
    for ( int u : to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}


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

    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	int a, b, c; cin >> a >> b >> c;
	if ((a - c) * (b - c) < 0)co("Yes");
	else co("No");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int aa, bb, a, b;
	char n[13] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1 };
	
	scanf("%d %d", &a, &b);

	for (aa = 0; aa < 13; aa++) if (n[aa] == a) break;
	for (bb = 0; bb < 13; bb++) if (n[bb] == b) break;
	
	if (aa > bb) printf("Alice\n");
	else if (bb > aa) printf("Bob\n");
	else printf("Draw\n");

	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class19
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var DP = new long[N + 2];
            DP[0] = 0;
            for (int i = 1; i < N + 2; i++) DP[i] = long.MaxValue;

            for(int i = 0; i < N-1; i++)
            {
                int df1 = Math.Abs(h[i] - h[i + 1]);
                DP[i + 1] = Math.Min(DP[i + 1], DP[i] + df1);

                if (i < N - 2)
                {
                    int df2 = Math.Abs(h[i] - h[i + 2]);
                    DP[i + 2] = Math.Min(DP[i + 2], DP[i] + df2);
                }
            }
            Console.WriteLine(DP[N - 1]);
        }
    }
}


Measured memory_bytes: 18528
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int a,b,c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

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

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

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    sort(s.begin(), s.end());
    rep(i, n) cout << s[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t n = s.size();
    for (auto i : irange(0L, (n - 1) / 2)) {
        if (s[i] != s[(n - 1) / 2 - 1 - i] ||
            s[(n + 3) / 2 + i - 1] != s[n - 1 - i] || s[i] != s[n - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200005];
long long cnt[10010];
int main()
{
	long long n,p;cin>>n>>p>>s;
	
	long long sum=0;
		if(p==2||p==5)
	{for(int i=0;i<n;++i)
	
		if((s[i]-'0')%p==0) sum+=(i+1);
}
	else { cnt[0]=1;long long t=0,x=1;
		for(int i=n-1;i>=0;--i)
		{
		t=(t+(s[i]-'0')*x)%p;
		x=x*10%p;
		sum+=cnt[t];
		cnt[t]++;
		}
	}
cout<<sum;

}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:

    vector<vector<char>> decode(string s) {
        vector<vector<char>> ret(1);
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == '/') {
                ret.push_back(vector<char>());
            } else if (s[i] == 'b') {
                ret.back().push_back('b');
            } else {
                rep(j, '0', s[i]) {
                    ret.back().push_back('.');
                }
            }
        }
        return ret;
    }

    string encode(vector<vector<char>> vv) {
        string ret;
        for (int i = 0; i < vv.size(); ++i) {
            for (int j = 0; j < vv[i].size(); ++j) {
                if (vv[i][j] == 'b') {
                    ret.push_back('b');
                } else {
                    if (!ret.size() || ret.back() == 'b' || ret.back() == '/') {
                        ret.push_back('1');
                    } else {
                        ret.back()++;
                    }
                }
            }
            if (i + 1 < vv.size()) {
                ret += '/';
            }
        }
        return ret;
    }

    bool solve() {
        string s;
        cin >> s;
        if (s == "#") return false;
        Int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        auto tapu = decode(s);
        tapu[a][b] = '.';
        tapu[c][d] = 'b';
        string tapi = encode(tapu);
        cout << tapi << endl;

        return true;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    while (Solve().solve());


    return 0;
}



Measured memory_bytes: 3196
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned LL
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector< PII >
#define VVI vector< VI >
#define MP make_pair
#define PB push_back
#define F first
#define S second
const int INF=1e9;
const int MOD=1e9+7;
// >.<
int p[100000];
void init(){
    for(int i=0;i<100000;i++)p[i]=i;
}
int find(int x){
    return (p[x]==x)?x:(p[x]=find(p[x]));
}
bool merge(int x,int y){
    x=find(x);
    y=find(y);
    if(x!=y){
        p[x]=y;
        return 1;
    }
    return 0;
}
int n;
pair< pair<LL,LL>,int > point[100000];
vector< pair< LL,PII > > edge;
bool by_x(pair< pair<LL,LL>,int > x,pair< pair<LL,LL>,int > y){
    return (x.F.F<y.F.F);
}
bool by_y(pair< pair<LL,LL>,int > x,pair< pair<LL,LL>,int > y){
    return (x.F.S<y.F.S);
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld %lld",&point[i].F.F,&point[i].F.S);
        point[i].S=i;
    }
    sort(point,point+n,by_x);
    for(int i=1;i<n;i++){
        edge.PB({point[i].F.F-point[i-1].F.F,{point[i].S,point[i-1].S}});
    }
    sort(point,point+n,by_y);
    for(int i=1;i<n;i++){
        edge.PB({point[i].F.S-point[i-1].F.S,{point[i].S,point[i-1].S}});
    }
    sort(edge.begin(),edge.end());
    init();
    LL mst=0;
    for(auto i:edge){
        LL w=i.F;
        int u=i.S.F;
        int v=i.S.S;
        if(merge(u,v)){
            mst+=w;
        }
    }
    printf("%lld\n",mst);
    return 0;
}

Measured memory_bytes: 8688
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;


void solve(int a) { cout << (a ? "You can win" : "You will lose") << endl; }
int main(){
	int n;
	cin >>n;
	map<int,int>data;//at,point
	long long ans=0;
	int bef1;
	int bef2;
	auto itr=data.begin();
	for(int i=0;i<n;i++){
		cin >>bef1>>bef2;
		data[bef2]+=0;
		data[bef2]+=bef1;
	}
	itr=data.begin();
	//itr--;
	//for(auto itr=data.begin();itr!=data.end();itr++){
	//	cout <<(itr->first)<<"    "<<(itr->second)<<endl; 
	//}
	ans+=(long long)(itr->second);
	//cout<<ans<<endl;
	ans +=(long long)(itr->first);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,k,x,y;


//moddivとnCk
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(__int128_t a,__int128_t b,__int128_t ar,__int128_t br){
  __int128_t tmp=(br-ar)%b*modinv(a,b)%b;
  if (tmp<0)tmp+=b;
  return ar+tmp*a;
}

ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}









int main(){
  ll ans=0;
  cin >> n;

  if (n==1){
    cout<<1<<endl;
    return 0;
  }
  if (n%2==0){
    ans=2*n-1;
  }else{
    ans=n-1;
  }

  n*=2;
  
  for(ll i=2;i<=n+2;i++){
    if (i*i>n)break;
    if (n%i==0){
      ll val0=i;
      ll val1=n/i;
      if (val0==1)continue;
      if (val1==1)continue;
      if (gcd(val0,val1)==1){
        ll ans0=garner(val0,val1,1,0)-1;
        ll ans1=garner(val0,val1,0,1)-1;
        if (ans0>1)
          ans=min(ans,ans0);
        if (ans1>1)
          ans=min(ans,ans1);
      }
    }
  }
  


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

/*
30742895626683

695989518504 30742895626682 2 30742895626683
34542528895425 20495263751121 3 20495263751122
52994067520842 51238159377804 6 10247631875561
22669646754795 39784923752177 17 3616811250198
10472202270114 9042028125494 34 1808405625099
11352643890447 60280187503299 51 1205603750066
12660437818086 29537291876616 102 602801875033
*/

Measured memory_bytes: 7036