akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
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 int nmax=40,abmax=10,INF=100000;
 int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];
 vector<int> a(nmax),b(nmax),c(nmax);

int main(int argc, char const *argv[]) {
  int n,ma,mb;
  cin >> n >> ma >> mb;
  rep(i,n) cin >> a[i] >> b[i] >> c[i];

  for(int i=0; i<=n; i++){
    for(int j=0; j<=nmax*abmax; j++){
      for(int k=0; k<=nmax*abmax; k++){
        dp[i][j][k]=INF;
      }
    }
  }

  dp[0][0][0]=0;

  for(int i=0; i<n; i++){
    for(int ca=0; ca<=nmax*abmax; ca++){
      for(int cb=0; cb<=nmax*abmax; cb++){
        if(dp[i][ca][cb]==INF) continue;
        dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
        dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i][ca][cb]+c[i],dp[i+1][ca+a[i]][cb+b[i]]);
      }
    }
  }

  int ans=INF;
  for(int ca=1; ca<=nmax*abmax; ca++){
    for(int cb=1; cb<=nmax*abmax; cb++){
      if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
    }
  }

  if(ans==INF) ans=-1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 25984
import java.util.Scanner;
import java.io.*;

class Main {
    public static void main(String[] args)throws IOException{ 
    	InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(in);
    	   	                                                 
    	while(true){
        String trump = reader.readLine();
            if(trump.equals("-")){
            break;
            }

            int m = Integer.parseInt(reader.readLine());

            for(int H = 0; H < m; H++){
                int h = Integer.parseInt(reader.readLine());
                String left = trump.substring(0, h);
                String right = trump.substring(h, trump.length());
                trump = right + left;
            }
            System.out.println(trump);
        }
    }
}

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

int main(){
    int N;
    cin >> N;
    int C[N-1],S[N-1],F[N-1];
    for(int i = 0; i < N-1;i++)cin >> C[i] >> S[i] >> F[i];
    for(int i = 0; i < N;i++){
        int t = 0;
        for(int j = i;j < N-1;j++){
            if(t < S[j])t = S[j];
            else if(t%F[j]==0);
            else t += F[j] - t%F[j];
            t += C[j];
        }
        cout << t << endl;
    }
}



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

#define int long long
#define fi first
#define se second
#define pb push_back

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 3e9;

string s, t;
int pref1[100005], pref2[100005];

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> s >> t;
	s = '*' + s;
	t = '*' + t;
	for(int i = 1; i < s.length(); i++) pref1[i] = (pref1[i - 1] + ((s[i] == 'A') ? 1 : -1));
	for(int i = 1; i < t.length(); i++) pref2[i] = (pref2[i - 1] + ((t[i] == 'A') ? 1 : -1));
	int q;
	cin >> q;
	while(q--){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if(!((pref1[b] - pref1[a - 1] - pref2[d] + pref2[c - 1] + oo) % 3)) cout << "YES\n";
		else cout << "NO\n";
	}
}


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

int main()
{
	int a, b, x; cin >> a >> b >> x;
	
	string ans = "YES";

	if (x < a) {
		ans = "NO";
	}
	else if (a + b < x) {
		ans = "NO";
	}

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
 public static void main(String[] args){
        String Alp[]={"a","b","c","d","e","f","g", "h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
        
        Scanner sc = new Scanner(System.in);
        String n=sc.next();
        for(int i=0;i<Alp.length;i++){
            if(Alp[i].equals(n)){
               System.out.println(Alp[i+1]);
        }
            sc.close();
    }
}
 
}

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

int main(){
	int n; cin >> n;
	int a[n], b[n], c[n];

	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	int dp[n][3];

	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

	for(int i=1;i<n;i++){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {
	//int a, b, c,d; cin >> a;
	//string s,t,u; cin >> s>>t>>u;
	vector<int> n(3);
	for (int i = 0; i < 3; i++) {
		cin >> n[i];
	}
	ssort(n);
	if (n[0] == 5 && n[1] == 5 && n[2] == 7)cout << "YES";
	else cout << "NO";
	

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append([i for i in input()])
b=[]
b_flg=False

for i in range(m):
  b.append([i for i in input()])
  
for i in range(n-m+1):
  flg=True
  if b_flg:
    break
  for j in range(n-m+1):
    if not flg:
      break
    for k in range(m):
      if not flg:
        break
      for l in range(m):
        if a[i+k][j+l]==b[k][l]:
          flg=True
        else:
          flg=False
    if flg:
      b_flg=True
      break
if b_flg:
  print("Yes")
else:
  print("No")
        
        

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static long process(TestCase testCase) {
        final List<Integer> p = testCase.p;
        p.sort((a, b) -> Integer.compare(b, a));

        return p.stream().mapToInt(i -> i).sum() - (p.get(0) / 2);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final long result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        List<Integer> p = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            p.add(sc.nextInt());
        }

        sc.close();
        return new TestCase(N, p);
    }

    private static void output(long result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;
        final List<Integer> p;

        public TestCase(int N, List<Integer> p) {
            this.N = N;
            this.p = p;
        }
    }
}


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

int nil =-1;

struct Node {
	int parent, left_child, right_sibling;
};
// parentで節点の親を参照　
// left_childで節点の一番左の子を参照
// right_sibilingで節点の一番右の兄弟を参照


Node T[100005];
int Depth[100005];

void print(int u){
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<T[u].parent<<", ";
	cout<<"depth = "<<Depth[u]<<", ";

	if(T[u].parent==nil) cout<<"root, ";
	else if(T[u].left_child==nil) cout<<"leaf, ";
	else cout<<"internal node, ";

	cout<<"[";
	int child=T[u].left_child;
	while(child!=nil){
		cout<<child;
		child=T[child].right_sibling;
		if(child!=nil) cout<<", ";
	}
	cout<<"]"<<endl;
}

void setdepth(int u,int p){
	Depth[u]=p;
	if(T[u].right_sibling!=nil) setdepth(T[u].right_sibling,p);
	if(T[u].left_child!=nil) setdepth(T[u].left_child,p+1);
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) T[i].parent = T[i].left_child = T[i].right_sibling = nil;

	int u,m,child,right;
	for(int i=0;i<n;i++){
		cin>>u>>m;
		for(int j=0;j<m;j++){
			cin>>child;
			if(j==0) T[u].left_child=child;
			else T[right].right_sibling=child;
			right=child; //一番右のchildを保持
			T[child].parent=u; //節点uの子の親はu
		}
	}

	int root;
	for(int i=0;i<n;i++){
		if(T[i].parent==nil) root=i; //iの親がnilならiがroot
	}

	setdepth(root,0);

	for(int i=0;i<n;i++) print(i);

	return 0;
}



Measured memory_bytes: 7752
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

long long gcd(long long x, long long y) {
    // 最大公約数を求める
    if (y == 0)
        return x;
    gcd(y, x % y);
}

long long lcm(long long x, long long y) {
    // 最小公倍数を求める
    long long GCD = gcd(x, y);
    long long ans = x / GCD * y;
    return ans;
}

long long gcd(vector<long long> x) {
    // すべての vector の最大公約数を求める
    long long ans = x[0];
    if (x.size() == 1)
        return ans;
    for (int i = 1; i < x.size(); i++) {
        ans = gcd(ans, x[i]);
    }
    return ans;
}

long long lcm(vector<long long> x) {
    // すべての vector の最小公倍数を求める
    long long ans = x[0];
    if (x.size() == 1) {
        return ans;
    }
    for (int i = 1; i < x.size(); i++) {
        ans = lcm(ans, x[i]);
    }
    return ans;
}

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

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

    auto ans = lcm(T);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
ll n,m,i,j,k,result=1,a[3];
char s[LIMIT1][10];
int x[LIMIT1][2];
char choice[LIMIT1]="",ch1,ch2;
int cc[3]={0};
int pp(int i,int p,int q){
  choice[i]=(char)('A'+p);
  a[p]++;
  a[q]--;
}
int main(void){
  initialize();
  scanf("%lld %lld %lld %lld",&n,&a[0],&a[1],&a[2]);
  rep(i,n){
    scanf("%s",s[i]);
    x[i][0]=s[i][0]-'A';
    x[i][1]=s[i][1]-'A';
  }
  
  rep(i,n){
    j=x[i][0];
    k=x[i][1];
    if(a[j]==0&&a[k]==0){
      result=0;
      break;
    }else if(a[j]==0){
      pp(i,j,k);
    }else if(a[k]==0){
      pp(i,k,j);
    }else{
      if(i!=n-1&&j==3-x[i+1][0]-x[i+1][1]) pp(i,k,j);
      else pp(i,j,k);
    }
  }
  
  if(result==0){
    printf("No");
  }else{
    printf("Yes\n");
    rep(i,n){
      printf("%c\n",choice[i]);
    }
  }
  return 0;
}



Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main() {
	long long int x,a=0;
	cin >> x;
	for (int i = 0; x >= 500; i++) {
		a += 1000;
		x -= 500;
	}
	for (int i = 0; x >= 5; i++) {
		a += 5;
		x -= 5;
	}
	cout << a;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
ll dp[200050][50];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    ll T;
    cin>>n>>T;
    T++;
    vector<pl>v,v2;
    for(int i=0;i<n;i++)
    {
        pl x;
        cin>>x.fi>>x.se;
        x.fi++,x.se++;
        if(x.fi>1)
            v.eb(x);
        else
            v2.eb(x);
    }
    sort(all(v),[](pl x,pl y){return x.fi*y.se+x.se>y.fi*x.se+y.se;});
    sort(all(v2));
    dp[0][0]=1;
    for(int i=1;i<40;i++)
        dp[0][i]=T+10;
    int m=v.size();
    for(int i=0;i<m;i++)
    {
        dp[i+1][0]=1;
        for(int j=1;j<40;j++)
            dp[i+1][j]=min(dp[i][j],dp[i][j-1]*v[i].fi+v[i].se);
    }
    int M=0;
    for(int i=0;i<40;i++)
    {
        ll t=dp[m][i];
        if(t>T)
            continue;
        int c=i;
        for(int j=0;j<(int)v2.size();j++)
        {
            t+=v2[j].se;
            if(t>T)
                break;
            c++;
        }
        M=max(M,c);
    }
    cout<<M<<endl;
    return 0;
}

Measured memory_bytes: 82284
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    ll a,b;
    cin>>a>>b;
    ll c=a%4LL,d=b%4LL;
    ll ans=0;
    if(b-a<4){
        for(ll i=0; i<=b-a; i++){
            ans=ans^(a+i);
        }
        cout<<ans<<endl;
        return 0;
    }
    for(ll i=0; i<=3-c; i++){
        if(a+i>=b) break;
        ans=ans^(a+i);
    }
    for(ll i=0; i<=d; i++){
        if(b-i<=a) break;
        ans=ans^(b-i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  long long int N;
  cin >> N;
  long long int a[5];
  for(int i=0; i<5 ; i++){
    cin >> a[i]; 
  }
  long long int first =0;
  long long int last =0;
  long long int min_trans = a[0]; 
  for(int j=0; j<5 ; j++){
    if(j==0){
      first = 1;
      if (N%a[j] ==0) last = (N-N%a[j])/a[j];
      else last = (N-N%a[j])/a[j] + 1;
      min_trans = a[j];      
    }
    if(j!=0 && min_trans > a[j]){
      if (N%a[j] ==0) last = first + (N-N%a[j])/a[j];
      else last = first + (N-N%a[j])/a[j] + 1;
      first += 1;
      min_trans = a[j];
    }
    else if(j!=0 && min_trans <= a[j]){
      first += 1;
      last += 1;
    }
  }
 
 
 
  cout << last << endl;
 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int INF = 1001001001;
 
int main() {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  vi dp(h+1, INF);
  dp[0] = 0;
  rep(i, n){
    rep(j, h){
      int nj = min(j + a[i], h);
      dp[nj] = min(dp[j] + b[i], dp[nj]);
    }
  }

  cout << dp[h] << endl;

  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N;
    cin >> N;

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

    int ans=INT_MAX;
    for (int i = -100; i <= 100; i++) {
        int cost=0;
        for (int j = 0; j < N; j++) {
            cost += (a[j]-i) * (a[j]-i);
        }
        ans = min(ans, cost);
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const lint INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vec a(n);
    rep(i, n) cin >> a[i];

    lint res = INF;
    lint x = 0;
    lint y = accumulate(all(a), 0LL);

    rep(i, n-1) {
        x += a[i];
        y -= a[i];
        res = min(res, abs(x-y));
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4052
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
					
public class Program
{
	static int[] color;
	
	public static void Main()
	{
		int[] tmp = Array.ConvertAll(Console.ReadLine().Split(" ".ToCharArray()), int.Parse);
		int n = tmp[0];
		int m = tmp[1];
		
		Node[] nodes = new Node[n];
		for(int i = 0; i < n; i++) {
			nodes[i] = new Node(i);
		}
		color = new int[n];
		
		for(int i = 0; i < m; i++) {
			tmp = Array.ConvertAll(Console.ReadLine().Split(" ".ToCharArray()), int.Parse);
			int s = tmp[0];
			int t = tmp [1];
			
			nodes[s].Children.Add(nodes[t]);
			nodes[t].Children.Add(nodes[s]);
		}
		
		AssignColor(nodes);
		
		int q = int.Parse(Console.ReadLine());
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < q; i++) {
			
			tmp = Array.ConvertAll(Console.ReadLine().Split(" ".ToCharArray()), int.Parse);
			int s = tmp[0];
			int t = tmp [1];

			sb.AppendLine( (color[s] == color[t])? "yes" : "no" );
		}
		Console.Write(sb);
	}
	
	static void AssignColor(Node[] nodes)
	{
		int rootId = 0;
		
		for(int i = 0; i < nodes.Length; i++) {
			if(color[i] == 0) DFS(nodes[i], ++rootId);
		}
	}
	
	static void DFS(Node r, int c)
	{
		var S = new Stack<Node>();
		
		S.Push(r);
		color[r.Id] = c;
		
		while(S.Any())
		{
			Node u = S.Pop();
			
			foreach (var d  in u.Children) {
				if(color[d.Id] == 0) { 
					S.Push(d);
					color[d.Id] = c;
				}
			}
		}
	}
}

class Node
{
	public int Id { get; private set; }
	public List<Node> Children = new List<Node>();
	
	public Node (int id)
	{
		this.Id = id;
	}
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

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


Measured memory_bytes: 256
while True:
    try:
        m,f,r = map(int,input().split())
        if m == -1 and f == -1 and r == -1:
            break
        elif m == -1 or f == -1:
            print("F")
        elif m + f >= 80:
            print("A")
        elif m + f >= 65:
            print("B")
        elif m + f >= 50 or r >= 50:
            print("C")
        elif m + f >= 30:
            print("D")
        elif m + f < 30:
            print("F")
        
            

    except:
        break


Measured memory_bytes: 5600
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>
 
#if __has_include(<string_view>)
#include <string_view>
#endif
#if __has_include(<optional>)
#include <optional>
 
template <class T>
constexpr const T& max(const T& a, const std::optional<T>& b)
{
    return b ? max(a, *b) : a;
}
 
template <class T>
constexpr const T& max(const std::optional<T>& a, const T& b)
{
    return a ? max(*a, b) : b;
}
 
template <class T>
constexpr const std::optional<T>& max(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a > *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}
 
template <class T>
constexpr const T& min(const T& a, const std::optional<T>& b)
{
    return b ? min(a, *b) : a;
}
 
template <class T>
constexpr const T& min(const std::optional<T>& a, const T& b)
{
    return a ? min(*a, b) : b;
}
 
template <class T>
constexpr const std::optional<T>& min(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a < *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}
 
#endif
#if __has_include(<any>)
#include <any>
#endif
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
 
using namespace std;
 
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}
 
template <class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}
 
template <class T>
istream& operator>>(istream& is, valarray<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}
 
template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}
 
template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}
 
template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}
 
void solution()
{
    int n;
    cin >> n;
    int head = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(head + 1 == a){
            head = a;
        }
    }
    if(head == 0){
        cout << -1 << '\n';
    }else{
        cout << (n-head) << '\n';
    }
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n),b(n),c(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
    c[i]=a[i]-b[i];
  }
  ll cnt=0;
  ll d=0;
  for(int i=0;i<n;i++){
    if(c[i]<0){
      cnt++;
      d+=c[i];
    }
  }
  sort(c.begin(),c.end(),greater<ll>());
  for(int i=0;i<n;i++){
    if(d>=0){
      break;
    }
    if(c[i]>0){
      d+=c[i];
      cnt++;
    }
  }
  if(d<0){
    cout << -1 << endl;
  }
  else{
    cout << cnt << endl;
  }
}

Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

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

    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll snum = 0;
    rep(i, n) {
        for(ll j = i + 1; j < n; j++) {
            if(a[i] > a[j]) snum++;
        }
    }

    ll pnum = 0;
    rep(i, n) {
        rep(j, n) {
            if(a[i] > a[j]) pnum++;
        }
    }

    ll num = 0, m = 1e9 + 7;
    num += snum * k;
    num %= m;
    num += pnum * (k * (k - 1) / 2 % m);
    num %= m;

    cout << num << endl;
}

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

int main() {

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int sum=0;
    if(a>=b){
        sum=b;
    }
    else{
        sum=a;
    }
    if(c>=d){
        cout<<sum+d<<endl;
    }
    else{
        cout<<sum+c<<endl;
    }


}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] a = new int[m+2];
		a[0] = -1;
		for(i = 1; i <=m; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		long[] fi = new long[100000+1];
		fi[0] = fi[1] = 1;
		for(i = 2; i < fi.length; i++) {
			fi[i] = fi[i-1] + fi[i-2];
			if(fi[i] >= 1000000007) fi[i] %= 1000000007;
		}
		a[m+1] = n+1;
		long cnt = 1;
		int dif = 0;
		for(i = 1; i <= m+1; i++) {
			dif = a[i] - a[i-1] -2;
//			System.out.println("dif:"+dif);
			if(dif == -1) {
				cnt = 0;
				break;
			}
//			System.out.println("fib("+dif+")");
			cnt *= fi[dif];
//			System.out.println("cnt:"+cnt);
			if(cnt >= 1000000007) {
				cnt %= 1000000007;
				if(cnt==0)break;
			}
		}
		System.out.println(cnt);
//		System.out.println(cnt%1000000007);
	}
	
	public static int fib(int n) {
		if(n == 0 || n == 1) return 1;
		return fib(n-1)+fib(n-2);
	}

}


Measured memory_bytes: 47044
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	string s;
  	cin >> s;
  	if(s == "Sunny"){
    	s = "Cloudy";
    }else if(s == "Rainy"){
    	s = "Sunny";
    }else{
      	s = "Rainy";
    }
	cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const double PI = 3.14159265359;
typedef pair<int,int> P;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for(int i = 0;i < N;i++) {
        cin >> A.at(i);
    }
    for(int i = 0;i < N;i++) {
        cin >> B.at(i);
    }
    for(int i = 0;i < N;i++) {
        cin >> C.at(i);
    }
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    int ret = 0;
    for(int i = 0;i < N;i++) {
        auto it = lower_bound(A.begin(),A.end(),B.at(i));
        int D = it - A.begin();
        auto it2 = upper_bound(C.begin(),C.end(),B.at(i));
        int E = it2 - C.begin();
        ret += D * (N - E);
    }
    cout << ret << endl;
}

Measured memory_bytes: 2560
<?php
$w = str_split(trim(fgets(STDIN)));
$count = array_count_values($w);

$odd = 0;
foreach($count as $val){
    if($val % 2 == 1){
        $odd ++;
        break;
    }
}

if($odd == 0){
    echo "Yes";
}else{
    echo "No";
}
?>

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
	
	string input;
	cin>>input;
	
	if(input.compare("ABC")==0)
		cout<<"ARC"<<endl;
	else if(input.compare("ARC")==0)
		cout<<"ABC"<<endl;
	
	return 0;
}

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

#define int long long int

signed main(void)
{
    int N,K;
    cin >> N >> K;
    vector<pair<int, int> > ab(N);
    int a[N];
    int b[N];
    for( int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }
    for( int i = 0; i < N; i++){
        ab[i] = make_pair(a[i], b[i]);
    }
    sort(ab.begin(), ab.end());
    /*
    for( int i = 0; i < N; i++){
        cout << ab[i].first << " " << ab[i].second << endl;
    }
    */
    int ans = 0;
    for( int i = 0; i < N; i++){
        ans += ab[i].second;
        if( K <= ans ){
            cout << ab[i].first << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3328
use std::collections::HashSet;
#[derive(Default)]
//NOTE
//declare variables to reduce the number of parameters for dp and dfs etc.
struct Solver {}

impl Solver {
    fn solve(&mut self) {
        let stdin = std::io::stdin();
        let mut scn = Scanner {
            stdin: stdin.lock(),
        };
        let k: usize = scn.read();
        let mut rest = 0;
        let mut result = 1;
        let mut rests = HashSet::new();
        loop {
            rest = (10 * rest + 7) % k;
            if rest == 0 {
                println!("{}", result);
                return;
            }
            if rests.contains(&rest) {
                break;
            }
            rests.insert(rest);
            result += 1;
        }
        println!("-1");
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| {
            let mut solver = Solver::default();
            solver.solve()
        })
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 28656
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const a = lines[1].split(" ").map(v=>v-0);
    const b = lines[1].split(" ").map(v=>v-0).sort((a,b)=>a-b);
    let ans = a.filter((v,i)=>v!=b[i]).length;
    console.log(ans<=2?"YES":"NO");
});

min = (...a)=>{return a.reduce((a,b)=>a<b?a:b, a[0])};


Measured memory_bytes: 30104
//BISMILLAHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
#define PI             acos(-1.0)
#define IOS            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ms(a,b)         memset(a, b, sizeof(a))
#define filein      freopen("input.txt", "r", stdin);
#define fileout     freopen("output.txt", "w", stdout);
#define debug       cout<<"Hello, i am in here."<<endl;
#define bit_cnt(mask) __builtin_popcountll(mask)
#define ll long long int
#define dst(u,v,x,y) sqrt((x*1.0-u*1.0)*(x*1.0-u*1.0)+(y*1.0-v*1.0)*(y*1.0-v*1.0))
using namespace std;
const int MOD = (int)1e9+7;
void solve()
{
   char ch;
   cin>>ch;
   if(ch>='A' &&ch<='Z')cout<<"A"<<endl;
   else cout<<"a"<<endl;
}
int  main()
{
    IOS
        solve();
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    int k;
    cin>>s>>k;
    
    int n=s.size();
    vector<int> v(n);
    rep(i,n){
        v[i]=s[i]-'a';
    }
    rep(i,n){
        if(v[i]==0) continue;
        if(v[i]+k>=26){
            k-=26-v[i];
            v[i]=0;
        }
    }
    //cout<<k<<endl;
    v[n-1]=(v[n-1]+k)%26;
    rep(i,n){
        cout<<char('a'+v[i]);
    }
    cout<<endl;
}




Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

ll N;
vector<ll> A;

ll i;

int main(){
    scanf("%lld",&N);
    fornum(i,0,N){
        ll a;
        scanf("%lld",&a);
        A.push_back(a);
    }
    
    sort(A.begin(),A.end());
    ll ans=0;
    fornum(i,0,N/2)
        ans-=A[i]*2;
    fornum(i,N/2,N)
        ans+=A[i]*2;
    if(N%2){
        ans=ans-(A[N/2+1]+A[N/2]-A[N/2-1])*2;
        ll a=A[N/2+1]*2-A[N/2]-A[N/2-1];
        ll b=A[N/2+1]+A[N/2]-A[N/2-1]*2;
        ans+=a>b?a:b;
    }else{
        ans=ans+A[N/2-1]-A[N/2];
    }
    printf("%lld",ans);
    
    
    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    vector<int> dp(n, 0);
    dp[1] = (s[0] != s[1]);
    for(int i = 2; i < n; i++)  dp[i] = max(dp[i-1], (s[i]!=s[i-1])*(dp[i-2]+1));
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3468
n = 0
T=""
s= input().lower()
while True:
    t=input()
    T += t + " "
    if T.count("END_OF_TEXT")>0:
        break

TL = T.split(" ")

for i in TL:
    i = i.replace('"','')
    i= i.replace(".","")
    if i.lower() == str(s):
        n += 1
    else:
        pass
print (n)

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

int main() {
  int n;
  cin >> n;
  char s;
  int type = 3;
  int i;
  for (i = 0; i < n; i++) {
    cin >> s;
    if (s == 'Y') {
      type = 4;
    }
  }
  cout << (type == 3 ? "Three" : "Four") << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll f(ll a, ll b) {
  return a / b;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll g = __gcd(c, d);
  ll l = c / g * d;

  ll all = b - a + 1;
  ll cc = f(b, c) - f(a - 1, c);
  ll dc = f(b, d) - f(a - 1, d);
  ll cdc = f(b, l) - f(a - 1, l);

  cout << all - cc - dc + cdc << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast_io {cin.sync_with_stdio(0); cout.sync_with_stdio(0);}
#define out(x,y) {cout<<x<<y;}
using ll = int;

int main(){
	fast_io;
	double r; cin>>r;
	double p =  (2.0* M_PI * r);
	printf("%.8f\n",p);
}

Measured memory_bytes: 3808
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <random>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
#include <time.h>

using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    V A(n), B(n);
    rep(i, n) cin >> A[i] >> B[i];
    ll res = 0;
    for (int i = 0; i <= 30; i++)
    {
        ll tempmask = 0;
        if((k<(1<<i))&&i!=0)continue;
        if(!(k&(1<<i))&&i!=0)continue;
        tempmask = k&~(1<<i);
        for(int j=0;j<i;j++){
            tempmask|=(1<<j);
        }
        if(i==0){
            tempmask = k;
        }
        ll tempsum = 0;
        for (int j = 0; j < n;j++){
            if(tempmask==(tempmask|A[j])){
                tempsum += B[j];
            }
        }
        chmax(res, tempsum);
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int N, ans=0, tmp1, tmp2, res=0;
    cin >> N;
    int H[N];
    cin >> tmp1;
    REP(i, N-1){
        cin >> tmp2;
        if(tmp1 >= tmp2){
            res+=1;
            // printf("%d, %d :%d\n", tmp1, tmp2, res);
        } else {
            ans = max(ans, res);
            res = 0;
        }
        tmp1 = tmp2;
    }
    ans = max(ans, res);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int a,b;
	cin>>a>>b;
	a--;b--;
	cout<<(b+a-1)/a;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int dp[100010][2];
string L; 
int calc(int x, int smaller) {
    if(x >= L.length()) return dp[x][smaller] = 1;
    if(dp[x][smaller] != -1) return dp[x][smaller];
    if(smaller) {
        return dp[x][smaller] = (calc(x + 1, smaller) * 3) % mod;
    }
    if(L[x] == '0') {
        return dp[x][smaller] = (calc(x + 1, smaller));
    }
    return dp[x][smaller] = (calc(x + 1, 0) * 2 + calc(x + 1, 1)) % mod;

}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> L;
    rep(i, 100010) rep(j, 2) dp[i][j] = -1;
    cout << calc(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 5200
def solve(s):
    l, r = 0, len(s) - 1

    ans = 0
    while l < r:
        if s[l] != s[r] and s[l] != 'x' and s[r] != 'x':
            return -1
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == 'x':
            ans += 1
            l += 1
        elif s[r] == 'x':
            ans += 1
            r -= 1
    return ans


if __name__ == '__main__':
    print(solve(input()))

Measured memory_bytes: 40304
import java.util.*;

public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int D = sc.nextInt();
        
        int ans = N / (2*D+1);
        ans += (N % (2*D+1)) == 0 ? 0 : 1;
        
        System.out.println(ans);
    }
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=1; i<n; i++){
        cin>>a[i]; a[i]--;
    }

    vector<int> bu(n);
    for(int i=n-1; i>=1; i--){
        bu[a[i]]+=1;
    }

    for(int i=0; i<n; i++) cout << bu[i] << endl;
    return 0;
}


Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int H,W;
vector<string> fi;

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

int main(){
    cin>>H>>W;
    fi.resize(H);
    rep(i,H) cin>>fi[i];

    vector<vector<int>> dist(H,vector<int>(W,-1));
    using pint=pair<int,int>;
    queue<pint> que;
    rep(i,H){
        rep(j,W){
            if(fi[i][j]=='#'){
                dist[i][j]=0;
                que.push(pint(i,j));
            }
        }
    }

    while(!que.empty()){
        auto cur=que.front();
        que.pop();
        rep(dir,4){
            int nx=cur.first+dx[dir];
            int ny=cur.second+dy[dir];
            if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
            if(dist[nx][ny]==-1){
                dist[nx][ny]=dist[cur.first][cur.second]+1;
                que.push(pint(nx,ny));
            }
        }
    }
    int res=0;
    rep(i,H){
        rep(j,W){
            res=max(res,dist[i][j]);
        }
    }
    cout<<res<<endl;
}

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

int main() {
  string s;cin>>s;
  int sn=0,tn=0;
  for (auto c: s) {
    if (c=='S') {
      sn ++;
    } else {
      if (sn>0) sn--;
      else tn++;
    }
  }
  cout << tn*2;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;
typedef long long ll;
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 INF = 1LL << 60;
typedef pair<int, int> P;



int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    int K = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] == K+1) {
            K++;
        }
    }
    if (K == 0) {
        cout << -1 << endl; return 0;
    }
    cout << N - K << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    int n,s[1001]={0},i,j;
    s[0]=s[1]=1;
    vector<int> p;
    for (i=2;i<=1000;i++)
    {
        if (!s[i])
        {
            p.pb(i);
            for (j=i*i;j<=1000;j+=i)
                s[j]=1;
        }
    }
    ll f,cnt,ans=1;
    cin>>n;
    for (i=0;i<p.size() && p[i]<=n;i++)
    {
        f=p[i];
        cnt=0;
        while (f<=n)
        {
            cnt+=n/f;
            f*=p[i];
        }
        ans=(ans*(cnt+1))%M;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256