akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <climits>
using namespace std;
#define MAX_V 101

typedef pair<int, int> P;
struct edge { int to, cost; };

int n;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + n + 1, INT_MAX / 4);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  while (true) {
    for (int i = 0; i < MAX_V; i++) {
      G[i].erase(G[i].begin(), G[i].begin() + G[i].size());
    }
    int k;
    cin >> n >> k;
    if (!n && !k) return 0;
    for (int i = 0; i < k; i++) {
      int res;
      cin >> res;
      if (res == 1) {
        int c, d, e;
        cin >> c >> d >> e;
        edge tmp;
        tmp.to = d;
        tmp.cost = e;
        G[c].push_back(tmp);
        tmp.to = c;
        tmp.cost = e;
        G[d].push_back(tmp);
      } else {
        int a, b;
        cin >> a >> b;
        dijkstra(a);
        if (d[b] < INT_MAX / 4) cout << d[b] << endl;
        else cout << -1 << endl;
      }
    }
  }
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r,g;
  cin>>r>>g;
  if(r==g){
    cout<<r<<endl;
    return 0;
  }
  if(r>g){
    cout<<g-(r-g)<<endl;
  }
  else {
    cout<<g+g-r<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  ll ans = 0, w=0;
  string s;
  cin >> s;
  ll n = s.length();
  REP(i,0,n){
    if(s[i] == 'W'){
      ans += i-w;
      w++;
    }
  }

  cout << ans << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3760
n,m=map(int,input().split())
itv=[]
for i in range(m):
  a,b=map(int,input().split())
  itv+=[(b,a)]
itv=sorted(itv)
cnt=0
l=1
for t,s in itv:
  if l<=s:
    l=t
    cnt+=1
print(cnt)

Measured memory_bytes: 83500
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
var n=Arr.shift()-0;
if(n==0)break;
var m=Arr.shift()-0;
var N=[];
for(var i=0;i<n;i++){
   N[i]=[];
   for(var j=0;j<n;j++){
      N[i][j]=Infinity;
      if(i==j)N[i][j]=0;
   }
}
var arr=[];
for(var i=0;i<m;i++){
   var abc=Arr.shift().split(",").map(Number);
   var a=abc[0];
   var b=abc[1];
   var c=(abc[2]/100)-1;
   N[a][b]=c;
   N[b][a]=c;
}
var city=[0];
var cost=0;
while(true){
   if(city.length==n)break;
   var min=Infinity;
   var select=-1;
   for(var i=0;i<city.length;i++){
      for(var j=0;j<n;j++){
         if(city.indexOf(j)!=-1)continue;
         if(N[city[i]][j]<min){
            select=j;
            min=N[city[i]][j];
         }
      }
   }
   if(select!=-1){
      cost+=min;
      city.push(select);
   }
}
console.log(cost);
}

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

#ifdef LOCAL
#include <local.h>
#endif

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int n, W; cin >> n >> W;

  vector<ll> w(n), v(n);
  for (int i = 0; i < n; ++i)
    cin >> w[i] >> v[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));

  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j <= W; ++j)
      if (j >= w[i])
        dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
      else
        dp[i][j] = dp[i+1][j];
  }

  cout << dp[0][W] << ende;
  return 0;
}


Measured memory_bytes: 80256
/* Don't try to hack it :|
 
            _/﹋\_
            (҂`_´)
            <,︻╦╤─҉- - - - - - - - - - - - - - -
            _/﹋\_
*/

#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b ,a%b);
}
int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b ; cin >> a >> b;
	cout <<  6-a-b;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  
  cout <<setprecision(9)<< n * 2 * pi << endl;
  return 0;
}



Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

	if (n % 2 == 1) {

	}
	int count =0;

	for (int i = 0; i < n / 2; i++) {
		if (s[i] == s[n / 2 + i]) {
			count++;
		}
	}

	if (count >= n / 2 && n % 2 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

ll gcd(ll a, ll b){
  return (b ? gcd(b,a%b) : a);
}

int main(){
  ll a,b; cin >> a >> b;
  ll c = gcd(a, b);

  int ans = 1;
  ll n = c;
  for (ll i = 2; i*i <= n; i++) {
    if (c%i==0) {
      ans++;
      while(c%i==0) c /= i;
    }
  }
  if(c != 1) ans++;

  std::cout << ans << '\n';
}


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

#define ll long long
#define ss second
#define ff first
#define pb push_back

using namespace std;

const int N = 1e6 + 69;

int n;
ll A[20][20], cost[(1<<20)], dp[(1<<20)];

int main(){

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

        for(int mask = 0; mask < (1 << n); mask++){
                for(int i = 0; i < n; i++){
                        for(int j = i + 1; j < n; j++){
                                if((mask&(1<<i)) && (mask&(1<<j)))
                                cost[mask] += A[i][j];
                        }
                }
        }


        for(int mask = (1 << n) - 1; mask > 0; mask--){
                for(int mask1 = mask; mask1 > 0; mask1 = mask&(mask1-1)){
                        dp[mask^mask1] = max(dp[mask^mask1], dp[mask] + cost[mask1]);
                }
        }

        cout << dp[0] << endl;
}


Measured memory_bytes: 2816
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

bool find1(string &a,char &c)
{
    for(int i=0;i<a.length();i++)
    {
        if(a[i]==c)return 1;
    }
    return 0;
}

int main()
{
    string s;
    while(cin>>s)
    {
        char i;
        for(i='a';i<='z';i++)
        {
            if(!find1(s,i)){printf("%c\n",i);break;}
        }
        if(i>'z') printf("None\n");
    }
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	char str[1000];
	int  i;
	
	gets(str);
	for (i = 0; str[i]; i++){
		if ('a' <= str[i] && str[i] <= 'z'){
			str[i] -= 32;
		}
	}
	puts(str);
	
	return (0);
}

Measured memory_bytes: 524
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int brr[1000],arr[4][4];
int main()
{
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
            cin>>arr[i][j];
        }
    }
    int n;cin>>n;
    for(int i=1;i<=n;i++)
    {
        int a;cin>>a;
        brr[a]=1;
    }
    bool flag=false;
    if(brr[arr[1][1]]&&brr[arr[2][2]]&&brr[arr[3][3]]||brr[arr[3][1]]&&brr[arr[2][2]]&&brr[arr[1][3]])flag=true;
    if(flag==false)
    {
        for(int i=1;i<=3;i++)
        {
            int cnt=0;
            for(int j=1;j<=3;j++)
            {
                if(brr[arr[i][j]])cnt++;
                else break;
            }
            if(cnt==3){flag=true;break;}
        }
        for(int i=1;i<=3;i++)
        {
            int cnt=0;
            for(int j=1;j<=3;j++)
            {
                if(brr[arr[j][i]])cnt++;
                else break;
            }
            if(cnt==3){flag=true;break;}
        }
    }
    if(flag)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
	int n;
	long long a[205];
	while(scanf("%d",&n) != EOF)
	{
		for(int i=0; i<n; i++)
		{
			scanf("%lld",&a[i]);
		}
		int j = 1, k = 0;
		do{
			k++; 
			for(int i=0; i<n; i++)
			{
				if(a[i]%2 != 0)
				{
					j = 0;
					k--;
					break;
				}
				else a[i]/=2;
			}
		}while(j);
		printf("%d\n",k);
	}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i,N) cin >> p[i];

  sort(p.begin(), p.end());
  int ans = 0;
  rep(i,K) ans += p[i];
  cout << ans << endl;
  return 0;
}

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

using namespace std;


void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int res = n;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i-1]) {
            res = min(res, max(i, n-i));
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
  	int x;
  	for(int i=0;i<5;i++)
    {
		cin>>x;
      	if(x==0)
        {
          cout<<i+1;
          break;
        }
    }
  return 0;
}
  	

Measured memory_bytes: 3596
import sys
readline = sys.stdin.readline

L, N = map(int, readline().split())
X = [int(readline()) for _ in range(N)]

Acl = X[:]
for i in range(1, N):
    Acl[i] += Acl[i-1]

Acl += [0]

Acr = [L-x for x in X]
for i in range(N-2, -1, -1):
    Acr[i] += Acr[i+1]

Acr += [0]

res = max(L-X[0], X[-1])

for i in range(N):
    k = min(i+1, N-1-i)
    if i+1 == N-1-i:
        res = max(res, 2*(Acr[i+1] + Acl[i]) - X[i])
    elif i+1 < N-1-i:
        res = max(res, 2*(Acr[i+1] - Acr[i+1+k] + Acl[i]) - X[i])
    else:
        res = max(res, 2*(Acr[i+1] + Acl[i] - Acl[i-k-1]) - X[i])
    
    k = min(i, N-i)
    if i == N-i:
        res = max(res, 2*(Acr[i] + Acl[i-1]) - L + X[i])
    elif i < N-i:
        res = max(res, 2*(Acr[i] - Acr[i+k+1] + Acl[i-1]) - L + X[i])
    else:
        res = max(res, 2*(Acr[i] + Acl[i-1] - Acl[i-1-k]) - L + X[i])
print(res)

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> G(H, vector<int>(W));
    rep(i, H) rep(j, W) {
        cin >> G[i][j];
        G[i][j] %= 2;
    }
    ddump(G);

    int cnt = 0;
    vector<vector<int>> O(0, vector<int>(4, 0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W - 1; j++) {
            if (G[i][j] == 1) {
                cnt++;
                G[i][j + 1] += 1, G[i][j + 1] %= 2;
                O.push_back(vector<int>{i + 1, j + 1, i + 1, j + 2});
            } else {
                continue;
            }
        }
    }

    for (int i = 0; i < H - 1; i++) {
        if (G[i][W - 1] == 1) {
            cnt++;
            G[i + 1][W - 1] += 1, G[i + 1][W - 1] %= 2;
            O.push_back(vector<int>{i + 1, W, i + 2, W});
        } else {
            continue;
        }
    }

    cout << cnt << endl;
    for (int i = 0; i < O.size(); i++) {
        rep(j, 4) {
            cout << O[i][j];
            if (j < 3)
                cout << ' ';
            else
                cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 11100
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
using namespace std;
#define pb push_back
#define TEST ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    fast_io;
    ll n;
    cin>>n;
    if(n%2==0)
    cout<<(n/2)-1<<endl;
    else
    cout<<(n/2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>


int main() {

	int n, k;
	std::cin >> n >> k;
	std::vector<long long> v(n + 1);

	for (int i = 0; i < n; ++i) std::cin >> v[i];
	
	std::sort(v.rbegin(), v.rend()),v[v.size() - 1] = 0;
	for (int i = k; i < n; ++i) v[v.size() - 1] += v[i];

	std::cout << v[v.size() - 1] << std::endl;
	return 0;
}

Measured memory_bytes: 1792
void main() {
	auto N = ri;
	auto arr = N.iota.map!(i => rs).array;
	long cnt, cntA, cntB, both;
	foreach(v; arr) {
		cnt += v.count("AB");
		switch([v.front == 'B' ? 10 : 0, v.back == 'A' ? 1 : 0].sum) {
			case 11:
				both++;
				break;
			case 10:
				cntB++;
				break;
			case 1:
				cntA++;
				break;
			default:
				break;
		}
	}
	if(cntA == 0 && cntB == 0) writeln(cnt + max(0, both - 1));
	else writeln(both + min(cntA, cntB) + cnt);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 2684
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N,K;
	int l[50];
	scanf("%d %d", &N, &K);

	for(int i=0;i<N;i++){
		scanf("%d",&l[i]);
	}

	sort(l,l+N);
	reverse(l, l + N);

	int ans = 0;
	for(int i=0;i<K;i++){
		ans += l[i];
	}

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

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	string s;
	cin>>n>>s>>k;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[k-1])
		s[i]='*';
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
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;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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 end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double A, B, ans = 0;
    in >> A >> B;
    //vector<ll> X(N);
    
    

    if(B == 1){
        ans = 0;
    }else if(A < B){
        B -= A;
        A--;
        ans++;
        ans+=ceil(double(B/A));
        
    }else{
        ans++;
    }
    
    out << ans << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)50+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

ll n,m,q;
ll ans = 0;
ll a[MAXN], b[MAXN], c[MAXN], d[MAXN];
vector <int> V;

ll find(vector<int>& v)
{
	ll ret = 0;
	for (int i = 1; i <= q; ++i)
		ret += ((v[b[i]] - v[a[i]]) == c[i]) * d[i];
	return ret;
}

void rec(int idx, int mn)
{
	if(idx == n+1)
	{
		ans = max(ans, find(V));
		return;
	}

	for (int i = mn; i <= m; ++i)
	{
		V.pb(i);
		rec(idx+1, i);
		V.pop_back();
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> m >> q;
	for (int i = 1; i <= q; ++i)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	
	V.pb(0);
	rec(1, 1);

	cout << ans << endl;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

const int MAX_N = 100;
const int MAX_M = 1000;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;

int main() {
  int n, m, ans = 0;
  map<pii, int> dist;
  int dp[MAX_N][MAX_N];
  cin >> n >> m;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      dp[i][j] = INF;
    }
  }
  for (int i=0; i<m; i++) {
    int a, b, c;
    cin >> a >> b >> c; a--; b--;
    pii tmpx(a, b), tmpy(b, a);
    dist[tmpx] = dist[tmpy] = c;
    dp[a][b] = dp[b][a] = c;
  }

  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=0; j<=i; j++) {
      pii tmp(i, j);
      if (dist.find(tmp) == dist.end()) continue;
      if (dp[i][j] < dist[tmp]) {
        // cout << i+1 << ", " << j+1 << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
program caddi2018_b
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i
    integer(int32):: a
    logical:: all_even = .true.

    read*, n

    do i=1,n
        read*, a
        all_even = all_even .and. (mod(a,2)==0)
    end do

    if (all_even) then
        print'(a)', 'second'
    else
        print'(a)', 'first'
    end if
end program caddi2018_b

Measured memory_bytes: 512
#include "stdio.h"


int main(){
  int sharp=0,right=0,large=0;
  
  while(1){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);

    if (a>b){
      int temp=a;
      a=b;
      b=temp;
    }

    if (b>c){
      int temp=b;
      b=c;
      c=temp;
    }

    if (a>b){
      int temp=a;
      a=b;
      b=temp;
    }
    
    if (a+b<=c)
      break;

    int judge=a*a+b*b-c*c;
    if(judge==0)
      right++;
    else if (judge<0)
      large++;
    else
      sharp++;
  }

  printf("%d %d %d %d\n",sharp+right+large,right,sharp,large);

  return 0;
}


Measured memory_bytes: 2080
var
  n,i,j:integer;
  x,y:array[1..100] of integer;
  h:array[1..100] of longint;
function abs(x:longint):longint;
begin
  if x<0 then
  begin
    abs:=-x;
  end
  else
  begin
    abs:=x;
  end;
end;
function check(xx,yy:integer):boolean;
var
  now:integer;
  tmpw:longint;
begin
  for now:=1 to n do
  begin
    if h[now]<>0 then
    begin
      tmpw:=h[now]+abs(x[now]-xx)+abs(y[now]-yy);
      break;
    end;
  end;
  check:=true;
  for now:=1 to n do
  begin
    if not ((tmpw-abs(x[now]-xx)-abs(y[now]-yy)=h[now]) or ((tmpw-abs(x[now]-xx)-abs(y[now]-yy)<0) and (h[now]=0))) then
    begin
      check:=false;
      break;
    end;
  end;
end;
function get(xx,yy:integer):longint;
var
  now:integer;
begin
  for now:=1 to n do
  begin
    if h[now]<>0 then
    begin
      get:=h[now]+abs(x[now]-xx)+abs(y[now]-yy);
      break;
    end;
  end;
end;
begin
  readln(n);
  for i:=1 to n do
  begin
    readln(x[i],y[i],h[i]);
  end;
  for i:=0 to 100 do
  begin
    for j:=0 to 100 do
    begin
      if check(i,j) then
      begin
        writeln(i,' ',j,' ',get(i,j));
        exit;
      end;
    end;
  end;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;
  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }
  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> a(n);
  vector<P> v(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
    v[i].first = a[i];
    v[i].second = i;
  }
  BinaryIndexedTree<int> bit(n+1);
  for(int i=0;i<n;++i) {
    bit.add(i, 1);
  }
  sort(v.begin(), v.end());
  vector<int> nowidx;
  int now = v[0].first;
  nowidx.emplace_back(v[0].second);
  bit.add(v[0].second, -1);
  ll cnt = 0;
  for(int i=1;i<n;++i) {
    int nxt = v[i].first, idx = v[i].second;
    if(nxt == now) {
      bit.add(idx, -1);
      nowidx.emplace_back(idx);
    } else {
      for(int j=0;j<(int)(nowidx.size());++j) {
        cnt += min(bit.sum(nowidx[j]), bit.sum(n-1) - bit.sum(nowidx[j]));
      }
      nowidx.clear();
      now = nxt;
      nowidx.emplace_back(idx);
      bit.add(idx, -1);
    }
  }
  for(int i=0;i<(int)(nowidx.size());++i) {
    cnt += min(bit.sum(nowidx[i]), bit.sum(n-1) - bit.sum(nowidx[i]));
  }
  cout << cnt << endl;
}



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

int main(){
  int N,sum=0;
  cin >> N;
  vector<int>pb(N);

  for(int i=0;i<N;i++){
    cin >> pb.at(i);
  }
  
  for(int i=0;i<N;i++){
     if(pb.at(i) != i+1 ) sum+=1;
  }
  if (sum<=2)
    cout << "YES";
  else
    cout << "NO";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef long long ll;
struct point {
    ll number;
    ll x, y;
};

int touch(const struct point *p);
ll dist(const struct point *p);
int cmp(const void *x, const void *y);

ll r, c;
struct point p[200005];
struct point q[200005];
ll q_n = 0;

ll stack[200005];
ll sp;

ll color[200005];

int main()
{
    ll n;
 

    scanf("%lld %lld %lld", &r, &c, &n);

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

        scanf("%lld %lld", &p[i].x, &p[i].y);
        scanf("%lld %lld", &p[i + n].x, &p[i + n].y);

        p[i].number = p[i + n].number = i;

        if (touch(p + i) && touch(p + i + n)) {
            q_n += 2;
            q[q_n - 1] = p[i];
            q[q_n - 2] = p[i + n];
        }
    }

    qsort(q, q_n, sizeof(q[0]), cmp);

    for (int i = 0; i < q_n; i++) {
        //        printf("%lld ", q[i].number);
        color[q[i].number]++;

        if (color[q[i].number] == 2) {
            if (q[i].number == stack[sp - 1]) {
                sp--;
            }
            else {
                puts("NO");
                return 0;
            }
        }
        else {
            stack[sp] = q[i].number;
            sp++;
        }
    }

    puts("YES");

    return 0;
}

int touch(const struct point *p)
{
    if (p->x == 0 || p->x == r) {
        return 1;
    }
    if (p->y == 0 || p->y == c) {
        return 1;
    }

    return 0;
}

ll dist(const struct point *p)
{
    if (p->y == 0) {
        return p->x;
    }
    else if (p->x == r) {
        return r + p->y;
    }
    else if (p->y == c) {
        return r + c + r - (p->x);
    }
    else if (p->x == 0) {
        return r+ r + c + (c - p->y);
    }

    return -1;
}

int cmp(const void *x, const void *y)
{
    if (dist(x) > dist(y)) {
        return 1;
    }
    else if (dist(x) == dist(y)) {
        return 0;
    }
    else {
        return -1;
    }
}


Measured memory_bytes: 17148
number=list(map(int,input().split()))
n,m,q=number[0],number[1],number[2]
nums=[]
for i in range(q):
    tmp=list(map(int,input().split()))
    nums.append(tmp)
answer=0
mid=0
List1=[]
for i in range(m):
  List1.append(i)
import itertools
for i in list(itertools.combinations_with_replacement(List1,n)):
    mid=0
    for j in range(q):
        if i[nums[j][1]-1]-i[nums[j][0]-1]==nums[j][2]:
            mid+=nums[j][3]
    answer=max(mid,answer)
    
print(answer)


Measured memory_bytes: 84888
//#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=0;
    rep(l,n){
        string S=s.substr(l);
        int A[S.size()];//S と S[i:|S|-1(i?)] の最長共通接頭辞の長さ//Sの0文字目から何桁が（Sからi文字取り除いた部分列）と何文字共通するか？ということ
        A[0] = S.size();
        int i = 1, j = 0;   
        while (i < S.size()) {//i文字の差の場所から始める場合
            while (i+j < S.size() && S[j] == S[i+j]) ++j;//j文字共通だった
            A[i] = j;//i文字ずれた場合j文字共通だった
            if(i>=j){
                ans=max(ans,A[i]);
            }
            if (j == 0) { ++i; continue;}//共通部分なし
            int k = 1;//長さjだけ共通の場所があるから
            while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;//そのjのにおさまる範囲で共通の部分が存在するなら、その部分は確定で共通なので入れてしまおうということ//https://snuke.hatenablog.com/entry/2014/12/03/214243
            i += k; j -= k;//jからはみ出す範囲で共通な可能性を調べる
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
  string a, b; cin >> a >> b;

  int h = stoi(a + b);
  for (int i = 1; i < 400; ++i) {
    if (h == i * i) {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<int> dp(n);
  dp[n - 1] = 0;
  dp[n - 2] = abs(a[n - 1] - a[n - 2]);
  for(int i = n - 3; i >= 0; --i) {
    dp[i] = min(abs(a[i] - a[i + 1]) + dp[i + 1], abs(a[i] - a[i + 2]) + dp[i + 2]);
  } 
  cout << dp[0] << '\n';
  return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <map>
#include <cstring>
#include <vector>

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

int main(){
    string s;
    int k;
    cin>>s>>k;
    
    static int dp[2][2][2001][2001];
    memset(dp,0,sizeof(dp));
    
    map<char,int> mp[2][2];
    mp[0][0]['U']= 0, mp[0][0]['D']= 0, mp[0][0]['R']=+1, mp[0][0]['L']=-1;
    mp[0][1]['U']= 0, mp[0][1]['D']= 0, mp[0][1]['R']=-1, mp[0][1]['L']=+1;
    mp[1][0]['U']=+1, mp[1][0]['D']=-1, mp[1][0]['R']= 0, mp[1][0]['L']= 0;
    mp[1][1]['U']=-1, mp[1][1]['D']=+1, mp[1][1]['R']= 0, mp[1][1]['L']= 0;
    
    
    rep(x_y,2){
        rep(pos_neg,2){
            for(int i=1;i<=s.size();i++){
                rep(j,k+1){
                    int sign = j%2 ? -1:1 ;
                    int add = mp[x_y][pos_neg][s[i-1]] * sign;
                    dp[x_y][pos_neg][i][j] = dp[x_y][pos_neg][i-1][j]+add;
                    if(j-1>=0) dp[x_y][pos_neg][i][j] = max(dp[x_y][pos_neg][i][j],dp[x_y][pos_neg][i-1][j-1]-add);
                }
            }
        }
    }
    
    vector<int> x(k+1),y(k+1);
    rep(i,k+1)  x[i] = max(abs(dp[0][0][s.size()][i]),abs(dp[0][1][s.size()][i]));
    rep(i,k)    x[i+1] = max(x[i+1],x[i]);
    
    rep(i,k+1)  y[i] = max(abs(dp[1][0][s.size()][i]),abs(dp[1][1][s.size()][i]));
    rep(i,k)    y[i+1] = max(y[i+1],y[i]);
    
    
    
    int ans = -INF;
    rep(i,k+1){
        ans = max(ans,x[i]+y[k-i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 65748
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    set<pii> E;
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        E.insert({a, b});
        E.insert({b, a});
    }
    REP(i, N) {
        REP(j, N) {
            if (i == j) continue;
            if (!CONTAIN(E, pii(i, j))) {
                g[i].push_back(j);
            }
        }
    }

    bitset<800> dp(1);
    vector<int> col(N, -1);
    bool ng = false;
    REP(i, N) {
        if (col[i] != -1) continue;

        int one = 0;
        int comp = 0;
        function<void(int, int)> dfs = [&](int v, int c) {
            comp++;
            col[v] = c;
            if (c == 0) one++;
            FORE(w, g[v]) {
                if (col[w] != -1 && col[w] != (c ^ 1)) {
                    ng = true;
                    return;
                }
                if (col[w] != -1) continue;
                dfs(w, c ^ 1);
            }
        };

        dfs(i, 0);
        if (ng) {
            cout << -1 << endl;
            return 0;
        }

        int other = comp - one;
        dp = (dp << one) | (dp << other);
    }

    int ans = INF;
    REP(x, N + 1) {
        if (dp[x]) {
            int y = N - x;
            chmin(ans, x * (x - 1) / 2 + y * (y - 1) / 2);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 30848
#include <bits/stdc++.h>
using namespace std ;
int a , b , c , d ;
signed main () {
    cin >> a >> b >> c >> d ;
    while ( 1 ) {
        c -= b ;
        if ( c <= 0 ) { cout << "Yes\n" ; break ; }
        a -= d ;
        if ( a <= 0 ) { cout << "No\n" ; break ; }
    }
    return 0 ;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int a[100010][5], dp[100010][5];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i][1] >> a[i][2] >> a[i][3];
        for (int j = 1; j <= 3; ++j) {
            for (int k = 1; k <= 3; ++k) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
                }
            }
        }
    }
    cout << max({dp[n][1], dp[n][2], dp[n][3]});
}

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

typedef long long ll;

int main(){
    ll h, w;
    cin >> h >> w;
    ll ans = 0;
    if(h == 1 && w == 1) ans = 1LL;
    else if(h == 1 || w == 1) ans = max(h, w) - 2LL;
    else ans = (h-2LL) * (w-2LL);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  int a,b,c;
  int sum=0;
  cin>>a>>b>>c;

  vector<int>vec;

  int j;
  for (int i = 0; i < a; i++) {
    cin >> j;
    vec.push_back(j);
  }

  for (int el: vec) {
    sum += floor((b-1) / el)+1;
  }

  sum += c;

  cout<<sum;

  return 0;

}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val aMap: Map<Int, Int> = readLine()
        ?.split(" ")
        ?.map { it.toInt() }
        ?.groupBy { it }
        ?.mapValues { it.value.size }
        ?: return
    if (aMap.size <= k) {
        println(0)
        return
    }
    val result = aMap.values.sorted().take(aMap.size - k).sum()
    println(result)
}

Measured memory_bytes: 110932
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    string str;
    cin>>n>>k;
    cin>>str;
    for(int i=0;i<n;i++){
        if(i+1==k){
            cout<<char(tolower(str[i]));
        }
        else{
            cout<<str[i];
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
  return os << "{" << p.first << ", " << p.second << "}";
}
template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
  os << "{";
  rep(i, v.size()) { if(i) os << ", "; os << v[i]; }
  return os << "}";
}
// template<class t> ostream& operator<<(ostream& os, const set<t>& se) {
//   os << "{";
//   auto itr = se.begin();
//   rep(i, se.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
// template<class t, class u>
// ostream& operator<<(ostream& os, const map<t, u>& mp) {
//   os << "{";
//   auto itr = mp.begin();
//   rep(i, mp.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int M;
  cin >> M;
  vector<int> D(M);
  vector<ll> C(M);
  ll sum = 0;
  rep(i, M) {
    cin >> D[i] >> C[i];
    sum += D[i] * C[i];
  }
  cout << accumulate(all(C), 0LL) - 1 + sum / 9 - (sum % 9 == 0) << endl;
  return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define EPS 0.0000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int a,b,c;
    cin>>a>>b>>c;
    a=a+b;
    if(a>=c){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int r, d;
	int x[11] = { 0 };

	cin >> r >> d >> x[0];

	for (int i = 0; i < 10; i++) {
		x[i + 1] = r * x[i] - d;

		cout << x[i + 1] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N;
  cin>>N;
  vector<vector<ll>> vec(2,vector<ll>(N));
  for(ll i=0;i<2;i++) {
for(ll j=0;j<N;j++) {
  cin>>vec[i][j];
}
  }
  
  ll ans=0;
  
  
  for(ll i=0;i<N;i++) {
if(vec[0][i]-vec[1][i]>0) {
  ans+=vec[0][i]-vec[1][i];
}
  }
  
  
  cout<<ans<<endl;
}

  


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    ll ans=0;
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=n; ++j){
            if((n-r*i-g*j)>=0&&(n-r*i-g*j)%b==0)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
   // val seq = readLine.split("")
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

def solve(aaa:String): String={
  val seq = aaa.split(" ").map(_ .toInt)
  (( seq(0) * 3 + seq(1) ) / 2 ).toString
}
}


Measured memory_bytes: 25656
H,W=map(int,input().split())
a=[list(map(int,input().split())) for _ in[0]*H]
res=[]
for i in range(H):
    for j in range(W-1):
        if a[i][j]%2==1:
            a[i][j]-=1
            a[i][j+1]+=1
            res.append([i,j,i,j+1])
for i in range(H-1):
    if a[i][-1]%2==1:
        a[i][-1]-=1
        a[i+1][-1]+=1
        res.append([i,W-1,i+1,W-1])
print(len(res))
for a,b,c,d in res:
    print(a+1,b+1,c+1,d+1)

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0], X = line[1];

            var xDem = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var min = int.MaxValue;
            var cur = X;

            if (N == 1)
            {
                Console.WriteLine(Gcd(0, Math.Abs(xDem[0]-X)));
                return;
            }

            for (var i = 0; i < N-1; i++)
            {
                min = Math.Min(Gcd(Math.Abs(xDem[i]-X), Math.Abs(xDem[i+1]-xDem[i])), min);
            }
            Console.WriteLine(min);
        }

        static int Gcd(int a, int b)
        {
            if (a < b) Gcd(b, a);
            if (b == 0) return a;
            return Gcd(b, (a % b));
        }
    }
}


Measured memory_bytes: 21728
#include <stdio.h>
int main(){
    int N;
    scanf("%d", &N);
    char s[N+1];
    s[N] = '\0';
    scanf("%s", s);
    int nR = 0, nB = 0;
    for(int i=0;i<N;i++){
        if(s[i] == 'R'){
            nR += 1;
        }
        else{
            nB += 1;
        }
    }
    if(nR>nB){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin>>n;
  vector<long long >nos(100001,0);
  long long sum=0;
  for(int i=0,a;i<n;i++){cin>>a;sum+=a;nos[a]+=1;}
  int k;cin>>k;
  int b,c;
  for(int i=0;i<k;i++){
  	cin>>b>>c;
    sum = sum-nos[b]*b+nos[b]*c;
    nos[c]+=nos[b];
    nos[b]=0;
    cout<<sum<<'\n';
  }
}

Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

ll n, k;
int main(){
    cin >> n >> k;
    ll r = n%k;
    ll ans = min(r, abs(r-k));
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

int solve2(int x, int y) {
	if (x > y) {
		if (-x < y) return solve2(-x, y) + 1;
		return solve2(x, -y) + 1;
	} // x <= y
	if (y <= 0 || 0 <= x) return y - x; // x < 0 && 0 < y
	if (-x <= y) return solve2(-x, y) + 1; // y < -x
	return solve2(x, -y) + 1;
}

void solve() {
	int x, y; cin >> x >> y;
	cout << solve2(x, y) << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256