akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define  mp make_pair
#define  pb push_back
using namespace std;
bool comp(pair<int,int> a, pair<int,int> b) {
	if(a.second == b.second) {
		return a.first>b.first;
	}
	return a.second>b.second;
}
int main() {
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;++i) {
		cin>>a[i];
	}
	sort(a,a+n);
	vector<pair<int,int>> v;
	for(int i=0;i<m;++i) {
		int b,c;
		cin>>b>>c;
		v.pb(mp(b,c));
		
	}
	sort(v.begin(), v.end(),comp);
	int k=0;
	for(int i=0;i<n;++i) {
		if(k<m && v[k].first <= 0) {
			k++;
		}
		if(a[i]<v[k].second) {
			a[i] = v[k].second;
			v[k].first--;
		}
	}
	long long ans = 0;
	for(int i=0;i<n;++i) {
		ans += a[i];
	}
	cout<<ans;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a; cin>>a;
	string s; cin>>s;

	cout << ((a>=3200) ? s : "red") << "\n";
	return 0;
}

Measured memory_bytes: 764
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)

ans = 0
for i in 0..n-1
  atk = b[i]
  if a[i] <= atk
    ans += a[i]
    atk -= a[i]
  else
    ans += atk
    atk = 0
  end
  if a[i+1] <= atk
    ans += a[i+1]
    a[i+1] = 0
  else
    ans += atk
    a[i+1] -= atk
  end
end

puts ans

Measured memory_bytes: 17556
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
//#define int ll

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll btc = 30;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(2e9 + 239);
const int MOD = (int)(1e9 + 7); //998244353;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
mt19937_64 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 18;
const int T = (1 << 20);
const int B = 500;
const int X = 5e5 + 239;

int dp[two][X];

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        dp[0][i] = 1;
        if (i > 0 && s[i] == s[i - 1])
            dp[0][i] = dp[0][i - 1] + 1;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        dp[1][i] = 1;
        if (i + 1 < n && s[i] == s[i + 1])
            dp[1][i] = dp[1][i + 1] + 1;
    }
    ll ans = 0;
    if (s[0] == '>')
        ans += dp[1][0];
    if (s[n - 1] == '<')
        ans += dp[0][n - 1];
    for (int i = 0; i + 1 < n; i++)
    {
        int cur = 0;
        if (s[i] == '<')
            cur = max(cur, dp[0][i]);
        if (s[i + 1] == '>')
            cur = max(cur, dp[1][i + 1]);
        ans += cur;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4764
'''input
100000 1000000000
'''
from math import sqrt
def div(n):
	s = set()
	for i in range(1,int(sqrt(n))+1):
		if n%i == 0:
			s.add(i)
			s.add(n//i)
	return s
n,m = map(int,raw_input().split())
s = div(m)
aa = -1
for i in s:
	if i*n <= m:
		aa = max(aa,i)
print aa



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

int n, m;
bool done[10];
int map[256];
std::vector<char> check;
std::vector<std::string> list;
bool top[256];
int left;
int right;
int atom[256];
int btom[256];

int decode(const std::string & str) {
  int time = 1;
  int sum = 0;
  for (int i = str.length() - 1; 0 <= i; --i) {
    sum += map[str[i]] * time;
    time *= 10;
  }
  return sum;
}

bool ok() {
  int sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    sum += decode(list[i]);
  }
  return sum == decode(list[n - 1]);
}

int dfs(int depth) {
  if (depth == check.size()) {
    return left == right;
  }
  int cnt = 0;
  for (int i = 0; i < 10; ++i) {
    if (done[i]) {
      continue;
    }
    if (i == 0 && top[check[depth]]) {
      continue;
    }
    done[i] = true;
    map[check[depth]] = i;
    left += atom[check[depth]] * i;
    right += btom[check[depth]] * i;
    cnt += dfs(depth + 1);
    left -= atom[check[depth]] * i;
    right -= btom[check[depth]] * i;
    done[i] = false;
  }
  return cnt;
}

int main() {
  for (;;) {
    std::cin >> n;
    if (n == 0) {
      break;
    }
    list.clear();
    memset(atom, 0, sizeof(atom));
    memset(btom, 0, sizeof(btom));
    memset(top, 0, sizeof(top));
    std::set<char> set;
    for (int i = 0; i < n; ++i) {
      std::string str;
      std::cin >> str;
      list.push_back(str);
      for (char c : str) {
        set.insert(c);
      }
      int time = 1;
      for (int j = str.length() - 1; 0 <= j; --j) {
        if (i < n - 1) {
          atom[str[j]] += time;
        } else {
          btom[str[j]] += time;
        }
        time *= 10;
      }
      if (str.length() > 1) {
        top[str[0]] = true;
      }
    }
    check.clear();
    for (char c : set) {
      check.push_back(c);
    }
    memset(done, 0, sizeof(done));
    int ans = dfs(0);
    std::cout << ans << std::endl;
  }
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n; cin >> n;
	VI ans(n+1,0);
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				int p=i*i+j*j+k*k+i*j+j*k+k*i;
				if(p<=n)
					ans[p]++;
			}
		}
	}
	REP(i,n)
		cout << ans[i+1] << endl;
	return 0;
}

Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))
S = set()
_S = 0
for a in A:
    if a <= 399:
        S.add(0)
    elif 400 <= a <= 799:
        S.add(1)
    elif 800 <= a <= 1199:
        S.add(2)
    elif 1200 <= a <= 1599:
        S.add(3)
    elif 1600 <= a <= 1999:
        S.add(4)
    elif 2000 <= a <= 2399:
        S.add(5)
    elif 2400 <= a <= 2799:
        S.add(6)
    elif 2800 <= a <= 3199:
        S.add(7)
    else:
        _S += 1
print(max(1, len(S)), len(S) + _S)


Measured memory_bytes: 9100
import java.util.*;

public class Main {
    static int a,b;
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        a=scanner.nextInt();
        b=scanner.nextInt();
        solve();
    }
    public static void solve(){
        put((a-1)*(b-1));
    }

    public static void put(Object object){
        System.out.println(object);
    }
    public static String format(String string,Object... args){
        return String.format(string,args);
    }

    public static class Pair{
        final public int x,y;
        Pair(int x,int y){
            this.x=x;
            this.y=y;
        }
    }
}


Measured memory_bytes: 23124
<?php
list($K) = ints();
$sum6 = 0;
$sum1 = 0;
for($i = 1; $i <= $K; $i++)
for($j = 1; $j <= $K; $j++)
$memo[$i][$j] = $memo[$j][$i] = gcd($i, $j);

for($i = 1; $i <= $K; $i++)
for($j = $i+1; $j <= $K; $j++)
for($k = $j+1; $k <= $K; ++$k)
    $sum6+=$memo[$memo[$i][$j]][$k];

for($i = 1; $i <= $K; $i++)
for($j = $i+1; $j <= $K; $j++)
    $sum6+=$memo[$i][$j];

for($i = 1; $i <= $K; $i++)
    $sum1+=$i;

echo $sum6*6+$sum1;


function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 19004
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define LLINF 1145141919810LL
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, M, x, y; cin >> N >> M;
  vector<int> cnt(N, 1);
  vector<bool> red(N, 0); red[0] = 1;
  REP(i, M){
    cin >> x >> y;
    x--; y--;
    if(red[x]){
      if(cnt[x] > 1) red[y] = 1;
      else{
        red[x] = 0; red[y] = 1;
      }
    }
    cnt[x]--; cnt[y]++;
  }
  int ans = 0;
  REP(i, N) if(red[i]) ans++;

  cout << ans << endl;

}

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

bool is_over(int n, int ih, int iw, int h, int w) {
    if (ih + h > n) return false;
    if (iw + w > n) return false;
    return true;
}


int main() {
    int n, h, w;
    cin >> n;
    cin >> h;
    cin >> w;
    int counts = 0;
    for (int ih=0; ih<n; ih++) {
        for (int iw=0; iw<n; iw++) {
            if (is_over(n, ih, iw, h, w)) counts++;
        }
    }


    cout << counts << endl;
}

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

int main(){
  int sx, sy, gx, gy;
  cin >> sx >> sy >> gx >> gy;
  //ここまで入力

  //点Sと点Gのx, y座標に関する最短距離
  int X = gx-sx, Y = gy-sy;

  //点S, Gを対角とする長方形に沿って進む
  rep(i, Y)
    cout << "U" ;
  rep(i, X)
    cout << "R" ;
  rep(i, Y)
    cout << "D" ;
  rep(i, X)
    cout << "L" ;

  //点S, Gを対角とする長方形の一回り大きい長方形に沿って進む
  cout << "L" ;
  rep(i, Y+1)
    cout << "U" ;
  rep(i, X+1)
    cout << "R" ;
  cout << "DR" ;
  rep(i, Y+1)
    cout << "D" ;
  rep(i, X+1)
    cout << "L" ;
  cout << "U" << endl;
	    
  
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, K, Q;



int main() {
	ios::sync_with_stdio(false);
	cin >> N >> K >> Q;
	if ((N * 100 + K * 10 + Q) % 4)cout << "NO\n";
	else cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static long MOD = 1000000007L;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String S = in.readLine();
		long[][] dp = new long[S.length() + 1][13];
		dp[0][0] = 1;
		for (int i = 0; i < S.length(); ++i) {
			int c = S.charAt(i) == '?' ? -1 : Integer.parseInt(S.substring(i, i + 1));
			for (int j = 0; j < 10; ++j) {
				if (c != -1 && c != j) {
					continue;
				}
				for (int k = 0; k < 13; ++k) {
					dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
				}
			}
			for (int j = 0; j < 13; ++j) {
				dp[i + 1][j] %= MOD;
			}
		}
		System.out.println(dp[S.length()][5]);
	}
}


Measured memory_bytes: 51920
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap<String, Integer> b = new HashMap<String, Integer>();
        List<String> a = new ArrayList<String>();
        for(int i = 0; i < N; i++){
            String s = sc.next();
            if(b.containsKey(s)) b.put(s, b.get(s) +1);
            else{
                b.put(s, 1);
                a.add(s);
            }
        }
        int M = sc.nextInt();
        for(int i = 0; i < M; i++){
            String s = sc.next();
            if(b.containsKey(s)) b.put(s, b.get(s) -1);
        }
        int ans = 0;
        for(String s : a){
            ans = Math.max(ans, b.get(s));
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x,y,z,count1,count2;
		count1 = count2 = 0;
		
		while(sc.hasNext()){
			String[] integer = sc.next().split(",",0);
			
			x = Integer.parseInt(integer[0]);
			y = Integer.parseInt(integer[1]);
			z = Integer.parseInt(integer[2]);
			
			if((x * x) + (y * y) == (z * z))count1++;
			if(x == y)count2++;
		}
		System.out.println(count1);
		System.out.println(count2);
		
		sc.close();
	}
}

Measured memory_bytes: 17140
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        Map<Integer,Long> map = new TreeMap<>();
        for(int i = 0; i < n; i++) {
            int key = sc.nextInt();
            long value = sc.nextInt();
            if(map.containsKey(key)) {
                map.put(key, map.get(key) + value);
            }else {
                map.put(key, value);
            }
        }
        long sum = k;
        for(Entry<Integer, Long> entry : map.entrySet()) {
            long tmp = entry.getValue();
            if(sum > tmp) {
                sum -= tmp;
            } else {
                System.out.println(entry.getKey());
                return;
            }
        }
    }
}

Measured memory_bytes: 64864
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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 dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int a, b;
	cin >> a >> b;
	int n = b - a - 1;
	n = (1 + n) * n / 2;
	cout << n - a << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll h,w;

int main(){
  ll ans=0;
  cin >> h >> w;

  vvi dp(w, vi(h,201));


  vvi data(w, vi(h,0));
  string s;
  REP(i,h){
    cin>>s;
    REP(j,w){
      if (s[j]=='#'){
        data[j][i]=1;
      }
    }
  }


  /*
  
  REP(i,h){
    REP(j,w){
      cout<<data[j][i];
    }
    cout<<endl;
  }
  */
  dp[0][0]=0;

  REP(i,h+w-1){
    
    REP(j,h){
      REP(k,w){
        if (j+k==i){
          if (k!=0){
            dp[k][j]=min(dp[k-1][j]+(data[k-1][j]!=data[k][j]),dp[k][j]);
            
          }
          if (j!=0){
            dp[k][j]=min(dp[k][j-1]+(data[k][j-1]!=data[k][j]),dp[k][j]);
          }
          break;
        }
        else
        {
          continue;
        }
      }

    }
  }

  ans=dp[w-1][h-1];
  if (ans!=-1){
    if (ans%2==1){
      ans=(ans+1)/2;
    }else{
      ans=ans/2+data[0][0];
    }
  }
  cout<<ans<<endl;




  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
typedef struct tuple{ll x,w,id;}E;
int psort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).x<(*q).x)return -1;
	if((*p).x>(*q).x)return  1;
	//以下を処理するのは「ちょうどL秒経過した瞬間にすれ違う2匹」を比較するとき
	//すれ違い回数のカウントでは、ちょうどのときを回数にカウントしているので
	//時計回りの方が+ε、反時計周りの方が-εにいると考えて良い
	if((*p).w>(*q).w)return -1;
	return 1;
}

ll n,L,T;
ll x[100010],w[100010];
E ans[100010];
int main(){
	scanf("%lld%lld%lld",&n,&L,&T);
	rep(i,0,n)scanf("%lld%lld",x+i,w+i);
	//L秒後の蟻の位置のなす集合
	rep(i,0,n){
		if(w[i]==1){
			ans[i].x=(x[i]+T)%L;
		}else{
			ans[i].x=((x[i]-T)%L+L)%L;
		}
		ans[i].w=w[i];
		ans[i].id=i;
	}
	qsort(ans,n,sizeof(E),psort);
	
	ll cnt=0;
	rep(i,1,n)if(w[0]!=w[i]){
		//大体L/2秒ごとにすれ違う
		cnt+=T/L*2;
		//残りのT%L秒で高々2回すれ違う
		if(w[0]==1){
			if(x[i]-x[0]<=T%L*2)cnt++;
			if(x[i]-x[0]+L<=T%L*2)cnt++;
		}else{
			if(L-(x[i]-x[0])<=T%L*2)cnt++;
			if(L-(x[i]-x[0])+L<=T%L*2)cnt++;
		}
		cnt%=n;
	}
	
	//最初に0番のゼッケンの蟻はcnt匹とすれ違ったので(w[0]==1?cnt:-cnt)番のゼッケンをつけている
	//ans[offset].id==0なるものがそうなので、0番目はans[offset-(w[0]==1?cnt:-cnt)].xにいる
	ll offset=0;
	rep(i,0,n)if(ans[i].id==0){
		offset=i;
		break;
	}

	if(w[0]==1){
		rep(i,0,n)printf("%lld\n",ans[(i+offset-cnt+n)%n].x);
	}else{
		rep(i,0,n)printf("%lld\n",ans[(i+offset+cnt+n)%n].x);
	}
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
typedef long long int unsigned lliu;
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

void suma(vlli &total, vi &sum){
	forn(i, sum.size())
		total[i]+=sum[i];
}

bool checa(vlli &total, int x){
	forn(i, total.size())
		if(total[i]<x)
			return false;
	return true;
}

int main(){
	fastIO
	int n, m, x;
	cin>>n>>m>>x;
	vvi v(n, vi(m));
	vi costos(n);
	forn(i, n){
		cin>>costos[i];
		forn(j, m)
			cin>>v[i][j];
	}
	lli res=1e18, cost;
	for(int mask = (1<<n)-1; mask>=0; mask--){
		cost=0;
		vlli total(m, 0);
		forn(i, n){
			if((1<<i) & mask){
				suma(total, v[i]);
				cost+=costos[i];
			}
		}
		if(checa(total, x))
			res=min(cost, res);
	}
	if(res!=1e18)
		cout<<res<<endl;
	else
		cout<<"-1\n";


	
	return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<algorithm>
#include<cmath>
#define N 200050
#define Pi acos(-1.0) 

using namespace std;
 
struct dot{int x, y;} d[N]; int cnt;
int q[N], len;
int n;
double ans;
bool rev;
 
bool cmp(dot a, dot b){return a.x < b.x;}
 
int main(){
	int x, y, i, x1, y1, x2, y2, l, r, mid, t;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	if(x2 < x1){swap(x1, x2); swap(y1, y2);}
	if(y1 > y2){y1 = -y1; y2 = -y2; rev = 1;} 
	
	scanf("%d", &n);
	for(i = 1; i <= n; ++i){
		scanf("%d %d", &x, &y);
		if(rev) y = -y;
		if(x >= x1 && x <= x2 && y >= y1 && y <= y2)
			d[++cnt] = (dot){x, y};
	}
	//for(i = 1; i <= cnt; ++i) printf("%d %d\n", d[i].x, d[i].y);
	
 
	sort(d + 1, d + cnt + 1, cmp);
	for(i = 1; i <= cnt; ++i){
		l = 1; r = len; t = 0;
		while(l <= r){
			mid = l + r >> 1;
			if(d[i].y > q[mid]) l = (t = mid) + 1; else r = mid - 1;
		}
		if(t == len) q[++len] = d[i].y; else q[t+1] = min(q[t+1], d[i].y);
	}
	
	ans = (x2 - x1 + y2 - y1) * 100.0;
	if(x1 == x2 || y1 == y2){
		if(cnt) ans += 10.0 * Pi - 20.0;
	} else{
		ans-= (20.0 - 5.0 * Pi) * len;
		if(len == min(x2 - x1, y2 - y1) + 1) ans += 5 * Pi;
	}
	printf("%.13lf\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int m,d; cin>>m>>d;
    int ans = 0;
    rep(i,m){
        int month = i+1;
        rep(j,d){
            int day = j+1;
            if(day>=10){
                string s = to_string(day);
                if(s[0] - '0'<2||s[1]-'0' <2) continue;
                int x = (s[0] -'0')*(s[1]-'0');
                if(x == month) ans++; 
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  int n = in() ;
  if(n % 1000) cout << 1000 - n % 1000 << endl ;
  else cout << 0 << endl ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){  a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,d;
      cin>>n>>d;
      d=2*d;
      d++;
      cout<<(n/d)+(n%d>0?1:0);
}
// I never lose. I either win or I learn

Measured memory_bytes: 256
import math
from itertools import product
x = int(input())
limit = 10**5
sosu = -1
flag = 1
i = x
while True:
  for j in range(2, int(math.sqrt(i))+1):
    if (i%j)==0:
      flag = 0
      break
  if flag:
    sosu = i
    break
  else:
    i += 1
    flag = 1
print(sosu)

Measured memory_bytes: 3064
N = int(input())
Num = [int(i) for i in input().split()]

Max = Num[0]
Min = Num[0]
cnt  = 1
for i in range(1,N):
    if Num[i] <= Max and  Min>=Num[i] :
        cnt +=1
        
    Max = max(Max,Num[i])
    Min = min(Min,Num[i])
    #print(Max,Min)
print(cnt)


Measured memory_bytes: 24744
abc=list(reversed("bcdefghijklmnopqrstuvwxyza"))
s=list(input())
K=int(input())
S=[]
for i in s:
  S.append(abc.index(i))

for i in range(len(S)):
  if S[i]<=K:
    K-=S[i]
    S[i]=0
    
if K>0:
  S[-1]-=K%26
  
if S[-1]<0:
  S[-1]=26+S[-1]
  
ans=[]
for i in S:
  ans.append(abc[i])
  
print("".join(ans))

Measured memory_bytes: 5688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>



int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int c=b-a-1;
    int ans=(1+c)*c/2-a;
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]

k, v = list(Counter(a).keys()), list(Counter(a).values())
if len(k) == 3 and k[0] ^ k[1] == k[2] and v[0] == v[1] == v[2] :
    print('Yes')
elif len(k) == 2 and ((k[0] == 0 and v[0] * 2 == v[1]) or (k[1] == 0 and v[1] * 2 == v[0])) :
    print('Yes')
elif len(k) == 1 and k[0] == 0 :
    print('Yes')
else :
    print('No')


Measured memory_bytes: 106952
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    ll n, a[100010];
    map<ll, int> mp;
    vector<ll> v;
    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
        if (mp[a[i]] % 2 == 0)
        {
            v.push_back(a[i]);
        }
    }

    SORT(v);

    ll ans = 0;
    if (v.size() < 2)
        ans = 0;
    else
        ans = v[v.size() - 1] * v[v.size() - 2];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7296
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int INF=1<<29;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	for(int h,w;scanf("%d%d",&w,&h),h;){
		int hor[50][50],ver[50][50];
		rep(i,h){
			rep(j,w-1) scanf("%d",ver[i]+j);
			if(i<h-1){
				rep(j,w) scanf("%d",hor[i]+j);
			}
		}

		int d[50][50];
		rep(i,h) rep(j,w) d[i][j]=INF;
		d[0][0]=1;
		rep(_,h*w){
			rep(i,h) rep(j,w) rep(k,4) {
				int y=i+dy[k],x=j+dx[k];
				if(k==0 && ver[ i ][ j ]==0
				|| k==1 && hor[i-1][ j ]==0
				|| k==2 && ver[ i ][j-1]==0
				|| k==3 && hor[ i ][ j ]==0) d[y][x]=min(d[y][x],d[i][j]+1);
			}
		}
		printf("%d\n",d[h-1][w-1]<INF?d[h-1][w-1]:0);
	}

	return 0;
}

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

using namespace std;

void Main() {
    long long N, K;
    cin >> N >> K;

    if (K == 0) {
        cout << N * N << endl;
        return;
    }
    long long ans = 0;
    for (long long b = K + 1; b <= N; ++b) {
        ans += (b - K) * (N / b);
        if (N % b != 0) {
            long long begin = b * (N / b) + K;
            long long end = N + 1;
            ans += max(0LL, end - begin);
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return a;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

int main(void){
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<std::setprecision(10)<<1.0*w*h/2.0<<" ";
	cout<<(w/2.0 == x && h/2.0 == y ? 1 : 0) <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n1,n2) for(int i=n1;i<n2;i++)
using namespace std;
typedef long long ll;

int main() {
    ll n,m;
    cin >> n >> m;
    ll res = abs((n-2)*(m-2));
    cout << res << endl;
    /*vector<pair<int,int>> pair1(n);
     vector<pair<int,int>> pair2(n);
     REP(i,n){
     int a,b;
     cin >> a >> b;
     pair1[i] = make_pair(a,b);
     }
     REP(i,n){
     int c,d;
     cin >> c >> d;
     pair2[i] = make_pair(c,d);
     }
     
     sort(pair1.begin(),pair1.end());
     sort(pair2.begin(),pair2.end());
     REP(i, n){
     cout << pair1[i].first << pair1[i].second <<endl;
     }
     int maxn = -1;
     int cand = -1;
     REP(i,n){
     REP(j,n){
     if(pair1[i].first<pair2[j].first){
     if(pair1[i].second>maxn){
     cand = i;
     }
     }
     }
     }
     /*REP(i, n){
     cout << pairs[i].first << pairs[i].second <<endl;
     }
     /*int n;
     int res = 100000;
     cin >> n;
     //vector<int> x(n);
     REP2(i,1,n/2+1){
     res = min(res,psum(i)+psum(n-i));
     if(psum(i)+psum(n-i)==1){
     cout << "i:" << i <<endl;
     }
     }
     cout << res << endl;*/
    return 0;
}




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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        if(a > m) continue;
        jobs[m-a].push_back(b);
    }
    
    priority_queue<int> q;
    int ans = 0;
    for(int i=m-1;i>=0;i--){
        // cout << i << endl;
        for(int b : jobs[i]) q.push(b);
        if(!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5504
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

const long double pi=3.141592653;
const long double p=360;

int main(){
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	double l=0,r=90;
  double ax=(double)x/a;
	if((x*2)<=(a*a*b)){
		while(r-l>0.00000001){
			double mid=(l+r)/2;
			double si=sin(2*pi*mid/p);
			double co=cos(2*pi*mid/p);
			double cta=co/si;
			if(b*b*cta>=2*ax)l=mid;
			else r=mid;
    //      printf("%.8lf\n",mid);
	}
	}else{
     	while(r-l>0.00000001){
			double mid=(l+r)/2;
			double si=sin(2*pi*mid/p);
			double co=cos(2*pi*mid/p);
			double ta=si/co;
			if((double)a*a*ta<=((double)b*a-ax)*2)l=mid;
			else r=mid;
        //  printf("%.8lf\n",a*a*ta);
	}
    }
  printf("%.10lf\n",r);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import bisect

while(True):
    try:
        *ls,v1,v2 = list(map(int,stdin.readline().split(",")))
        rs = [sum(ls[:i+1]) for i in range(len(ls))]
        idx = bisect.bisect_left(rs,rs[-1]*v1/(v1+v2))
        print(idx+1)
    except:
        break


Measured memory_bytes: 5644
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut counter = 0u32;
    for &num in a.iter() {
        if num == counter + 1 {
            counter += 1
        }
    }
    println!(
        "{}",
        if counter != 0 {
            (n as u32 - counter) as i32
        } else {
            -1
        }
    );
}


Measured memory_bytes: 4060
// inputに入力データ全体が入る
function Main(input) {

    input = input.split("\n");
  
   let N = parseInt(input[0], 10);

    let line = input[1].split(" ");

    let cur = 0;
    let next = 0;

    let stock = 0;
    let money = 1000;
    for (let i = 1; i < N; i++) {
        cur = parseInt(line[i-1], 10);
        next = parseInt(line[i], 10);

        stock = 0;
        if (cur < next) {
            stock = Math.trunc(money / cur);
        }
        money += (next - cur) * stock;

    }
    
	//出力
	console.log('%d',money);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29584
N,Q=map(int,input().split())
S=input()+' '
TD=[input().split() for _ in [0]*Q]
def ith_move(i):
    k=i
    for t,d in TD:
        if S[k]==t:
            k+=1 if d=='R' else -1
        if k==-1 or k==N:return k
    return k
#print([(i,ith_move(i)) for i in range(N)])

low=0; high=N; L=(high+low)//2 #左に落ちる一番右を探索
while low<=high:
    fall = ith_move(L)==-1
    #print(f"L [{low}, {high}); {L}:{fall}")
    if low==high: L = high if fall else high-1; break
    if fall: low = L+1
    else: high = L-1
    L = (high+low)//2

low=0; high=N; R=(high+low)//2 #右に落ちない一番右を探索
while low<=high:
    fall = ith_move(R)==N
    #print(f"R [{low}, {high}); {R}:{fall}")
    if low==high: R = high-1 if fall else high; break
    if fall: high = R-1
    else: low = R+1
    R = (high+low)//2

#print(L,R)
print(R-L)

Measured memory_bytes: 41364
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def ok(li):
    for i in range(len(li) - 1):
        if li[i] > li[i + 1]:
            return False
    return True


def print_ans(start):
    print(N * 2)
    for y in range(start, N):
        x = max(start, y - 1)
        print(x + 1, y + 1)
        print(x + 1, y + 1)
    for y in reversed(range(0, start)):
        x = min(start - 1, y + 1)
        print(x + 1, y + 1)
        print(x + 1, y + 1)


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

for start in range(N + 1):
    result = A.copy()
    # 右に足してく
    for y in range(start, N):
        x = max(start, y - 1)
        result[y] += result[x] * 2
    # 左に足してく
    for y in reversed(range(0, start)):
        x = min(start - 1, y + 1)
        result[y] += result[x] * 2
    if ok(result):
        print_ans(start)
        break


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(){
	char str;
	cin >> str;
	if(str == 'a' || str == 'e' || str == 'i' ||str == 'u' || str == 'o') cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}

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

int main(){

  char a,b;
  cin >> a>>b;
   int i=0;
  if(a<=b){
   
   while(i<b-'0'){ cout <<a;
    i++;
             }
  }
  else{
   while(i<a-'0'){  cout <<b;
         i++;
             }         
  }
  cout << endl;
}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    if(N>=1000){
        N=N-999;
        if(N<10) cout<<"ABD"<<endl;
        else if(N<100) cout<<"ABD"<<endl;
        else if(N<1000) cout<<"ABD"<<endl;
    }else{
        if(N<10) cout<<"ABC"<<endl;
        else if(N<100) cout<<"ABC"<<endl;
        else if(N<1000) cout<<"ABC"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		int ans = 0;
		while(N>0) {
			N/=K;
			ans++;
		}
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
import heapq

n, m = map(int, input().split())
l = [[] for _ in range(m)]
 
for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        l[a-1].append(b)

a = []
ans = 0

for i in range(m):
    for j in l[i]:
        heapq.heappush(a, (-1) * j)
    if a:
        ans += heapq.heappop(a) * (-1)
        
print(ans)


Measured memory_bytes: 18504
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int I,O,T,J,L,S,Z;
	cin>>I>>O>>T>>J>>L>>S>>Z;
	
	ll ans = 0;
	ans+=O*2;
	
	if(I>2){
		if(I%2==0){
			ans+=(I-2)/2*4;
			I = 2;
		}else{
			ans+=(I-1)/2*4;
			I = 1;
		}
	}

	if(J>2){
		if(J%2==0){
			ans+=(J-2)/2*4;
			J = 2;
		}else{
			ans+=(J-1)/2*4;
			J = 1;
		}
	}

	if(L>2){
		if(L%2==0){
			ans+=(L-2)/2*4;
			L = 2;
		}else{
			ans+=(L-1)/2*4;
			L = 1;
		}
	}
	
	int c=0;
	if(I==2)c++;
	if(J==2)c++;
	if(L==2)c++;
	
	if(c<=1 && I&&J&&L){
		ans+=6;
	}else{
		ans+=4*c;
	}
	
	cout<<ans/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	string a;
	cin>>n>>m;
	cin>>a;
	if(a[n]!='-')
	{
		cout<<"No"<<'\n';
		return 0;
	}
	for(int i=0;i<n+m+1;i++)
	{
		if(i!=n&3&a[i]<48||a[i]>57)
		{
			cout<<"No"<<'\n';
			return 0;
		}
	}
	cout<<"Yes"<<'\n';
	return 0;
}

Measured memory_bytes: 256
class Levenshtein:
#ここで配列を立ち上げて、初期値を入れる
    def initArray(self,str1,str2):
        distance = []
        for i in range(len(str1)+1):
            distance.append([0]*(len(str2)+1))
            distance[i][0] = i
        for j in range(len(str2)+1):
            distance[0][j] = j
        return distance
#セルに値を入れる
    def editDist(self,str1,str2,distance):
        dist = [0]*3
        for i in range(1,len(str1)+1):
            for j in range(1,len(str2)+1):
                dist[0] = distance[i-1][j-1] if str1[i-1]==str2[j-1] else distance[i-1][j-1]+1
                dist[1] = distance[i][j-1]+1
                dist[2] = distance[i-1][j]+1
                distance[i][j]=min(dist)
        return distance[i][j]

    def __init__(self,str1,str2):
        self.str1 = str1
        self.str2 = str2
        Levenshtein.distance = self.initArray(str1,str2)
        Levenshtein.dist = self.editDist(str1,str2,Levenshtein.distance)

if __name__ == '__main__':
    str1 = input()
    str2 = input()
    leven = Levenshtein(str1,str2)
    print(leven.dist)


Measured memory_bytes: 41972
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    map<ll, vector<ll>> party;
    for (ll i = 0; i < N; i++) {
        ll pt = A[i] - i;
        party[pt].push_back(i);
    }

    ll result = 0;
    for (ll i = 0; i < N; i++) {
        ll tgtp = -i - A[i];
        if (party.count(tgtp)) {
            result += party[tgtp].end() - upper_bound(party[tgtp].begin(), party[tgtp].end(), i);
        }
    }
    print(result);
}


Measured memory_bytes: 24984
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int N; cin >> N;
	string S[2];
	cin >> S[0] >> S[1];
	vector<bool> V;
	for (int i = 0; i < N; i++) {
		if (i < N - 1 && S[0][i] == S[0][i + 1]) {
			V.push_back(false);
			i++;
		}
		else V.push_back(true);
	}
	bool befo = V[0]; // 前が縦
	ll ans;
	if (befo) ans = 3;
	else ans = 6;
	for (int i = 1; i < V.size(); i++) {
		if (befo) {
			ans *= 2;
			ans %= MOD;
			befo = V[i];
		}
		else {
			if (V[i]) befo = V[i];
			else {
				ans *= 3;
				ans %= MOD;
				befo = V[i];
			}
		}
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int A;
	int B;
	scanf("%d%d", &A, &B);
	if(A >= 10 || B >= 10) printf("-1\n");
	else if(A < 1 || B < 1)printf("-1\n");
	else printf("%d\n", A * B);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %f\n",d,r,f);
   return 0;
 }

Measured memory_bytes: 1064
d = {}

def bfs(graph, start, goal): 
#These variables define the visited set (to make sure that the program doesn’t go through the same nodes twice) a queue to make sure that the node seen next is visted first. 
 
    visited, queue = set(), [start] 
    pathsTo = {} 
    pathsTo[start] = [start] 
    index = 0
    lenqueue = 1
# Ensuring that the queue is not empty at any point in time. 
    while index < lenqueue: 
# Getting the next node and getting rid of the node in the front of the queue. 
        vertex = queue[index] 
        if vertex not in visited: 
            visited.add(vertex) 
 
 
            # Going through each element in the adjacency list and making sure that it hasn’t been visited, and that it is not in the same path. 
            for newVertex in (graph[vertex]): 
                if newVertex not in visited: 
                    if newVertex not in pathsTo: 
                        pathsTo[newVertex] = list() 
 
                    for path in pathsTo[vertex]: 
                        pathsTo[newVertex].append(str(path)+"->"+str(newVertex)) 
                    queue.append(newVertex)
                    lenqueue += 1
        index += 1
    # Return the paths toward the goal.
    if goal not in pathsTo.keys():
        return ["8384793->8->4->7-> 9 8 23748"]
    return pathsTo[goal] 

N, M = map(int,input().split())
for i in range(M):
    a,b = map(int,input().split())
    if a not in d.keys():
        d[a] = [b]
    else:
        d[a].append(b)

    if b not in d.keys():
        d[b] = [a]
    else:
        d[b].append(a)

dist = len(bfs(d,1,N)[0].split("->")) - 1
if dist <= 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 149296
#include <iostream>
#include <algorithm>
#include <map>
#include <functional>
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;

int main(){
	int n,m;
	while(cin >> n >> m,n||m){
		P p[10000];
		for(int i = 0; i < n; i++) cin >> p[i].sec >> p[i].fi;
		sort(p,p+n,greater<P>());
		for(int i = 0; i < n; i++){
			if(p[i].sec >= m){
				p[i].sec -= m;
				break;
			}
			m -= p[i].sec;
			p[i].sec = 0;
		}
		int ans = 0;
		for(int i = 0; i < n; i++) ans += p[i].fi*p[i].sec;
		cout << ans << endl;
	}
}

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

#define MAX_N 100009

using namespace std;

int n;

typedef long long lint;

lint rez = 0;
lint sum1[MAX_N + 1];
lint sum2[MAX_N + 1];
lint mx2[MAX_N + 1];
lint mx1[MAX_N + 1];
lint mx12[MAX_N + 1];
lint mx22[MAX_N + 1];

lint d[MAX_N + 1];
lint cal[MAX_N + 1];

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

    int i;
    lint rez = 0;
    for(i = 1; i <= n; i ++)
    {
        cin >> d[i] >> cal[i];

        sum1[i] = sum1[i - 1] + cal[i] - (d[i] - d[i - 1]);
        if(i > 1)
            mx1[i] = max(mx1[i - 1], sum1[i]);
        else
            mx1[i] = sum1[i];

        if(i > 1)
            mx12[i] = max(mx12[i - 1], sum1[i] - d[i]);
        else
            mx12[i] = sum1[i] - d[i];

        rez = max(rez, sum1[i]);
    }

    sum2[n] =  - (C - d[n]) + cal[n];
    mx2[n] = sum2[n];
    mx22[n] = sum2[n] - (C - d[n]);
     rez = max(rez, sum2[n]);
    for(i = n - 1; i >= 1; i --)
    {
        sum2[i] = sum2[i + 1] + cal[i] - (d[i + 1] - d[i]);
        mx2[i] = max(sum2[i], mx2[i + 1]);
        rez = max(rez, sum2[i]);

        mx22[i] = max(mx22[i + 1], sum2[i] - (C - d[i]));
    }


    for(i = n - 1; i >= 1; i --)
    {
        rez = max(rez, sum1[i] + mx2[i + 1] - d[i]);
        rez = max(rez, sum1[i] + mx22[i + 1]);
    }

    for(i = 2; i <= n; i ++)
    {
        rez = max(rez, sum2[i] + mx1[i - 1] - d[i - 1]);
        rez = max(rez, sum2[i] + mx12[i - 1]);
    }


    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 6528