akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int x;
    cin >>x;
    cout <<x<<":";
    for(int i=2;i<=sqrt(x);i++){
        while(x%i==0){
            cout <<" "<<i;
            x/=i;
        }
    }
    if(x!=1) cout<<" "<<x;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> B(N);
  REP(i, N) cin >> B[i];

  vector<pair<int, int>> vec1(N, {0, 0});
  vec1[0] = {A[0], A[0]};
  FOR(i, 1, N){
    if(A[i-1] < A[i]) vec1[i] = {A[i], A[i]};
    else{
      vec1[i] = {1, A[i-1]};
    }
  }

  vector<pair<int, int>> vec2(N, {0, 0});
  vec2[N-1] = {B[N-1], B[N-1]};
  RREP(i, N-1){
    if(B[i+1] < B[i]) vec2[i] = {B[i], B[i]};
    else{
      vec2[i] = {1, B[i+1]};
    }
  }

  int ans = 1;
  REP(i, N){
    int MIN = max(vec1[i].first, vec2[i].first);
    int MAX = min(vec1[i].second, vec2[i].second);
    if(MAX < MIN){
      cout << 0 << endl;
      return 0;
    }
    ans *= (MAX-MIN+1);
    ans %= MOD;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>

int main(){
  

  int n;
  cin>>n;
  
  vector<ll> height(n);
  
  rep(i,n){
    int tmp;
    cin>>tmp;
    height.at(i)=tmp;
  }
  
  string answer="Yes";
  
  
  height.at(0)-=1;
  
  rep2(i,1,n){
    if (height.at(i)<height.at(i-1)){
      answer="No";
      break;
    }
  
    else if (height.at(i)>=height.at(i-1)+1){
      height.at(i)-=1;
    }
  }
  
  cout<<answer<<endl;
  

  
  
  
  
  
  
      
 

  
}



Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    ll t1 = 0, t2 = 0, a1 = 0, a2 = 0, b1 = 0, b2 = 0;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    if (a1*t1 + a2*t2 == b1*t1 + b2*t2) {
        cout << "infinity" << endl;
    }  else if (a1 > b1) {
        if (a1*t1 + a2*t2 > b1*t1 + b2*t2) {
            cout << 0 << endl;
        } else {
            ll dif = - a1*t1 - a2*t2 + b1*t1 + b2*t2;
            ll diff = (a1 - b1) * t1;
            cout << 1 + diff / dif * 2 - ((diff % dif == 0) ? 1 : 0) << endl;
        }
    } else if (a1 < b1) {
        if (a1*t1 + a2*t2 < b1*t1 + b2*t2) {
            cout << 0 << endl;
        } else {
            ll dif = a1*t1 + a2*t2 - b1*t1 - b2*t2;
            ll diff = (b1 - a1) * t1;
            cout << 1 + diff / dif * 2 - ((diff % dif == 0) ? 1 : 0) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// C - Average Length
#include <stdio.h>
#include <math.h>

int main(void){
    int i, n;
    double x[8], y[8], xlen, ylen, sum=0.0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%lf%lf", &x[i], &y[i]);
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            xlen = x[i] - x[j];
            ylen = y[i] - y[j];
            sum += sqrt(xlen*xlen + ylen*ylen);
        }
    }
    printf("%f\n", sum/n*2);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k,num=0,cnt=0;
int main(){
	cin >> k;
	while (cnt <= k){
		num = (num*10+7)%k;
		cnt++;
		if (!num) {cout<<cnt;return 0;}
	}
	cout << "-1"; return 0;
}


Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;


class Main{
	static long ans=0;
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		long[][] dp=new long[N+1][K+1];
		long MOD=1000000007;
		for(int i=0; i<=N; i++) {
			for(int j=0; j<=K; j++) {
				dp[i][j]=0;
			}
		}
		dp[0][0]=1;
		for(int i=1; i<=N; i++) {
			for(int j=1; j<=K; j++) {
				dp[i][j]+=dp[i-1][j]*j;	//j個の箱の中にi-1個のボールが入っていてi個目のボールを入れる	新しく入れるボールはi種類（ボール1を、ボール2をボール３を。。。ボールiを）
				dp[i][j]+=dp[i-1][j-1]*j;	//i-1個のボールがj-1個の箱に入っている状態で、i個目のボールは新しい箱に入れる場合　は i通り
				dp[i][j]%=MOD;
			}
		}
		pl(dp[N][K]);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 33528
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

int n, l, q;
int x[100010];
int p[100010][20];

int main(){

  n = in();
  REP( i , n ){
    x[i] = in();
  }
  l = in();
  q = in();

  REP( i , n ){
    p[i][0] = upper_bound( x , x+n , x[i]+l ) - x - 1;
    // cout << p[i][0] << endl;
  }

  REP( j , 19 ){
    REP( i , n ){
      p[i][j+1] = p[ p[i][j] ][j];
    }
  }

  REP( i , q ){
    int a = in() - 1;
    int b = in() - 1;
    if( a > b ){
      swap( a , b );
    }

    int ans = 0;
    for( int j = 19; j >= 0; j-- ){
      if( p[a][j] < b ){
	ans += PW(j);
	a = p[a][j];
      }
    }
    ans++;

    printf( "%d\n" , ans );
  }

  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
  
#define INF 2000000010
#define mod7 1000000007
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define INF_LL 9223372036854775
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double 
 
using namespace std;

#define MAX_N 100005
#define MAX_M 100005

int N;
LL A[MAX_N];
LL L;

int main(){

  cin >> N >> L;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  bool flag = false;
  int num = -1;
  for(int i = 0; i < N-1 && !flag; i++){
    if(A[i]+A[i+1] >= L){
      flag = true;
      num = i;
    }
  }

  if(!flag){
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  for(int i = 0; i < N-1; i++){
    if(i == num)
      break;
    cout << i+1 << endl;
  }
  for(int i = N-2; 0 <= i; i--){
    if(i == num)
      break;
    cout << i+1 << endl;
  }
  cout << num+1 << endl;

  return 0;

}


Measured memory_bytes: 1536
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int INFTY = 1000000000;

	int n;
	scanf("%d", &n);

	int p[n + 1];
	for (int i = 0; i < n; i++) {
		scanf("%d %d", p + i, p + i + 1);
	}

	int m[n + 1][n + 1];

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			m[i][j] = 0;
		}
	}

	for (int l = 2; l <= n; ++l) {
		for (int i = 1; i <= n - l + 1; ++i) {
			int j = i + l - 1;
			m[i][j] = INFTY;
			for (int k = i; k < j; ++k) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << endl;

	return 0;
}

Measured memory_bytes: 3128
import math

A, B, C, X, Y = map(int, input().split())
lowest = A*X + B*Y

for c in range(0, max(2*X, 2*Y)+1, 2):
  a = max(0, math.ceil(X-0.5*c))
  b = max(0, math.ceil(Y-0.5*c))
  if A*a + B*b + C*c < lowest:
    lowest = A*a + B*b + C*c

print(lowest)

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N;
  cin >> N;
  unordered_map<ll,int> mp;
  ll ans = 0;
  ll tmp;
  rep(i,N){
    cin >> tmp;
    mp[tmp]++;
  }
  for(auto x:mp){
    if(x.first != x.second){
      ll add;
      if(x.first < x.second){
        add = x.second - x.first;
      }
      else{
        add = x.second;
      }
      ans += add;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4260
package main

import "fmt"

func main() {
	var s, num int
	fmt.Scan(&s)

	a := make([]int, 1000000)
	a[0] = s

	for i := 1; i < 1000000; i++ {
		if a[i-1]%2 == 0 {
			num = a[i-1] / 2
		} else {
			num = a[i-1]*3 + 1
		}

		if contains(num, a, i) {
			fmt.Println(i+1)
			break
		} else {
			a[i] = num
		}
	}
}

func contains(n int, a []int, index int) bool {
	for i, v := range a {
		if v == n {
			return true
		}

		if i == index {
			return false
		}
	}
	return false
}


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

#define CodeTyper main
#define Bye return 0
#define ll long long

using namespace std;


void solve(){
    int n; cin>>n;
    int m[n][2];
    int flag = 0;
    for (int i=0; i<n; i++){
        int x, y; cin>>x>>y;
        m[i][0] = x;
        m[i][1] = y;
    }

    int x = 0, y = 1, z = 2;

    while(z<n){
        if(m[x][0] == m[x][1] && m[y][0] == m[y][1]
            && m[z][0] == m[z][1]) flag = 1;
        x++;
        y++;
        z++;
    }

    cout<<(flag == 1 ? "Yes" : "No")<<endl;

}

int CodeTyper(){
    solve();
    Bye;
}

Measured memory_bytes: 3576
#include <stdio.h>

int main(void)
{
	double a, b;
	
	while (scanf("%lf %lf", &a, &b) != EOF){
		if (a < 35.5 && b < 71) puts("AAA");
		else if (a < 37.5 && b < 77) puts("AA");
		else if (a < 40 && b < 83) puts("A");
		else if (a < 43 && b < 89) puts("B");
		else if (a < 50 && b < 105) puts("C");
		else if (a < 55 && b < 116) puts("D");
		else if (a < 70 && b < 148) puts("E");
		else puts("NA");
	}
	
	return 0;
}

Measured memory_bytes: 608
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef vector<VB> VBB;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}


// g++ -std=c++11 prac.cpp

bool func(string s){
  string t(s.rbegin(), s.rend());
  return s==t;
}

int main() {
  ll z=0,k,n,m,h,w,ans=0,sum=0,Max=1,Min=1e9+1;
  double l;
  bool ok = false;
  string s,t,r;
  cin >> l;
  //cout << setprecision(15) << (double)l*l*l/27 << endl;
  double aa = l/3;
  //out << setprecision(15) << (double)aa*aa*aa << endl;
  cout << setprecision(15) << pow((double)l/3,3) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, L, R;

  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;

  if(L > R){
    cout << "Left" << endl;
  }  
  else if(L == R){
    cout << "Balanced" << endl;
  }
  else if(L < R){
    cout << "Right" << endl;
  }

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		N int
		A int
		B int
	)

	fmt.Scan(&N, &A, &B)

	var ans int = 0
	if A != 0 {
		if N >= A+B {
			syou := N / (A + B)
			amari := N % (A + B)
			if amari >= A {
				ans = syou*A + A
			} else {
				ans = syou*A + amari
			}
		} else {
			if N >= A {
				ans = A
			} else {
				ans = N
			}
		}
	} else {
		ans = 0
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << " " << (a+b)*2 << endl;

  return 0;
}



Measured memory_bytes: 3100
#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>

#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())

#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 int;
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>;

//struct edge {int from, to, cost;};

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 n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    double rsum = 0;
    REP(i,0,n) rsum += 1.0 / a[i];
    printf("%.6lf\n", 1.0 / rsum);
}

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

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

const uint64_t kMax = UINT64_MAX;

int main()
{
  uint64_t n, a, b;

  cin >> n >> a >> b;

  cout << min(n * a, b);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    string s;
    ll K;
    cin >> s >> K;
    ll N = s.size();
    rep(i, 0, N-1){
        ll t = s[i] - 'a';
        if(t == 0) continue;
        if(26 - t <= K){
            K -= (26 - t);
            s[i] = 'a';
        }
    }
    K %= 26;
    if(s[N-1] + K > 'z') s[N-1] = 'a' + K - ('z' + 1 - s[N-1]);
    else s[N-1] += K; 
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
n, x = [ int(v) for v in input().split() ]

num_list = [ int(v) for v in input().split() ]
profit_list = []

low, high = None, None
for i in range(n):
    if low == None:
        low = num_list[i]
    if high == None:
        high = num_list[i]
    
    if low > num_list[i]:
        if high != low:
            profit_list.append(high-low)
        low, high = num_list[i], num_list[i]
    if num_list[i] > high:
        high = num_list[i]
    if i == n-1 and high != low:
        profit_list.append(high-low)


max_prof = max(profit_list)
ans = profit_list.count(max_prof)
print(ans)

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

int main()
{
    int a, b, ans, rem;
    cin >> a >> b;
    ans = (b-1)/(a-1);
    rem = (b-1)%(a-1);
    if (rem!=0) {
        cout << ans+1;
    } else {
        cout << ans;
    }
}

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

using ll = long long int;
using P = pair<int,int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1<<30;

bool solve(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<P> > g(n);
    for(int i=0;i<m;i++){
        int a, b, l;
        cin >> a >> b >> l;
        a--; b--;
        g[a].push_back(P(b,l));
        g[b].push_back(P(a,l));
    }
    vector<int> d(n,INF);
    priority_queue<P,vector<P>,greater<P> > que;
    for(int i=0;i<k;i++){
        int s;
        cin >> s;
        s--;
        d[s] = 0;
        que.push(P(0,s));
    }
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(p.first > d[v]) continue;
        for(auto e : g[v]){
            int u = e.first, l = e.second;
            if(d[u] > d[v] + l){
                d[u] = d[v] + l;
                que.push(P(d[u],u));
            }
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(auto e : g[i]){
            int j = e.first, l = e.second;
            ans = max(ans, int(round(double(d[i]+d[j]+l)/2)));
        }
    }
    cout << ans << endl;
}

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



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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;

    int first = min(a+b, 2*c);
    int ans = min(x,y) * first;

    if(x == y) {
        // do nothing
    } else if(x > y) {
        ans += (x-y) * min(a, 2*c);
    } else {
        ans += (y-x) * min(b, 2*c);
    }

    cout << ans << endl;

    return 0;
}



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

#define INF (int)1e9
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define qq queue
#define w(n) while(n--)
#define for0(i, n) for(i = 0; i < n; i++)
#define for1(i, n) for(i = 1; i <= n; i++)

#define MAXN 100001
ll day[MAXN][3], dp[MAXN][3], n;

ll solve(int idx, int curr) {
    if (idx < 0) return -1;
    if (idx == 0) return day[0][curr];
    
    if (dp[idx][curr] !=  -1) return dp[idx][curr];
    
    ll best = -1;
    int i;
    for0(i, 3) {
        if (i == curr) continue;
        best = max(best, solve(idx-1, i) + day[idx][curr]);
    }
    
    dp[idx][curr] = best;
    return dp[idx][curr];
} 

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    
    int i;
    for0(i, n) {
        ll a, b, c;
        cin >> a >> b >> c;
        
        day[i][0] = a;
        day[i][1] = b;
        day[i][2] = c;
        
        dp[i][0] = -1;
        dp[i][1] = -1;
        dp[i][2] = -1;
    }
    
    ll best = max({solve(n-1, 0), solve(n-1, 1), solve(n-1, 2)});
    cout << best << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll x;
       cin>>x;
       for(ll i=-200;i<=200;i++)
       {
           for(ll j=-200;j<=200;j++)
           {
               if(pow(i,5)-pow(j,5)==x)
               {
                   cout<<i<<" "<<j;
                   return 0;
               }
           }
       }
    }
    return 0;
}


Measured memory_bytes: 4060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      sc.nextLine();

      String s = sc.nextLine();

      if(n % 2 != 0) {
        System.out.print("No");
      } else {
          if(s.substring(0, n/2).equalsIgnoreCase(s.substring(n/2, n))) {
              System.out.print("Yes");
          } else {
              System.out.print("No");
          }
      }


    }
}

Measured memory_bytes: 23764
#pragma gcc optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i=(ll)(r);i<(ll)(n);++i)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define pb(n) push_back(n)
#define endl '\n'
#define debug(x) cout << #x << " = " << (x) << endl
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define VIN(V) for(int ii = 0; ii < (V).size(); ii++) {cin >> (V).at(ii);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(ii,(V).size()){cout << (V)[ii] << " ";} cout<<endl;
#define VOUT2(V) REP(jj,(V).size()){VOUT(V[jj])}
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi > vvi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
ll n, m, k, ans, sum, cnt = 0; string s; char c;

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

  OUT(3*n*n);
}


Measured memory_bytes: 256
/*  ex4_1
    potter0723sw  */

#include <stdio.h>
#include <math.h>

int main(void) {
    float num,d;//小数点以下も考えたいのでfloat型
    int answer;
    scanf("%f %f",&num ,&d);
    answer = ceil(num/(d * 2 + 1));
	//監視員が見れるのは自分がいる木と周囲d本だから2d+1本見れる。
	//監視範囲が被ってもいいことを考慮し小数以下切り上げ
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// const int N = 1e5 + 7;
// typedef long long int lli;
// int a[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> ve;
    for (int i = 0; i < n; i++) {
        vector<int> v(3, 0);
        cin >> v[0] >> v[1] >> v[2];
        ve.push_back(v);
    }
    for (int i = 1; i < n; i++) {
        ve[i][0] = max(ve[i - 1][1], ve[i - 1][2]) + ve[i][0];
        ve[i][1] = max(ve[i - 1][0], ve[i - 1][2]) + ve[i][1];
        ve[i][2] = max(ve[i - 1][1], ve[i - 1][0]) + ve[i][2];
    }
    cout << max(ve[n - 1][0], max(ve[n - 1][1], ve[n - 1][2])) << endl;
    return 0;
}

Measured memory_bytes: 6964
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
	bool operator<(const Edge &e)const { return w < e.w; }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int s, int d, Weight w = 1) { g[s].emplace_back(s, d, w); }


struct Dinic {
	int n, s, t;
	vector<int> level, prog, que;
	vector<vector<Flow>> cap, flow;
	vector<vector<int>> g;
	Flow inf;
	Dinic(const Graph &graph)
		: n(graph.size()),
		cap(n, vector<Flow>(n)),
		flow(n, vector<Flow>(n)),
		g(n, vector<int>()),
		inf(numeric_limits<Flow>::max() / 8) {
		for (int i = 0; i < n; i++) {
			for (auto &e : graph[i]) {
				int u = e.s, v = e.d;
				Flow c = e.c;
				cap[u][v] += c;
				cap[v][u] += c;
				flow[v][u] += c;
				g[u].push_back(v);
				g[v].push_back(u);
			}
		}
	}
	inline Flow residue(int u, int v) { return cap[u][v] - flow[u][v]; }
	Flow solve(int s_, int t_) {
		this->t = t_, this->s = s_;
		que.resize(n + 1);
		Flow res = 0;
		while (levelize()) {
			prog.assign(n, 0);
			res += augment(s, inf);
		}
		return res;
	}
	bool levelize() {
		int l = 0, r = 0;
		level.assign(n, -1);
		level[s] = 0;
		que[r++] = s;
		while (l != r) {
			int v = que[l++];
			if (v == t) break;
			for (const int &d : g[v])
				if (level[d] == -1 && residue(v, d) != 0) {
					level[d] = level[v] + 1;
					que[r++] = d;
				}
		}
		return level[t] != -1;
	}
	Flow augment(int v, Flow lim) {
		Flow res = 0;
		if (v == t) return lim;
		for (int &i = prog[v]; i < (int)g[v].size(); i++) {
			const int &d = g[v][i];
			if (residue(v, d) == 0 || level[v] >= level[d]) continue;
			const Flow aug = augment(d, min(lim, residue(v, d)));
			flow[v][d] += aug;
			flow[d][v] -= aug;
			res += aug;
			lim -= aug;
			if (lim == 0) break;
		}
		return res;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	Graph g(V);
	rep(i, 0, E) {
		int s, t, c; cin >> s >> t >> c;
		add_arc(g, s, t, c);
	}
	Dinic d(g);
	auto res = d.solve(0, V - 1);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3280
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

k = readInt()

n = 7
for i in range(10**6):
	if n%k==0:
		print(i+1)
		exit()
	else:
		n = (n*10+7)%k

print(-1)

Measured memory_bytes: 9340
/*
2020-05-05
atcoder ABC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int K, X;
    cin >> K >> X;
    if(500 * K >= X){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int r;
  cin >> r;
  cout << r * r << endl;
  
  return 0;
}

Measured memory_bytes: 3656
/** Seek God..Trust God..Praise God..**/

#include<bits/stdc++.h>
using namespace std;


#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////



/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/


int main()
{
    FASTIO;


    string s;

    cin >> s;

    int cnt = 0 , ans = 0;


    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='R')
        {
            cnt++;
        }
        else
        {
            ans = max(ans,cnt);
            cnt = 0;
        }
    }

    if(cnt>0)
    {
        ans = max(ans,cnt);
    }

    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long double n,x;
    long long int t,r;
    cin>>n>>x>>t;
    if(n>x)
    {
        r = ceil(n/x);
        cout<<r*t<<endl;
    }
    else
        cout<<t<<endl;

}


Measured memory_bytes: 3720
n = int(input())
r = (int(n**0.5)+1)
c = 0
for i in range(1,r):
    if n%i == 0 and n/i <10:
        c = 1
        break
    else:
        c = 0
if c == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    m = n // 2
    if n & 1:
        l = s[m::-1]
        r = s[m:]
    else:
        l = s[m-1::-1]
        r = s[m:]
    base = l[0]

    cnt = m
    i = 0
    if n & 1:
        m += 1
    while i < m:
        if l[i] == r[i] == base:
            i += 1
            cnt += 1
        else:
            break
    return cnt
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3188
import sys

def solve():
    input = sys.stdin.readline
    N, H, W = map(int, input().split())
    count = 0
    for i in range(N):
        A, B = map(int, input().split())
        if A >= H and B >= W: count += 1
    print(count)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9096
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
#ifdef DEBUG
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#endif
void reader(int *x) { int k, m = 0; *x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { *x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; *x = (*x) * 10 + k - '0'; }if (m)(*x) = -(*x); }
void reader(int *x, int *y) { reader(x); reader(y); }
void reader(int *x, int *y, int *z) { reader(x); reader(y); reader(z); }
void reader(int*x, int*y, int*z, int*w) { reader(x); reader(y); reader(z); reader(w); }
void writer(int x, char c) { int i, sz = 0, m = 0; char buf[10]; if (x<0)m = 1, x = -x; while (x)buf[sz++] = x % 10, x /= 10; if (!sz)buf[sz++] = 0; if (m)mypc('-'); while (sz--)mypc(buf[sz] + '0'); mypc(c); }

int s1[2001][2001], s2[2001][2001], s3[2001][2001];
int main() {
	int n, m, q; reader(&n, &m, &q);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			s1[i][j] = getchar_unlocked() - '0';
			s2[i][j] = (s1[i][j] && s1[i - 1][j]);
			s3[i][j] = (s1[i][j] && s1[i][j - 1]);
		}
		getchar_unlocked();
	}
	for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)
		s1[i][j] += s1[i - 1][j], s2[i][j] += s2[i - 1][j], s3[i][j] += s3[i - 1][j];
	for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)
		s1[i][j] += s1[i][j - 1], s2[i][j] += s2[i][j - 1], s3[i][j] += s3[i][j - 1];
	rep(i, q) {
		int x1, y1, x2, y2; reader(&x1, &y1, &x2, &y2); x1--; y1--;
		writer(s1[x2][y2] - s1[x2][y1] - s1[x1][y2] + s1[x1][y1] - (s2[x2][y2] - s2[x2][y1] - s2[x1 + 1][y2] + s2[x1 + 1][y1] + s3[x2][y2] - s3[x2][y1 + 1] - s3[x1][y2] + s3[x1][y1 + 1]), '\n');
	}
}

Measured memory_bytes: 48768
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n, k;
	cin >> n >> k;
	if(n % k != 0)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}

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

using namespace std;

#define fread(x)        freopen(x,"r",stdin)
#define fwrite(x)       freopen (x,"w",stdout)

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEMSET(a,x)     memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define white 			1
#define grey 			2
#define black 			3

#define ll              long long
#define pb              push_back
#define pf 				push_front
#define INF             2e16
#define inf 			2e8
#define PI              acos(-1.0)
#define pii             pair<int,int>
#define pll             pair<ll, ll>

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define fastread        ios_base::sync_with_stdio(0);cin.tie(nullptr);
//====================== default ends ====================//
int main(){
	int n;
	cin>>n;
	if(n&1){
		cout<<(n/2)*((n/2)+1)<<endl;
	}else{
		cout<<(n/2)*(n/2)<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> v(n + 1);
    rep(i, n) {
        cin >> a[i];
        v[i + 1] = v[i] + a[i];
    }

    ll ans = LINF;
    for (int i = 1; i < n - 1; i++) {
        ll pq = v[i], rs = v[n] - v[i];
        auto itr1 = lower_bound(all(v), pq / 2);
        ll p = *itr1;
        ll q = pq - p;
        auto itr2 = lower_bound(all(v), v[i] + rs / 2);
        ll r = *itr2 - v[i];
        ll s = rs - r;
        if (min({p, q, r, s}) > 0) {
            if (chmin(ans, max({p, q, r, s}) - min({p, q, r, s}))) {
                // cout << pq << " " << rs << endl;
                // cout << p << " " << q << " " << r << " " << s << endl;
            }
        }
        itr1--;
        p = *itr1;
        q = pq - p;
        r = *itr2 - v[i];
        s = rs - r;
        if (min({p, q, r, s}) > 0) {
            if (chmin(ans, max({p, q, r, s}) - min({p, q, r, s}))) {
                // cout << pq << " " << rs << endl;
                // cout << p << " " << q << " " << r << " " << s << endl;
            }
        }
        itr1++;
        itr2--;
        p = *itr1;
        q = pq - p;
        r = *itr2 - v[i];
        s = rs - r;
        if (min({p, q, r, s}) > 0) {
            if (chmin(ans, max({p, q, r, s}) - min({p, q, r, s}))) {
                // cout << pq << " " << rs << endl;
                // cout << p << " " << q << " " << r << " " << s << endl;
            }
        }
        itr1--;
        p = *itr1;
        q = pq - p;
        r = *itr2 - v[i];
        s = rs - r;
        if (min({p, q, r, s}) > 0) {
            if (chmin(ans, max({p, q, r, s}) - min({p, q, r, s}))) {
                // cout << pq << " " << rs << endl;
                // cout << p << " " << q << " " << r << " " << s << endl;
            }
        }
    }
    cout << ans << endl;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll A[N],B[N],C[N];
    ll ans = 0;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) cin >> C[i];
    sort(A, A+N); sort(C, C+N);
    rep(i, N){
        ll aok = -1, ang = N; ll am = (aok+ang)/2;
        ll cok = N, cng = -1; ll cm = (cok+cng)/2;
        while(abs(aok-ang) > 1){
            if(A[am] < B[i]) aok = am;
            else ang = am;
            am = (aok+ang)/2;
        }
        while(abs(cok-cng) > 1){
            if(C[cm] > B[i]) cok = cm;
            else cng = cm;
            cm = (cok+cng)/2;
        }
        ans += (aok+1)*(-cok+N);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
s=input()
n=len(s)
s=s[::-1]
accum=[0]*n
p=2019
d=dict()
for i in range(n):
    accum[i]=int(s[i])*pow(10,i,p)%p
for i in range(n-1):
    accum[i+1]+=accum[i]
    accum[i+1]%=p
accum[-1]%=p
ans=0
#print(accum)
for i in range(n):
    #print(d)
    if accum[i] not in d:
        if accum[i]==0:
            ans+=1
        d[accum[i]]=1
    else:
        if accum[i]==0:
            ans+=1
        ans+=d[accum[i]]
        d[accum[i]]+=1
print(ans)

Measured memory_bytes: 16488
from collections import deque
INF = float("inf")

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch, cw = ch-1, cw-1
dh, dw = dh-1, dw-1
S = [input() for _ in range(h)]

dist = [[INF] * w for _ in range(h)]
dist[ch][cw] = 0
q = deque([(cw, ch)])

while q:
    x, y = q.popleft()
    for _x in range(-2, 3):
        for _y in range(-2, 3):
            if _x == _y == 0:
                continue
            next_x, next_y = x + _x, y + _y
            if not 0 <= next_x < w:
                continue
            if not 0 <= next_y < h:
                continue
            if S[next_y][next_x] == "#":
                continue
            if abs(_x) + abs(_y) <= 1:
                if dist[next_y][next_x] <= dist[y][x]:
                    continue
                q.appendleft((next_x, next_y))
                dist[next_y][next_x] = dist[y][x]
            else:
                if dist[next_y][next_x] <= dist[y][x] + 1:
                    continue
                q.append((next_x, next_y))
                dist[next_y][next_x] = dist[y][x] + 1

if dist[dh][dw] != INF:
    print(dist[dh][dw])
else:
    print(-1)

Measured memory_bytes: 98852
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int sum_a = 0, sum_b = 0, temp, check;
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  for (int j = 0; j < N; j++) {
    temp = a.at(0);
    check = 0;
    for (int k = 1; k < N; k++) {
      if (a.at(k) > temp) {
        temp = a.at(k);
        check = k;
      }
    }
    a.at(check) = 0;
    
    if (j % 2 == 0) {
      sum_a += temp;
    }
    else {
      sum_b += temp;
    }
  }
  
  cout << sum_a - sum_b << endl;
  
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll s = accumulate(A.begin(), A.end(), 0LL);
    rep2(i, 1, N) {
        if (i % 2) {
            s -= 2 * A[i];
        }
    }
    vector<ll> ans(N, 0);
    ans[0] = s;
    rep2(i, 1, N) {
        ans[i] = 2 * A[i-1] - ans[i-1];
    }
    rep(i, N) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(j%2==1)
	    {
	      if(i%2==1)printf("#");
	      else printf(".");
	    }
	  else 
	    {
              if(i%2==1)printf(".");
	      else printf("#");
	    }
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
	freopen("C:\\code\\input.txt", "r", stdin);
#endif
	//freopen("C:\\code\\output.txt","r",stdin);
	int k = readint();
	int a = readint();
	int b = readint();
	int isok = 0;
	repd(i, a, b)
	{
		if ((i % k) == 0)
		{
			isok = 1;
		}
	}
	if (isok)
	{
		printf("OK\n");
	} else
	{
		printf("NG\n");
	}

	return 0;
}




Measured memory_bytes: 3640