akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC130A
{
    static class Program
    {
        static void Main(string[] args)
        {
            var line = ReadLine().SplitTryParseToList<int>();

            if (line[0] < line[1])
            {
                WriteLine("0");
            }
            else
            {
                WriteLine("10");
            }
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


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

using namespace std;

#define ll long long

const int mod  = 1e9 + 7;
const int INF = 1e9;

void solve(){

    int n; cin >> n;
    int mn = -1;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        ans += max(0, mn - x);
        mn = max(mn, x);
    }
    cout << ans << "\n";

    return;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	solve();

	return 0;
}



Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}

    mint operator-() const { return mint(-x); }

    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 { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    mint ans = 0;
    ll two_factor = 1;

    rep(d, 60) {
        ll even = 0, odd = 0;
        rep(i, N) {
            if (A[i] & (1LL << d)) {
                odd++;
            } else {
                even++;
            }
        }

        ll now = (odd * even) % MOD * (two_factor % MOD);
        two_factor = (two_factor * 2) % MOD;
        ans += now;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5552
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m;
    cin>>n;
    m=n%10;
    if(m==2||m==4||m==5||m==7||m==9)
        cout<<"hon"<<endl;
    else if(m==0||m==1||m==6||m==8)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;
}

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

int gcd(int a, int b){
	if(a == 0 || b == 0)
		return a+b;
	return gcd(b, a%b);
}

int main(){
	int N;
	cin >> N;
	vector<int> A(N), L(N+1), R(N+1);
	for(int i = 0; i < N; i++)
		cin >> A.at(i);

	int maxi = 0;
	for(int i = 0; i < N; i++)
		L.at(i+1) = gcd(L.at(i), A.at(i));
	for(int i = N-1; 0 <= i; i--)
		R.at(i) = gcd(R.at(i+1), A.at(i));
	for(int i = 0; i < N; i++){
		int part = gcd(L.at(i), R.at(i+1));
		if(maxi < part)
			maxi = part;
	}
	
	cout << maxi << endl;
}

Measured memory_bytes: 1408
n = int(input())
l = [list(map(int,input().split())) for i in range(n*(n-1)//2)]
p = [[0,i,0] for i in range(n+1)]

for i in range(n*(n-1)//2):
    if l[i][2] == l[i][3]:
        p[l[i][0]][0] += 1
        p[l[i][1]][0]  += 1
    elif l[i][2] > l[i][3]:
        p[l[i][0]][0]  += 3
    else:
        p[l[i][1]][0]  += 3

p = sorted(p,key = lambda x:-x[0])
p.pop(-1)

rank = 1
k = [p[i][0] for i in range(n)]

for i in range(n):
    if k.count(p[i][0]) == 1:
        p[i][2] = rank
        rank += 1

    else:
        p[i][2] = rank
        if i+2 == rank + k.count(p[i][0]):
            rank += k.count(p[i][0])

p = sorted(p,key = lambda x:x[1])
for i in range(n):
    print(p[i][2])



Measured memory_bytes: 6164
N=int(input())
a=list(map(int,input().split()))
ans=[[0 for e in range(N+1)] for f in range(N+1)]
for j in range(1,N+1):
 ans[j][1]=a[j-1]
if N>1:
 for i in  range(2,N+1):
  for j in range(1,N+2-i):
   ans[j][i]=max(a[j-1]-ans[j+1][i-1],a[j+i-2]-ans[j][i-1])
print(ans[1][N])


Measured memory_bytes: 119900
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


struct distanceData {
	int distance, id;
};

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> board(H, vector<char>(W));
	vector<bool> compH(H, true), compW(W, true);
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			cin >> board[h][w];
			if (board[h][w] == '#') {
				compH[h] = false;
				compW[w] = false;
			}
		}
	}
	for (int h = 0; h < H; h++) {
		if (compH[h])continue;
		for (int w = 0; w < W; w++) {
			if (compW[w]) continue;
			cout << board[h][w];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b && a>=c){cout<<a*10+b+c<<endl;}
	else if(b>=c && b>=a){cout<<b*10+a+c<<endl;}
	else if(c>=b && c>=a){cout<<c*10+a+b<<endl;}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  int d = y % 5;
  y -= d, n -= d;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      if (y == i * 10 + j * 5 + n - i - j) {
        cout << i << " " << j << " " << n - i - j + d;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1";
  return 0;
}


Measured memory_bytes: 256
from collections import deque
n, q = map(int, input().split())

que = deque()
for _ in range(n):
    k, v = input().split()
    que.append([k, int(v)])

#%%
p_time = 0
while True:
    k, v = que.popleft() # 先頭にあるプロセスを取り出す
    if v <= q: # プロセス制限時間q以内に終わるならば、そのまま削除してこれまでの実行時間を表示
        p_time += v
        print(k, p_time)
    else: # プロセス制限時間q以内に終わらないときは、再びqueに追加する
        p_time += q
        que.append([k, v-q])

    if len(que) == 0: # すべてのqueがなくなったら終了
        break


Measured memory_bytes: 13280
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  int res = 0;
  while(n > 0) {
    int d = n % 10;
    if(d == 2) {
      ++res;
    }
    n /= 10;
  }
  cout << res << endl;
  
  return 0;
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

vector < vector < ll > > adj(MAXN, vector < ll > ());
vector < vector < ll > > d(MAXN, vector < ll > (3, LLONG_MAX));
vector < bool > used(MAXN, false);

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

  ll n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    ll u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }
  ll st, t;
  cin >> st >> t;

  d[st][0] = 0;
  set < pair < vector < ll >, ll > > s;
  s.insert({d[st], st});
  while(!s.empty()){
    ll u = s.begin() -> second;
    s.erase(s.begin());
    for(auto to : adj[u]){
      if(d[u][0] != LLONG_MAX && d[to][1] > d[u][0] + 1){
        s.erase({d[to], to});
        d[to][1] = d[u][0] + 1;
        s.insert({d[to], to});
      }
      if(d[u][1] != LLONG_MAX && d[to][2] > d[u][1] + 1){
        s.erase({d[to], to});
        d[to][2] = d[u][1] + 1;
        s.insert({d[to], to});
      }
      if(d[u][2] != LLONG_MAX && d[to][0] > d[u][2] + 1){
        s.erase({d[to], to});
        d[to][0] = d[u][2] + 1;
        s.insert({d[to], to});
      }
    }
  }

  if(d[t][0] == LLONG_MAX) cout << -1 << endl;
  else cout << d[t][0] / 3 << endl;
}


Measured memory_bytes: 15480
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split(' ');
	var s = toInt(input[0]);
	var k = toInt(input[1]);


	console.log((s-1)*(k-1));

}

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

int main(){
  ll n, k;
  cin >> n >> k;
  map<ll, ll> mp;
  rep(i,n){
    ll a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  ll num = 0;
  for(auto n : mp){
    num += n.second;
    if(num >= k){
      cout << n.first << endl;
      return 0;
    }
  }
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const int MAXN = 2e5 + 10;

int n;
int A[ MAXN ];
int freq[ MAXN ];

int main()
{
	cin >> n;
	int mx = 0, mmx = 0;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
		freq[ A[ i ] ]++;
		if ( A[ i ] > mx )
		{
			mmx = mx;
			mx = A[ i ];
		} else if ( A[ i ] > mmx )
		{
			mmx = A[ i ];
		}
	}
	
	FOR( i, 0, n )
	{
		if ( A[ i ] < mx )
			cout << mx << "\n";
		else if ( A[ i ] == mx )
		{
			freq[ mx ]--;
			if ( freq[ mx ] == 0 )
				cout << mmx << "\n";
			else
				cout << mx << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 3072
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    s=[0]*N
    mn=100000
    for i in range(N):
        s[i]=I()
        if s[i]%10!=0:
            mn=min(mn,s[i])
            
    mn=min(mn,sum(s))
    if sum(s)%10!=0:
        mn=0
    print(sum(s)-mn)
        
    

main()


Measured memory_bytes: 38384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input! {
        n: usize,
        mut ls: [i64; n],
    }

    ls.sort();

    let mut ans = 0;

    for i in 0..n {
        for j in i + 1..n {
            let a = ls[i];
            let b = ls[j];

            let mut l = j;
            let mut r = n;

            while r - l >= 2 {
                let mi = (l + r) / 2;
                if ls[mi] < a + b {
                    l = mi;
                } else {
                    r = mi;
                }
            }

            ans += r - (j + 1);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;

    vector<ll> as(n);
    ll tas = 0;
    rep(i, n) {
        tas += a[i];
        as[i] = tas;
        // cout << tas << " ";
        // cout << as[i];
        if (tas == 0) {
            ans += 1;
        }
    }
    // cout << endl;

    map<ll, ll> m;
    rep(i, n) {
        if (m.count(as[i])) {
            ans += m[as[i]];
            m[as[i]] += 1;
        } else {
            m[as[i]] = 1;
        }
    }
    // cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15104
import math
K = int(input())

def S(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret

def scr(n):
    return n/S(n)

def f(N):
    maxd = math.ceil(math.log(N,10)) + 1
    minScr = 10**15
    ret = 0
    for d in range(maxd):
        x = (10**(d)) * (N // (10**(d)) + 1) - 1
        s = scr(x)
        if minScr > s:
            minScr = s
            ret = x
    return ret

N = 0
for i in range(K):
    N = f(N + 1)
    print(N)


Measured memory_bytes: 3188
use std::str::FromStr;
use std::io::{ self, stdin };

fn main() {
    let mut inputs: Vec<u32> = Vec::new();
    for _ in 0..10 {
        inputs.push(input());
    }
    inputs.sort();
    inputs.reverse();
    let mut out_iter = inputs.iter().take(3);
    for _ in 0..3 {
        println!("{}", out_iter.next().unwrap());
    }
}

pub fn input<T>() -> T
where T:FromStr
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).expect("input error");
    let parse_result = buf.trim().parse::<T>();
    if let Ok(v) = parse_result {
        v
    } else {
        panic!("parse error");
    }
}


Measured memory_bytes: 5028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 0;
		switch (s){
			case "RRR":
				ans = 3;
				break;
			case "RRS":
				ans = 2;
				break;
			case "SRR":
				ans = 2;
				break;
			case "RSR":
				ans = 1;
				break;
			case "SSR":
				ans = 1;
				break;
			case "SRS":
				ans = 1;
				break;
			case "RSS":
				ans = 1;
				break;
			case "SSS":
				ans = 0;
				break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	
	ll A,B;
	cin >> A >> B;
	if((A+B)%2==0){
		cout << (A+B)/2 << endl;
 	}else{
 		cout << "IMPOSSIBLE" << endl;
 	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int r, g, b , n; cin >> r >> g >> b >> n;

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int diff = n - r * i - g * j;
            if ( (diff % b == 0) && (diff >= 0) ) ans++;
        }
    }
    cout << ans << endl;
}

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

int _;

int n,k,a[100050],ans;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	sort(a,a+n);
	for(int i=n-1;i >= n-k;i--)
		ans += a[i];
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 3740
n = int(input())
from collections import Counter
a = list(map(int,input().split()))
b = []
for i in range(n):
  b.append(a[i]-i-1)
b = Counter(b)
k = -a[0]-1
a.append(10**10)
ans = 0
for i in range(n):
  ans += b[k]
  k -= 1
  k += a[i]-a[i+1]
print(ans)

Measured memory_bytes: 129936
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	string s,t;
	cin >> s >> t;
	int cnt=0;
	rep(i,3){
		if(s[i] == t[i])cnt++;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n/10%111==0 || n%1000%111==0) co("Yes");
  else co("No");

  return 0;
}


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

MOD = (10 ** 9) + 7
ans = 0

min_val = 0
max_val = n
p = 1

for i in range(n + 1):
    # print(min_val, max_val)
    if i + 1 >= k:
        ans += max_val - min_val + 1
        ans = ans % MOD
    min_val += p
    max_val += n - p
    p += 1

print(ans)


Measured memory_bytes: 8952
#include<iostream>
#include<vector>
#include<cctype>
#include<cstdio>
#include<cstring>
using namespace std;


int main() {
    vector<int> vec(26);
    char ch;
    while (cin >> ch) {
        ch = tolower(ch);
        if (isalpha(ch)) {
            vec[ch-'a']++;
        }
    }
    
    for (int i=0; i<26; ++i) {
        printf("%c : %d\n", 'a'+i, vec[i]);
    }
    
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>

using namespace std;
int main()
{
	int h,w;
	cin >> h >> w;
	string s[h];
	for(int i=0; i<h; i++){
		cin >> s[i];
	}
	for(int i=0; i<w + 2; i++){
		cout << '#';
	}
	cout << endl;
	for(int i=0; i<h; i++){
		cout << '#' << s[i] << '#' << endl;
	}
	for(int i=0; i<w + 2; i++){
		cout << '#';
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
cnt = [0]*N
for i in range(1,N):
    cnt[i] = cnt[i-1]
    if S[i-1] == 'A' and S[i] == 'C':
        cnt[i] += 1
for i in range(Q):
    l, r = map(int, input().split())
    print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 50776
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<pair<long long int, long long int>>v(N);
	for (auto &i : v)cin >> i.first >> i.second;
	sort(v.begin(), v.end());
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		while (M&&v[i].second) {
			M--;
			v[i].second--;
			ans += v[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//入力
ll n,k;
vector<ll>a;

bool ok(ll keta,vector<ll>v){
    ll res = 0;
    ll l = v.size();
    rep(i,l){
        if((v[i]>>keta)&1){
            res++;
        }
    }
    if(res>=k)return true;
    return false;
}

vector<ll>furui(ll keta,vector<ll>v){
    ll l = v.size();
    vector<ll>res;
    rep(i,l){
        if((v[i]>>keta)&1){
            res.push_back(v[i]);
        }
    }
    return res;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    vector<ll>v;
    rep(i,n){
        cin>>a[i];
    }
    vector<ll>rui(n+1,0);
    rep(i,n){
        rui[i+1]=rui[i]+a[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<=n;j++){
            v.push_back(rui[j]-rui[i]);
        }
    }
    ll ans = 0;
    for(ll i=40;i>=0;i--){
        if(ok(i,v)){
            v = furui(i,v);
            ans += pow(2,i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13056
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    set<char> s;
    char c;
    int n; cin >> n;
    rep(i,n) {
        cin >> c;
        s.insert(c);
    }

    if (s.size() == 3)
        cout << "Three" << endl;
    else
        cout << "Four" << endl;

}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// 二分探索で目的の値より大きいインデックスを返す
func upperBound(list []int64, n int64) int64 {
	var l int64 = 0
	var r int64 = int64(len(list) - 1)
	for l <= r {
		var mid int64 = l + (r-l)/2
		if list[mid] <= n {
			l = mid + 1
		} else {
			r = mid - 1
		}
	}
	return l
}

func main() {
	list := getStdinIntArr64()
	N := list[0]
	M := list[1]
	K := list[2]
	A := getStdinIntArr64()
	B := getStdinIntArr64()
	Asum := make([]int64, N+1)
	Bsum := make([]int64, M+1)

	var i int64 = 0
	var ans int64 = 0

	for i = 0; i < N; i++ {
		Asum[i+1] = Asum[i] + A[i]
	}
	for i = 0; i < M; i++ {
		Bsum[i+1] = Bsum[i] + B[i]
	}

	var apos int64 = 0
	for ; apos <= N; apos++ {
		if Asum[apos] > K {
			break
		}
		if M > 0 {
			var bpos int64 = upperBound(Bsum, K-Asum[apos])
			if bpos != 0 {
				bpos--
			}
			if apos+bpos > ans {
				ans = apos + bpos
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 21264
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector< pair<int,int> > pairs(n);
    for(int i=0; i<n; i++){
        int a; cin >> a;
        pairs[i] = make_pair(a,i);
    }

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

    for(int i=0; i<n; i++){
        if(i==pairs[n-1].second) cout << pairs[n-2].first << "\n";
        else cout << pairs[n-1].first << "\n";
    }

    return 0;
}

Measured memory_bytes: 3200
x = gets.to_i

x.downto(1) do |i|
    2.upto(i) do |j|
        if i % j == 0
            y = i
            cnt = 0
            while y % j == 0
                y /= j
                cnt += 1
            end
            if y == 1 && cnt > 1
                puts i
                exit
            end
        end
    end
end

p 1

Measured memory_bytes: 1788
#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 a,b;
  cin >> a >> b;
  int count = 0;
  int sockets = 1;
  if(sockets == b){
    cout <<"0" << endl;
  }else if(a>=b){
    cout << "1" << endl;
  }else{
    sockets = a;
    count =1;
    while(1){
      sockets+=a-1;
      count++;
      if(sockets>=b){
        cout << count << endl;
        break;
      }
    }
  }


  return 0;
}

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 3e5 + 41;
int const INF = 1e9 + 41;

int n;
char s[MAX];
int ans;
int pref[MAX];

void solve() {	
	fi(1, n) {
		pref[i] = pref[i - 1];
		if (s[i] == 'W') pref[i]++;
	}
	ans = INF;
	fi(1, n) {
		int wl = pref[i - 1];
		int er = n - i - (pref[n] - pref[i]);
		ans = min(ans, wl + er);
	}
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	scanf(" %s", s + 1);  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 1664
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	ans := canDance(s)
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func canDance(s string) string {
	n := len(s)
	for i := 0; i < n; i++ {
		if i%2 == 1 && s[i] == 'R' {
			return "No"
		}
		if i%2 == 0 && s[i] == 'L' {
			return "No"
		}
	}
	return "Yes"
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  string s;
  cin>>s;
  bool can=true;
  for(int i=0;i<s.size();i++){
    if(s[i]!=s[s.size()-1-i]) can=false;
  }
  for(int i=0;i<(s.size()-1)/2;i++){
    if(s[i]!=s[(s.size()-1)/2-1-i]) can=false;
  }
  for(int i=(s.size()+3)/2-1;i<s.size();i++){
    if(s[i]!=s[s.size()-1-i]) can=false;
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define N 100000
 
struct Vertex{
	long long cost;
	int u; // Component
 
	Vertex(){}
 
	Vertex(int u, long long cost){
		this->u = u;
		this->cost = cost;
	}
 
	bool operator < (const Vertex &b) const{
		return cost > b.cost;
	}
};
 
vector<int> g[N + 1];
long long a[N + 1];
bool seen[N + 1];
priority_queue<Vertex> pq; // Rest
deque<Vertex> aux;
int cur, n, m;
vector<long long> cost[N + 1];
int color[N + 1];
int edges[N + 1];

bool comp(int a, int b){
	return a > b;
}
 
void dfs(int u){
	int v, i;
 
 	// Marking as visited and pushing cost.
	seen[u] = true;
	color[u] = cur;
	cost[cur].push_back(a[u]);
 
 	// For every adjacent v.
	for (i = 0; i < (int)g[u].size(); i++){
		v = g[u][i];
 
		if (!seen[v]){
			dfs(v);
		}
	}
}
 
int main(){
	int total_edges, one_count, u, v, i;
	long long ans;
	Vertex head;
 
	scanf("%d%d", &n, &m);
 	
 	// Reading costs
	for (u = 1; u <= n; u++){
		scanf("%lld", a + u);
	}
 
 	// Reading edges
	for (i = 1; i <= m; i++){
		scanf("%d%d", &u, &v);
		g[u + 1].push_back(v + 1);
		g[v + 1].push_back(u + 1);
	}

	// Fill components
	for (u = 1; u <= n; u++){
		if (!seen[u]){
			cur++;
			dfs(u);
		}
	}

	if (cur == 1){
		printf("0\n");
		return 0;
	}

	// Adding first edge to every component
	total_edges = 2 * (cur - 1);
	one_count = cur;
	ans = 0;

	for (u = 1; u <= cur; u++){
		sort(cost[u].begin(), cost[u].end(), comp);
		ans += cost[u].back();
		cost[u].pop_back();

		total_edges--;
		edges[u] = 1;
	}

	for (u = 1; u <= cur; u++){
		for (i = 0; i < (int)cost[u].size(); i++){
			pq.push(Vertex(u, cost[u][i]));
		}
	}

	while (!pq.empty() and total_edges > 0){
		head = pq.top();
		pq.pop();

		u = head.u;

		// Cant add this edge
		if (edges[u] == 1 and one_count == 2){
			continue;
		}

		ans += head.cost;
		edges[u]++;
		total_edges--;

		if (edges[u] == 2){
			one_count--;
		}
	}
 
	if (total_edges == 0){
		printf("%lld\n", ans);
	}
	else{
		printf("Impossible\n");
	}
 
	return 0;
}

Measured memory_bytes: 12408
// 19:17 - 
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 1000 + 5;
const int M = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

struct Adj{
	int v, id;
};
vector<Adj> a[N];

void DFS(int u, int ban, int eid, int vst[]){
	if(u == ban || vst[u]) return;
	vst[u] = eid;
	for(auto e: a[u])
		DFS(e.v, ban, eid, vst);
}

int vst[2][N];
bool g[N][N], ok[M];

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

	int n, m;
	cin >> n >> m;
	
	static pint edg[M];
	for(int i=1; i<=m; i++){
		int u, v; cin >> u >> v;
		a[u].push_back((Adj){v, i});
		edg[i] = make_pair(u, v);
	}

	for(int i=1; i<=n; i++){
		memset(vst, 0, sizeof(vst));
		for(auto e: a[i])
			DFS(e.v, i, e.id, vst[0]);
		reverse(a[i].begin(), a[i].end());
		for(auto e: a[i]){
			DFS(e.v, i, e.id, vst[1]);
			if(vst[0][e.v] != vst[1][e.v])
				ok[e.id] = 1;
		}
		for(int j=1; j<=n; j++)
			if(vst[0][j])
				g[i][j] = 1;
	}

	for(int i=1; i<=m; i++){
		int u = edg[i].fi, v = edg[i].se;
		if(ok[i] ^ g[v][u]) cout << "diff\n";
		else cout << "same\n";
	}

	return 0;
}

Measured memory_bytes: 7040
/*

Author : @karngyan
Team : BlundersPride
Date : 09-03-2019
Time : 05:20:14

*/


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
vector<pll> v;
signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	ll n , m;
	cin >> n >> m;
	rep(i,0,n)
	{
		ll a,b;
		cin >> a>> b;
		v.pb({a,b});
	}
	sort(all(v));

	ll ans = 0;
	ll tot = m;
	for(auto it : v)
	{

		if(tot == 0)
			break;

		if(tot - it.ss >=0 )
		{
			ans += it.ss*it.ff;
			tot -= it.ss;
		}
		else
		{
			ans += it.ff*(tot);
			tot = 0;
		}

	}

	cout<<ans<<endl;





////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


int main(void) {
    int N; cin >> N;
    vector<string> vs(N);
    for (int i = 0; i < N; i++) {
        cin >> vs[i];
    }

    int right_A = 0;
    int B_A = 0;
    int B_left = 0;
    for (int i = 0; i < N; i++) {
        if (vs[i][0] == 'B' && vs[i][vs[i].length()-1] == 'A') {
            B_A++;
        } else if (vs[i][vs[i].length()-1] == 'A') {
            right_A++;
        } else if (vs[i][0] == 'B') {
            B_left++;
        }
    }

    long long ans = 0;
    ans += min(right_A, B_left);
    if (ans > 0) {
        ans += B_A;
    } else {
        if (right_A) {
            ans += B_A;
        } else if (B_left) {
            ans += B_A;
        }
    }
    if (ans == 0) {
        if (B_A > 1) {
            ans += B_A-1;
        }
    }

    for (int i = 0; i < N; i++){
        for (int j = 0; j < vs[i].length() - 1; j++) {
            if (vs[i][j] == 'A' && vs[i][j+1] == 'B') {
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, K; cin >> N >> K;
  vector<bool> vec(10);
  for (ll i = 0; i < K; i++) {
    ll d; cin >> d;
    vec.at(d) = true;
  }

  auto sat = [&](ll x) -> bool {
    if (x == 0) return !vec.at(0);
    for ( ; x > 0; x /= 10) {
      if (vec.at(x % 10)) return false;
    }
    return true;
  };
  ll n = N;
  while (true) {
    if (sat(n)) {
      cout << n << endl;
      return 0;
    }
    n++;
  }

  return 0;
}



Measured memory_bytes: 256
a,b,c=map(int,input().split())
d=[]
e=[]
for i in range(c):
  d.append(int(input()))
for i in range(a):
  e.append(b-c)
for i in d:
  e[i-1]+=1
for i in e:
  if i<=0:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 11768
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0

for i in range(n):
  ans += B[A[i]-1]
  if(i > 0 and A[i] == A[i-1]+1):
    ans += C[A[i]-2]

print(ans)

Measured memory_bytes: 9032
#include "bits/stdc++.h"

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string solve(string s){
    if(s.substr(0,2)==">'"){
        int eq=0;
        for(int i=2;i<s.size();i++){
            if(s[i]!='=')break;
            else{
                eq++;
            }
        }
        
        if(eq==0)return "NA";
        
        if( s[ (2 + eq -1) +1 ] != '#')return "NA";
        
        if( s.substr( ((2+eq-1)+1) +1 ,eq )   !=   s.substr( 2,eq ) )return "NA";

        if( 2+eq+1+eq+1 == s.size() && s[ (2+eq+1+eq+1) -1 ]=='~')return "A";
        
    }else if(s.substr(0,2)==">^"){
        int c=2;
        while( s[c]=='Q' && s[c+1]=='=' ){
            c+=2;
        }
        if(c==2)return "NA";
        
        
        if( c+1==s.size()-1 && s[c]=='~' && s[c+1]=='~')return "B";
        else return "NA";
        
        
    }else return "NA";

    return "NA";
}


int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        
        cout<<solve(s)<<endl;
    }

    return 0;
}

Measured memory_bytes: 1216
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
using namespace std;

int main() {
	long long int x, y;
	cin >> x >> y;
	long long int v = x;
	int cnt = 0;
	while(v <= y)
	{
		v *= 2;
		cnt++;
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
def main():
    a, b, x=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
    rev = 0
    if x == a*a*b:
        print(0)
    elif x > (a*a*b/2):
        #print("lar")
        x = a*a*b - x
        print(90-math.degrees(math.atan(a*a*a/2/x)))
    else:
        print(math.degrees(math.atan(b*b*a/2/x)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    ll X;cin >> X;

    ll b = 100;
    int year = 0;
    while(1){
        b += (b/100);
        year++;
        if(b>=X)break;
    }

    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.*
import java.math.*
import java.lang.Math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }
private val MOD = 1e9.toLong()+7
private val INF = Int.MAX_VALUE/2
private val LINF = Long.MAX_VALUE/2


fun solveD(M: Int, W: List<Int>, V: List<Int>): Long {
    var res = 0
    val N = W.size
    val MMAX = 1e5.toInt()
    val dp = Array(N+1){LongArray(MMAX+1){0L}}
    // dp[i][j] := [0,i) の品物で重さ j 以下で取れる最大価値

    for (i in 0 until N) {
        for (j in 1 .. M) {
            dp[i+1][j] = dp[i][j]
            if (j>=W[i]) {
                dp[i+1][j] = max(dp[i][j], dp[i][j - W[i]] + V[i])
            }
        }
    }

    return dp[N][M]
}


fun main(args: Array<String>) {
    val (N, M) = readListInt()
    val W = IntArray(N){0}
    val V = IntArray(N){0}
    for (i in 0 until N) {
        val (w, v) = readListInt()
        W[i] = w; V[i] = v
    }

    val ans = solveD(M, W.toList(), V.toList())

    println(ans)
}


Measured memory_bytes: 156084
#include<bits/stdc++.h>
using namespace std;
 
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000
 
 
ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a=(a * a) % MOD;
	}
	return res;
}
 
void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2;i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}
 
void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}
ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {1, 0, -1, 0};
 
ll BFS(vector<string>&a, ll n, ll m, ll i, ll j)
{
  vector< vector<bool> >vis(n, vector<bool>(m, false));
  vector< vector<ll> >dis(n, vector<ll>(m, LLMX));
  queue< pair<ll, ll> >q;
  dis[i][j] = 0;
  q.push({i, j});
  vis[i][j] = true;
  ll res = 0;
  while(!q.empty())
  {
    pair<ll, ll>temp = q.front();
    ll x = temp.first;
    ll y = temp.second;
    q.pop();
    for(ll c=0;c<4;c++)
    {
      ll xd = x+dx[c];
      ll yd = y+dy[c];
      
      if(xd >= 0 && xd < n && yd >= 0 && yd < m && a[xd][yd] == '.' && !vis[xd][yd])
      {
        dis[xd][yd] = min(dis[xd][yd], dis[x][y]+1);
        res = max(res, dis[xd][yd]);
        vis[xd][yd] = true;
        q.push({xd, yd});
      }
    }
    
  }
  return res;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k;
  string s;
  cin>>n>>m;
  vector<string>a(n);
  for(ll i=0;i<n;i++) cin>>a[i];
  ll res = LLMN;
  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<m;j++)
    {
      if(a[i][j] == '.')
      {
        res = max(res, BFS(a, n, m, i, j));
      }
    }
  }
  cout<<res;
  return 0;
}

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

ans = 0
while True:
    l,r = 0,0

    for i in range(len(h)):
        if h[i] != 0:
            l = i
            break

    if h.count(0) == len(h):
        break

    for i in range(l+1,len(h)):
        if h[i] == 0:
            r = i
            break
        if i + 1 == len(h):
            r = i+1

    if l == len(h) - 1:
        ans += h[-1]
        break



    for i in range(l,r):
        h[i] -= 1

    if l == r:
        h[l] -= 1

    ans += 1


print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
void need_enter() {
	while (getchar() != '\n');
	while (getchar() != '\n');
}
int main() {
	int N, Q;
	cin >> N >> Q;
	string str;
	cin >> str;
	str = " " + str;
	int *count = new int[N + 1];
	count[0] = 0;
	for (int i = 1; i <= N; ++i) {
		count[i] = count[i - 1];
		if (str.substr(i,2) == "AC") {
			++i;
			count[i] = count[i - 1] + 1;
		}
	}
	for (int i = 0; i < Q; ++i) {
		int a, b;
		cin >> a >> b;
		cout << count[b] - count[a] << endl;
	}
	return 0;
}

Measured memory_bytes: 1404