akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if((a < b) && (b < c)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }
}



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

int n, a[100], alice = 0, bob = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a+n);

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a[n - i - 1];
		}
		else {
			bob += a[n - i - 1];
		}
	}

	cout << alice - bob << endl;
}

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

#define MOD (1000000007)

typedef long long ll;
ll memo[220001];

void initTable(ll n)
{
    ll i;
    memo[1] = 1;
    for (i = 2; i <= n; i++){
        memo[(int)i] = (i * memo[(int)(i - 1)]) % MOD;
    }
}

ll extgcd(ll a, ll b, ll *x, ll *y)
{
    ll d = a;
    if (b != 0){
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * *x;
    }
    else {
        *x = 1;
        *y = 0;
    }
    return (d);
}

ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, &x, &y);
    return ((m + x % m) % m);
}

ll mod_fact(ll n, ll p, ll *e)
{
    ll res;
    int look;
    *e = 0;
    if (n == 0){
        return (1);
    }
    
    res = mod_fact(n / p, p, e);
    *e += n / p;
    
    if (n / p % 2 != 0){
        return (res * (p - memo[(int)(n % p)]) % p);
    }
    look = n % p;
    return (res * memo[(int)(n % p)] % p);
}

ll mod_comb(ll n, ll k, ll p) {
    ll e1, e2, e3;
    ll a1, a2, a3;
    
    if (n < 0 || k < 0 || n < k){
        return (0);
    }
    
    a1 = mod_fact(n, p, &e1);
    a2 = mod_fact(k, p, &e2);
    a3 = mod_fact(n - k, p, &e3);
    
    if (e1 > e2 + e3){ //divisible
        return (0);
    }
    return (a1 * mod_inverse(a2 * a3 % p, p) % p);
}

int main(void)
{
    int x, y, k;
    int i, j;
    ll res;
    ll xgrid, ygrid;
    
    scanf("%d%d%d", &x, &y, &k);
    
    memset(memo, -1, sizeof(memo));
    initTable(x + y + 2 * k);
    memo[0] = 1;
    res = 0;
    
    for (i = 0; i <= k; i++){ // ãºÉy + 2 * iñ, ¶EÉ x + 2 * k - 2 * iñ®­
        xgrid = (mod_comb(x + 2 * (k - i) , k - i, MOD) - mod_comb(x + 2 * (k - i), k - i - 1, MOD) + MOD) % MOD;
        ygrid = (mod_comb(y + 2 * i, i, MOD) - mod_comb(y + 2 * i, i - 1, MOD) + MOD) % MOD;
        
        res = (res + ((xgrid * ygrid) % MOD) * mod_comb(x + y + 2 * k, y + 2 * i, MOD)) % MOD;
    }
    
    printf("%lld\n", (res + MOD) % MOD);
    return (0);
}

Measured memory_bytes: 0
N = int(input())
h = list(map(int, input().split()))

h.append(10**10)
cnt = 0
ans = 0
for i in range(N):
    if h[i] >= h[i+1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

print(ans)

Measured memory_bytes: 63984
#include<bits/stdc++.h>
#define endl '\n'
#define INF ((1 << 31) - 1)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int a[100005], b[100005], c[100005];
  int dpt[3][100005];
  fill(dpt[0], dpt[3], 0);
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  
  dpt[0][0] = a[0];
  dpt[1][0] = b[0];
  dpt[2][0] = c[0];
  for(int i = 1;i < n;i++){
    dpt[0][i] = max(dpt[1][i - 1] + a[i], dpt[2][i - 1] + a[i]);
    dpt[1][i] = max(dpt[0][i - 1] + b[i], dpt[2][i - 1] + b[i]);
    dpt[2][i] = max(dpt[0][i - 1] + c[i], dpt[1][i - 1] + c[i]);
  }

  cout << max(dpt[0][n - 1], max(dpt[1][n - 1], dpt[2][n - 1])) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000000
#define INF 1000000
#define M 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std; 
int main(){
    fast_io 
    long double n;cin>>n;
    ll y = ceil(n/1000);
    ll ans = (1000*y) - n;
    cout<<ans<<endl;
    return 0;
}

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

    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 10000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair

    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;  
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    const double PI=acos(-1.0);

    int main(){ 
                            
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif 

        fast;   
        int t=1;
        // cin>>t; 
        while(t--){
            int n,m;
            cin>>n>>m;
            int s=0;
            rep(i,0,m){
                int x;
                cin>>x;
                s+=x;
            }
            if(s>n) cout<<-1;
            else cout<<n-s;
        }  
        return 0;       
    }       


    // First, solve the problem. Then, write the code. 
    

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rush() int T;scanf("%d",&T);int kase=1;while(T--)
#define all(x) (x).begin(),(x).End()
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define pb(x) push_back(x)
using namespace std;
using std::bitset;
typedef long long ll;
const ll maxn=1e6+5;
const ll mod=998244353;
const ll INF=0x3f3f3f3f3f3f3f3f;
const long double PI=acos(-1.0);
const long double eps=1e-5;
inline ll read(){ll ans=0,flag=1;char c;c=getchar();while(c<'0' || c>'9'){if(c=='-')flag=-1;c=getchar();}while(c>='0' && c<='9'){ans=ans*10+(ll)(c-'0');c=getchar();}return ans*flag;}
ll quickpow(ll x,ll y,ll mod){ll ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}

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


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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
  //  sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main()
{
	long long  x,min;
	cin >> x;
	vector<long long> v = divisor(x);

	min = (long long)pow(10,12)+1;
	for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < v.size(); j++){
			if (v[i] * v[j] == x && v[i] + v[j] < min)
				min = v[i] + v[j];
		}
	}

	cout << (min - 2) << endl;
	return 0;
}

Measured memory_bytes: 384
def main():
    h, w = map(int, input().split())
    inlis = list()
    for _ in range(h):
        alis = list(input())
        inlis.append(alis)
    
    for i in range(h):
        for j in range(w):
            if inlis[i][j] == "#":
                tmp = 0
                if i+1 < h:
                    if inlis[i+1][j] != "#":
                        tmp += 1
                else:
                    tmp += 1
                if j+1 < w:
                    if inlis[i][j+1] != "#":
                        tmp += 1
                else:
                    tmp += 1
                if j-1 >= 0:
                    if  inlis[i][j-1] != "#":
                        tmp += 1
                else:
                    tmp += 1
                if i-1 >= 0:
                    if inlis[i-1][j] != "#":
                        tmp += 1
                else:
                    tmp += 1
                       
                if tmp == 4:
                    print("No")
                    exit()
    print('Yes')
        




if __name__ == "__main__":
    main()

Measured memory_bytes: 66276
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

ll ans, n, v[N];

void solve(){
    scanf("%lld", &n);
    for(int i=0;i<n;i++) scanf("%lld",v+i);
    sort(v,v+n,greater<ll>());
    ans = v[0];
    for(int i=2;i<n;i++){
        ans+=v[i/2];
    }
    printf("%lld\n", ans);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 5368
#include <iostream>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c-a, y = d-b;
    cout << c-y << ' ' << d+x << ' ' << a-y << ' ' << b+x << endl;
    return 0;
}


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

int main()
{   
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c) cout<<1<<endl;
    else if(a==b || b==c || c==a)  cout<<2<<endl;
    else cout<<3<<endl;
    
    
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))

 
count=0
count_list=[0]

 
for i in range(n-1):
    if h[i]>=h[i+1]:
        count+=1
        count_list.append(count)
    else :
        count=0

print(max(count_list))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

void solve(){
	int a,b;
	cin>>a>>b;
	if(a>b){
		while(a--){cout<<b;}
	}
	else{
		while(b--)cout<<a;

	}

}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define gc getchar()
#define lint long long
#define mod 1000000007
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
#define f(x,y) dp[(x)+BAS+5][(y)+BAS+5]
#define N 200010
#define BAS 2010
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
inline int inn() { int x,ch;while((ch=gc)<'0'||ch>'9');x=ch^'0';while((ch=gc)>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^'0');return x; }
int a[N],b[N],dp[BAS*2+100][BAS*2+100],fac[N],facinv[N];
inline int fast_pow(int x,int k,int ans=1) { for(;k;k>>=1,x=(lint)x*x%mod) (k&1)?ans=(lint)ans*x%mod:0;return ans; }
inline int S(int n)
{
	rep(i,1,n) f(-a[i],-b[i])++;int ans=0;
	rep(i,-BAS,BAS) rep(j,-BAS,BAS) if(f(i,j)) f(i+1,j)+=f(i,j),f(i,j+1)+=f(i,j),(f(i+1,j)>=mod?f(i+1,j)-=mod:0),(f(i,j+1)>=mod?f(i,j+1)-=mod:0);
	rep(i,1,n) ans+=f(a[i],b[i]),(ans>=mod?ans-=mod:0);return ans;
}
inline int prelude(int n)
{
	rep(i,fac[0]=1,n) fac[i]=(lint)fac[i-1]*i%mod;facinv[n]=fast_pow(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) facinv[i]=(i+1ll)*facinv[i+1]%mod;return 0;
}
inline int C(int n,int m) { return (lint)fac[n]*facinv[n-m]%mod*facinv[m]%mod; }
int main()
{
	int n=inn();rep(i,1,n) a[i]=inn(),b[i]=inn();int ans=S(n);prelude(10000);
	rep(i,1,n) ans-=C(2*a[i]+2*b[i],2*a[i]),(ans<0?ans+=mod:0);
	return !printf("%lld\n",(lint)fast_pow(2,mod-2)*ans%mod);
}

Measured memory_bytes: 67712
def f_bracket_sequencing():
    N = int(input())
    Brackets = [input() for _ in range(N)]

    total = 0  # 正なら '(' が多い、負なら ')' が多い
    increase, decrease = [], []
    for s in Brackets:
        # 文字列を ±1 とみなして累積和を取ったとき、
        # ')' に対する '(' の多さの最終値と、それの最小値
        height, bottom = 0, 0
        for ch in s:
            height += 1 if ch == '(' else -1
            bottom = min(bottom, height)
        if height > 0:
            increase.append((bottom, height))
        else:
            decrease.append((bottom - height, -height))
        total += height
    increase.sort(reverse=True)
    decrease.sort(reverse=True)

    def accept(pairs):
        h = 0
        for p in pairs:
            b = h + p[0]
            if b < 0:
                return False  # '(' より ')' が多く、括弧列を構成できない
            h += p[1]
        return True

    return 'Yes' if accept(increase) and accept(decrease) and total == 0 else 'No'

print(f_bracket_sequencing())

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    
    long long k;
    cin >> k;
    
    int cnt = 0;
    while(s[cnt] == '1')
    {
        cnt++;
    }
    
    if(cnt == s.size())
    {
        cout << 1 << endl;
    }
    else
    {
        if(cnt >= k)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << s[cnt] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n, m;
	long *h;
	int *a;
	int *b;
	int *flgs;
	scanf("%d", &n);
	scanf("%d", &m);
	h = (long *)malloc(sizeof(long) * n);
	flgs = (int *)malloc(sizeof(int) * n);
	a = (int *)malloc(sizeof(int) * m);
	b = (int *)malloc(sizeof(int) * m);
	for(int i=0; i<n; i++){
		scanf("%ld", &h[i]);
		flgs[i] = 1;
	}
	for(int j=0; j<m; j++){
		scanf("%d", &a[j]);
		scanf("%d", &b[j]);
	}
	for(int k=0; k<m; k++){
		int tmp_a = a[k] - 1;
		int tmp_b = b[k] - 1;
		if(h[tmp_a] > h[tmp_b]){
			flgs[tmp_b] = 0;
		}
		else if(h[tmp_a] < h[tmp_b]){
			flgs[tmp_a] = 0;
		}
		else{
			flgs[tmp_a] = 0;
			flgs[tmp_b] = 0;
		}
	}
	int sum = 0;
	for(int l=0; l<n; l++){
		if(flgs[l] == 1){
			sum++;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 3692
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=1500;

int dp[maxn][maxn],G[maxn][maxn];
int n,m;

int main(){
    int maxedge=0;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            scanf("%d",&G[i][j]);
            if(G[i][j]==1)dp[i][j]=0;
            else dp[i][j]=1,maxedge=1;
        }
    }
    for(int i=1;i<n;++i){
        for(int j=1;j<m;++j){
            if(!G[i][j]){
                dp[i][j]=min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1]))+1;
                maxedge=max(maxedge,dp[i][j]);
            }
        }
    }
    printf("%d\n",maxedge*maxedge);
    return 0;
}

Measured memory_bytes: 19116
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  float s;
  if(n%2==0)
  {
    s=1/(float)2;
    cout<<fixed<<setprecision(6)<<s;
  }
  else
  {
    s=(n/2+1)/(float)n;
    cout<<fixed<<setprecision(6)<<s;
  }
}
  

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h,w,m=parseMap(split(readline()))
    data=[parseMap(split(readline())) for i=1:m]
    h_cnt=zeros(Int,h)
    w_cnt=zeros(Int,w)
    for (hi,wi)=data
        h_cnt[hi]+=1
        w_cnt[wi]+=1
    end
    h_m,w_m=maximum(h_cnt),maximum(w_cnt)
    pat=count(x->x==h_m,h_cnt)*count(x->x==w_m,w_cnt)
    for (hi,wi)=data
        if h_cnt[hi]==h_m && w_cnt[wi]==w_m
            pat-=1
        end
    end
    if pat>0
        println(h_m+w_m)
    else
        println(h_m+w_m-1)
    end
end
main()

Measured memory_bytes: 234540
N, M, X = map(int, input().split())
RB = [list(map(int, input().split())) for _ in range(N)]
ans = float('inf')

for x in range(2**N):
    indexes = [n for n in range(N) if (x >> n) % 2]
    if X <= min([sum([RB[i][j] for i in indexes]) for j in range(1, M+1)]):
        temp = sum([RB[i][0] for i in indexes])
        if ans > temp:
            ans = temp

if ans == float('inf'):
    print(-1)
else:
    print(ans)

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

int const N = 50000, M = 100000;
int n, m, T;
bool al[N + 1];
char an[M + 1];
bitset<N> msk[N + 1];

struct E{
	int a, b;
	E(){}
	void sc() { scanf("%d%d", &a, &b); }
}ed[M];

void no() { printf("-1\n"); exit(0); }

void solve1(){
	f(i, 1, n + 1)msk[i][i] = true;
	for (int i = m - 1; i >= 0; --i)msk[ed[i].a] = msk[ed[i].b] = msk[ed[i].a] | msk[ed[i].b];
	f(i, 2, n + 1)msk[1] &= msk[i];
	int x = 0;
	f(i, 1, n + 1)if (msk[1][i]){
		x = i;
		break;
	}
	if (!x)no();
	al[x] = true;
	for (int i = m - 1; i >= 0; --i)if (al[ed[i].a] + (int)al[ed[i].b] == 1){
		an[i] = al[ed[i].a] ? '^' : 'v';
		al[ed[i].a] = al[ed[i].b] = true;
	}
	else an[i] = '^';
}

void J(int a, int b, char c){
	if (al[a] && al[b])--n;
	if (c == '^')al[a] = max(al[a], al[b]), al[b] = false;
	else al[b] = max(al[a], al[b]), al[a] = false;
}

void solve2(){
	if (n == 2)no();
	f(i, 1, n + 1)al[i] = true;
	int i = 0;
	while (i < m && n != 3)J(ed[i].a, ed[i].b, an[i] = '^'), ++i;
	if (n == 3)f(j, i, m - 1){
		int sm = al[ed[j].a] + (int)al[ed[j].b];
		if (sm == 0)an[j] = '^';
		else if (sm == 1)an[j] = al[ed[j].a] ? '^' : 'v';
		else {
			int k = j + 1;
			while (k < m - 1 && al[ed[k].a] + (int)al[ed[k].b] < 2)++k;
			an[j] = ed[j].a == ed[k].a || ed[j].a == ed[k].b ? 'v' : '^';
		}
	}
	an[m - 1] = '^';
}

int main(){
	scanf("%d%d%d", &n, &m, &T);
	f(i, 0, m)ed[i].sc();
	if (T == 1)solve1();
	else solve2();
	printf("%s\n", an);
}

Measured memory_bytes: 306688
#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() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  int ans = 0;
  if (n % 2 == 0) {
    int mn = a[n / 2 - 1] + a[n / 2];
    int mx = b[n / 2 - 1] + b[n / 2];
    ans = mx - mn + 1;
  } else {
    int mn = a[n / 2];
    int mx = b[n / 2];
    ans = mx - mn + 1;
  }
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    REP(i,N) REP(j,D) cin >> X[i][j];
    int ans = 0;
    REP(i,N) for (int j=i+1; j<N; j++) {
        int dist = 0;
        REP(k,D) {
            dist += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
        }
        REP(k,1000) {
            if (k*k == dist) {
                ans++;
                break;
            }
        }
        //cout << i << " " << j << " " << dist << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
solve :: [Int] -> Int -> Int
solve [] res = res
solve (x:xs) res = solve xs res'
  where res' = if abs x < abs res
               then x
               else res

main :: IO ()
main = do
  [n, l] <- map read . words <$> getLine
  let tastes = map (\n -> l + n - 1) [1..n]
  print $ sum tastes - solve tastes 1000 


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int n, m; cin >> n >> m;
    vector<int> cnt(n, 0);

    rep(i, m){
        int a, b; cin >> a >> b;
        if(a==1) ++cnt[b];
        if(b==n) ++cnt[a];
    }

    bool ok = false;
    rep(i, n) if(cnt[i] >= 2) ok = true;
    if(ok) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
    
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
    int a, b;
    cin >> a >> b;
    int s = 1;
    int cnt = 0;
    while (s < b){
		s += a - 1;
		cnt++;
	}
	cout << cnt << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

  int A[4][3][10];
  int n, b, f, r, v;

  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 10; k++)
        A[i][j][k] = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    A[b-1][f-1][r-1] += v;

  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << A[i][j][k];
      }
      cout << endl;
    }
    if (i < 3)
      cout << "####################" << endl;
  }

  return 0;
}



Measured memory_bytes: 3072
A = int(input())
B = list()
tmp = 0
#for i in range(A):
B= input().split()
C = list(map(int, B))
D = sorted(C)
#print(D)
tmp = D[0]
#print(range(A-1))
for i in range(A-1):
    tmp = (tmp + D[i+1])/2
print(tmp)


Measured memory_bytes: 3060
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
typedef long long LL;
const int mod = 1000000009;
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    LL n;
    while (cin >> n)
    {
        LL flag = 1,x;
        while (n--)
        {
            cin >> x;
            if (x % 2 == 0)
            {
                if (x % 3 != 0 && x % 5 != 0)
                    flag = 0;
            }
            
        }
        if (flag)cout << "APPROVED\n";
        else cout << "DENIED\n";
    }
}



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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  const ll INF = 1LL << 60;
  vector<vector<vector<ll>>> dp(N, vector<vector<ll>>(N, vector<ll>(2)));
  REP(i, 0, N) REP(j, 0, N) {
    dp[i][j][0] = -INF;
    dp[i][j][1] = +INF;
  }
  REP(i, 0, N) {
    dp[i][i][0] = +A[i];
    dp[i][i][1] = -A[i];
  }

  REP(k, 2, N + 1) {
    REP(i, 0, N) {
      ll j = i + k - 1;
      if (j >= N) break;
      dp[i][j][0] = max(dp[i + 1][j][1] + A[i], dp[i][j - 1][1] + A[j]);
      dp[i][j][1] = min(dp[i + 1][j][0] - A[i], dp[i][j - 1][0] - A[j]);
    }
  }

  cout << dp[0][N - 1][0] << endl;
}

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

using namespace std;

#define ll long long 

int const N = 1e5 + 20;
int const INF = 1e9 + 7;

ll W, t, memo[N], w, v;

int main(){
	
	cin>>t>>W;
	
	for(int i = 0; i < t; ++i){
		cin>>w>>v;
		for(int j = W - w; j >= 0; --j){
			memo[j+w] = max(memo[j+w], memo[j] + v);
		}
	}
	
	ll ans = 0;
	
	for(int i = 0; i <= W; ++i)
		ans = max(ans, memo[i]);
		
	cout<<ans;	
	
	return 0;
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int l = 0;
    int r = 0;
    rep(i, s.size()){
        if(s[i] == 'T'){
            if(r > 0)r--;
            else l++;
        }else{
            r++;
        }
    }
    cout << l + r << endl;
}

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

int main(void){
  char s[100],p[100];
  char l;
  int sCnt = 0;
  int pCnt = 0;
  bool getAns = false;
  scanf("%s %s",s,p);
  sCnt = strlen(s);
  pCnt = strlen(p);
  for(int i = 0; i < sCnt; i++){
	l = s[0];
	for(int j = 0; j < sCnt; j++){
	  s[j] = s[j+1];
	}
	s[sCnt-1] = l;
	if(strstr(s,p) == NULL){
	  getAns = false;
	}else{
	  getAns = true;
	  break;
	}
  }

  if(getAns){
	cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }


  return 0;
}



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

int calcdif(int a[], int n) {
	int min = a[1] - a[0];
	for (int i = 1; i < n - 1; i++) {
		if (a[i+1] - a[i] < min)
			min = a[i+1] - a[i];
	}
	return min;
}

void sort(int a[], int n) {
	for (int i = 0; i < n; i++)
		for (int j = i; j > 0; j--)
			if (a[j-1] > a[j]) {
				int t = a[j-1];
				a[j-1] = a[j];
				a[j] = t;
			}
}

int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		int a[n];
		for (int i = 0; i < n; i++)
			cin >> a[i];
		
		sort(a, n);
		int ans = calcdif(a, n);
		cout << ans << endl;
	}
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n][n],b[n],i,j,day=0;
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      cin>>a[i][j];
      a[i][j]--;
    }
  }
  bool flag,f[n];
  for(i=0;i<n;i++){
    b[i]=0;a[i][n-1]=0;
  }
  while(1){
    flag=0;
    for(i=0;i<n;i++){
      f[i]=0;
    }
    for(i=0;i<=n-2;i++){
      j=a[i][b[i]];
      if(j>i&&a[j][b[j]]==i&&f[i]==0&&f[j]==0){
        b[i]++;b[j]++;
        flag=1;f[i]=1;f[j]=1;
      }
    }
    if(flag==1){
      day++;
    }
    else break;
  }
  if(day==0) day=-1;
  for(i=0;i<n;i++){
    if(b[i]!=n-1) day=-1;break;
  }
  cout<<day<<endl;
  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define tc int t; cin>>t; while(t--)
#define mod 1000000007
#define pie 3.141592653589793
#define endl "\n"
using namespace std;

void fastio(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed;
    cout.precision(9);
}

int main(){
    fastio();
	int n;
	cin>>n;
	string s;
	cin>>s;
	int flag=0;
	for(int i=0;i<s.length();i++){
		if(i<n)cout<<s[i];
		else {
			flag=1;break;}
	}
	if(flag)cout<<"...";
    return 0;
}

Measured memory_bytes: 3656
head0 :: String -> String -> (String,String)
head0 [] _ = ([],[])
head0 _ [] = (['a'],[])
head0 (k:ey) (l:ls) = if k == l then head0 ey ls else (k:ey,l:ls)

main :: IO ()
main = do
  l <-  getLine 
  if (fst $ head0 (reverse $ fst $ head0 "keyence" l) (reverse $ snd $ head0 "keyence" l)) == [] 
    then putStrLn "YES" else putStrLn "NO"

Measured memory_bytes: 380
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<bitset>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// ÉÏ ×ó ÏÂ ÓÒ
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a,ans;
map<int,int> mp;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a),mp[a]++;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
		if(it->second!=it->first)
		{
			if(it->second<it->first)
				ans+=it->second;
			else
				ans+=it->second-it->first;
		}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
const ll IMF = 1LL << 60;
int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll s = A * N;
  ll t = A * (N - 1);
  
  ll ans = (A * (B - 1)) / B;
  if(B == 1) { cout << 0; return 0; }
  if(B > N) { cout << s / B; return 0; }
  else if(B < N) { cout << max(s / B - A * (N / B) ,max(ans, (A - 1))); return 0; }
  else if(B == N) { cout << ((A * (N - 1)) / B);}
   



  return 0;
}

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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x+r>W || x+r<1 || y+r>H || y+r<1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for(int i = 0; i < n; i++)
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)

int main()
{
    int N; cin >> N;
    int ans = 0;
    int M = 0;
    REP(i, N) {
        int p; cin >> p;
        ans += p;
        M = max(M, p);
    }
    ans -= M / 2;
    cout << ans << endl;
    return 0;
}

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

using ll = long long int;
using ld = long double;
using pii = pair<int,int>;

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()

int main(){
  int h,w;cin >> h >> w;
  string s[h+1];
  rep(i,h){ cin >> s[i];s[i].push_back('#');}
  rep(i,w+1) s[h].push_back('#');
  vector<vector<int>> ah(h+1,vector<int>(w+1,0));
  vector<vector<int>> aw(h+1,vector<int>(w+1,0));
  
  rep(i,h){
    int cnt = 0, str = 0;
    rep(j,w+1){
      if(s[i][j] != '#' )cnt++;
      else {
        REP(k , str , j) aw[i][k]=cnt;
        str=j+1; cnt = 0;
      }
    }
  }
  rep(i,w){
    int cnt=0,str=0;
    rep(j,h+1){
      if(s[j][i] !='#')cnt++;
      else { 
        REP(k,str,j) ah[k][i]=cnt;
        str=j+1;
        cnt = 0;
      }
    }
  }
  int ans = 0;
  rep(i,h)rep(j,w){
    if(s[i][j]=='#') continue;
      ans = max(ans, ah[i][j]+aw[i][j]-1);
  }
  cout << ans << endl;
}
       
  

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

int main()
{
  int n;
  cin>>n;
  int a[n];
  int x = 0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    x = x^a[i];
  }
  for(int i=0;i<n;i++)
  {
    int temp = x;
    int ans = temp ^ a[i];
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 4364
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			long num[] = new long[n];
			for (int i = 0; i < n; i++)
			{
				num[i] = sc.nextLong();
			}
			long count = 0;
			for (int i = n; i > 0; i--)
			{
				for (int j = 1; j < i; j++)
				{
					if (num[j-1] > num[j])
					{
						long tmp = num[j-1];
						num[j-1] = num[j];
						num[j] = tmp;
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(){
  char s[100010],w[100010];
  int i,j,n,a,b,c[100010]={};
  int d[100010]={};
  scanf("%s %s",s,w);
  for(i=0;s[i];i++){
    if(s[i]=='A')d[i+1]=1;
    else         d[i+1]=2;
    d[i+1]+=d[i];
  }
  for(i=0;w[i];i++){
    if(w[i]=='A')c[i+1]=1;
    else         c[i+1]=2;
    c[i+1]+=c[i];
  }
  scanf("%d",&n);
  while(n--){
    scanf("%d %d %d %d",&i,&j,&a,&b);
    if((d[j]-d[i-1])%3==(c[b]-c[a-1])%3)printf("YES\n");
    else                                    printf("NO\n");
  }
  return 0;
}
  


Measured memory_bytes: 1536
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin(), x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;

signed main(void) {
  	int N;
  	cin >> N;
  	vector<ll> A;
  	vector<ll> B;
  	ll ans = 0;

  	rep(i, N+1) {
  		ll tmp;
  		cin >> tmp;
  		A.pb(tmp);
  	}

  	rep(i, N) {
  		ll tmp;
  		cin >> tmp;
  		B.pb(tmp);
  	}

  	rep(i, N) {
  		if (A[i] >= B[i]) {
  			ans += B[i];

  		} else {
  			ans += A[i];
  			B[i] -= A[i];
  			if (A[i+1] >= B[i]) {
  				ans += B[i];
  				A[i+1] -= B[i];
  			} else {
  				ans += A[i+1];
  				A[i+1] = 0;
  			}
  		}
  	}

  	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2548
#include <stdio.h>

int main(void) {
  
  char S[3];
  char s[3];
  int ans = 0;
  
  scanf("%s", S);
  scanf("%s", s);
  	for (int i = 0; i < 3; i++)
      if (S[i] == s[i])
        ans++;
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N, K;
    cin >> N >> K;
    vvll g(N);
    rep(i, N) {
        ll a;
        cin >> a;
        a--;
        g[i].push_back(a);
    }

    vector<bool> check(N, false);
    queue<ll> que;
    que.push(0);
    bool end = false;
    vll dist(N, 0);
    dist[0] = 0;
    ll loop = -1, cnt = 0;

    while((!que.empty()) && (!end)) {
        ll now = que.front();
        que.pop();
        check[now] = true;

        for(auto next : g[now]) {
            cnt++;
            if(check[next]) {
                end = true;
                loop = next;
                continue;
            }
            que.push(next);
            dist[next] = dist[now] + 1;
        }
    }

    debug(loop)
    debug(cnt)

    ll ans = -1;
    if(K <= dist[loop]) {
        rep(i, N) if(dist[i] == K) ans = i+1;
        cout << ans << endl;
        return 0;
    }

    ll res = (K - dist[loop]) % (cnt - dist[loop]);
    debug(res)

    ans = loop;
    rep(i, res) {
        ans = g[ans][0];
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  int cnt = 10000;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    int cntdiv2 = 0;
    while( (a & 1) != 1){
      a >>= 1;
      cntdiv2++;
    }
    cnt = min(cnt, cntdiv2);
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
n, *D  = [list(map(int, s.split())) for s in open(0)]
imp = 0
dic = dict()
D = sorted(D)
cond = []
for d in D:
    if n[0] != 1 and d[0] == 1 and d[1] == 0:
        imp += 1
    if d not in cond:
        cond.append(d)
        if d[0] in dic:
            imp += 1
        else:
            dic[d[0]] = d[1]

s = ""
if imp:
    print(-1)
else:
    for i in range(n[0]):
        if i + 1 in dic:
            s += str(dic[i+1])
        else:
            if i == 0 and n[0] > 1:
                s += str(1)
            else:
                s += str(0)
    print(s)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b && a!=c)
        printf("Yes\n");
    else if(a==c && a!=b)
        printf("Yes\n");
    else if(b==c && a!=b)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9;
const int mod=1000000007;
//const int mod=998244353;

int n,m,k;
const int N=1e6+10;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,u,v,h;
    ll x,a,b,c,d,y,w,z;
    string s;
    cin >> s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
        cout << 3 << el;
    }
    else if((s[0]=='R'&&s[1]=='R')||(s[1]=='R'&&s[2]=='R')){
        cout << 2 << el;
    }
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R'){
        cout << 1 << el;
    }
    else{
        cout << 0 << el;
    }
    
    return 0;
}



Measured memory_bytes: 3648
import java.io.*;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
// import java.io.BufferedReader;
// import java.io.IOException;
// import java.io.InputStreamReader;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.Collections;
// import java.util.List;
// import java.util.HashSet;
// import java.util.Set;
// import java.util.Map;
// import java.util.HashMap;

import java.math.*;

public class Main {
    private static Scanner sc;
    private static final long mod = 1000000007;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private static String getUpperAlpha(int i) {
        return String.valueOf((char) (i + 64));
    }

    /* i=1 return a */
    private static String getLowerAlpha(int i) {
        return String.valueOf((char) (i + 96));
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int[] nextIntArray(int n) throws NumberFormatException, IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            int n = sc.nextInt();
            int x = sc.nextInt();
            int t = sc.nextInt();
            int add = 0;
            if (n % x != 0)
                add = 1;

            System.out.println((n / x + add) * t);
        } catch (

        Exception e) {
            e.printStackTrace();
        }

    }
}


Measured memory_bytes: 32624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println((int) Math.ceil((0.0 + b - 1) / (a - 1)));
		sc.close();
	}
}


Measured memory_bytes: 35676
N=int(input())
D=[]
for i in range(N):
    D.append(list(map(int,input().split())))
def total(N):
    for i in range(N-2):
        if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
            print('Yes')
            return
    print('No')
    return
total(N)

Measured memory_bytes: 9172
#include <cstdio>
#include <algorithm>
using namespace std;
int N, dp[100001];
int main() {
  scanf("%d", &N);
  for(int i = 1; i < 100001; i++) dp[i] = N;
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= i; j *= 6) dp[i] = min(dp[i], dp[i-j]+1);
    for(int j = 1; j <= i; j *= 9) dp[i] = min(dp[i], dp[i-j]+1);
  }
  printf("%d", dp[N]);
}

Measured memory_bytes: 512
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define INF 1e18
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6],dp[10009][109];
ll power(ll x,ll n)
{   if(n==0||x==0) return 1;
    else if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=MAX;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll pred(ll i,ll a,ll b){
    return (i/a)+(i/b)-(i/(a*b));
}
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,n,a,b,t,q,ans,test,sum;
    test=1;
    while(test--){
        string sk;
        cin>>sk;
        if(sk[0]=='9'||sk[1]=='9') cout<<"Yes";
        else cout<<"No";
        
        
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    N, M = map(int, input().split())
    if N == 0 and M == 0: break
    travel = [list(map(int, input().split())) for _ in range(N)]
    travel.sort(reverse=True, key=lambda x:x[1])
    for i, (d, _) in enumerate(travel):
        if M == 0: break
        travel[i][0] = max(0, d-M)
        M = max(0, M-d)
    print(sum(d*p for d, p in travel))

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

int main(){
    int n;
    cin >> n;
    set<string> st;
    REP(i, n){
        string tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    if(st.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <utility>

const int MAXN = 20;
const int INF = 400;

bool maze[MAXN][MAXN];  // '1' = road, '0' = wall.
bool is_vis[MAXN][MAXN];
int min_move[MAXN * MAXN][MAXN * MAXN];  // src -> dest

void bfs(int x, int y, int r, int c) {
  if (maze[x][y] == false) return;
  
  auto hash = [&](int i, int j) -> int {
    return i * c + j;
  };

  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      is_vis[i][j] = false;
    }
  }

  std::queue<std::pair<int, int>> que;
  int dx[4] = {-1, 0, 0, 1};
  int dy[4] = {0, -1, 1, 0};
  que.emplace(x, y);
  is_vis[x][y] = true;
  int src_hash = hash(x, y);
  min_move[src_hash][src_hash] = 0;
  while (!que.empty()) {
    auto cur = que.front();
    que.pop();
    for (int k = 0; k < 4; ++k) {
      int i = cur.first + dx[k];
      int j = cur.second + dy[k];
      int cur_hash = hash(cur.first, cur.second);
      if (i < 0 || i >= r || j < 0 || j >= c) continue;
      if (is_vis[i][j] || maze[i][j] == false) continue;
      min_move[src_hash][hash(i, j)] = min_move[src_hash][cur_hash] + 1;
      is_vis[i][j] = true;
      que.emplace(i, j);
    } 
  }
}

int solve(int r, int c) {
  int tot = r * c; 
  for (int i = 0; i < tot; ++i) {
    for (int j = 0; j < tot; ++j) {
      min_move[i][j] = INF;
    }
  }
  
  for (int i = 0; i < r; ++i) {
    for (int j = 0; j < c; ++j) {
      bfs(i, j, r, c);
    }
  }

  int res = 0;
  for (int i = 0; i < tot; ++i) {
    for (int j = 0; j < tot; ++j) {
      if (min_move[i][j] != INF && min_move[i][j] > res)
        res = min_move[i][j];
    }
  }
  return res;
}

int main() {
  int r, c;
  std::cin >> r >> c;
  for (int i = 0; i < r; ++i) {
    std::string s;
    std::cin >> s;
    for (int j = 0; j < c; ++j) {
      if (s[j] == '.') maze[i][j] = true;
      else maze[i][j] = false;
    }
  }
  std::cout << solve(r, c) << std::endl;
  return 0;
}


Measured memory_bytes: 896