akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, n1, n2;

	string s;

	cin>>s;

	n=stoi(s);

	n1=n/100; n2=n%100;

	if(n1>=1&&n1<=12&&n2>=1&&n2<=12){
		cout<<"AMBIGUOUS"<<endl;
	} else if(n1>=1&&n1<=12){
		cout<<"MMYY"<<endl;
	} else if(n2>=1&&n2<=12){
		cout<<"YYMM"<<endl;
	} else{
		cout<<"NA"<<endl;
	}
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(int x){return x*(x+1)/2;}

int main(){
  int n,k; cin >> n >> k;
  vector<double> v(n);
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    v[i] = 1.*Sum(x) / x;
  }
  double x = 0, y = 0;
  for(int i = 0; i < n; ++i){
    x += v[i];
    if(i >= k) x -= v[i-k];
    ChangeMax(y, x);
  }
  cout << setprecision(10) << y << endl;
  return 0;
}


Measured memory_bytes: 4772
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, M, K;
    cin >> N >> M >> K;

    ll A[N + 1];
    A[0] = 0;
    FOR(i, 1, N)
    {
        cin >> A[i];
    }

    ll B[M + 1], bsum = 0;
    B[0] = 0;
    FOR(j, 1, M)
    {
        cin >> B[j];
        bsum += B[j];
    }

    ll ans = 0, asum = 0, bmindex = M;

    // 机Aの本をAiまで読んだ場合に、机Bの本をどこまで読めるか？
    FOR(i, 0, N)
    {
        //机Aの本を一冊追加
        asum += A[i];

        // 机Aの本を追加で一冊読もうとして時間をオーバーしているのであれば、これ以上探索する必要はない
        if (asum > K)
            break;

        FORD(j, bmindex, 0)
        {
            //机A上の本をAiまで読んでかつ時間を超えない限りで机Bの本を最大まで読み進めた場合のj
            if (asum + bsum <= K)
            {
                bmindex = j;
                break;
            }
            //時間をオーバーする場合、机B上の本のうち読む本を一つ減らす
            bsum -= B[j];

            if (j == 0)
                bmindex = 0;
        }

        //読めた本の最大数を更新
        if (i + bmindex > ans)
            ans = i + bmindex;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6724
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
list = [a,b,c,d,e]
for i in range(4):
    for j in range(4-i):
        if list[j+1]-list[i] <k+1:
            continue
        else:
            print(":(")
            exit()
print("Yay!")

Measured memory_bytes: 3064
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, k, x):
        k += 1
        while k <= self.n:
            self.bit[k] += x
            k += k & -k

    def sum(self, k):
        s = 0
        while k > 0:
            s += self.bit[k]
            k -= k & -k
        return s


from collections import defaultdict
N, K = map(int, input().split())
A = []
for i in range(N):
    A.append(int(input()))


B = [0]
s = 0
for i in range(N):
    B.append(s + A[i] - (i + 1) * K)
    s += A[i]

D = [0] * (N + 1)
d = defaultdict(list)
for i in range(len(B)):
    d[B[i]].append(i)

B = sorted(B)
k = 0
i = 0
while i < N + 1:
    m = len(d[B[i]])
    for l in d[B[i]]:
        D[l] = k
    k += 1
    i += m

bt = BIT(N + 1)
num = 0
for i in range(N + 1):
    num += bt.sum(D[i] + 1)
    bt.add(D[i], 1)
print(num)


Measured memory_bytes: 105556
#include <bits/stdc++.h>
#define int long long

using namespace std;

int N;
map<string, int> cnt;

signed main()
{
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        ostringstream oss;
        oss << i;
        string num = oss.str();
        string key = num.substr(0, 1) + num.substr(num.length() - 1, 1);
        cnt[key]++;
    }

    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        ostringstream oss;
        oss << i;
        string num = oss.str();
        string key = num.substr(num.length() - 1, 1) + num.substr(0, 1);
        ans += cnt[key];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}	
	int add = 0;
	for (int i = n - 1; i >= 0; i--) {
		a[i] += add;
		add += (b[i] - a[i] % b[i]) % b[i];
	}
	cout << add << '\n';
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n,m,x;
    cin>>n>>m>>x;

    int to0 = 0,ton=0;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        if(a>=0&&a<=x)to0++;
        if(a<=n&&a>=x)ton++;
    }

    cout<<min(to0,ton)<<endl;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int N; std::cin >> N;
	std::vector<int> D(N);
	for (auto& r : D) std::cin >> r;
	std::sort(D.begin(), D.end());
	std::cout << D[N / 2] - D[N / 2 - 1] << std::endl;

	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
 
#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
  ll n;
  ll count0 = 0;
  ll ans = 0;
  vector<ll> num;

void sumeven(ll border);
void allpos(){
    REP(i,n){
        if(num[i] < 0) num[i] *= -1;
        ans += num[i];
      }
      sort(num.begin(), num.end());
      //REP(i,n) cout << num[i] << " ";
      cout << endl;
  }

void sum(ll border){
        if(border % 2 == 0 ) sumeven(border);
        else if(count0 >= 1) sumeven(border + 1);
        else{
            if(abs(num[border-1]) < abs(num[border])){
              REP(i,n){
                  if(i < (border - 1)) num[i] *= -1;
                  ans += num[i];
                } 
            }else{
              REP(i, n){
                if(i < (border + 1)) num[i] *= -1;
                ans += num[i];
                }
              }
          }
}

void sumeven(ll border){
          REP(i,n){
            if(i < border) num[i] *= -1;
            ans += num[i];
          }
}
int main(){


  cin >> n;
  REP(i,n){
      ll t;
      cin >> t;
      num.pb(t);
    }

    sort(num.begin(),num.end());
    ll border = 0,now = num[0];;

    while(now < 0){
        now = num[++border];
      }
      for(ll i = border; num[i] != 0;i++){
        if(num[i] == 0) count0 ++;
      }
        allpos();
        if(border % 2 != 0 && num[0] != 0) ans -= (num[0] * 2);
         // cout << num[border] << endl;
          cout << ans << endl;
          return 0;
}


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int A,B,C;
    cin>>A>>B>>C;

    return A*B/2;
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 256
import math


def combinations_count(n, r):
    try:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    except ValueError:
        return 0
    

li = list(map(int, input().split()))
n = li[0]
m = li[1]

print(combinations_count(m, 2)+combinations_count(n, 2))


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

int main () {
  ios_base::sync_with_stdio(0);
  int n;
  string s;

  cin >> n;
  cin >> s;

  vector < string > strings;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        string tmp(1, (char)(i+'0'));
        tmp = tmp + (char)(j+'0');
        tmp = tmp + (char)(k+'0');
        strings.push_back(tmp);
      }
    }
  }

  int ans = 0;
  for (string x: strings) {
    int i = 0;
    for (int j = 0; j < n; j++) {
      if (x[i] == s[j]) {
        i++;
        if (i == 3) {
          ans++;
          break;
        }
      }
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  ll n,ans=0,a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> n;



  pri(a[n-1]);

}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Palindromic Number
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  if (s[0] == s[2]) puts("Yes");
  else puts("No");
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    swap(a, b);
    
    const int N = 100;
    int g[N][N];
    fill(&g[0][0], &g[N - 1][N - 1] + 1, '.');

    vector<pair<int, int>> v;
    vector<pair<int, int>> u;

    set<pair<int, int>> taboo;
    taboo.insert(make_pair(0, 0));
    taboo.insert(make_pair(N-1, N-1));
    taboo.insert(make_pair(0, N-1));
    taboo.insert(make_pair(N-1, 0));
    
    int di[] = {0, +1, 0, -1};
    int dj[] = {+1, 0, -1, 0};
    {
      int dir = 0;
      int len = N;
      int i = 0;
      int j = -1;
      while (len) {
        for (int k = 0; k < len; ++k) {
          i += di[dir];
          j += dj[dir];
          v.push_back(make_pair(i, j));
        }
        dir = (dir + 1) % 4;
        --len;
      }
    }

    {
      int dir = 3;
      int len = N - 1;
      int i = N;
      int j = 0;
      while (len) {
        for (int k = 0; k < len; ++k) {
          i += di[dir];
          j += dj[dir];
          u.push_back(make_pair(i, j));
        }
        dir = (dir + 1) % 4;
        --len;
      }
    }

    each (i, v) {
      g[i.first][i.second] = '#';
    }
    each (i, u) {
      g[i.first][i.second] = '.';
    }
    reverse(u.begin(), u.end());

    for (int i = 0, j = 0; j < a - 1; ++i) {
      int k = 2 * i + 1;
      unless (taboo.count(v[k])) {
        g[v[k].first][v[k].second] = '.';
        ++j;
      }
    }
    for (int i = 0, j = 0; j < b - 1; ++i) {
      int k = 2 * i + 1;
      unless (taboo.count(v[k])) {
        g[u[k].first][u[k].second] = '#';
        ++j;
      }
    }

    cout << N << ' ' << N << endl;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        cout << (char)g[i][j];
      }
      cout << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	const double time[7][2]={
		{35.5,1*60+11},
		{37.5,1*60+17},
		{40,1*60+23},
		{43,1*60+29},
		{50,1*60+45},
		{55,1*60+56},
		{1*60+10,2*60+28}
	};
	const char* name[8]={
		"AAA",
		"AA",
		"A",
		"B",
		"C",
		"D",
		"E",
		"NA"
	};
	double a,b;
	int i;
	while(~scanf("%lf %lf",&a,&b)) {
		for(i=0;i<7;i++) {
			if(a<time[i][0] && b<time[i][1])break;
		}
		puts(name[i]);
	}
	return 0;
}

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string root;
	rep (ty-sy) root += "U";
	rep (tx-sx) root += "R";
	rep (ty-sy) root += "D";
	rep (tx-sx) root += "L";
	root += "L";
	rep (ty-sy+1) root += "U";
	rep (tx-sx+1) root += "R";
	root += "D";
	root += "R";
	rep (ty-sy+1) root += "D";
	rep (tx-sx+1) root += "L";
	root += "U";
	cout << root << endl;
}


Measured memory_bytes: 256
/* sortあります */
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N, K; cin >> N >> K;
  int ans = 0;
  int curr;
  for (int i = 0; i < N; i++) {
    cin >> curr;
    if(curr >= K){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())

m = map(int, read().split())
A, B = zip(*zip(m, m))
A = np.array(A[::-1])
B = np.array(B[::-1])

cnt = 0
for i in range(N):
    acc = B[i] - A[i] % B[i] if A[i] % B[i] != 0 else 0
    A[i:] += acc
    cnt += acc

print(cnt)


Measured memory_bytes: 51680
#include<bits/stdc++.h>
int main(){
    std::vector<int>a(9);
    for(int i=0;i<9;i++)std::cin>>a.at(i);
    std::vector<int>ckd(9);
    int n;std::cin>>n;
    for(int i=0;i<n;i++){
        int x;std::cin>>x;
        for(int j=0;j<9;j++){
            ckd.at(j)|=x==a.at(j);
        }
    }
    bool ok=false;
    for(int i=0;i<3;i++){
        ok|=ckd.at(i)&&ckd.at(i+3)&&ckd.at(i+6);
        ok|=ckd.at(3*i)&&ckd.at(3*i+1)&&ckd.at(3*i+2);
    }
    ok|=ckd.at(0)&&ckd.at(4)&&ckd.at(8);
    ok|=ckd.at(2)&&ckd.at(4)&&ckd.at(6);
    std::cout<<(ok?"Yes":"No")<<std::endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1000000000;

string S;

int f(char c) {
  int cnt = 0, res = -INF;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == c) {
      if (res == -INF) {
        res = max(res, cnt);
        cnt = 0;
      }
      else {
        res = max(res, cnt - 1);
        cnt = 0;
      }
    }
    else if (i == S.size() - 1) {
      res = max(res, cnt);
    }
    cnt++;
  }
  return res;
}

void agc016a() {
  int res = INF;
  for (char c = 'a'; c <= 'z'; c++) {
    res = min(res, f(c));
  }
  cout << res << "\n";
  return;
}

int main() {
  cin >> S;
  agc016a();
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

struct UnionFind{
        Vec par;
        Vec sz;
        Vec rank;
        UnionFind(ll n):par(n),sz(n),rank(n){
            rep(i,n){
                par[i]=i;
                sz[i]=1;
                rank[i]=0;
            }
        }
        ll root(ll x){
            if(par[x]==x){
                return x;
            }else{
                return root(par[x]);
            }
        }

        void unite(ll x, ll y){
            x = root(x);
            y = root(y);
            if(rank[x]<rank[y]){
                par[x]=y;
                sz[y]+=sz[x];
            }else{
                par[y]=x;
                sz[x]+=sz[y];
                if(rank[x]==rank[y]){
                    rank[x]++;
                }
            }
        }

        bool same(ll x, ll y){
            return root(x)==root(y);
        }

        ll size(ll x){
            return sz[root(x)];
        }
    };

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll LIM = 1e5+5;
    //ll LIM = 12;
    UnionFind uf(LIM*2+1);

    rep(i,n){
        int a,b;
        cin>>a>>b;
        uf.unite(a,b+LIM);
    }

    Vec rx(2*LIM+3,0);
    Vec ry(2*LIM+3,0);


    rep(i,LIM){
        int r = uf.root(i);
        rx[r]++;
    }
    REP(i,LIM,LIM*2){
        int r = uf.root(i);
        ry[r]++;
    }
    ll ans = 0;
    rep(i,LIM*2){
        if(rx[i]&&ry[i]){
            ans += (rx[i])*(ry[i]);
        }
    }
    if(ans > 0){
        ans -= n;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 8192
n,a=map(int,raw_input().split())
ans=10**12+5
for eat_num in xrange(45):
    if 2**(eat_num-1)>n:break
    time=eat_num*a
    bake=eat_num+1
    l=0;r=n
    while r-l>1:
        m=(r+l)/2
        if m**bake>=n:r=m
        else:l=m
    for surplus in xrange(1,bake+1):
        if r**(bake-surplus) * (r-1)**surplus < n:break
    surplus-=1
    time+=r*(bake-surplus)+(r-1)*surplus
    ans=min(ans,time)
print ans

Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
const int N=3e5+5, INF=1e9;
using namespace std;
int n, a, b;
vector<int> v, rem;
signed main()
{
    cin >> n >> a >> b;
    if(a + b - 1 > n)
    {
        cout << -1;
        return 0;
    }
    if(a*b<n)
    {
        cout << -1;
        return 0;
    }

    for(int i = b; i >= 1; i--) //LDS
    {
        v.pb(i);
    }
    int curr = b;
    for(int i = 1; i < a; i++)
    {
        int currsz = (n - curr) / (a-i) + ((n - curr) % (a-i) != 0);
        for(int j = curr + currsz; j > curr; j--)
        {
            v.pb(j);
        }
        curr = curr+currsz;
    }
    for(auto it: v)
    {
        cout << it << " ";
    }
}   

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

/*================================================
	GCD function
================================================*/
ll gcd(ll a, ll b) {
	if (a < b) return gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

/*================================================
	LCM function
================================================*/
ll lcm(ll a, ll b) {
	return (a / (gcd(a, b))) * b;
}

int main()
{
	ll N, M, GCD, LCM, ans = -1;
	string S, T;
	bool ok = true;

	cin >> N >> M >> S >> T;
	GCD = gcd(N, M);
	LCM = lcm(N, M);

	for (ll i = 0; i < GCD; i++) {
		if (S[i * (N / GCD)] != T[i * (M / GCD)]) ok = false;
	}

	if (ok) ans = LCM;
	else ans = -1;

	cout << ans << endl;

	return 0;
}


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

class Solution
{
    static Dictionary<decimal, decimal> fact = new Dictionary<decimal, decimal>();

    public static decimal Factorial(decimal n)
    {
        if (n == 0)
        {
            return 1;
        }
        if(fact.ContainsKey(n))
        {
            return fact[n];
        }
        var ret = n * Factorial(n - 1);
        fact[n] = ret;
        return ret;
    }

    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int n = vals[0];
        int p = vals[1];

        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int oddCount = a.Count(x => x % 2 == 1);
        int evenCount = a.Length - oddCount;

        decimal oddPattern = (decimal)Math.Pow(2, oddCount);
        decimal evenPattern = (decimal)Math.Pow(2, evenCount);
        if (p == 0)
        {
            // oddから奇数個選んだものを取り除く
            for (int i = 1; i <= oddCount; i += 2)
            {
                //oddCount C i
                oddPattern -= Factorial(oddCount) / (Factorial(i) * Factorial(oddCount - i));

            }
        }
        else
        {
            // oddから偶数個選んだものを取り除く
            for (int i = 0; i <= oddCount; i += 2)
            {
                //oddCount C i
                oddPattern -= Factorial(oddCount) / (Factorial(i) * Factorial(oddCount - i));
            }
        }

        Console.WriteLine(oddPattern * evenPattern);
    }
}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c || a == c && a != b || b == c && a != b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vel vector<long long>
#define vech vector<char>
#define veb vector<bool>
#define vvel vector<vel>
#define vvech vector<vech>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define maxel(vec, j) *max_element(vec.begin(), vec.begin()+j)

using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
int vsum(vel v){ return accumulate(v.begin(), v.end(), 0); }
int msum(vvel v){
    int ans = 0;
    rep(i, v.size()){
        ans += vsum(v[i]);
    }
    return ans;
}
signed main() {
    int pr = 1000;
    pr *= pr * pr; pr += 7;
    int N, K;
    cin >> N;
    cin >> K;
    cout << N - K + 1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define INF 1000000000
#define p make_pair

void bfs(vector<pair<int,int>> start,Graph graph,Graph &ans)
{
    int n=graph.size(),m=graph[0].size();
    Graph visit(n,vector<int> (m,0));
    Graph dis (n,vector<int> (m,INF));
    queue<pair<int,int>> que;
    int s,t;
    for (int i=0;i<start.size();i++)
    {
        s=start[i].first;t=start[i].second;
        visit[s][t]=1;
        dis[s][t]=0;
        que.push(p(s,t));
    }
    int x,y,a,b;vector<pair<int,int>> next(4);
    while (!que.empty())
    {
        x=que.front().first;y=que.front().second;
        que.pop();
        next={p(x-1,y),p(x+1,y),p(x,y-1),p(x,y+1)};
        for (int i=0;i<4;i++)
        {
            a=next[i].first;b=next[i].second;
            if (0<=a && a<n && 0<=b && b<m)
            {
                if (graph[a][b]==1 && visit[a][b]==0)
                {
                    dis[a][b]=dis[x][y]+1;
                    if (ans[a][b]>dis[a][b]) ans[a][b]=dis[a][b];
                    visit[a][b]=1;
                    que.push(p(a,b));
                }
            }
        }
    }
    return;
}

int main()
{
    int H,W,cnt=0,root;cin>> H >>W;
    Graph graph(H,vector<int> (W,0));
    Graph ans(H,vector<int> (W,INF));
    vector<pair<int,int>> start;
    string input;
    int x,y;
    for (int i=0;i<H;i++)
    {  
        cin >> input;
        for (int j=0;j<W;j++)
        {
            if (input[j]=='.')
            {
                graph[i][j]=1;
            }
            else
            {
                ans[i][j]=0;
                start.push_back(p(i,j));
            }
        }
    }
    bfs(start,graph,ans);
    int answer=0;
    for (int i=0;i<H;i++)
    {
        for (int j=0;j<W;j++)
        {
            answer=max(answer,ans[i][j]);
        }
    }
    cout << answer << endl;
return 0;
}

Measured memory_bytes: 43752
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
using namespace std;
typedef long long int ll;
int main()
{
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    string sk=s;
    reverse(s.begin(),s.end());
    int i=0;
    while (i<n) {
        if(s[i]=='W')i++;
        else{
                break;
        }
    }
  //  cout<<i<<endl;
    int r=0,w=0;
    for(int k=i;k<n;k++)
    {
       // cout<<i<<" "<<s[i]<<endl;
        if(s[k]=='R')r++;
        //else w++;
    }
    
    for(int i=0;i<r;i++)
        if(sk[i]=='R')w++;
    //cout<<w<<endl;
    cout<<(r-w);
    return 0;
}


Measured memory_bytes: 3920
n, m = map(int, input().split())
y_inputs = []
dct = dict()
for _ in range(m):
  p, y = map(int, input().split())
  y_inputs.append(y)
  if dct.get(p) == None:
    dct[p] = [y]
  else:
    dct[p].append(y)

citycodes = dict()
for pref in sorted(dct.items()):
  pid = int(pref[0])
  years = sorted(pref[1])
  for i, y in enumerate(years):
    code = format(pid, '06') + format(i+1, '06')
    citycodes[y] = code

for y in y_inputs:
  print(citycodes[y])

Measured memory_bytes: 50692
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B,C;
    R(A,B,C);
    W(max(C-(A-B),0));
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N%2!=0:
    n=(N+1)//2
    ans=B[n-1]-A[n-1]+1
else:
    n=N//2
    ans1=(A[n-1]+A[n])/2
    ans2=(B[n-1]+B[n])/2
    ans=(ans2-ans1)*2+1
print(int(ans))

Measured memory_bytes: 25560
from heapq import heapify,heappush,heappop

n,m,s,t = map(int,input().split())#順に都市の数、電車の数、スタート、ゴール
adj_list = [[]for i in range(0,(n+1),1,)]#隣接リスト(都市1~nをそのまま使いたいのでn+1の大きさで宣言して0は使わない)
for i in range(0,m,1):
    u,v,a,b = map(int,input().split())
    adj_list[u].append([v,a,b])#[0]行先[1]円[2]スヌーク
    adj_list[v].append([u,a,b])

D_INF = 10**15
d = [D_INF]*(n+1)#最速到達距離。でかい数で初期化
d[s] = 0#スタート
que = []
heapify(que)
heappush(que,(d[s],s))

while(len(que)):
    time,place = heappop(que)
    if time > d[place]:
        continue
    for i in range(0,len(adj_list[place]),1):
        if d[adj_list[place][i][0]] > time + adj_list[place][i][1]:#とりあえず円で
            d[adj_list[place][i][0]] = time + adj_list[place][i][1]
            heappush(que,(d[adj_list[place][i][0]],adj_list[place][i][0]))


d_sn = [D_INF]*(n+1)#最速到達距離。でかい数で初期化
d_sn[t] = 0#スタート
heappush(que,(d_sn[t],t))

while(len(que)):
    time,place = heappop(que)
    if time > d_sn[place]:
        continue
    for i in range(0,len(adj_list[place]),1):
        if d_sn[adj_list[place][i][0]] > time + adj_list[place][i][2]:
             d_sn[adj_list[place][i][0]] = time + adj_list[place][i][2]
             heappush(que,(d_sn[adj_list[place][i][0]],adj_list[place][i][0]))

for i in range(1,n+1,1):
    d[i]=d[i]+d_sn[i]
    heappush(que,(d[i],i))
minimum,minimum_place = heappop(que)

for i in range(0,n,1):
    if minimum_place <= i:
        while(len(que)):
            minimum,minimum_place = heappop(que)
            if minimum_place > i:
                break
    print(10**15-minimum)


Measured memory_bytes: 67956
#include<stdio.h>

int map[102][102];

void paint(int x,int y,int type){
    if(map[x][y]==type){
        map[x][y]=0;
        paint(x-1,y,type);
        paint(x+1,y,type);
        paint(x,y-1,type);
        paint(x,y+1,type);
    }
}

int main(void){
    int h,w,i,j,ans;
    char str[110];
    scanf("%d%d",&h,&w);

    while(h!=0 || w!=0){
        ans=0;
        for(i=0; i<=h+1; i++){
            for(j=0; j<=w+1; j++){
                map[i][j]=0;
            }
        }
        for(i=1; i<=h; i++){
            scanf("%s",str);
            for(j=0; j<w; j++){
                if(str[j]=='@'){
                    map[i][j+1]=1;
                }else if(str[j]=='#'){
                    map[i][j+1]=2;
                }else if(str[j]=='*'){
                    map[i][j+1]=3;
                }
            }
        }
        for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
                if(map[i][j]!=0){
                    paint(i,j,map[i][j]);
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
        scanf("%d%d",&h,&w);
    }
    return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int n; cin>>n;
    vector<pair<int, P>> info(n);
    rep(i,n) cin>>info.at(i).S.F>>info.at(i).S.S>>info.at(i).F;
    sort(all(info));
    rep(i,101){
        rep(j,101){
            int H=info.back().F+abs(i-info.back().S.F)+abs(j-info.back().S.S);
            bool B=true;
            rep(k,n-1){
                if(max<int>(H-abs(i-info.at(k).S.F)-abs(j-info.at(k).S.S),0)!=info.at(k).F){
                    B=false;
                    break;
                }
            }
            if(B){
                cout<<i<<' '<<j<<' '<<H<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    
    let n = read_t_in_line::<i32>()[0];
    let mut a = read_t_in_line::<i32>();
    let mut cnt = 0;
    for i in 1..n {
        if a[(i - 1) as usize] == i {
            a.swap((i - 1) as usize, i as usize);
            cnt += 1;
        }
    }
    if a[(n - 1) as usize] == n {
        cnt += 1;
    }
    println!("{}", cnt);


}


Measured memory_bytes: 10104
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  sort(all(a));
  auto lb = lower_bound(all(a), k);
  if (lb == a.begin()) {
    printf("0\n");
    return 0;
  }

  a.resize(lb - a.begin());
  int m = (int)a.size();
  int sum_under_k = 0;
  rep (i, m) {
    sum_under_k += a[i];
  }
  if (sum_under_k < k) {
    printf("%d\n", m);
    return 0;
  }

  reverse(all(a));
  int ans_lowest = k;
  deque<bool> dp(k, false);
  dp[0] = true;
  int possible_max = 0;
  rep (i, m) {
    if (k - a[i] <= possible_max) {
      ans_lowest = a[i];
    }

    for (int j = k - a[i] - 1; j >= 0; --j) {
      if (dp[j]) {
        dp[j + a[i]] = true;
        possible_max = max(possible_max, j + a[i]);
      }
    }
  }

  reverse(all(a));
  printf("%d\n", (int)(lower_bound(all(a), ans_lowest) - a.begin()));

  return 0;
}


Measured memory_bytes: 384
/*                        
                            In the name of Almighty ALLAH

   code from :::::::::::::::::::::
   ******************************* R E S H A D ********************************
   
   
   
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE 
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
                 FREE PALESTINE           FREE PALESTINE            FREE PALESTINE
                 
    FREE PALESTINE           FREE PALESTINE            FREE PALESTINE           FREE PALESTINE
   
 
*/     

#include <bits/stdc++.h>

#define ll               long long
#define db               double
#define Pi               2*acos(0.0)
#define pb(a)            push_back(a)
#define VI               vector <int>
#define FASTIO           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ull              unsigned long long
#define all(a)           a.begin(),a.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
// 90 degree = acos(x)*180/acos(0.0)

using namespace std;

int main() {
    
    FASTIO;
    
    char a[3];
    for(int i=0; i<3; i++) cin >> a[i];
    
    if(a[0]=='R' && a[1]=='R' && a[2]=='R') cout << 3 << endl;
    else if(a[0]=='R' && a[1]=='R' && a[2]=='S') cout << 2 << endl;
    else if(a[0]=='S' && a[1]=='R' && a[2]=='R') cout << 2 << endl;
    else if(a[0]=='R' && a[1]=='S' && a[2]=='R') cout << 1 << endl;
    else if(a[0]=='R' && a[1]=='S' && a[2]=='S') cout << 1 << endl;
    else if(a[0]=='S' && a[1]=='S' && a[2]=='R') cout << 1 << endl;
    else if(a[0]=='S' && a[1]=='R' && a[2]=='S') cout << 1 << endl;
    else if(a[0]=='S' && a[1]=='S' && a[2]=='S') cout << 0 << endl;
    
    
    
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int conv16(string i){
  int result = 0;
  if(i == "A"){
    return 1;
  }else if(i == "B"){
    return 2;
  }else if(i == "C"){
    return 3;
  }else if(i == "D"){
    return 4;
  }else if(i == "E"){
    return 5;
  }else if(i == "F"){
    return 6;
  }
  return result;
}

int main(){
  string X, Y;
  int x,y;

  cin >> X >> Y;
  x = conv16(X);
  y = conv16(Y);
  
  if(X < Y){
    cout << '<' << endl;
  }else if(X > Y){
    cout << '>' << endl;    
  }else if(X == Y){
    cout << '=' << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int a,b,c;
 
  scanf("%d %d %d", &a, &b, &c );
  
  if (a < b && b < c){
  	printf("Yes\n");
  } 
  else{
  	printf("No\n");
  }
  
  return 0;

}

Measured memory_bytes: 580
ary = $stdin.readlines

nmxy=ary[0].split.map!(&:to_i)
n=nmxy[0]
m=nmxy[1]
xx=nmxy[2]
yy=nmxy[3]

xn=ary[1].split.map!(&:to_i)
yn=ary[2].split.map!(&:to_i)
xn.push(xx)
yn.push(yy)
x_max=xn.max
y_min=yn.min


if x_max >= y_min
  puts'War'
end

if x_max < y_min
  puts'No War'
end

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

int main() {
  int N, M; cin >> N >> M;
  int l=1, r=N;
  int L, R;
  for(int i=0; i<M; i++) {
    cin >> L >> R;
    if (L > l) l = L;
    if (R < r) r = R;
  }
  if (r-l+1 > 0) cout << r-l+1 << endl;
  else cout << 0 << endl;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> prime(1000000 + 1, 0), A(n);
    for(auto &x : A) {
        cin >> x;
    }
    ll ret = 0;
    sort(A.begin(), A.end());
    for(i = 0; i < n; i++) {
        if(prime[A[i]] == 0) {
            for(j = A[i]; j < 1000000 + 1; j += A[i]) {
                prime[j] = 1;
            }
            if((i + 1 < n && A[i] == A[i + 1]) || (i - 1 >= 0 && A[i] == A[i - 1])) {
            }else{
                ret++;
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 12764
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int r,d,x;
    cin >> r >> d >> x;
    for(int i=0; i<10; i++){
        x=r*x-d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
while line=$stdin.gets do
    a,b=line.split(" ").collect{|x| x.to_i}

    c=a

    d=b

    if c<d

        c,d=d,c

    end

    while d!=0

        c,d=d,c%d

    end

    $stdout.print c," ",(a*b)/c,"\n"
end

Measured memory_bytes: 6088
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;

	LL N_ = N, digit = 0, maxN = 1;
	while (N > 0)
	{
		N /= 10;
		++digit;
		maxN *= 4;
	}
	N = N_;

	LL ans = 0;
	std::vector<std::string>temp;
	for (LL i = 0; i < maxN; ++i)
	{
		LL num = i;
		std::string res;
		while (num > 0)
		{
			res += std::to_string(num % 4);
			num /= 4;
		}
		std::map<char, bool>flag;
		bool ok = true;
		for (auto& c : res)
		{
			if (c == '1') c = '7';
			else if (c == '2') c = '5';
			else if (c == '3') c = '3';
			else
			{
				ok = false;
				break;
			}
			flag[c] = true;
		}
		if (!ok) continue;
		std::reverse(res.begin(), res.end());
		if (flag['7'] && flag['5'] && flag['3'] && std::stoi(res) <= N) ++ans, temp.push_back(res);
	}

	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    cin >> s;
    int ans = 0;
    int n = (int) s.size();
    for (int i = 0; i < n/2; i++){
        if (s[i] != s[n-i-1]) ans++;
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3580