akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a%b);
}

int main(void) {
	long long p, q, r;
	while (cin >> p >> q) {
		if (p < q) {
			swap(p, q);
		}
		r = gcd(p, q);
		cout << r << ' ' << p*q / r << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

def main():
    N = i2n()
    L = i2nn()
    lsum = 0
    lmax = 0
    for l in L:
        lsum += l
        if lmax < l:
            lmax = l
    if lsum - lmax > lmax:
        print('Yes')
    else:
        print('No')

main()


Measured memory_bytes: 9484
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  var w = ""

  def shuffle(cnt:Int, w:String):String =
    if(cnt == 0)  w else { val m = readInt;shuffle(cnt-1, (w drop m)+(w take m)) }

  def exec(w:String):Unit =
    if(w=="-") return else { val n = readInt;println(shuffle(n,w));exec(readLine) }

  exec(readLine.trim)
}

Measured memory_bytes: 43948
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  vector <long long  int> lucas(100,0);
  long long  int a[100],tmp;
  a[0] = 2,a[1]=1;
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for(int i = 2;i<100;i++){
    a[i] = a[i-1] + a[i-2];
    lucas.at(i) = a[i];
  }
  int c;
  cin >> c;
  cout << lucas.at(c);
}

Measured memory_bytes: 3600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        string s = (Console.ReadLine());
        Console.WriteLine(s.Last() == '3' ? "bon" : new[] { '0', '1', '6', '8' }.Contains(s.Last()) ? "pon" : "hon");
    }
}

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

int main() {
    int N; string S; int Q;
    cin >> N >> S >> Q;

    while(Q--) {
        int k; cin >> k;
        long long d = 0, m = 0, dm = 0, res = 0;
        for(int i=0; i<N; ++i) {
            if(i - k >= 0) {
                if(S[i - k] == 'D') d -= 1, dm -= m;
                if(S[i - k] == 'M') m -= 1;
            }
            if(S[i] == 'D') d += 1;
            if(S[i] == 'M') dm += d, m += 1;
            if(S[i] == 'C') res += dm; 
        }
        cout << res << '\n';
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,M,A[202020];
ll i, j, k;
vector<ll> uvv[202020];
ll anss[202020];
ll mk[202020];

void dfs(ll a,ll p){
    anss[a] = anss[p];
    ll ii = lower_bound(mk, mk + N, A[a]) - mk;
    ll mkmem = mk[ii];
    mk[ii] = A[a];
    if(mkmem==1e18){
        ++anss[a];
    }
    ll i;
    fornum(i,0,uvv[a].size()){
        ll b = uvv[a][i];
        if(b==p)
            continue;
        dfs(b, a);
    }
    mk[ii]=mkmem;
}

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i+1]);
    }
    fornum(i,1,N){
        ll u, v;
        scanf("%lld%lld", &u, &v);
        uvv[u].push_back(v);
        uvv[v].push_back(u);
    }
    fornum(i,0,N){
        mk[i] = 1e18;
    }

    dfs(1, 0);
    fornum(i,0,N){
        printf("%lld\n", anss[i + 1]);
    }
    
    return 0;
}

Measured memory_bytes: 33856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    ll ans = 1;
    ll cnt = 0;
    ll mode = 0;
    rep(i, n){
        cin >> a[i];
        cnt++;
        if(cnt >= 2 && mode == 0 && a[i] != a[i-1]){
            mode = (a[i] > a[i-1] ? 1 : -1);
        }else if(mode != 0 && ((a[i] > a[i-1] && mode == -1) || (a[i] < a[i-1] && mode == 1))){
            mode = 0;
            cnt = 1;
            ans++;
        }
        dump(ans, cnt, mode);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	arr := make([]string, 3)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &arr[0])
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &arr[1])
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &arr[2])

	fmt.Print(strings.Split(arr[0], "")[0])
	fmt.Print(strings.Split(arr[1], "")[1])
	fmt.Println(strings.Split(arr[2], "")[2])
}


Measured memory_bytes: 640
// 解答不能.
// 以下のソースコードを勉強する.
// pekempey氏.
// https://atcoder.jp/contests/abc141/submissions/7549014
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;
char c[5005];

int main(){
    int N;
    scanf("%d %s", &N, c);
    string S(c);
    vector<int> sa(N + 1); rep(i, N + 1) sa[i] = i;
    sort(range(sa), [&](int i, int j) {
        return S.substr(i) < S.substr(j);
    });
    vector<int> lcp(N + 1);
    rep(i, N){
        int h = 0;
        while(sa[i] + h < N && sa[i + 1] + h < N && S[sa[i] + h] == S[sa[i + 1] + h]) h++;
        lcp[i] = h;
    }
    
    int l = 0, r = N;
    while(r - l > 1){
        int m = (l + r) / 2;
        int i = 0;
        bool any = false;
        while(i < N){
            int mn = sa[i];
            int mx = sa[i];
            while(i < N && lcp[i] >= m){
                i++;
                mn = min(mn, sa[i]);
                mx = max(mx, sa[i]);
            }
            any |= mx - mn >= m;
            i++;
        }
        if(any) l = m;
        else    r = m;
    }
    printf("%d\n", l);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll ans=0;
    string s1,s2;
    cin>>s1>>s2;
    for(ll i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[i])
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3800
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s, t;
	cin >> s >> t;
	rep(i, s.size()){
		s = s.substr(1, (int)s.size() - 1) + s[0];
		if(s == t){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
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 ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  char s;
  cin >> s;
  cout << (s > 91 ? "a" : "A") << endl;
}

Measured memory_bytes: 3584
n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    if C[a] > 0:
        tmp = 2
        while a * tmp <= maxA:
            D[a * tmp] = 1
            tmp += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 203556
n,k=map(int,input().split())
a_b=[[0,0,0]]
for i in range(n):
    a,b=map(int,input().split())
    a_b.append([a,b,b])
a_b.sort(key=lambda x: x[0])
for i in range(n):
    a_b[i+1][2]+=a_b[i][2]
for i in range(len(a_b)):
    if a_b[i][2]<k<=a_b[i+1][2]:
        print(a_b[i+1][0])
        exit()


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,M,R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    rep(i,R) {
        int a;
        cin >> a;
        a--;
        r[i] = a;
    }
    sort(r.begin(),r.end());
    
    vector<vector<ll>> C(N,vector<ll> (N,INF));

    rep(i,M) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        C[a][b] = c;
        C[b][a] = c;
    }

    rep(k,N) {
        rep(i,N) {
            rep(j,N) {
                C[i][j] = min(C[i][j], C[i][k]+C[k][j]);
            }
        }
    }

    ll ans = INF;
    do {
        ll tmp = 0;
        rep(i,r.size()-1) {
            tmp += C[r[i]][r[i+1]];
        }
        ans = min(ans,tmp);
    } while (std::next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001
 
int X[4]={1,-1,0,0};
int Y[4]={0,0,1,-1};
bool vis[1001][1001]={};
char arr[1001][1001];
int h,w;
int cal[1001][1001]={};
 
bool valid(int x,int y){
    if(x<0 || y<0 || x>=h || y>=w || arr[x][y]=='#' || vis[x][y]){
        return 0;
    }
    return 1;
}
 
int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    string s;
	    cin >> s;
	    ll temp=0;
	    for(int i=0 ; i<s.length() ; i++){
	        temp+=s[i]-'0';
	    }
	    if(temp%9==0){
	        cout << "Yes" << endl;
	    }else{
	        cout << "No" << endl;
	    }
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,k,x,y;cin>>n>>k>>x>>y;

  if(n<=k)out(n*x)
  else out(k*x+(n-k)*y)

  return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];
	sort(a.rbegin(), a.rend());

	ll res = a[0];
	int cnt = 1;
	int i = 1;
	while (true) {
		if (cnt == n - 1) break ;
		res += a[i];
		cnt++;
		if (cnt == n - 1) break ;
		res += a[i];
		cnt++;
		i++;
	}
	cout << res << '\n';
    return 0;
}


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

int main(){
  long long N;
  cin >> N;
  long long loop,ans=1;
  for(loop=0;loop<N;loop++){
    ans = (ans*(loop+1))%1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a = [int(input()) for i in range(m)]
broken = set(a)
dp=[0]*(n+1)
mod = 10**9 + 7

for i in range(n,-1,-1):
  if i in broken:
    continue
  elif i==n or i==n-1:
    dp[i]=1
  else:
    dp[i]=dp[i+1]+dp[i+2]
print(dp[0]%mod)

Measured memory_bytes: 460020
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

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)*}};}
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)*}};}
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, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: usize
    }

    let mut ans = 0;

    println!("{}", a + a * a + a * a * a);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2232
uses math;
const fi='digitnum.inp';
      fo='digitnum.out';
      maxn=10000;
      modu=trunc(1e9)+7;
var f:array[1..maxn,0..99,0..2] of uint64;
    s:ansistring;
    d,len:int16;
procedure nhap;
begin
   readln(s);
   read(d);
end;
procedure init;
var i,j,x:int32;
begin
   x:=ord(s[1])-48;
   for i:=1 to 9 do
    begin
       if i<x then j:=0
       else if i>x then j:=2
       else j:=1;
       inc(f[1,i mod d,j]);
    end;
end;
function calc(n:ansistring):uint64;
var i,j,r,st,x,newst,newr:int32;
    ans:uint64;
begin
   len:=length(n);
   for i:=1 to len-1 do
    for r:=0 to d-1 do
     for st:=0 to 2 do
      begin
         x:=ord(n[i+1])-48;
         for j:=0 to 9 do
          begin
             newst:=st;
             if newst=1 then
              begin
                 if j<x then newst:=0
                 else if j>x then newst:=2
                 else newst:=1;
              end;
             newr:=(r+j) mod d;
             f[i+1,newr,newst]:=(f[i+1,newr,newst]+f[i,r,st]) mod modu;
          end;
      end;
   ans:=0;
   for i:=1 to len-1 do
    for j:=0 to 2 do inc(ans,f[i,0,j]);
   exit((ans+f[len,0,0]+f[len,0,1]) mod modu);
end;

procedure xuli;
begin
   init;
   write(calc(s));
end;
begin
//   assign(input,fi); reset(input);
//   assign(output,fo); rewrite(output);
   nhap;
   xuli;
//   close(input); close(output);
end.


Measured memory_bytes: 23680
# -*- coding: utf-8 -*-
import sys
N,M=map(int, sys.stdin.readline().split())

par=[ i for i in range(N+1) ]
size=[ 1 for i in range(N+1) ]

#Union Find
def root(x):
    while par[x]!=x:
        x=par[x]
    return x

def same(x,y):
	return root(x)==root(y)

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y: return
    if size[y]<size[x]: x,y=y,x  #yの要素数を大きくする
    size[y]+=size[x]
    par[x]=y #yが親ノード

def getsize(x):
	return size[root(x)]

for _ in range(M):
    a,b=map(int, sys.stdin.readline().split())
    unite(a,b)

ans=float("-inf")
for i in range(1,N+1):
    ans=max(ans,getsize(i))
print ans

Measured memory_bytes: 77504
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int D, G;
    cin >> D >> G;
    int p[D], c[D];
    REP(i, D) {
        cin >> p[i] >> c[i];
    }
    int ans = 100000;
    for (int bit = 0; bit < (1 << D); bit++) {
        bool can = true;
        int num = 0;
        int score = 0;
        REP(i, D) {
            if (bit >> i & 1) {
                score += 100 * (i + 1) * p[i] + c[i];
                num += p[i];
            }
        }
        if (score >= G) {
            ans = min(ans, num);
            continue;
        }
        for (int i = D - 1; i >= 0; i--) {
            if (!(bit >> i & 1)) {
                int x = (G - score - 1) / 100 / (i + 1) + 1;
                if (x > p[i]) { can = false; }
                else {
                    num += x;
                }
                break;
            }
        }
        if (can)ans = min(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("").sort();
    const T = arg[1].split("").sort().reverse();

    console.log(T > S ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;
   cin >> n >> m;
   if(n == 1 and m == 0){
      cout << "0";
      return 0;
   }
   vector<pii> q;
   f(i,0,m){
      int a,b;
      cin >> a >> b;
      a--;
      q.push_back({a,b});
   }
   f(i,0,1000){
      string s = to_string(i);
      if(s.length() == n){
         int c = 1;
         f(i,0,m){
            c = c*(s[q[i].F] == q[i].S+'0');
         }
         if(c){
            cout << s << '\n';
            return 0;
         }
      }
   }
   cout << "-1\n";
   return 0;
}

Measured memory_bytes: 256
N = input()
if int(N[-1:]) == 2 or int(N[-1:]) == 4 or int(N[-1:]) == 5 or int(N[-1:]) == 7 or int(N[-1:]) == 9:
    print('hon')
elif int(N[-1:]) == 0 or int(N[-1:]) == 1 or int(N[-1:]) == 6 or int(N[-1:]) == 8:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {
	//int a, b, c,d; cin >> a>>b>>c;
	//string s,t,u; cin >> s>>t>>u;
	vector<int> n(3);
	for (int i = 0; i < 3; i++) {
		cin >> n[i];
	}
	ssort(n);
	eerase(n);
	cout << n.size();

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    ll ans = 1;
    ll p = 0;
    rep(i,n){
        if(a[i]/2>=p){
            if(a[i]==2*p){
                p++;
                ans *=p;
                ans %= mod;
                p--;
            }else{
                p++;
            }
        }else{
            while(a[i]/2<p){
                ans *=p;
                ans %= mod;
                p--;
            }
            p++;
        }
        //cerr << ans << " " << p << endl;
    }
    while(p>=1){
        ans *=p;
        ans %= mod;
        p--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import accumulate

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    S = str(input().strip())
    S += 'x'

    A = []
    S0 = S[0]
    cnt = 0
    for s in S:
        if S0 == s:
            cnt += 1
        else:
            A.append(cnt)
            cnt = 1
            S0 = s


    n = len(A) // 2
    if len(A) % 2 == 1 and S[0] == '0':
        n += 1

    if n <= K:
        return sum(A)

    if S[0] == '0':
        A = [0] + A
    if S[-2] == '0':
        A = A + [0]
    A = [0] + list(accumulate(A))

    ans = 0
    for i in range(0, len(A) - 2*K, 2):
        ans = max(ans, A[i + 2*K + 1] - A[i])

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9324
n = gets.chomp.to_i
isOverlap = Hash.new(0)
previous = gets.chomp
isOverlap[previous] += 1
isOk = true
(n-1).times do
    current = gets.chomp
    if isOverlap.include?(current) then
        isOk = false
    elsif previous[-1] != current[0] then
        isOk = false
    end
    isOverlap[current] += 1
    previous = current
end
puts isOk ? "Yes" : "No"

Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  int n,d,x;
  scanf("%d%d%d",&n,&d,&x);
  int a[n+1],i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    x+=(d-1)/a[i]+1;
  }
  printf("%d\n",x);
  return 0;
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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;
}

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

template<class Abel> struct PotentialUnionFind {
 vector<int> par;
 vector<int> rank;
 vector<Abel> diff_weight;

 PotentialUnionFind(int n = 1, Abel SUM_UNITY = 0) {
  init(n, SUM_UNITY);
 }

 void init(int n = 1, Abel SUM_UNITY = 0) {
  par.resize(n); rank.resize(n); diff_weight.resize(n);
  for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
 }

 int root(int x) {
  if (par[x] == x) {
   return x;
  }
  else {
   int r = root(par[x]);
   diff_weight[x] += diff_weight[par[x]];
   return par[x] = r;
  }
 }

 Abel weight(int x) {
  root(x);
  return diff_weight[x];
 }

 bool issame(int x, int y) {
  return root(x) == root(y);
 }

 bool merge(int x, int y, Abel w) {
  w += weight(x); w -= weight(y);
  x = root(x); y = root(y);
  if (x == y) return false;
  if (rank[x] < rank[y]) swap(x, y), w = -w;
  if (rank[x] == rank[y]) ++rank[x];
  par[y] = x;
  diff_weight[y] = w;
  return true;
 }

 Abel diff(int x, int y) {
  return weight(y) - weight(x);
 }
};


void solve() {
    string s;
    cin>>s;
    ll n=s.size();
    ll con=0;
    ll ans=0;
    REP(i,n){
        if(s[i]=='A') con++;
        else if(i+1<n &&s.substr(i,2)=="BC"){ 
            ans+=con;
            i++;
        }else con=0;
    }
    cout<<ans<<en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


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

constexpr int MAX_N = 1e5;
int d[MAX_N];

int main() {
  int N;
  cin >> N;
  for (int i{}; i < N; ++i)
    cin >> d[i];
  sort(d, d+N);

  cout << d[N/2] - d[N/2 -1] << endl;
  return 0;
}


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

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


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


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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;}

string S;
int ans=0;
signed main(){
    cin>>S;
    int cnt=0;
    for(int i=0;i<3;++i){
        if(S[i]=='R')cnt++;
        else cnt=0;
        chmax(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b;
	int sum;
	int i;
	for(i=0;i<4;i++){
		cin>>a>>b;
		if(a==1){
			cout<<b*6000<<endl;
		}
		else if(a==2){
			cout<<b*4000<<endl;
		}
		else if(a==3){
			cout<<b*3000<<endl;
		}
		else{
			cout<<b*2000<<endl;
		}
	}
	return 0;
}
			


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007

map<int, int> m;
int dp[10005];
string sp[10005];
int lu[10005];

signed main(){
    fast;
    // #ifndef ONLINE_JUDGE
    //     freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
    //     freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    // #endif
    int n; cin>>n;
    int ct[10]={0,2,5,5,4,5,6,3,7,6};
    int z;
    cin>>z;
    int arr[z]; For(i, 0, z){cin>>arr[i];} sort(arr, arr+z); 
    For(i, 0, z){
        m[ct[arr[i]]]=arr[i];
    }

    memset(dp, -1, sizeof(dp));
    dp[0]=0;
    sp[0]="";

    for(int i=1; i<=n; i++){
        tr(m){
            int c = it->F;
            int v = it->S;
            if(i>=c && dp[i-c]!=-1){
                if(dp[i]==-1){
                    dp[i] = dp[i-c]+1;
                    lu[i] = v;
                    sp[i] = sp[i-c]+to_string(v);
                }
                else{
                    if(lu[i]<v && dp[i]-dp[i-c]==1){
                        lu[i] = v;
                        sp[i] = sp[i-c]+to_string(v);
                    }
                }
            }
        }
    }
    string ans = sp[n];
    sort(all(ans));
    reverse(all(ans));
    cout<<ans;
}

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

int u_b(vector<int> &a, int x){
    int left=-1,right=a.size();
    while(right-left>1){
        int mid=(left+right)/2;
        if(a[mid]>x) right=mid;
        else left=mid;
    }
    return right;
}

int main(){
    int n; cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int &x: a) cin>>x;
    for(int &x: b) cin>>x;
    for(int &x: c) cin>>x;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());

    vector<long long> mem(n+1,0);
    for(int i=0;i<n;i++){
        mem[i+1]=mem[i]+n-u_b(c,b[i]);
    }

    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=mem[n]-mem[u_b(b,a[i])];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<string> w(n);
    for(auto &x:w)cin >> x;

    set<string> check;
    bool ans = true;
    for(int i=0;i<n;i++){
        if(check.count(w[i])){
            ans = false;
            break;
        }
        check.insert(w[i]);
        if(i==0)continue;
        if(w[i][0]!=w[i-1].at(w[i-1].size()-1)){
            ans = false;
            break;
        }
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int D[40][40];
int c[505][505];
int cost[3][40];

int main(void)
{
    int N,C;
    cin >> N >> C;
    REP(i, C)REP(j, C) cin >> D[i][j];
    REP(i, N)REP(j, N) cin >> c[i][j];

    REP(i, N)REP(j, N){
        REP(k, C){        
            cost[(i+j)%3][k] += D[c[i][j]-1][k];
        }
    }

    int ans = INF;
    REP(i, C)REP(j, C)REP(k,C){
        if(i == j || j == k || k == i) continue;
        chmin(ans, cost[0][i] + cost[1][j] + cost[2][k]);
    }

    pr(ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, total;
  double ave;
  cin >> N;
  total = 0; ave = 0;
  
  vector<int>P(N);
  for(int i = 0;i < N;i++){
  cin >> P.at(i);
  ave = ave + P.at(i);
  }
  ave = round(ave / N);
  
  for(int i = 0;i < N;i++){
  total = total + (P.at(i) - ave) * (P.at(i) - ave);
  }
  cout << total << endl;
}

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

int main(){
  char x;
  char y=0;
  for(int i=0;i<4;i++){
   cin>>x;
   if(x=='+'){
    y++;
   }
   else {y--;}
  }
  cout<<int(y)<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  char M[36];
  int N[36];
}Card;

int main(){
  int i,j,m,n,minj,F=0;
  char l;
  Card card1,card2;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%*c%c%d",&card1.M[i],&card1.N[i]);
  }

  card2=card1;
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(card1.N[j]<card1.N[j-1]){
	m=card1.N[j];
	card1.N[j]=card1.N[j-1];
	card1.N[j-1]=m;

	l=card1.M[j];
	card1.M[j]=card1.M[j-1];
	card1.M[j-1]=l;
      }
    }
  }

  for(i=0;i<n-1;i++){
    printf("%c%d ",card1.M[i],card1.N[i]);
  }
  printf("%c%d\n",card1.M[i],card1.N[i]);
  printf("Stable\n");

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(card2.N[j]<card2.N[minj]){
	minj=j;
      }
    }
    if(minj!=i){
      m=card2.N[i];
      card2.N[i]=card2.N[minj];
      card2.N[minj]=m;
      
      l=card2.M[i];
      card2.M[i]=card2.M[minj];
      card2.M[minj]=l;
    }
  }

  for(i=0;i<n-1;i++){
    printf("%c%d ",card2.M[i],card2.N[i]);
  }
  printf("%c%d\n",card2.M[i],card2.N[i]);

  for(i=0;i<n;i++){
    if(card1.M[i]!=card2.M[i]) F=1;
  }

  if(F==0) printf("Stable\n");
  else if(F==1) printf("Not stable\n");
  
  return 0;
}



Measured memory_bytes: 2144
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .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 ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($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, parser) => {
        $next
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        m: usize,
        dc: [(usize, usize); m],
    }

    let mut s = 0;
    let mut ds = 0;
    for (d, c) in dc {
        ds += c;
        s += d * c;
    }

    println!("{}", ds - 1 + (s - 1) / 9);
}


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

typedef long long LL;
#define SZ(a) int((a).size())
#define FOR(var,a,b) for(int var=(a);var<(b);var++)
#define REP(var,n) FOR(var,0,n)
#define RFOR(var,a,b) for(int var=(b)-1;(a)<=var;var--)
#define INT(n) int n;scanf("%d",&n);
#define AI(a,n) int a[n];REP(i,n){scanf("%d",&a[i]);}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  INT(n); INT(a); AI(xs, n);
  LL ans = 0LL, dp[n + 1][2501]; MSET(dp, 0LL); dp[0][0] = 1LL;
  int s[n + 1]; MSET(s, 0);
  FOR(i, 0, n){
    RFOR(j, 1, i + 2){
      RFOR(k, xs[i], 50 * j + 1){
        dp[j][k] += dp[j - 1][k - xs[i]];
      }
    }
  }
  FOR(i, 1, n + 1){
    ans += dp[i][a * i];
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, m, dp[1001][1001], mod = 1e9 + 7;
string s;
vector <string> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    a.push_back("");
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++){
        cin >> s;
        s = ';' + s;
        a.push_back(s);
    }
    dp[1][1] = 1;
    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= m ; j++){
            if((i == 1 && j == 1) || a[i][j] == '#') continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[n][m] << endl;
}


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

int sort(const void *b, const void *a){
    return *(int*)b-*(int*)a ;
}
   
int main(void){
    int n;
    scanf("%d",&n);
    int a[n],b[2*n+2],c[n],d[2*n+2];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        scanf("%d",&b[a[i]]);
    }
    for (int i=0; i<n; i++){
        scanf("%d",&c[i]);
        scanf("%d",&d[c[i]]) ;
    }
    qsort (a,n,sizeof(int),sort);
    qsort (c,n,sizeof(int),sort);
    
    int ans=0;
    for (int i=0; i<n; i++){
        int tmp=-1;
        int tmpb=-1;
        for (int j=0; j<n; j++){
            if(a[j]<c[i] && b[a[j]]<d[c[i]] && tmpb<b[a[j]]){
                    tmp=j;
                    tmpb=b[a[j]];
            }    
        }
        if (tmp!=-1){
            ans++;
            a[tmp]=300;
            c[i]=300;
        }
    }

    printf ("%d\n",ans);
    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin>>N;
  bool first=false;
  rep(i,N){
    int A;
    cin>>A;
    if(A%2==1){
      first=true;
      break;
    }
  }
  if(first==true){
    cout<<"first"<<endl;
  }else{
    cout<<"second"<<endl;
  }
}

Measured memory_bytes: 256
// Problem : D - 3N Numbers
// Contest : AtCoder Regular Contest 074
// URL : https://atcoder.jp/contests/arc074/tasks/arc074_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define size(x) (int)x.size()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, a[N];
ll ans = -LLONG_MAX, sum = 0, mx[N];
multiset<int> ms;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= 3 * n; i++) {
		cin >> a[i];
		if (i <= n) {
			ms.insert(a[i]);
			sum += (i <= n) * a[i];
		}
	}
	for (int i = n + 1; i <= 2 * n; i++) {
		auto beg = ms.begin();
		mx[i] = sum;
		if (a[i] > *beg) {
			sum -= *beg;
			ms.erase(beg);
			ms.insert(a[i]);
			sum += a[i];
		}
	}
	mx[2 * n + 1] = sum;
	ms.clear();
	sum = 0;
	for (int i = 3 * n; i > 2 * n; i--) ms.insert(a[i]), sum += a[i];
	ans = max(ans, mx[2 * n + 1] - sum);
	for (int i = 2 * n; i > n; i--) {
		auto bacc = --ms.end();
		if (a[i] < *bacc) {
			sum -= *bacc;
			ms.erase(bacc);
			ms.insert(a[i]);
			sum += a[i];
		}
		ans = max(ans, mx[i] - sum);
	}
	cout << ans;
}


Measured memory_bytes: 9856
from collections import deque, Counter

N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

def dfs(s, c):
    """
    s: node
    c: number
    """

    q = deque()
    q.append(s)
    visited[s] = True
    color[s] = c
    
    while q:
        u = q.pop()
        for v in graph[u]:
            if visited[v]:
                continue
                
            visited[v] = True
            color[v] = c
            q.append(v)


graph = [[] for _ in range(N)]
for a, b in AB:
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

visited = [False] * N
color = [-1] * N
c = 0

for i in range(N):
    if not visited[i]:
        dfs(i, c)
        c += 1
        
ctr = Counter(color)

block = [[] for _ in range(N)]
for c, d in CD:
    if color[c - 1] == color[d - 1]:
        block[c - 1].append(d - 1)
        block[d - 1].append(c - 1)

ans = [0] * N
for i in range(N):
    ans[i] = ctr[color[i]] - 1 - len(graph[i]) - len(block[i])
    
print(*ans)


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

int main(){
  int N;  cin >> N;
  vector<long long> A(N+1), B(N);
  for(int i=0; i<N+1; ++i)  cin >> A[i];
  for(int i=0; i<N; ++i)  cin >> B[i];
  long long ans = 0;
  for(int i=0; i<N; ++i){
    if(A[i]<B[i]){
      ans += A[i];
      B[i] -= A[i];
      if(A[i+1]>B[i]){
        ans += B[i];
        A[i+1]-=B[i];
      }else{
        ans += A[i+1];
        A[i+1] -= A[i+1];
      }
    }
    else{
      ans += B[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const ll INF = 10000000000000;

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

int N, K;

int main() {
	cin >> N >> K;
	vector<int> h(N);
	vector<int> dp(N);
	rep(i, 0, N) {
		cin >> h[i];
		dp[i] = INF;
	}
	dp[0] = 0;
	rep(i, 1, N) {
		rep(j, 0, K) {
			if (i > j)chmin(dp[i], dp[i - j - 1] + abs(h[i] - h[i - j - 1]));
		}
		
	}

	cout << dp[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024
using System;

namespace _81
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            String ans = "No";

            for(int x = 1; x < 10; x++){
                for(int y = 1; y < 10; y++){
                    if(n - (x * y) == 0) ans = "Yes";
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	w := next()
	cnt := make([]int, 26)
	for i := range w {
		cnt[w[i]-'a']++
	}
	ok := true
	for i := range cnt {
		if cnt[i]&1 == 1 {
			ok = false
			break
		}
	}
	if ok {
		puts("Yes")
	} else {
		puts("No")
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640