akhauriyash/Code-Regression huggingface dataset:
import sys

def main():
    lines = sys.stdin.readlines()

    for line in lines:
        if len(line) == 0:
            continue
        # print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        # print elems
        if elems[0] == "0" or elems[1] == "0":
            continue
        for height_ind in range(int(elems[0])):
            width_str = ""
            for width_ind in range(int(elems[1])):
                if ( (height_ind + 1) % 2 == 1 and (width_ind + 1) % 2 == 1 ) or ((height_ind + 1) % 2 == 0 and (width_ind + 1) % 2 == 0):
                    width_str = width_str + "#"
                else:
                    width_str = width_str + "."
            print width_str
        print("")

if __name__ == "__main__":
    main()

Measured memory_bytes: 6472
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long tt;

tt AA[1<<17];
tt BB[1<<17];
int N;

tt mmin(tt a, tt b){
    return a<b?a:b;
}

tt mmax(tt a, tt b){
    return a>b?a:b;
}

bool check(){
    if(AA[N]!=BB[1])
        return false;
    for(int i = 1;i<=N;i++){
        if(AA[i]!=AA[i-1] &&BB[i]!=BB[i+1]&&AA[i]!=BB[i])
            return false;
        if((AA[i]!=AA[i-1] && AA[i]>BB[i]) || (BB[i]!=BB[i+1] && BB[i]>AA[i]) )
            return false;
    }
    return true;
}

int main(){
    tt dat = 1L;
    cin >> N;
    for(int i=1;i<=N;i++)
        cin >> AA[i];
    AA[N+1] = AA[N];
    for(int i=1;i<=N;i++)
        cin >> BB[i];
    BB[N+1] = 0;
    if(check()){
        for(int i=1;i<=N;i++){
            if(AA[i]==AA[i-1] &&BB[i]==BB[i+1]){
                dat *= mmin(AA[i],BB[i])%1000000007L;
                dat %= 1000000007L;
            }
        }
        cout << dat << endl;
    }
    else
        cout << "0" << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <unordered_map>
#include <vector>

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    std::unordered_map<char, std::vector<int>> char_pos;
    for (int i = 0; i < s.length(); i++) {
        char_pos[s[i]].push_back(i);
    }

    for (int i = 0; i < s.length(); i++) {
        char_pos[s[i]].push_back(i + s.length());
    }

    long long ans = 0;
    int ptr = 0;
    for (auto c : t) {
        if (char_pos[c].empty()) {
            std::cout << -1 << std::endl;
            return 0;
        }

        ptr = *lower_bound(char_pos[c].begin(), char_pos[c].end(), ptr) + 1;
        if (ptr >= s.length()) {
            ptr -= s.length();
            ans += s.length();
        }
    }

    ans += ptr;
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

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;
}

int main() {
    ll C, D;
    cin>>N;
    rep(i,N) {
        ll x, y;
        cin >> A >> B >> C >> D;
        if(B > D || B > A) {
            S = "No";
        }else if(C + 1 >= B) {
            S = "Yes";
        }else {
            ll g = extgcd(max(B, D), min(B, D), x, y);
            K = (max(0LL, C - (A % B) + g)) / g;
            S = K * g + (A%B) < B ? "No" : "Yes";
            //if(K * g + (A%B) <= C) cout<<i<<' '<<K<<endl;
        }
        cout<<S<<endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
K, N = map(int, input().split())
A_list = list(map(int, input().split()))

max_dist = 0
for i in range(N - 1):
    max_dist = max(max_dist, A_list[i + 1] - A_list[i])

max_dist = max(max_dist, K - A_list[N - 1] + A_list[0])
print(K - max_dist)

Measured memory_bytes: 25840
import java.util.*

    fun main(args: Array<String>) {
        val n: Long
        val sc = Scanner(System.`in`)
        n = sc.nextLong()
        var ac = 0
        var wa = 0
        var tle = 0
        var re = 0
        for (i in 0..n) {
            val arr = sc.nextLine()
            if (arr == "AC") {
                ac++
            }
            if (arr == "WA") {
                wa++
            }
            if (arr == "TLE") {
                tle++
            } 
            if (arr == "RE") {
                re++
            }
        }
        println("AC x $ac")
        println("WA x $wa")
        println("TLE x $tle")
        println("RE x $re")
    }


Measured memory_bytes: 59580
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        var n = sc.Int;
        var a = sc.Long;
        var b = sc.Long;

        var sn = new long[n];
        for (var i = 0; i < n; i++)
            sn[i] = sc.Int;

        int l = 0;
        int r = 1000000010;

        while (r - l > 1)
        {
            int mid = (l + r) / 2;

            long cnt = 0;
            for (var i = 0; i < n; i++)
            {
                long res = sn[i] - b * mid;

                if (res > 0)
                    cnt += (res + a - b - 1) / (a - b);
            }

            bool ok = cnt <= mid;

            if (ok)
                r = mid;
            else
                l = mid;
        }

        Console.WriteLine(r);
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Line { get { return Console.ReadLine(); } }

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Line.Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public string[] StrArr { get { return Line.Split(' '); } }
    public int Int { get { return int.Parse(Str); } }
    public int[] IntArr { get { return Line.Split(' ').Select(int.Parse).ToArray(); } }
    public long Long { get { return long.Parse(Str); } }
    public long[] LongArr { get { return Line.Split(' ').Select(long.Parse).ToArray(); } }
    public double Double { get { return double.Parse(Str); } }
    public double[] DoubleArr { get { return Line.Split(' ').Select(double.Parse).ToArray(); } }
}

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

int main() {
  
  int N;
  cin >> N;
  
  int n=0;
  
  if (N%2 == 0) {
    cout << N << endl;
  }
  else {
    cout << 2*N << endl;
  }
  
return 0;
}

Measured memory_bytes: 3592
// AtCoder :: Beginner Contest 179 :: C - A x B + C
// https://atcoder.jp/contests/abc179/tasks/abc179_c

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    ll soln{0};
    for (ll a{1}; a < N; a++) {
        for (ll b{1}; a * b < N; b++) {
            soln++;
        }
    }
    cout << soln << endl;
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3648
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=5005;
int n,k;
int a[maxn];
bool dp[maxn];

bool check(int id){
	rep(i,maxn)dp[i]=false;
	dp[0]=true;
	REP(i,n){
		if(i==id)continue;
		for(int j=k;j>=0;j--){
			if(!dp[j])continue; 
			if(j+a[i]<=k)
			dp[j+a[i]]=true;
		}
	}
	for(int i=max(k-a[id],0);i<k;i++)
	if(dp[i])return false;
	return true; 
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	REP(i,n)cin>>a[i];
	sort(a+1,a+1+n);
	int l=0,r=n+1;
	while(r-l>1){
		int mid=(l+r)>>1;
		if(check(mid))l=mid;
		else r=mid;
	}
	cout<<l;
	return 0;
}

Measured memory_bytes: 256
import math as mt

N, D = list(map(int, input().split()))

xlis = [[0 for _ in range(D)] for _ in range(N)]

for i in range(N):
    inputlis = list(map(int, input().split()))
    for l in range(D):
        xlis[i][l] = inputlis[l]

cnt = 0

for i in range(N):
    for s in range(N):
        res = 0
        if i == s:
            continue
        for l in range(D):
           res += ((xlis[i][l] - xlis[s][l]) ** 2)

        if mt.sqrt(res).is_integer():
            cnt += 1


print(int(cnt/2))


Measured memory_bytes: 3064
n,m=map(int,input().split())

a=[]

for i in range(n):
    tmp=list(input())
    d=[-1]*n
    for j in range(n):
        if tmp[j]=="#":
            d[j]=1
    a.append(d)

b=[]

for i in range(m):
    tmp=list(input())
    d=[-1]*m
    for j in range(m):
        if tmp[j]=="#":
            d[j]=1
    b.append(d)
    
ans="No"

for i in range(n-m+1):
    for j in range(n-m+1):
        flag=1
        for k in range(m):
            for l in range(m):
                x=i+k
                y=j+l
                if a[y][x]*b[k][l]<0:
                    flag=-1
        if flag==1:
            ans="Yes"
#print(a)
#print(b)            
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
 
void solve(){
	int l,r,k;
	cin >> l >> r >> k;	
 	cout << r/k-(l-1)/k;
}
 
int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret;
    if(b & 1) ret *= a;
    return ret;
}
ll K;
string FESTIVAL = "FESTIVAL";
vector<int> ans;
ll val[10][1000];
ll num[10];
void f(int index, ll v) {
    //cerr << "f: " << index << " " << v << endl;
    ll tmp = 0;
    ll NumBefore = 0;
    for(int i = 0; i < ans.size(); i++) {
        //cerr << i << " " << ans[i] << endl;
        if(ans[i] == index - 1) {
            NumBefore++;
            tmp += val[index-1][NumBefore];
        }
        if(tmp == v) {
            ans.insert(ans.begin() + i + 1, index);
            num[index]++;
            val[index][num[index]] = v;
            return;
        }
        assert(tmp <= v);
    }
    assert(false);
}
void g(int index) {
    ll tmp = 0;
    ll NumBefore = 0;
    for(int i = 0; i < ans.size(); i++) {
        //cerr << i << " " << ans[i] << endl;
        if(ans[i] == index - 1) {
            NumBefore++;
            if(tmp + val[index-1][NumBefore] > K) {
                cerr << "L" << i << endl;
                ans.insert(ans.begin() + i, index);
                K -= tmp;
                return;
            }
            tmp += val[index-1][NumBefore];
        }
    }
    ans.push_back(index);
    K -= val[index-1][NumBefore];
}
const int UNIT = 9;
void print(vector<int> v) {
    for(auto t : v) cerr << t << " ";
    cerr << endl;
}
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> K;
    for(int i = 1; i <= beki(2, UNIT); i++) {
        ans.push_back(0);
        num[0]++;
        val[0][i] = 1;
    }
    for(int index = 1; index <= 6; index++) {
        f(index, 1);
        for(int j = 0; beki(2, j) <= val[index-1][num[index-1]] * beki(2, UNIT); j++) {
            f(index, beki(2, j));
        }
        //print(ans);
        for(int j = 1; j <= beki(2, UNIT) - 1; j++) {
            /*
            val[index][num[index]+1] = val[index][num[index]] + val[index-1][num[index-1]];
            ans.push_back(index);
            num[index]++;
            */
            f(index, beki(2, UNIT) * val[index-1][num[index-1]]);
            //print(ans);
        }
        //for(int j = 1; j <= num[index]; j++) cerr << val[index][j] << " ";
        //cerr << endl;
    }
    //print(ans);
    for(int j = 0; j <= 6; j++) {
        for(int k = 1; k <= num[j]; k++) cerr << val[j][k] << " ";
        cerr << endl;
    }
    while(K > 0) g(7);
    for(auto v : ans) cout << FESTIVAL[v];
    cout << endl;
    cerr << ans.size() << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int W, H, x, y;

    cin >> W >> H >> x >> y;

    double ans = (double)W*H/2.0;
    int f = 0;

    if((double)W/2 == x && (double)H/2 == y) f = 1;

    cout << ans  << " "<< f;
    
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   int k;
   cin>>k;
   while(b<=a)
   {
       b*=2;
       k--;
   }
   while(c<=b)
   {
       c*=2;
       k--;
   }
   if(k<0)
    cout<<"No"<<endl;
   else
    cout<<"Yes"<<endl;



}


Measured memory_bytes: 3632
from math import factorial

n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
a.remove(max_a)
dis = float('inf')
ans = 0
for a_i in a:
    if abs(a_i - max_a//2) < dis:
        ans = a_i
        dis = abs(a_i - max_a//2)

print(max_a, ans)

        


Measured memory_bytes: 14180
import math

a ,b , h ,m = map(int,input().split())

tyousin = m * 6
tansin = (h*60+m) * 0.5
kakudo = max(tyousin,tansin) - min(tyousin,tansin)
kakudo = min(kakudo,360-kakudo)
kosain = math.cos(math.radians(kakudo))

ans = (a**2 + b **2 - 2*a*b*kosain)**0.5
print(ans)

Measured memory_bytes: 9516
function main(input) {
  var a = input[1].trim().split(" ").map(e => parseInt(e, 10));
  var a_max = 10**6+1;
  var dp = new Array(a_max+1).fill(0);
  for(var i of a){
    dp[i]++;
  }
 
  for(var i=1;i<=a_max;i++){
    if(dp[i]===0){ 
      continue;
    }
    for(var j=i+i;j<=a_max;j+=i){
      if(dp[j]!==0){
        dp[j]=0;
      }
    }
  }
  console.log(dp.filter(function(x){return x==1}).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


Measured memory_bytes: 65924
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int n, k;
int dp[100000];
 

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	memset(dp,0, sizeof dp);
	cin >> n >> k;
	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = abs(arr[0] - arr[1]);
	for(int i = 2; i < n; i++){
		dp[i] = dp[i - 1] + abs(arr[i - 1] - arr[i]);
		for(int j = 2; j <= k; j++){
			if(j <= i) dp[i] = min(dp[i], dp[i - j] + abs(arr[i - j] - arr[i]));
			
		}
		
	}
	cout << dp[n - 1];
	
}


Measured memory_bytes: 4428
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;

#define rep(i,N) for(int (i)=0; (i)<(N); (i)++)
#define revrep(i,N) for(int (i)=(N)-1; (i)>=0; (i)--)
#define dump(vec) for(int i = 0; i < (vec).size(); i++){cout << vec.at(i) << ",";}cout << endl

typedef long long ll;

int main(void)
{
    int N;
    string S;
    cin >> N >> S;

    rep(i,S.size()){
        const char* c = S.substr(i,1).c_str();
        char c2 = c[0];
        c2 += N;
        if (c2 > 90) {c2 -= 90;c2+=64;}

        cout << c2;

    }
    cout << endl;
    

    return 0;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t a,b,c;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> a>>b>>c;

	int32_t count = 0;
	if ((a & 1) || (b & 1) || (c & 1)) {
		std::cout << count << endl;
		return 0;
	}
	while (!(a == b && b == c))
	{
		if ((a & 1) || (b & 1) || (c & 1)) {
			std::cout << count<<endl;
			return 0;
		}
		++count;
		auto newa = ((b + c) / 2);
		auto newb = ((c + a) / 2);
		c = ((a + b) / 2);
		a = newa;
		b = newb;
	}
	std::cout << -1 << endl;

	return 0;
}
#endif



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::endl;
typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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



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

int main() {
    
    int L, R;
    cin >> L >> R;
    //Lを2019でmodをとる
    //そこからmin(2019,R-L)個までを全部調べればいい
    
    int l = L % 2019;
    int n = std::min(2019, R-L);
    int ans = 2019;
    for (int i = l; i < l+n; i++) {
        for (int j = i+1; j < l+1+n; j++) {
            ans = std::min(ans, (i*j)%2019);
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int N = 5e5 + 100, inF = N;

int n, k, cnt, a[N], b[N], dex[N];
int seg[N << 1];
bool mark[N];
priority_queue<int> pq;

void change(int dex, int val) {
	for (seg[dex += n] = val; dex >>= 1;)
		seg[dex] = max(seg[dex << 1], seg[dex << 1 | 1]);
}
int get(int l, int r) {
	l = max(l, 0);
	r = min(r, n);

	int res = 0;
	for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
		if (l & 1)
			res = max(res, seg[l++]);
		if (r & 1)
			res = max(res, seg[--r]);
	}
	return res;
}

void check(int x) {
	int mx = get(x * k, x * k + k);
	if (mx == -inF)
		return;
	int me = dex[mx];
	if (a[me] >= get(me - k + 1, me + k) && mark[me] == false) {
		mark[me] = true;
		pq.push(me);
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		dex[a[i]] = i;
		change(i, a[i]);
	}
	cnt = (n + k - 1) / k;
	for (int i = 0; i < cnt; i++)
		check(i);
	for (int i = n; i; i--) {
		int x = pq.top();
		pq.pop();
		b[x] = i;
		change(x, -inF);
		x /= k;
		if (x)
			check(x - 1);
		check(x);
		if (x + 1 < cnt)
			check(x + 1);
	}
	for (int i = 0; i < n; i++)
		cout << b[i] << ' ';
}


Measured memory_bytes: 15856
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    string a, b, ans = "No";
    cin >> a >> b;
    int c = stoi(a+b);
    int i = 0;
    while(i*i < c){
        i++;
        if (i*i == c){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

int main() {
	int A,B,S=0,T=0;
	for(int i=0;i<4;i++) {
		scanf("%d",&A);
		S+=A;
	}
	for(int i=0;i<4;i++) {
		scanf("%d",&B);
		T+=B;
	}
	printf("%d\n",max(S,T));
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A; int B; int K;
  cin >> A >> B >> K ;
  
  int div;
  vector<int> comdiv;
  int j=0;
  int  ans;
  
  for(int i=1; i <A+1; i++){
    if(A%i==0 && B%i==0){
      comdiv.push_back(i);
    }
  }
    
  j = comdiv.size()-K;
  
  cout << comdiv.at(j) << endl;
}


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

int main() {
	int n;cin>>n;
	vector<int> l(n),r(n);
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
		ans+=r[i]-l[i]+1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
long long MIN(long long a, long long b){
    return a<b?a:b;
}
int main()
{   int n;
    scanf("%d",&n);
    long long a[n],full=0;
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        full+=a[i];
    }
    long long left=0,point;
    for(int i=0;i<n;i++){
        left+=a[i];
        if(left>=full/2){
            point=i;
            break;
        }
    }
    long long ans=MIN(llabs(left-(full-left)),llabs((left-a[point])-(full-(left-a[point]))));
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n;
  cin>>n;
  if(n%1000==0){
    cout<<0<<endl;
    return 0;
  }
  cout<<1000-(n%1000)<<endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX 999999

/*void pollock(int po[], int od[]) {
	int i = 1, j = 1;
	while (po[i - 1] < 1000000) {
		po[i] = (i * (i + 1) * (i + 2)) / 6;
		if (po[i] % 2 == 1) {
			od[j] = po[i];
			j++;
		}
		i++;
	}
}*/

int main() {
	vector<int> tmp(1000000, MAX);
	vector<int> odtmp(1000000, MAX);
	tmp[0] = 0, odtmp[0] = 0;
	int t = 1, i = 1;
	while (t <= MAX) {
			for (int j = 0; j + t <= MAX; ++j) {
				tmp[j + t] = min(tmp[j + t], tmp[j] + 1);
				if (t % 2 == 1) odtmp[j + t] = min(odtmp[j + t], odtmp[j] + 1);
			}
			i++;
			t = (i * (i + 1) * (i + 2)) / 6;
		}
	int n;
	while (cin >> n && n) {
		cout << tmp[n] << " " << odtmp[n] << endl;
	}

	return 0;
}


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


class Main{
	public static void main(String[] args){
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		long V=sc.nextLong();
		long[] a=new long[N];
		long[] b=new long[N];
		long[] c=new long[N];
		long[] d=new long[N];
		long[] first=new long[N*N];
		long[] sec=new long[N*N];
		for(int i=0; i<N; i++){
			a[i]=sc.nextLong();
		}
		for(int i=0; i<N; i++){
			b[i]=sc.nextLong();
		}
		for(int i=0; i<N; i++){
			c[i]=sc.nextLong();
		}
		for(int i=0; i<N; i++){
			d[i]=sc.nextLong();
		}

		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				first[i*N+j]=a[i]+b[j];
			}
		}
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				sec[i*N+j]=c[i]+d[j];
			}
		}
		Arrays.sort(sec);
		long sum=0;
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				long s=lower_bound(sec,V-first[i*N+j]);
				long t=lower_bound(sec,V-first[i*N+j]+1);
				if(s==-1){
					continue;
				}
				else if(t==-1 && sec[(int)s]==V-first[i*N+j]){
					sum+=(N*N-s);
				}
				else{
					if(sec[(int) s]==V-first[i*N+j]){
						sum+=t-s;
					}
				}
			}
		}
		pl(sum);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static final int lower_bound(final long[] arr, final long value) {
		int low = 0;
		int high = arr.length;
		int mid;
		while (low < high) {
			mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
			if (arr[mid] < value) {
				low = mid + 1;
			} else {
				high = mid;
			}
		}
		if(low<arr.length) {
			return low;
		}
		else {
			return -1;
		}
	}
}


Measured memory_bytes: 46848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main(){
    ll n,x; cin>>n>>x;
    vector<ll> town(n);
    rep(i,n) cin>>town[i];
    town.push_back(x);
    sort(town.begin(), town.end());
    ll res;
    rep(i,n){
        ll d=town[i+1]-town[i];
        if(i==0){
            res=d;
            continue;
        }
        res=gcd(res, d);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::stoi;

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;

    for (int i = 0; i < S.length(); i++)
    {
        int current = int(S[i]) - int('A');
        int next = current + N;
        cout << char(int('A') + (next % 26));
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
//#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

int main() {
	while (cin >> n, n) {
		int w, h;
		cin >> w >> h;
		//w--; h--;
		bool a[110][110];
		for (int i = 0; i < 110; i++) {
			for (int j = 0; j < 110; j++) {
				a[i][j] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			a[--y][--x] = 1;
		}
		/*for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << a[i][j];
			}
			cout << endl;
		}*/
		int s, t;
		cin >> s >> t;
		int maxcont = -inf;
		int nowcont = 0;
		for (int i = 0; i + t - 1 <h; i++) {
			for (int j = 0; j + s - 1 < w; j++) {
				nowcont = 0;
				for (int k = i; k < t+i; k++) {
					for (int l = j; l < s+j; l++) {
						if (a[k][l] == 1)nowcont++;
					}
				}
				//cout << i << " " << j << " " << nowcont << endl;
				maxcont = max(maxcont, nowcont);
			}
		}
		cout << maxcont << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
//Author : Vivek Dubey
#include <bits/stdc++.h>
using namespace std;

// debug start
	template <typename A, typename B>
	string to_string(pair<A, B> p);
	 
	template <typename A, typename B, typename C>
	string to_string(tuple<A, B, C> p);
	 
	template <typename A, typename B, typename C, typename D>
	string to_string(tuple<A, B, C, D> p);
	 
	string to_string(const string& s) {
	  return '"' + s + '"';
	}
	 
	string to_string(const char* s) {
	  return to_string((string) s);
	}
	 
	string to_string(bool b) {
	  return (b ? "true" : "false");
	}
	 
	string to_string(vector<bool> v) {
	  bool first = true;
	  string res = "{";
	  for (int i = 0; i < static_cast<int>(v.size()); i++) {
	    if (!first) {
	      res += ", ";
	    }
	    first = false;
	    res += to_string(v[i]);
	  }
	  res += "}";
	  return res;
	}
	 
	template <size_t N>
	string to_string(bitset<N> v) {
	  string res = "";
	  for (size_t i = 0; i < N; i++) {
	    res += static_cast<char>('0' + v[i]);
	  }
	  return res;
	}
	 
	template <typename A>
	string to_string(A v) {
	  bool first = true;
	  string res = "{";
	  for (const auto &x : v) {
	    if (!first) {
	      res += ", ";
	    }
	    first = false;
	    res += to_string(x);
	  }
	  res += "}";
	  return res;
	}
	 
	template <typename A, typename B>
	string to_string(pair<A, B> p) {
	  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
	}
	 
	template <typename A, typename B, typename C>
	string to_string(tuple<A, B, C> p) {
	  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
	}
	 
	template <typename A, typename B, typename C, typename D>
	string to_string(tuple<A, B, C, D> p) {
	  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
	}
	 
	void debug_out() { cerr << endl; }
	 
	template <typename Head, typename... Tail>
	void debug_out(Head H, Tail... T) {
	  cerr << " " << to_string(H);
	  debug_out(T...);
	}
	 
	#ifndef ONLINE_JUDGE
	#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
	#else
	#define debug(...) 42
	#endif
// end debug

	#define int long long

const int mxN = 3e5 + 1;
const int mod = 1e9 + 7;

int n, k;
int a[mxN];

void solve() {
	cin >> n;
	int ans = 1, ans1 = 1, ans2 = 2;
	ans %= mod;

	for(int i = 1; i <= n; i++) {
		ans *= 10;
		ans %= mod;

		ans1 *= 8;
		ans1 %= mod;

		ans2 *= 9;
		ans2 %= mod;
	}

	ans -= ans2 - ans1;

	ans += mod;
	ans %= mod;

	cout << ans;
}

int32_t main() {
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
		freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    //this can be opted out if you want to print the output to the sublime console
		freopen("output.txt", "w", stdout);
	#endif

	// for fast i/o
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);

	// test cases
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 3660
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let a: usize = sc.next();
    let b: usize = sc.next();
    println!("{}", (a-1)*(b-1));
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

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

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
 
sa = sum(a)
 
for i,b in enumerate(b):
	c = min(a[i],b)
	a[i] -= c
	a[i+1] -= min(a[i+1],b-c)
 
print(sa-sum(a))

Measured memory_bytes: 18624
S = input()
if len(S) == 26:
    last = None
    l = [False for i in range(26)]
    for i, s in enumerate(S):
        l[ord(s)-ord('a')] = True
        o = ord(s)-ord('a')
        while o <= ord('z')-ord('a'):
            if l[o] == False:
                last = S[:i] + chr(ord('a') + o)
                break
            o += 1
    if last:
        print(last)
    else:
        print(-1)
else:
    l = [False for i in range(26)]
    for s in S:
        l[ord(s)-ord('a')] = True
    for i in range(26):
        if l[i] == False:
            print(S+chr(ord('a') + i))
            break


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
 
#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}
 
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
 
using namespace std;
 
typedef pair<int,int> pii;
typedef pair<llong, llong> pll;
 
int main(){
  llong n, k;
  cin >> n >> k;

  vector<pll> v;
  map<llong, int> mp;


  REP(i,n){
    llong a, b;
    cin >> a >> b;
    v.push_back(MP(b,a));
  }

  sort(ALL(v), greater<pll>());

  llong type = 0;
  llong ans = 0;
  
  priority_queue<llong> que_mx;
  priority_queue<llong, vector<llong>, greater<llong>> que_mn;

  REP(i,k){
    if(mp.find(v[i].second) == mp.end()){
      mp[v[i].second] = 1;
    }else{
      que_mn.push(v[i].first);
    }
    ans += v[i].first;
  }


  type = mp.size();
  for(int i = k; i < n; ++i){
    if(mp.find(v[i].second) == mp.end()){
      que_mx.push(v[i].first);
      mp[v[i].second] = 1;
    }
  }

  llong ans_type = type;
  llong val = ans;
  while(!que_mn.empty() && !que_mx.empty()){
    type++;
    val = val - que_mn.top() + que_mx.top();
    que_mn.pop(); que_mx.pop();

    if(ans + ans_type * ans_type <= val + type * type){
      ans = val;
      ans_type = type;
    }
  }  
  cout << ans + ans_type * ans_type << endl;

  return 0;
}
 



Measured memory_bytes: 8432
use std::io::stdin;
fn get_string() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

macro_rules! input {
    ($single:ty) => ( get_string().parse::<$single>().unwrap() );
    ($plural:ty,) => ({
        let line = get_string();
        line.split_whitespace().map(|v| v.parse::<$plural>().unwrap()).collect::<Vec<$plural>>()
    });
    ($($plural:ty),+) => ({
        let line = get_string();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$plural>().unwrap()),+)
    });
    ($single:ty; $times:expr) => ( (0..$times).map(|_| input!($single)).collect::<Vec<$single>>() );
    ($($plural:ty),+; $times:expr) => ( (0..$times).map(|_| input!($($plural),+)).collect::<Vec<($($plural),+)>>() );
}

#[allow(dead_code)]
fn get_value<T: std::str::FromStr>() -> T {
    get_string().parse().ok().unwrap()
}
#[allow(dead_code)]
fn get_values_for<T: std::str::FromStr>(times: u64) -> Vec<T> {
    (0..times).map(|_| get_value()).collect()
}
#[allow(dead_code)]
fn get_vector<T: std::str::FromStr>() -> Vec<T> {
    get_string()
        .split_whitespace()
        .map(|v| v.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn get_vectors_for<T: std::str::FromStr>(times: u64) -> Vec<Vec<T>> {
    (0..times).map(|_| get_vector()).collect()
}

fn main() {
    let (n, k) = input!(usize, usize);
    let x = input!(i64,);

    let mut ans = Vec::new();
    let mut l = 0;
    while l + k <= n {
        let r = l + k - 1;
        ans.push(x[l].abs() + (x[l] - x[r]).abs());
        ans.push(x[r].abs() + (x[l] - x[r]).abs());
        l += 1;
    }
    println!("{}", ans.iter().min().unwrap());
}


Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr LL inv(LL x, LL m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr LL mpow(LL a, LL k, LL m) { LL r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }


const int N = 1005;
int n, A[N], k;
LL S[N];
vector<LL> X;

int main() {
    scanf("%d%d", &n, &k);
    FI(i, 1, n) scanf("%d", &A[i]);
    FI(i, 1, n) S[i] = S[i - 1] + A[i];
    vector<int> Cnt(41);
    FI(i, 1, n) FI(j, i, n) {
        LL sum = S[j] - S[i - 1];
        X.push_back(sum);
        FI(l, 0, 40) if (sum & 1LL << l) Cnt[l]++;
    }
    vector<int> Not(X.size());
    LL ans = 0;
    FD(i, 40, 0) {
        if (Cnt[i] >= k) {
            ans |= 1LL << i;
            for (size_t j = 0; j < X.size(); j++) {
                if (Not[j]) continue;
                if (!(X[j] & 1LL << i)) {
                    FI(l, 0, 40) if (X[j] & 1LL << l) Cnt[l]--;
                    Not[j] = 1;
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define l first
#define r second
#define int long long

int n;
vector<int > graph[500000];
int d[500000];
int dp[500000];

signed main()
{
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        int v, u;
        cin >> v >> u;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 1;
    for (int i = 4; i < 500000; i++)
    {
        if (dp[i - 1] == 2 || dp[i - 2] == 2) dp[i] = 1;
        else dp[i] = 2;
    }
    d[1] = 1;
    vector<int> q = {1};
    for (int i = 0; i < q.size(); i++)
    {
        for (int j = 0; j < graph[q[i]].size(); j++)
        {
            int u = graph[q[i]][j];
            if (d[u] == 0)
            {
                d[u] = d[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
    int idmx = 0;
    for (int i = 1; i <= n; i++) if (d[i] >= d[idmx]) idmx = i;
    fill(d, d + n + 1, 0);
    d[idmx] = 1;
    q = {idmx};
    for (int i = 0; i < q.size(); i++)
    {
        for (int j = 0; j < graph[q[i]].size(); j++)
        {
            int u = graph[q[i]][j];
            if (d[u] == 0)
            {
                d[u] = d[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
    for (int i = 1; i <= n; i++) if (d[i] >= d[idmx]) idmx = i;
    if (dp[d[idmx]] == 1)
    {
        cout << "First";
    }
    else
    {
        cout << "Second";
    }
}

Measured memory_bytes: 30704
#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() {
    ll a, b, x;
    cin >> a >> b >> x;
    a--;
    ll ans = b/x - a/x;
    if(b==0) ans = 1;
    else if(a==-1) ans = b/x + 1;
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> h.at(i);
	}
	vector<int> c(n);
	int count=0;
	for (int i = 0; i < n-1; ++i)
	{
		if(h.at(i)>=h.at(i+1)){
			count++;
          c.at(i)=count;
          
		}
		else{
			count=0;
		}
	}

    
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());
	cout << c.at(0) << endl;
}

Measured memory_bytes: 1024
month, day = gets.chomp.split.map(&:to_i)

ans = 0
(1..month).each do |m|
  (1..day).each do |d|
    a = d.to_s[0].to_i
    b = d.to_s[1].to_i
    if m == a * b && a>=2 && b>=2
      ans += 1
    end
  end
end

puts ans

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

int main() {
    int n;
    cin >> n;
    
    vector<pair<int, int>> vec(n);
    rep(i, n){
        cin >> vec[i].first >> vec[i].second;
    }
    
    int cnt = 0;
    rep(i, n){
        if(vec[i].first == vec[i].second){
            cnt++;
        }else cnt = 0;
        
        if(cnt == 3){
            cout << "Yes" << endl;
            break;
        }
    }
    
    if(cnt < 3) cout << "No" << endl;
}

Measured memory_bytes: 3628
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	long ans;
	foreach (i; 0..S.length/2)
	{
		if (S[i] != S[$-1-i])
			++ans;
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
          Yes(n/100==n%10);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include<iostream>
#include<cstdlib>
#include<cmath>

using namespace std;

int main() {
int A; int B; int C; int D;
  cin>>A>>B>>C>>D;
  bool a=std::abs(C-A)<=D;
  bool b=std::abs(C-B)<=D&&std::abs(B-A)<=D;
  if(a||b)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
   long n,x;
   cin >> n >> x;
   vector<long> a(n);
   for(int i = 0;i < n;i++){
       cin >> a[i];
   }
   sort(a.begin(),a.end());
   int ans = 0;;
   for(int i = 0;i < n - 1;i++){
       if(x >= a[i]){
           x -= a[i];
           ans++;
       }else{
           break;
       }
   }
   if(x == a[n - 1])ans++;
   cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        int minNow = Integer.MAX_VALUE;
        int maxValue = Integer.MIN_VALUE;
        int n, i, r;
        Scanner cin = new Scanner(System.in);
        n = cin.nextInt();
        for (i = 0; i < n; i++) {
            r = cin.nextInt();
            maxValue = Integer.max(maxValue, r - minNow);
            minNow = Integer.min(minNow, r);
        }
        System.out.println(maxValue);
    }
}


Measured memory_bytes: 68236
import sys
sys.setrecursionlimit(1000000)
memo = {0:1}
def fact(x):
  if x in memo:
    return memo[x]
  memo[x] = x * fact(x - 1)
  return memo[x]

def comb(x, y):
  return fact(x) // fact(x - y) // fact(y)
n, k = map(int, input().split())
if n > k:
  print(0)
else:
  print(comb(k, n) % 1000000007)


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

int main(){
  int N,K;
  cin >> N >> K;
  double b=0.0;
  for(int i=1;i<=N;i++){
    int j=i;
    double c=1.0;
    while(j<K){
      j*=2;
      c/=2.0;
    }
    b+=c;
  }
  cout << setprecision(12) <<(double)b/N << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,a,b,c; cin >>n>>a>>b>>c;
	vector<int> v(n);
	cinf(n,v);
	int ans=1e9;
	vector<int> w(n,0);

	while(w[0]<4){
		int A,B,C;
		A=B=C=0;
		int add=0;
		for(int i=0;i<n;i++){
			if(w[i]==0)A += v[i],add+=10;
			if(w[i]==1)B += v[i],add+=10;
			if(w[i]==2)C += v[i],add+=10;
		}
		if(A && B && C){
			ans=min(ans,add+abs(A-a)+abs(B-b)+ abs(C-c));
		}
		w[n-1]++;
		for(int i=n-1;i>=1;i--){
			if(w[i]==4){
				w[i]=0;
				w[i-1]++;
			}
		}
	}
	cout << ans-30 << endl;
	return 0;
}

Measured memory_bytes: 256