akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int D = cin.nextInt();
        int tmp = D * 2 + 1;
        int ans = (N + (tmp - 1)) / tmp;
        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 11092
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, *lst = map(int, read().split())
al = lst[:n]
bl = lst[n:]


def convert(A):
    return [x ^ y for x, y in zip(A, A[1:])] + [A[-1] ^ A[0]]


a = convert(al)
b = convert(bl)


def Z_algorithm(s):
    n = len(s)
    z = [0] * n
    l, r = 0, 0
    for i in range(1, n):
        if i <= r:
            z[i] = min(r - i - 1, z[i - l])
        while i + z[i] < n and s[z[i]] == s[i + z[i]]:
            z[i] += 1
        if i + z[i] - 1 > r:
            l, r = i, i + z[i] - 1
    return z


Z = Z_algorithm(b + [-1] + a + a)[n + 1:n + n + 1]

K = [i for i, x in enumerate(Z) if x == n]
X = [al[k] ^ bl[0] for k in K]

print('\n'.join('{} {}'.format(k, x) for k, x in zip(K, X)))

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

int main() {
  int N;
  cin >> N;
  vector<long long>a(3*N);
  for (int i = 0; i < 3*N; i++) {
    cin >> a.at(i);
  }
  vector<long long>b(N+1), c(N+1);
  priority_queue<long long, vector<long long>, greater<long long>>que_b;
  priority_queue<long long>que_c;
  long long B = 0, C = 0;
  for (int i = 0; i < N; i++) {
    que_b.push(a.at(i));
    B += a.at(i);
    que_c.push(a.at(3*N-1-i));
    C += a.at(3*N-1-i);
  }
  for (int i = 0; i < N+1; i++) {
    b.at(i) = B;
    B += a.at(N+i);
    que_b.push(a.at(N+i));
    B -= que_b.top();
    que_b.pop();
    c.at(i) = C;
    C += a.at(2*N-1-i);
    que_c.push(a.at(2*N-1-i));
    C -= que_c.top();
    que_c.pop();
  }
  long long ans = b.at(0) - c.at(N);
  for (int i = 1; i < N+1; i++) {
    if (ans < b.at(i) - c.at(N-i)) {
      ans = b.at(i) - c.at(N-i);
    }
  }
  cout << ans << endl;
}

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

int main() {
  vector<vector<int> > v;

  vector<int> xy(2);
  do {
    cin >> xy[0] >> xy[1];
    sort(xy.begin(), xy.end());
    v.push_back(xy);
  } while(!(xy[0] == 0 && xy[1] == 0));

  for (int i=0; i<v.size()-1; i++) {
    cout << v[i][0] << " " << v[i][1] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3128
fun main(args: Array<String>) {
    val (n, k, q) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val p = Array(n + 1) { 0 }
    0.until(q).forEach {
        val a = readLine()?.toInt() ?: return
        p[a]++
    }
    buildString {
        1.until(n + 1).forEach {
            if (k - (q - p[it]) > 0) {
                appendln("Yes")
            } else {
                appendln("No")
            }
        }
    }.let {
        println(it)
    }
}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

void visitPoint(int index, vector<vector<int>>& point, vector<bool>& visit) {
	if (visit[index]) {
		return;
	}

	visit[index] = true;
	for (int i = 0; i < point[index].size(); ++i) {
		int idx = point[index][i];
		visitPoint(idx, point, visit);
	}
}

int main() {
	int N, M;
	cin >> N >> M;

	vector<vector<int>> AB(N);
	vector<bool> visit(N);

	for (int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		if (find(AB[A - 1].begin(), AB[A - 1].end(), B-1) == AB[A - 1].end()) {
			AB[A - 1].push_back(B - 1);
		}
		if (find(AB[B - 1].begin(), AB[B - 1].end(), A - 1) == AB[B - 1].end()) {
			AB[B - 1].push_back(A - 1);
		}
	}
	
	visitPoint(0, AB, visit);

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (!visit[i]) {
			visitPoint(i, AB, visit);
			ans++;
		}
	}

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


Measured memory_bytes: 9580
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
using namespace std;
string s;
int a,b,c;
int main()
{
	cin>>s;
	for (int i=0;i<s.size();i++)
	{
		if (s[i]=='a')
			a++;
		if (s[i]=='b')
			b++;
		if (s[i]=='c')
			c++;
	}
	if (a==1 && b==1 && c==1)
		cout<<"Yes";
	else
		cout<<"No";
	system("pause");
    return 0;
}

Measured memory_bytes: 504
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    //漸化式 dp[i][j]は頭からi番目まで見てj余るものの個数
    char s[100002];
    ll dp[100002][13];
    dp[0][0]=1;
    scanf("%s", s);
    int n = strlen(s);

    for(int i=0;i<n;i++){
        int c;
        if(s[i] == '?') c = -1;
        else c = s[i]-'0';

        for(int j=0;j<10;j++){
            if(c != -1 && c != j) continue;
            for(int k=0;k<13;k++){
                dp[i+1][(k*10+j) % 13] +=dp[i][k];
            }
        }
        for(int j=0;j<13;j++) dp[i+1][j] %= 1000000007;
    }
    ll ans = dp[n][5];
    cout << ans;
    return 0;
}


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

int main(){
  int A,B;  cin >> A >> B;

  int count = 0;

  for(int i = A;i <= B;i++){

    string s = to_string(i);
    bool flag = true;

    for(int j = 0;j < s.size();j++){
      if(s[j] != s[s.size()-1-j])flag = false;
    }

    if(flag)count++;
  }

  cout << count << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


Int T, A, n, a, b;
vector<Int> AplusB;
int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a >> b;
    T -= b;
    A -= a;
    AplusB.push_back(a+b);
  }
  sort(AplusB.rbegin(), AplusB.rend());
  for(int i = 0;i < n;i++){
    if(i % 2 == 0)T += AplusB[i];
    else A += AplusB[i];
  }
  cout << T << endl;
  return 0;
}

Measured memory_bytes: 1400
n, p_ = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

ne = 0
no = 0
a.each do |i|
  if i.even? then
    ne += 1
  else
    no += 1
  end
end

@fac = Array.new(n)
def fact(n)
  @fac[0] = 1
  (1..n).each do |i|
    @fac[i] = @fac[i-1] * i
  end
end
fact(50)

def comb(n, k)
  return 1 if k == 0
  return @fac[n] / (@fac[n-k] * @fac[k])
end

ans = 0
if p_ == 0 then
  anse = (0..ne).map{|k| comb(ne, k)}.inject(:+)
  anso = 0
  0.step(no, 2){|k| anso += comb(no, k)}
  ans = anse * anso
else
  anse = (0..ne).map{|k| comb(ne, k)}.inject(:+)
  anso = 0
  1.step(no, 2){|k| anso += comb(no, k)}

  ans = anse * anso
end
puts ans

Measured memory_bytes: 3836
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int c[3][3] = {0};

  rep(i,3)
  rep(j,3)
  {
    cin >> c[i][j];
  }

  int a[3];
  int b[3];

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

  rep(i,3)
  rep(j,3)
  {
    if(c[i][j] != a[i] + b[j])
    {
      cout << "No" ;
      return 0;
    }
  }

  cout << "Yes";

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> m(N);
	int m_total = 0;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		m_total += m[i];
	}

	cout << (X - m_total) / *min_element(m.begin(), m.end()) + N;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(){
  set<int> a ={1,3,5,7,8,10,12};
  set<int> b ={4,6,9,11};
  int x,y; cin >> x >> y;
  if(a.count(x) and a.count(y) or b.count(x) and b.count(y))
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 3572
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong).toMutableList()
    val bcList = mutableListOf<Pair<Long, Long>>()
    for (i in 1..m) {
        val (b, c) = readLine()!!.split(' ').map(String::toLong)
        bcList.add(Pair(b, c))
    }
    bcList.sortByDescending { entry -> entry.second }

    val list = mutableListOf<Long>()
    for ((b, c) in bcList) {
        for (i in 1..b) list.add(c)
        if (list.size >= n) {
            break
        }
    }
    aList.addAll(list)
    aList.sortDescending()
    println(aList.take(n.toInt()).sum())
}

Measured memory_bytes: 106916
#include<cstdio>
long long a[200005];
long long b[200005];
long long lt[200005], rt[200005];
int right[200005];
int ptr = -1;

long long refresh(int p,long long pre,int n){
    ptr = right[p];
    long long res = 0, mul = 1;
    int r = right[p];
    while(b[p]<pre) b[p] *= 4, res++, mul *= 4;
    res *= (long long)(r-p+1);
    if(r==n) return res;
    else{ 
        if(r!=p) b[r] *= mul;
        if(b[r]>a[r+1]) res += refresh(r+1,b[r],n);
        return res;
    }
}

void preWork(int n,long long cnt[]){
    cnt[n] = 0; right[n] = n;
    for(int i = n-1; i >= 1; i--){
        if(a[i]<=a[i+1]){
            cnt[i] = cnt[i+1];
            right[i] = i;
        }
        else{
            ptr = -1;
            cnt[i] = cnt[i+1]+refresh(i+1,a[i],n);
            right[i] = ptr;
        }
        //printf("i = %d, right[i] = %d\n",i,right[i]);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){ 
        scanf("%lld",&a[i]);
        b[i] = a[i];
    }
    preWork(n,rt);
    for(int i = 1; i <= n; i++){
        b[i] = a[n-i+1];
    }
    for(int i = 1; i <= n; i++) a[i] = b[i];
    preWork(n,lt);
    /*for(int i = 1; i <= n; i++) printf("%lld ",rt[i]);
    printf("\n");
    for(int i = 1; i <= n; i++) printf("%lld ",lt[i]);
    printf("\n");*/
    long long ans = 1e18+7;
    for(int i = 0; i <= n; i++){
        long long cur = rt[i+1]*2+lt[n-i+1]*2+i;
        //printf("i = %d, cur = %lld\n",i,cur);
        if(cur<ans) ans = cur;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 8756
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;

typedef long long LL;
const int N = 2e5 + 50;
const LL mod = 1e9 + 7;

int n, tab[N];
pair <int, int> a[N], b[N];
LL mul[N << 2], sum[N << 2];

inline void Down(int x) {
  if (mul[x] > 1) {
    (mul[x << 1] *= mul[x]) %= mod;
    (sum[x << 1] *= mul[x]) %= mod;
    (mul[x << 1 | 1] *= mul[x]) %= mod;
    (sum[x << 1 | 1] *= mul[x]) %= mod;
    mul[x] = 1;
  }
}

#define mid ((L + R) >> 1)

inline void Add(int p, LL val, int x = 1, int L = 0, int R = n) {
  if (L == R) {
    sum[x] += val;
    if (sum[x] >= mod) sum[x] -= mod;
    return;
  }
  Down(x);
  if (p <= mid) Add(p, val, x << 1, L, mid);
  else Add(p, val, x << 1 | 1, mid + 1, R);
  sum[x] = sum[x << 1] + sum[x << 1 | 1];
  if (sum[x] >= mod) sum[x] -= mod;
}

inline LL Sum(int l, int r, int x = 1, int L = 0, int R = n) {
  if (l == L && R == r) return sum[x];
  Down(x);
  if (r <= mid) return Sum(l, r, x << 1, L, mid);
  else if (l > mid) return Sum(l, r, x << 1 | 1, mid + 1, R);
  else return ( Sum(l, mid, x << 1, L, mid) + Sum(mid + 1, r, x << 1 | 1, mid + 1, R) ) % mod;
}

inline void Double(int l, int r, int x = 1, int L = 0, int R = n) {
  if (l <= L && R <= r) {
    (sum[x] <<= 1) %= mod;
    (mul[x] <<= 1) %= mod;
    return;
  }
  Down(x);
  if (l <= mid) Double(l, r, x << 1, L, mid);
  if (r > mid) Double(l, r, x << 1 | 1, mid + 1, R);
  sum[x] = sum[x << 1] + sum[x << 1 | 1];
  if (sum[x] >= mod) sum[x] -= mod;
}

#undef mid

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    tab[i] = a[i].second;
  }
  for (int i = 1; i < (N << 2); i ++) mul[i] = 1;
  sort(a + 1, a + n + 1);
  sort(tab + 1, tab + n + 1);
  for (int i = 1; i <= n; i ++)
    b[i].second = max(b[i - 1].second, a[i].second);
  b[n + 1].first = 1e9;
  for (int i = n; i; i --)
    b[i].first = min(b[i + 1].first, a[i].second);
  sort(b + 1, b + n + 1);
  Add(0, 1);
  for (int i = 1, l, r; i <= n; i ++) {
    l = lower_bound(tab + 1, tab + n + 1, b[i].first) - tab;
    r = upper_bound(tab + 1, tab + n + 1, b[i].second) - tab - 1;
    LL val = Sum(l - 1, r - 1);
    Double(r, n);
    Add(r, val);
  }
  printf("%lld\n", Sum(n, n));
  return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);


    int N; cin >> N;
    int odd = (N+1) / 2;
    int even = N / 2;

    cout << odd / 1.0 / N << endl;

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
/****************************************************************************************************************************************************/

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define MOD 1000000007
/********************************************************************************************************************************************************/


const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
/*********************************************************************************************************************************************************/
const ll mx=1e5+3;
ll k,n,w[mx];
ll dp[mx];
ll ks(ll i)
{
    if(i>=n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll c=INT_MAX;
    for(int j=1; j<=k; j++)
    {
        if(i+j<=n)
            c=min(c,abs(w[i]-w[i+j])+ks(i+j));
    }
    return dp[i]=c;
}

int main()
{
    optimize();
    for(int i=0; i<mx; i++)
    {
        dp[i]=-1;
    }
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>w[i];
    cout<<ks(1)<<endl;

    return 0;
}






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

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int const INF = 1<<29;

int main() {
  
  int N;
  while(cin >> N && N) {
    int t[N][N];
    rep(i, N) rep(j, N)
      cin >> t[i][j];
    
    bool left[N][N]; memset(left, 0, sizeof left);
    bool right[N][N]; memset(right, 0, sizeof right);
    
    rep(i, N) {
      int mn = INF;
      rep(j, N) {
        mn = min(mn, t[i][j]);
      }
      rep(j, N) {
        if(mn == t[i][j]) { left[i][j] = 1; }
      }
    }
    
    rep(i, N) {
      int mx = 0;
      rep(j, N) {
        mx = max(mx, t[j][i]);
      }
      rep(j, N) {
        if(mx == t[j][i]) { right[j][i] = 1; }
      }
    }
    
    int ans = 0;
    rep(i, N) rep(j, N)
      if(left[i][j]&&right[i][j]) { ans = t[i][j]; }
    
    cout << ans << endl;
  }
  
  return 0;
}

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

int main() {

    int n, m;
    cin >> m >> n;
    int mn = INT_MAX, mx = INT_MIN;
    for (int i=0; i<n; i++) {
        int l, r;
        cin >> l >> r;
        mx = max(mx, l);
        mn = min(mn, r);
    }
    if (mn < mx) {
        cout << 0;
    }
    else {
        cout << mn - mx + 1;
    }

}

Measured memory_bytes: 256
H, W, K = map(int, input().split())

field = [input() for _ in range(H)]

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        tmp = 0
        for i2 in range(H):
            for j2 in range(W):
                if (i >> i2) & 1: continue
                if (j >> j2) & 1: continue
                if field[i2][j2] != '#': continue
                tmp += 1
        if tmp == K: ans += 1

print(ans)                 


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int x; cin >> x;
    cout << (!x) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vector<pair<ll, ll>> rl(n);
    rep(i, n){
        ll x, l; cin >> x >> l;
        ll leftArm = max((ll)0, x-l);
        ll rightArm = min((ll)10e9, x+l);
        rl[i] = make_pair(rightArm, leftArm);
    }
    sort(all(rl));
    vi ans;
    rep(i, n){
        if(!ans.size()) ans.push_back(rl[i].first);
        else if(*ans.rbegin() <= rl[i].second) ans.push_back(rl[i].first);
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 5724
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string a, b;
int cmp(char x, char y)
{
	return x > y;
}
int main()
{
	getline(cin, a);
	getline(cin, b);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end(), cmp);
	if (a < b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
M = N-K
p = 10**9+7

fact = [1]*(N+1)
for i in range(1,N+1):
    fact[i] = fact[i-1]*i

def comb(n, r):
    return fact[n]//fact[r]//fact[n-r]

for i in range(1,K+1):
    print((comb(M+1,i)*comb(K-1,i-1))%p)

Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<int,P> PP;

int dp[5][1<<8][301],dp2[6][301],d[5][301];
int main() {
  int n,m,l;
  cin >> n >> m >> l;
  vector<PP> a[5];
  for(int i=0,x,y,z,w; i<m; i++) {
    cin >> x >> y >> z >> w;
    a[x].push_back(PP(y-1,P(z,w)));
  }
  for(int s=0; s<5; s++) {
    for(int t=0; t<(1<<n); t++) {
      for(int k=0; k<a[s].size(); k++) {
        for(int i=0; i<a[s].size(); i++) {
          int c=0;
          for(int j=a[s][i].F; j<a[s][i].F+a[s][i].S.F; j++) c|=t&(1<<j);
          if(c) continue;
          int tt=t;
          for(int j=a[s][i].F; j<a[s][i].F+a[s][i].S.F; j++) tt|=1<<j;
          dp[s][tt][k+1]=max(dp[s][tt][k+1],dp[s][t][k]+a[s][i].S.S);
        }
      }
    }
  }
  for(int i=0; i<5; i++) {
    for(int t=0; t<(1<<n); t++) {
      for(int j=0; j<=a[i].size(); j++) d[i][j]=max(d[i][j],dp[i][t][j]);
    }
  }
  for(int i=0; i<5; i++) {
    for(int k=0; k<=m; k++) {
      for(int j=0; j<=a[i].size(); j++) {
        if(k+j<301) dp2[i+1][k+j]=max(dp2[i+1][k+j],dp2[i][k]+d[i][j]);
      }
    }
  }
  int ans=0;
  for(int i=0; i<=l; i++) ans=max(ans,dp2[5][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4592
#include <iostream>

int main(int argc, char *argv[]){
	int a, b, c, sum = 0;
	std::cin >> a >> b >> c;
	sum = a + b + c;
	if(sum > 21){
		std::cout << "bust" << std::endl;
		return 0;
	}
	std::cout << "win" << std::endl;
	return 0;
}

Measured memory_bytes: 256
/*

Author : AllKilled 
Date   : 201910277 

Contest: AtCoder Beginner Contest 144.    
Problem: Task A. 
Result : 
 
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;

const LL MAXN = 1e6+7;

///--------------------------------------------///



int main()
{
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10){
        cout << a * b << endl;
    }
    else cout << "-1" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, k; cin >> n >> k;
    vint a(n); vin(a);
    int ans = (n - 1) / (k - 1);
    if(n == k) ans = 1;
    else if((n - 1) % (k - 1)) ans++;
    print(ans);

    return 0;
}



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

const int N = 205;

int i, j, k, n, m, x, y, z, r;
vector<int> ord;
long long dist[N][N], rs = 1e18, ans;

int main() {
  ios_base::sync_with_stdio(0);

  cin >> n >> m >> r;
  for(i = 1; i <= r; ++i) cin >> x, ord.push_back(x);

  sort(ord.begin(), ord.end());

  for(i = 1; i <= n; ++i)
    for(j = 1; j <= n; ++j)
      dist[i][j] = 1e18;

  for(i = 1; i <= m; ++i) {
    cin >> x >> y >> z;
    dist[x][y] = z;
    dist[y][x] = z;
  }

  for(k = 1; k <= n; ++k)
    for(i = 1; i <= n; ++i)
      for(j = 1; j <= n; ++j)
        if(i != j) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  do {
    for(ans = 0, i = 1; i < ord.size(); ++i) ans += dist[ord[i - 1]][ord[i]];
    rs = min(rs, ans);
  } while(next_permutation(ord.begin(), ord.end()));

  cout << rs << '\n';

  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
using namespace std;
int main(){
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  
  int x, y;
  scanf("%d", &x);
  scanf("%d", &y);
  
  int cost;
  if(k > n)
    cost = n * x;
  else
    cost = k * x + (n - k) * y;
  
  printf("%d", cost);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int H, W;
int msearch(vector<vector<bool>> &s)
{
    queue<pair<int, int>> q;
    bool v[H][W] = {};
    int r[H][W] = {};
    q.push(make_pair(0, 0));
    v[0][0] = true;
    r[0][0] = 0;
    while (!q.empty())
    {
        int x = q.front().first, y = q.front().second;
        q.pop();
        if (x == W - 1 && y == H - 1)
            return r[H - 1][W - 1] + 1;
        if (x > 0 && s[y][x - 1] && !v[y][x - 1])
        {
            r[y][x - 1] = r[y][x] + 1;
            v[y][x - 1] = true;
            q.push(make_pair(x - 1, y));
        }
        if (x < W - 1 && s[y][x + 1] && !v[y][x + 1])
        {
            r[y][x + 1] = r[y][x] + 1;
            v[y][x + 1] = true;
            q.push(make_pair(x + 1, y));
        }
        if (y > 0 && s[y - 1][x] && !v[y - 1][x])
        {
            r[y - 1][x] = r[y][x] + 1;
            v[y - 1][x] = true;
            q.push(make_pair(x, y - 1));
        }
        if (y < H - 1 && s[y + 1][x] && !v[y + 1][x])
        {
            r[y + 1][x] = r[y][x] + 1;
            v[y + 1][x] = true;
            q.push(make_pair(x, y + 1));
        }
    }
    return -1;
}
void func()
{
    cin >> H >> W;
    vector<vector<bool>> s(H, vector<bool>(W));
    rep(i, 0, H)
    {
        string tmpstr;
        cin >> tmpstr;
        rep(j, 0, W)
        {
            s[i][j] = (tmpstr[j] == '.') ? true : false;
        }
    }
    int max = 0;
    rep(i, 0, H)
    {
        rep(j, 0, W)
        {
            if (s[i][j])
                ++max;
        }
    }
    int ans = msearch(s);
    // cout << ans << ' ' << max << endl;
    if (ans != -1)
        ans = max - ans;
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
		printf("res:%lld a:%lld\n", res,a);
	}
	return res;
}


lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}


int main()
{
    int N, M;
    int A[10000];
    int sum = 0;

    scanf("%d%d", &N, &M);

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

    if (N - sum >= 0)
        printf("%d\n", N - sum);
    else
        printf("-1\n");
}



Measured memory_bytes: 3764
#include <cstdio>
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n;
ll t[100010], a[100010];
ll hi_t[100010], lo_t[100010];
ll hi_a[100010], lo_a[100010];

int main() {
    scanf("%d", &n);
    memset(t, 0, sizeof(t));
    memset(a, 0, sizeof(a));
    memset(hi_t, 0, sizeof(hi_t));
    memset(lo_t, 0, sizeof(lo_t));
    memset(hi_a, 0, sizeof(hi_a));
    memset(lo_a, 0, sizeof(lo_a));
    for (int i = 1; i <= n; i++) {
        scanf("%lld", t + i);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%lld", a + i);
    }
    for (int i = 1; i <= n; i++) {
        if (t[i] > t[i - 1]) {
            hi_t[i] = lo_t[i] = t[i];
        } else if (t[i] == t[i - 1]) {
            hi_t[i] = t[i];
            lo_t[i] = 1;
        }
    }
    for (int i = n; i > 0; i--) {
        if (a[i] > a[i + 1]) {
            hi_a[i] = lo_a[i] = a[i];
        } else if (a[i] == a[i + 1]) {
            hi_a[i] = a[i];
            lo_a[i] = 1;
        }
    }
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ll h = min(hi_a[i], hi_t[i]);
        ll l = max(lo_a[i], lo_t[i]);
        if (l > h) {
            printf("0\n");
            return 0;
        }
        ans = (ans * (h - l + 1)) % MOD;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 4992
S = str(input())
T = str(input())


def Find(S, T):
    ans = ''
    for i in range(0, len(S)-len(T)+1):
        s = S[i:i+len(T)]
        boolen = 1
        for j in range(len(s)):
            if not(s[j] == '?' or T[j] == s[j]):
                boolen *= 0
        if boolen == 1:
            ans = S[:i] + T + S[i+len(T):]
    return ans


ans = Find(S, T)

if ans:
    ans = list(ans)
    for i, v in enumerate(ans):
        if v == '?':
            ans[i] = 'a'
    ans = ''.join(ans)
    print(ans)
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

H = int(read())

dicts = {}
cnt = 0
que = [H]
dicts[1] = 1

while len(que) != 0:
    acc = que.pop()
    if acc in dicts:
        cnt += dicts[acc]
    elif acc // 2 in dicts:
        dicts[acc] = dicts[acc // 2] * 2 + 1
        cnt += dicts[acc]
    else:
        que.append(acc // 2)
        que.append(acc // 2)
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
import sys

input = sys.stdin.readline

N = int(input())
*A, = map(int, input().split())

X = [0 for _ in range(N)]


for i in range(N):
    X[0] += (-1)**i * A[i]
for i in range(1, N):
    X[i] = -X[i-1] + 2*A[i-1]
 
 
print(*X)

Measured memory_bytes: 63460
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int a[5],ans;
int ab(int x){
	return max(x,0-x);
}
int main(){
	cin>>a[1]>>a[2]>>a[3];
	ans=1e9;
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			if(i==j) continue;
			for(int k=1;k<=3;k++){
				if(i==k || j==k) continue;
				ans=min(ans,ab(a[j]-a[i])+ab(a[k]-a[j]));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int MAX = 100;
main(){
  int N, k; 
  bool T[MAX][MAX], C[MAX];
  while(1){
    cin >> N;
    if ( N == 0 ) break;
    rep(i, N) rep(j, N) T[i][j] = C[i] = false;
    rep(i, N){
      cin >> k;
      rep(s, k) {
	int j; cin >> j; j--;
	T[i][j] = true;
      }
    }
    cin >> k;
    rep(i, k){
      int j; cin >> j; j--;
      C[j] = true;
    }
    vector<int> ans;
    rep(i, N){
      bool suc = true;
      rep(j, N){
	if ( C[j] && !T[i][j] ) suc = false;
      }
      if ( suc ) ans.push_back(i+1);
    }

    if ( ans.size() == 1 ) cout << ans[0] << endl;
    else cout << -1 << endl;
  }
}

Measured memory_bytes: 1228
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
class Solver{
public:
    void solve(){
        ios::sync_with_stdio(false);
        int K;
        cin>>K;
        queue<ll>q;
        for(ll u=1;u<10;u++)q.push(u);
        while(!q.empty()){
            ll t=q.front();
            q.pop();
            K--;
            if(!K){
                cout<<t;
                return;
            }
            if(t%10)q.push(t*10+t%10-1);
            q.push(t*10+t%10);
            if(t%10<9)q.push(t*10+t%10+1);
        }
    }
};
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    (new Solver())->solve();
}

Measured memory_bytes: 1792
use proconio::input;

fn main() {
    input! {
        n: usize,
        d: [usize; n]
    };
    let mut ans = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            ans += d[i] * d[j];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2080
x=int(input())
a=0
i=x
t=0
ans=0
while t==0:
	a=0 
	for k in range(2,round(i**0.5)+1):
		if i%k==0:
			a=a+1
	if a==0:
		t=i
	i=i+1
print(t)

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

int main()
{
    int x=1,y=2,z=3;
    int a,b,temp;
    cin>>a;
    cin>>b;

    temp=(x+y+z)-(a+b);


//    if(a==1)
//    {
//        if(b==3)
//        {
//            temp=2;
//        }
//        else if(b==2)
//        {
//            temp=3;
//        }
//    }
//
//    if(a==2)
//    {
//        if(b==3)
//        {
//            temp=1;
//        }
//        else if(b==1)
//        {
//            temp=3;
//        }
//    }
//
//    if(a==3)
//    {
//        if(b==2)
//        {
//            temp=1;
//        }
//        else if(b==1)
//        {
//            temp=2;
//        }
//    }

    cout<<temp;


}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;

int a, b;

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	cin >> a >> b;
}

void work ()
{
	// main work
	
	if ( !a || !b ){
		cout << ( qabs ( a ) + qabs ( b ) + ( ( a <= b ) ? 0 : 1 ) ) << endl;
		return;
	}
	
	int ans = qabs ( qabs ( a ) - qabs ( b ) ) + ( ( ( a > 0 ) == ( b > 0 ) ) ? 0 : 1 );
	if ( ( a > 0 ) == ( b > 0 ) && ( a > b ) ) ans += 2;
	
	cout << ans << endl;
}

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


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

    int k;  cin >> k;
    bool flag=true;

    // if(k%2==0 || k%5==0){
    //     flag = false;
    // }

    vector<int> x(k+1,0);
    double ans=1;
    int mod=7%k;
    while(mod!=0 && flag){
        int tmp=mod*10+7;
        mod=tmp%k;
        ans++;
        if(x[mod]==1){
            flag=false;
        }else{
            x[mod]=1;
        }
    }

    if(!flag){
        cout << "-1" << endl;
    }else{
        cout << ans << endl;
    }




    return 0;
}



Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;
const double PI=3.14159265358979323846;

int main(){
  int N; cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  ll ans = 1;
  vector<ll> B(N,0);
  for(int i=0;i<N;i++){
    if(A[i]>0){
      ans = ( ans * (B[A[i]-1] -B[A[i]]) ) % Q;
    }
    B[A[i]] ++;
    if(ans==0||B[A[i]]>3){
      cout << 0 << endl;
      return 0;
    }
  }
  ll maxy=0;
  for(int i=0;i<N;i++){
    maxy = max(maxy,B[i]);
  }
  if(maxy==1){
    ans = (ans * 3) % Q;
  }else{
    ans = (ans * 6) % Q;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        k: i32,
        x: [i32;n]
    }
    let mut s = 0;
    for i in 0..n as usize {
        s += std::cmp::min(x[i], (k - x[i])) * 2
    }
    println!("{}", s);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n;
    while (cin >> n, n) {
        string i; int p;
        map<string, int> price;
        for (int j=0; j<n; ++j) {
            cin >> i >> p;
            price[i] = p;
        }
        int m;
        cin >> m;
        vector<vector<string>> recipe(m);
        string o, q; int k;
        for (int j=0; j<m; ++j) {
            cin >> o;
            recipe[j].push_back(o);
            cin >> k;
            for (int l=0; l<k; ++l) {
                cin >> q;
                recipe[j].push_back(q);
            }
        }
        for (int j=0; j<m; ++j) {
            for (int l=0; l<m; ++l) {
                int new_price = 0;
                for (int kk=1; kk<(int)recipe[l].size(); ++kk) {
                    new_price += price[recipe[l][kk]];
                }
                price[recipe[l][0]] = min(price[recipe[l][0]], new_price);
            }
        }
        string name;
        cin >> name;
        cout << price[name] << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#define ll long long
#define ln printf("\n")
#define out(a) printf("%d",a)
const int N=1e5+50;
using namespace std;
int a,b;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
ll readl()
{
	ll s=0,t=1; char c;
	while (c<'0'||c>'9'){if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9'){s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	a=read(),b=read();
	a*=b;
	if (a&1) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){

    long long N;
    long long ans=1;
    long long ex=1,ex1=1;
    int mod=1000000007;
    cin>>N;

    if(N==1){
        cout<<0<<endl;
        return 0;
    }

    for(int i=0;i<N;i++){
        ans=(ans*10)%mod;
        ex=(ex*8)%mod;
        ex1=(ex1*9)%mod;
    }

    ans=(ans-2*ex1+ex)%mod;

    ans=(ans+mod)%mod;

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

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
n = int(input())
s = ["".join(sorted(input().split()[0])) for _ in range(n)]
cnt = {}
result = 0
for si in s:
    if si in cnt:
        result += cnt[si]
        cnt[si] += 1
    else:
        cnt[si] = 1
print(result)

Measured memory_bytes: 62556
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll dp[100010][20];

int main(void){
  string S;
  cin >> S;
  dp[0][0] = 1;

  for(int i = 1; i <= S.size(); i++){
    for(int j = 0; j < 13; j++){
      if(S[i-1] == '?'){
        for(int x = 0; x <= 9; x++){
          dp[i][(j * 10 + x) % 13] += dp[i-1][j];
          dp[i][(j * 10 + x) % 13] %= MOD;
        }
      }else{
        ll x = S[i-1] - '0';
        dp[i][(j * 10 + x) % 13] += dp[i-1][j];
        dp[i][(j * 10 + x) % 13] %= MOD;
      }
    }
  }
  cout << dp[S.size()][5] << endl;



}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);

	

	int a, b;
	cin >> a >> b;
	cout << (a / b) + (a % b != 0);
	
 
return 0;
}



Measured memory_bytes: 256