akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;

    UnionFind uf(n);
    vector<int> ans(n);
    vector<set<int> > exclusive(n);

    rep(i,n) ans[i] = 0;

    rep(i,m){
        int p, q;
        cin >> p >> q; p--; q--;
        exclusive[p].insert(q);
        exclusive[q].insert(p);

        uf.merge(p,q);
    }

    rep(i,k){
        int r, s;
        cin >> r >> s; r--; s--;
        if (!uf.issame(r, s)) continue;
        exclusive[r].insert(s);
        exclusive[s].insert(r);
    }

    rep(i,n) cout << -1 + uf.size(i) - exclusive[i].size() << " ";

    cout << endl;
}

Measured memory_bytes: 28288
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    int A1, A2, A3;
    int a1, a2, a3, a4, a5, a6;
    cin >> A1 >> A2 >> A3;
    int min = 500;
    int a[6];
    a[0] = abs(A2 - A1) + abs(A3 - A2);
    a[1] = abs(A1 - A2) + abs(A3 - A1);
    a[2] = abs(A1 - A3) + abs(A2 - A1);
    a[3] = abs(A3 - A1) + abs(A2 - A3);
    a[4] = abs(A3 - A2) + abs(A1 - A3);
    a[5] = abs(A2 - A3) + abs(A1 - A3);

    REP(i, 6)
    if(min > a[i]) min = a[i];

    cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

A.sort(key=lambda x:x[1])

ans = 1
end = A[0][1]
for i in range(1,M):
    if A[i][0]>=end:
        ans += 1
        end = A[i][1]
print(ans)

Measured memory_bytes: 64472
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
    int n = 0;
    cin >> n;
    map<string,int> counter;
    string tmp = "";
 
    for(int i = 0; i < n;i++){
        cin >> tmp;
        counter[tmp] ++;
    }
    int maxStr = 0;
    
    for(auto i: counter) maxStr = max(maxStr,i.second);
    for(auto i = counter.begin(); i != counter.end();++i){
        if(i->second == maxStr){
            cout << i->first << endl;
        }
    }

    return 0;
}

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int Maxvalue;
  if(K <= A + B && K >= A){
    Maxvalue = A;
  }else if(K < A){
    Maxvalue = K;
  }else if(K > A + B){
    int mainasu = K - A - B;
    Maxvalue = A - mainasu;
  }
  cout << Maxvalue << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  
  int as=0,bs=1000000;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0;i<M;i++){
    cin >> a[i];
    as=max(as,a[i]);
    cin >> b[i];
    bs=min(bs,b[i]);
  }
  if(as>bs){
    cout << 0 <<endl;
  }
  else{
  cout << bs-as+1 <<endl;
  }
  
}

  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i = l; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int dp[n+1] = {};
  int h[n+1];
  rep(i,1,n+1) scanf("%d", &h[i]);
  rep(i,2,n+1) {
    dp[i] = dp[i-1] + abs(h[i-1]-h[i]);
	rep(j,2,k+1) {
      if(i-j >= 1) dp[i] = min(dp[i], dp[i-j] + abs(h[i-j]-h[i]));
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}

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

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

    vector<string> A(N), B(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            ans += (A[i][j] != B[i][j]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 11084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int onedan=0;
		str=bfr.readLine();
		onedan=Integer.parseInt(str);
		str=bfr.readLine();
		onedan=onedan-Integer.parseInt(str);
		str=bfr.readLine();
		onedan=onedan%(Integer.parseInt(str));
		System.out.println(onedan);
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
      
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
       
 
		if(Character.isUpperCase(a.charAt(0)))System.out.println('A');
        else System.out.println('a');
 
	}
}

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

int main() {
	int X;
	cin >> X;
	int num, frac;
	num = X/100;
	frac = X%100;
	if (num != 0 && (frac/num < 5 || (frac/num == 5 && frac%num == 0))) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
data = [input().split() for i in range(m)]
for i in range(1,n+1):
    count = 0
    for j in range(m):
        if int(data[j][0]) == i or int(data[j][1]) == i:
            count += 1
    print(count)

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

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

  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int s = accumulate(l.begin(), l.end(), 0);
  string ans = (l[n-1] < (s + 1) / 2) ? "Yes" : "No";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
// header {{{
// header {{{
#include <bits/stdc++.h>
using namespace std;
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
 
#define ASSERT(expr...) assert((expr))
 
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;
 
#define M5 100007
 
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <ll>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
 
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
 
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
 
 
void solve() {
    int A,B,M;
    cin >> A >> B >> M;
    VI a,b;
    a.resize(A);
    b.resize(B);
    ll ma = 10000000;
    ll mb = 10000000;
    REP(i,A){
        cin >> a[i];
        if(ma>a[i])
        ma = a[i];
    }
    REP(i,B){
        cin >> b[i];
        if(mb>b[i])
        mb = b[i];
    }
    ll miab = ma+mb;
    REP(i,M){
        ll x,y,c;
        cin >> x >> y >> c;
        ll sum = a[x-1]+b[y-1]-c;
        if(sum < miab){
            miab = sum;
        }
    }
    cout << miab;
}
 
signed main() {
 
    solve();
 
    return 0;
}

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

namespace AtCoder
{
    public class AtCoder20171111D
    {
        static void Main(string[] args)
        {
            var s1 = Console.ReadLine();
            var s2 = Console.ReadLine();
            
            Console.WriteLine(funcMain(s1,s2));

            Console.ReadKey();
        }

        static public string funcMain(string arg1, string arg2)
        {
            long ret = 0;
            var list1 = arg1.Split().Select(f => long.Parse(f)).ToList();
            var list2 = arg2.Split().Select(f => long.Parse(f)).ToList();

            int N = (int)list1[0];
            long X = list1[1];
            long Y = list1[2];

            try {
                ret = Math.Max(Math.Abs(list2[N - 1] - list2[N - 2]), Math.Abs(list2[N - 1] - Y));
            }
            catch {
                ret = Math.Abs(list2[0] - Y);
            }

            return ret.ToString();
        }
    }
}


Measured memory_bytes: 13396
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll n, x, t;
    cin >> n >> x >> t;
    ll m = n / x;
    if (n % x != 0)
    {
        ++m;
    }
    cout << t * m << endl;
    return 0;
}

Measured memory_bytes: 3196
def question(query)
  puts "? " + query.join(" ")
  STDOUT.flush
  s = gets.chomp
  return s
end

N = gets.to_i
ans = ["?"] * (2*N+1)

res_1N = question((1..N).to_a)

ok, ng = N+1, 0
while (ok - ng).abs > 1
  mid = (ok + ng)/2
  query = (mid..mid+N-1).to_a
  if res_1N != question(query)
    ok = mid
  else
    ng = mid
  end
end

rb_half = (ok..ok+N-2).to_a
rb_half2 = (1..ok-2).to_a + (ok+N..2*N).to_a

1.upto(2*N) do |i|
  target = rb_half.include?(i) ? rb_half2 : rb_half
  res = question(target + [i])
  ans[i] = res == "Red" ? "R" : "B"
end

puts "! #{ans[1, 2*N].join}"
exit

Measured memory_bytes: 2376
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n, k;
int a[210000];

int main()
{
	cin >> n >> k;
	int ai;
	set<int>s;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	vector<P>v;
	v.push_back(P(1,a[0]));
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1])v[v.size() - 1].first++;
		else v.push_back(P(1, a[i]));
	}
	sort(v.begin(), v.end());
	if ((int)v.size() <= k)cout << 0 << endl;
	else {
		int cnt = 0;
		for (int i = 0; i < (int)v.size()-k; i++) {
			cnt += v[i].first;
		}
		cout << cnt << endl;
	}



	return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#define VMAX 2000001

void CountingSort(int[],int);

int C[VMAX + 1];
int B[VMAX + 1];

int main(){
    int *A,n;

    scanf("%d",&n);

    A = malloc(sizeof(int) * n + 1);

    for(int i = 0;i < n;i++)scanf("%d",&A[i]);

    CountingSort(A,n);

    for(int i = 1;i <= n;i++){
        printf("%d",B[i]);
        if(i < n)printf(" ");
    }
    printf("\n");

    return 0;
}

void CountingSort(int A[VMAX],int n){
    //C初期化
    for(int i = 0;i < VMAX;i++)C[i] = 0;
    //CのA[i]番目にA[i]が現れる回数をカウント
    for(int i = 0;i < n;i++)C[A[i]]++;
    //累積和を求める
    for(int i = 1;i < VMAX;i++)C[i] = C[i] + C[i - 1];

    for(int i = 0;i < n;i++){
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }
}




Measured memory_bytes: 25296
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop;

immutable long MOD = 1_000_000_007;

void main(){
    char[] buf; readln(buf);
    auto N = buf.split.to!(int[])[0];
    string[] ans;
    foreach(i ; 0 .. N){
        readln(buf);
        ans ~= buf.chomp.to!string;
    }
    sort(ans);
    foreach(str ; ans){
        write(str);
    }
    writeln;
}

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

const int maxn = 100009;
char s[maxn];
int l, r, mid, n;

bool check(int x) {
	char flag = s[x];
	for (int i=n-x+1; i<=x; i++)
		if (s[i] != flag) return 0;
	return 1;
}

int main() {
	scanf("%s", s+1); n = strlen(s+1);
	l = (n + 1) / 2; r = n;
	while (l < r) {
		mid = (l + r + 1) >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	printf("%d\n", l);
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll N, K;
    cin >> N >> K;
    double ans = 0;

    REP(i, N) {
        //! i+1が出る
        ll t = i + 1;
        double p = 1.0 / (double) N;
        while (t < K) {
            p *= 0.5;
            t *= 2LL;
        }
        ans += p;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<ll>> xdp(h, vector<ll>(w));
    vector<vector<ll>> ydp(h, vector<ll>(w));
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                xdp[i][j] = 0;
                ydp[i][j] = 0;
            }
            else {
                if (j == 0) {
                    xdp[i][j] = 1;
                }
                else {
                    xdp[i][j] = xdp[i][j - 1] + 1;
                }
                if (i == 0) {
                    ydp[i][j] = 1;
                }
                else {
                    ydp[i][j] = ydp[i - 1][j] + 1;
                }
            }
        }
    }
    rep(i, h) {
        rrep(j, w) {
            if ((j == (w - 1)) || (xdp[i][j] == 0) || (xdp[i][j + 1] == 0)) continue;
            xdp[i][j] = xdp[i][j + 1];
        }
    }
    rep(j, w) {
        rrep(i, h) {
            if ((i == (h - 1)) || (ydp[i][j] == 0) || (ydp[i + 1][j] == 0)) continue;
            ydp[i][j] = ydp[i + 1][j];
        }
    }
    ll ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, xdp[i][j] + ydp[i][j] - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 67200
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a;
  int b=0,c=0,d=0,e=0;
  for(int i=0;i<3;i++){
    cin>>a;
    if(a=='a'&&c==0||a=='b'&&d==0||a=='c'&&e==0){
      b++;
      if(a=='a'){
	c=1;
      }
      if(a=='b'){
	d=1;
      }
      if(a=='c'){
	e=1;
      }
    }
  }
  if(b==3){
    cout<<"Yes\n";
  }
  else{
   
    cout<<"No\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    cin>>N;
    int A[N];
    rep(i,N) cin>>A[i];
    sort(A,A+N);
    A[N-1]/=2;
    int sum=accumulate(A,A+N,0);
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1)
    a = 14;
  if(b == 1)
    b = 14;
  if(a < b){
    cout << "Bob" << endl;
   }
  else if(a == b)
    cout << "Draw" << endl;
  else
    cout << "Alice" << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct node{int a, b, c, d;};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int a[h][w];
    vector<node> v;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) cin >> a[i][j];
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		if(a[i][j] & 1){
    			if(j != w-1) {
    				v.push_back({i, j, i, j+1});
    				a[i][j+1]++;
    			}else{
    				if(i != h-1) a[i+1][j]++, v.push_back({i, j, i+1, j});
    			}
    		}
    	}
    }
    cout << v.size() << endl;
    for(auto& i : v){
    	cout << i.a + 1 << " " << i.b + 1 << " " << i.c + 1 << " " << i.d + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5232
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

fn main() {
    proconio::input!{
        n: usize,
        mut ab: [(i64, i64); n],
    }
    ab.sort_by_key(|p| p.1);
    let mut t = 0;
    for (a, b) in ab {
        t += a;
        if t > b {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 9072
n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
X_max = max(X)
Y_min = min(Y)
if X_max >= Y_min:
    print("War")
    exit()
else:
    XY = [i for i in range(x+1, y)]
    if Y_min in XY:
        print("No War")
    else:
        print("War")

Measured memory_bytes: 38428
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<int> dp(n + 1, -1);

  dp[n] = 0;
  int cur = n;
  while (cur > 0) {
    int far = cur;
    FOR(i, 1, m + 1) {
      if (cur - i < 0)
        break;
      if (s[cur - i] == '0') {
        dp[cur - i] = dp[cur] + 1;
        far = cur - i;
      }
    }
    if (cur == far) {
      cout << -1 << endl;
      return 0;
    }
    cur = far;
  }

  // 復元
  vi ans;
  cur = 0;
  while (cur <= n) {
    FOR(i, 1, m + 1) {
      if (cur + i > n)
        break;
      if (dp[cur + i] == dp[cur] - 1) {
        ans.push_back(i);
        cur += i;
        break;
      }
    }
    if (cur == n)
      break;
  }

  REP(i, (int)ans.size()) { cout << ans[i] << (i == (int)ans.size() - 1 ? "\n" : " "); }

  return 0;
}


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

int main(){
  int c1, c5, c10, c50, c100, c500, sum;
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

  sum = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;

  cout << (sum >= 1000) << endl;

  return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

int N, A, B, C;
vector<int> x;

int dfs(int i, int a, int b, int c) {
  if (i == N) {
    if (!a || !b || !c) return INF;
    return abs(a - A) + abs(b - B) + abs(c - C);
  }
  int res = dfs(i + 1, a, b, c);
  chmin(res, dfs(i + 1, a + x[i], b, c) + (a ? 10 : 0));
  chmin(res, dfs(i + 1, a, b + x[i], c) + (b ? 10 : 0));
  chmin(res, dfs(i + 1, a, b, c + x[i]) + (c ? 10 : 0));

  return res;
}

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

  cin >> N >> A >> B >> C;
  x.resize(N);
  arep(i, x) cin >> i;

  cout << dfs(0, 0, 0, 0) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B, C, D;
    int X;
    cin >> X;
    A = X / 1000;
    B = (X % 1000) / 100;
    C = (X % 100) / 10;
    D = X % 10;

    if(A+B+C+D == 7) {
        cout << A << '+' << B << '+' << C << '+' << D;
    }else if(A+B+C-D == 7) {
        cout << A << '+' << B << '+' << C << '-' << D;
    }else if(A+B-C+D == 7) {
        cout << A << '+' << B << '-' << C << '+' << D;
    }else if(A-B+C+D == 7) {
        cout << A << '-' << B << '+' << C << '+' << D;
    }else if(A+B-C-D == 7) {
        cout << A << '+' << B << '-' << C << '-' << D;
    }else if(A-B+C-D == 7) {
        cout << A << '-' << B << '+' << C << '-' << D;
    }else if(A-B-C+D == 7) {
        cout << A << '-' << B << '-' << C << '+' << D;
    }else if(A-B-C-D == 7) {
        cout << A << '-' << B << '-' << C << '-' << D;
    }
    cout << '=' << 7 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

signed main(){
    int n; cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];
    sort(a,a+n);
    vector<bool> used(1e6+1,false);
    int ans = 0;
    REP(i,n){
        if(used[a[i]])continue;
		if(i<n-1)if(a[i]!=a[i+1])ans++;
        if(i==n-1)ans++;
        int s = a[i];
        while(s<=1e6){
            used[s] = true;
            s += a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5312
#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define fastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define scan(a) scanf("%d", &a)
#define scanll(a) scanf("%lld", &a)
#define scanD(a) scanf("%lf", &a)
#define print(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printD(a) printf("%lf\n", a)
#define printTwo(a) printf("%.2lf\n", a);
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define showTime cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	ll n, m, k;
	scanll(n), scanll(m), scanll(k);
	vector<ll> a(n), b(m);
	rep(i, 0, n) {
		scanll(a[i]);
	}

	rep(i, 0, m) {
		scanll(b[i]);
	}

	vector<ll> sumOne(n + 1), sumTwo(m + 1);
	rep(i, 0, n) {
		sumOne[i + 1] = sumOne[i] + a[i];
	}

	rep(i, 0, m) {
		sumTwo[i + 1] = sumTwo[i] + b[i];
	}

	int total = 0;
	
	REP(i, 0, n) {
		ll other = k - sumOne[i];
		if(other < 0) {
			continue;
		}

		int index = lower_bound(sumTwo.begin(), sumTwo.end(), other) - sumTwo.begin();
		if(index > m || sumTwo[index] > other) {
			--index;
		}
		total = max(total, i + index);
	}
	print(total);
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

	solve();

	// __test {
	// 	solve();
	// }

	showTime;
	return 0;
}




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

signed main () {
    int n, m;
    cin >> n >> m;
    vector < int > a(n);
    for (int &x: a)
        cin >> x;
    sort(a.begin(), a.end());
    vector < pair < int, int > > cb(m);
    for (int i = 0; i < m; ++i) 
        cin >> cb[i].second >> cb[i].first;
    sort(cb.rbegin(), cb.rend());
    int i = 0;
    for (int j = 0; j < m; ++j) {
        int c = cb[j].first, b = cb[j].second, i_old = i;
        while (i < n && i - i_old != b && a[i] < c) {
            a[i] = c;
            ++i;
        }
    }
    int64_t ans = 0;
    for (int x: a)
        ans += x;
    cout << ans << '\n';
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int N,A[15];
int64 dp[15][2];
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	read(N);
	for(int i = 1 ; i <= N ; ++i) read(A[i]);
	dp[0][1] = 1;
	for(int i = 1 ; i <= N ; ++i) {
		for(int j = -1 ; j <= 1 ; ++j) {
			if((A[i] + j) & 1) {
				dp[i][1] += dp[i - 1][1];
				dp[i][0] += dp[i - 1][0];
			}
			else {
				dp[i][0] += dp[i - 1][0] + dp[i - 1][1];
			}
		}
	}
	out(dp[N][0]);enter;
}


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

int main() {
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

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

    // Mの約数のうち、M/N以下で最大のもの
    int maxD = 1;
    for (int i = 1; i <= sqrt(m); i++) {
        if(m%i == 0) {
            int d = m/i;
            if(d <= m/n && d > maxD) {
                maxD = d;
            } else if(i <= m/n && i > maxD) {
                maxD = i;
            }
        }
    }
    cout << maxD << endl;
}

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

using namespace std;
typedef unsigned long long int ll;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}


ll LCM(ll a, ll b){
  // get LCM value
  ll r, x, tmp;
  x = a * b;
  if (a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while (r != 0){
    a = b;
    b = r;
    r = a % b;
  }

  return x/b;
}
int main(void){

  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll lcm = LCM(C, D);

  ll c_num, d_num, both_num;

  c_num = B/C - ((A-1)/C);
  d_num = B/D - ((A-1)/D);
  both_num = B/lcm - ((A-1)/lcm);

  ll ans = B-A+1 - c_num - d_num + both_num;

  cout << ans << "\n";


  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)n ; i++)
#define invrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef long double ld;
const int MODULO = 1000000007;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){
        int num; cin >> num;
        a.pb(num);
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    rep(i, n){
        for (int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if (a[k] < a[i] + a[j] && a[i] != a[j] && a[j] != a[k] && a[k] != a[i]){
                    cnt++;
                }
            }
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3652
import sys
readline = sys.stdin.readline
N, M, Q = map(int, readline().split())
X = [[0] * N for _ in range(N)]
for _ in range(M):
    l, r = map(int, readline().split())
    X[l-1][r-1] += 1

S = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(N):
        S[i+1][j+1] = S[i+1][j] + X[i][j]

for _ in range(Q):
    p, q = map(int, readline().split())
    p -= 1
    q -= 1
    ans = sum(S[i][q+1] - S[i][p] for i in range(p + 1, q + 2))
    print(ans)

Measured memory_bytes: 62300
P = gets.split.map(&:to_f)
Q = gets.split.map(&:to_f)

def calc(x)
    6.times.map{|i| [P[i]*x, Q[i]*(1-x)].max}.inject(:+)
end

l = 0.0
u = 1.0
100.times do
    m1 = (2*l+u)/3
    m2 = (l+2*u)/3
    if calc(m1) < calc(m2)
        u = m2
    else
        l = m1
    end
end

puts calc(l)/100

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B,C;
int K;

signed main(){
	cin>>A>>B>>C>>K;
	int cnt=0;
	while(A>=B){
		B*=2;
		cnt++;
	}
	while(B>=C){
		C*=2;
		cnt++;
	}
	if(cnt<=K){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> a(n);
	rep(i, n) {
		int p, q;
		cin >> p >> q;
		a[i] = {p, q};
	}
	ll ans = 0;
	sort(all(a));
	rep(i, n) {
		ll cost = a[i].first;
		ll mx = a[i].second;
		if(m > mx) {
			ans += cost * mx;
			m -= mx;
		} else {
			ans += cost * m;
			break; 
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>

using namespace std;

using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const ll INF = (1e+18)+100;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repl(i, l, n) for(int i=l;i<n;++i)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

typedef long double ld;
const ld eps = 1e-8;

void solve() {
	int n; cin >> n;
	rep1(i, 50000) {
		int x = i * 1.08 + eps;
		if (x == n) {
			cout << i << endl; return;
		}
	}
	cout << ":(" << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

#n = 3
#p = [1,3,2]
#q = [3,1,2]

p_count = -1
q_count = -1

base = [i for i in range(1,n + 1)]

all_data = list(itertools.permutations(base))

for i, chk in enumerate(all_data):
   
   if list(chk) == p:
      p_count = i

   if list(chk) == q:
      q_count = i

   if p_count >= 0 and q_count >= 0:
      break


print(str(abs(p_count - q_count)))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
int i,i0,n,m,ans,a[100005];
int main()
{
    scanf("%d",&n);
    bool f=1;
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    a[1]--;
    for(i=2;i<=n;i++)
    {
        if(a[i]-1>=a[i-1])a[i]--;
        else if(a[i]<a[i-1])
        {
            f=0;
        }
    }
    if(f)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, M, K, A, res;
bool b[30][30];
int main() {
	cin >> N >> M;
	for (int i = 0; i != N; ++i) {
		cin >> K;
		for (int j = 0; j != K; ++j) {
			cin >> A;
			b[i][A - 1] = true;
		}
	}
	for (int i = 0; i != M; ++i) {
		for (int j = 0; j != N; ++j) {
			if (!b[j][i])break;
			if (j == N - 1)++res;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
ll dp[1010][1010];
int main()
{
    int h, w;
    ll mod = 1e9 + 7;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h)
    {
        cin >> s[i];
    }
    dp[0][0] = 1;
    rep(i, h)
    {
        rep(j, w)
        {
            if (j + 1 < w && s[i][j + 1] == '.')
            {
                dp[i][j + 1] += dp[i][j];
                dp[i][j + 1] %= mod;
            }
            if(i+1<h&&s[i+1][j]=='.'){
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=mod;
            }
        }
    }
    cout << dp[h-1][w-1] <<endl;
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#define ll long long
using namespace std;

int a,b,c,k,ans;

int main()
{
    cin>>a>>b>>c>>k;
    if(k<=a)
        ans=k;
    else if(k<=a+b)
        ans=a;
    else if(k<=a+b+c)
        ans=a-(k-a-b);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N, i;
	cin >> N >> i;


	cout << N - i + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    vector<int> a;
    int n;

    cin >> n;
    a.reserve(n);

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


    int sum = accumulate(a.begin(), a.end(), -n);

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21) ;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];
    
    for(int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    while(1) {
        minv = INFTY;
        int u = -1;
        for(int i = 0; i < n; i++) {
            if(minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(int v = 0; v < n; v++) {
            if(color[v] != BLACK && M[u][v] != INFTY) {
                if(d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }
    
    int k, c, u, v;
    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    dijkstra();
    
    return 0;
}


Measured memory_bytes: 3136
#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);
*/

const int mod = 1000000007;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  // 構造体の変数は public 変数であるためアクセス可能
  ll x; // typedef long long ll;

  // コンストラクタ
  mint(ll x=0):x((x%mod+mod)%mod){}

  // 単項演算子：符号やインクリメントなどを表すものなど
  // -（マイナス）演算子との区別は引数によって行う
  mint operator-() const { return mint(-x);}

  // 複合代入演算子のオーバーロード
  // *1 戻り値の型は必ず自分自身のクラスで参照を返す
  // *2 return文には「*this」を指定する
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }

  // 算術演算子のオーバーロード
  // 引数の型に & をつけることで参照を利用して受け取ることができる（コピーする必要がないため処理が高速化される）
  mint operator+(const mint a) const {  // メンバ変数の書き換えを防ぐために引数定義のあとに const をつけている
    mint res(*this);    // コピーコンストラクタ（コンパイラが自動で生成）
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // 素数の逆元計算にのみ有効
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

const int MAX = 1000100;
mint fac[MAX], finv[MAX], inv[MAX];
// 先にこれを行うことで O(1) で nCk を求められる
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;
        finv[i] = finv[i-1]/i;
    }
}

mint 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];
    // cout << COM(n,k).x << endl;
}

ll f(ll x, ll n){
    if(n == 0) return 1;
    ll res = f(x*x%mod, n/2);
    if(n%2 == 1){
        res *= x;
        res %= mod;
    }
    return res;
}

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

    if(n<3){
        cout << 0 << endl;
        return 0;
    }

    int hako = n/3;

    COMinit();

    ll res = 1;
    for(int k=2; k<=hako; k++){
        // cout << COM(n-3*k+1,k-1).x << endl;
        res += COM(n-2*k-1, k-1).x;
        res %= mod;
    }
    cout << res << endl;
}

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

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

    int n;
    cin>>n;
    char a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    int r=0;
    for(int i=0; i<n; i++) if(a[i]=='R') r++;

    int c=0;
    for(int i=0; i<r; i++){

        if(a[i]=='W') c++;
    }

    cout<<c;

	return 0;
}


Measured memory_bytes: 3812