akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextString()
	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}


Measured memory_bytes: 1756
package main

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

func main() {
	nextInt()
	K := nextInt()
	S := []rune(nextString())
	S[K-1] += 32
	fmt.Println(string(S))
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

int main(){
  int N;
  cin >> N;
  rep(i,10){
    rep(j,10){
      if(N == i*j){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define fi first
#define se second
 
#define mp make_pair
#define pb push_back
 
#define all(x) (x).begin(), (x).end()
 
#define F return
#define skip continue

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)

typedef long long ll;

using namespace std;                             

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

 
const int MAXN = 3e5 + 500;
const int INF = 1e9 + 23;
const int MOD = 1e9 + 7;

ll n, k, a[MAXN], pr[MAXN];
ll t[MAXN * 4];

int get(int v, int tl, int tr, int l, int r) {
    if (r < tl || tr < l) return 0;
    if (l <= tl && tr <= r) return t[v];
    int tm = (tl + tr) >> 1;
    return get(v + v, tl, tm, l, r) + get(v + v + 1, tm + 1, tr, l, r);
}                                         

void upd(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        t[v]++;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
        upd(v + v, tl, tm, pos);
    }
    else {
        upd(v + v + 1, tm + 1, tr, pos);
    }
    t[v] = t[v + v] + t[v + v + 1];
}

pair<ll, int> p[MAXN];

void solve() {
    cin >> n >> k;

    rep(i, 1, n) {
        cin >> a[i];
        a[i] += a[i - 1];
    }

    rep(i, 1, n) {
        a[i] -= k * i;
    }

    ll ans = 0;

    for (int i = 0; i <= n; i++) {
        p[i] = mp(a[i], i);
    }

    sort(p, p + n + 1);

    for (int i = 0; i <= n; i++) {
        a[p[i].se] = i;
    }
                         
    rep(i, 0, n) {
        upd(1, 0, n + 1, a[i]);
        ans += get(1, 0, n + 1, 0, a[i] - 1);
    }
    cout << ans;
}

int main() {                
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
     
    while (tt--) {
        solve();
        cout << '\n';
    }
 
    return 0;
    // you should actually read the stuff at the bottom
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
*/

Measured memory_bytes: 12544
implicit none

integer :: n
integer, allocatable :: h(:)
integer :: i
integer :: k

read *, n
allocate(h(n))
read *, (h(i), i = 1,n)

k = h(n)
do i = n-1, 1, -1
   if (h(i) > k+1) then
      write(6,'(a)') 'No'
      stop
   else if (h(i) < k) then
      k = h(i)
   endif
   if (k < 1) then
      write(6,'(a)') 'No'
      stop
   endif
enddo

write(6,'(a)') 'Yes'

stop
end

Measured memory_bytes: 1152
def isCLKWISE(ph):
    if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33864
# include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M,K,A;
  cin >> N >> M;
  vector<int> count(M, 0);
  
  for(int i = 0; i < N; i++){
    cin >> K;
    for(int j = 0; j < K; j++){
      cin >> A;
      A--;
      count[A]++;
    }
  }
  
  int ans = 0;
  for(int i = 0; i < M; i++){
    if(count[i] == N){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
 

vector <int > H;

int N,K,R,S,P; 
string T;

int main()
{
  cin >> N >> K >> R >> S >> P >> T;
  VI b;
  b.resize(N);
  long long ans = 0;
  REP(i,N){
    if(b[i] != -1 && i < N-K && T[i] == T[i+K]){
      b[i+K] = -1;
      continue;
    }
    switch(T[i]){
      case 'r':
        ans += P;
        break;
      case 's':
        ans += R;
        break;      
      case 'p':
        ans += S;
        break;
    }
//    debug(ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
/********************    I am only one, but still I am one.    **************************************/
/**************    I cannot do everything, but still I can do something.    *************************/
/***   And because I cannot do everything I will not refuse to do the something that I can do.    ***/
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

struct box{
	int v,d,c;
};
const int maxn = 1e5+5;
vector<int>g[maxn],lst(maxn),clr(maxn);
vector<box>q(maxn);
int n,m,t;
void dfs(int u,int d,int c){
	if(!clr[u]){
		clr[u] = c;
	}
	if( lst[u] >= d )return;
	lst[u]=d;
	
	if( d == 0 ) return;
	for(auto v:g[u]){
		dfs(v,d-1,c);
	}
}
int32_t main(){
	IOS
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>q[i].v>>q[i].d>>q[i].c;
	}
	reverse(q.begin()+1,q.begin()+t+1);
	for(int i=1;i<=t;i++){
		dfs(q[i].v,q[i].d,q[i].c);
	}
	for(int i=1;i<=n;i++){
		cout << clr[i] << endl;
	}
	
	
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 13484
'''
# 以下はTLである
H, N = map(int, input().split())
magic = []
# Aは威力Bは消費魔力
for i in range(N):
    A, B = map(int, input().split())
    magic.append([A,B])

# DPで解く
# DP[i]ダメージをi与えた時の最低使用魔力
# DP[H]ダメージがH以上になったときの最低使用魔力
# DP[i] = -1 のときは計算しない
DP = [-1 for _ in range(H+1)]
DP[0] = 0

for i in range(H):
    if DP[i] == -1:
        pass
    else:
        for j in range(N):
            h = i + magic[j][0]
            mp = DP[i] + magic[j][1]
            if h <= H and DP[h] == -1:
                DP[h] = mp
            elif h <= H and DP[h] != -1:
                if DP[h] > mp:
                    DP[h] = mp
            elif h > H and DP[H] == -1:
                DP[H] = mp
            elif h >H and DP[H] != -1:
                if DP[H] > mp:
                    DP[H] = mp

#print(DP)
print(DP[H])
'''


'''
# 改善しているがこれもTL
# おそらく関数のappendが足を引っ張っている
def test_func(dp, A_list, B_list, i, N):
    # 参考return(min([(dp[i - A_list[j]] if i >= A_list[j] else 0) + B_list[j] for j in range(N)]))
    magic = []
    for j in range(N):
        # 考えたいiに対してその元となるdpが存在するか
        if i >= A_list[j]:
            magic.append(dp[i-A_list[j]] + B_list[j])
        # 初めての
        else:
            magic.append(B_list[j])
    # 一番魔力がかからなかったものを採用する
    return min(magic)

H, N = map(int, input().split())
A_list = []
B_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

dp = [0 for _ in range(H+1)]

for i in range(1,H+1):
    dp[i] = test_func(dp, A_list, B_list, i, N)

print(dp[H])
'''

def test_func(dp, A_list, B_list, i, N):
    return(min([(dp[i - A_list[j]] if i >= A_list[j] else 0) + B_list[j] for j in range(N)]))
    '''
    # 最初から配列に格納
    magic = []
    for j in range(N):
        # 考えたいiに対してその元となるdpが存在するか
        if i >= A_list[j]:
            magic.append(dp[i-A_list[j]] + B_list[j])
        # 初めての
        else:
            magic.append(B_list[j])
    # 一番魔力がかからなかったものを採用する
    return min(magic)
    '''
H, N = map(int, input().split())
A_list = []
B_list = []
for i in range(N):
    A, B = map(int, input().split())
    A_list.append(A)
    B_list.append(B)

dp = [0 for _ in range(H+1)]

for i in range(1,H+1):
    dp[i] = test_func(dp, A_list, B_list, i, N)

print(dp[H])

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

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

// 入力
int N;
Graph G;

// res は答え
vector<int> res;

// v を c に塗る。p は v の親
void dfs(int v, int p, int c) {
    res[v] = c;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        if (e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}

int main() {
    cin >> N;
    G.resize(N);
    for (int i = 0; i < N-1; ++i) {
        int u, v, w; cin >> u >> v >> w;
        --u, --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}


Measured memory_bytes: 8960
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::prelude::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

const MOD: isize = 1_000_000_007;

fn main() {
    let (X, Y, A, B, C) = {
        let v = (0..5).map(|_| read::<usize>()).collect::<Vec<usize>>();
        (v[0], v[1], v[2], v[3], v[4])
    };
    let mut pp = (0..A).map(|_| read::<usize>()).collect::<Vec<usize>>();
    let mut qq = (0..B).map(|_| read::<usize>()).collect::<Vec<usize>>();
    let mut r = (0..C).map(|_| read::<usize>()).collect::<Vec<usize>>();

    pp.sort_by(|a, b| b.cmp(a));
    qq.sort_by(|a, b| b.cmp(a));
    r.sort_by(|a, b| b.cmp(a));
    let mut p = vec![];
    let mut q = vec![];

    for i in 0..X {
        p.push(pp[i]);
    }
    for i in 0..Y {
        q.push(qq[i]);
    }

    // let mut ps = vec![0usize;A+1];
    // let mut qs = vec![0usize;B+1];
    // let mut rs = vec![0usize;C+1];
    // for i in 0..A {
    //     ps[i+1] = ps[i] +p[i];
    // }
    // for i in 0..B {
    //     qs[i+1] = qs[i] +q[i];
    // }
    // for i in 0..C {
    //     rs[i+1] = rs[i] +r[i];
    // }

    // // (0,0) -> (0,1) -> (0,2) -> ...
    // for i in 0..C+1 {
    //     // i : r を i個使う場合

    // }
    let mut ap = p;
    ap.append(&mut q);
    ap.append(&mut r);
    ap.sort_by(|a, b| b.cmp(a));
    let mut ans = 0;
    for i in 0..X + Y {
        ans += ap[i];
    }
    println!("{}", ans);
}
fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let next: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    next.parse().ok().unwrap()
}


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

class runtime_modint{
    using u64=uint_fast64_t;
    static u64 &mod(){
        static u64 mod_=0;
        return mod_;
    }
    public:
    u64 a;
    static void set_mod(const u64 x){mod()=x;}
    static u64 get_mod(){return mod();}
    runtime_modint(const u64 x=0):a(x%get_mod()){}
    u64 &balue() noexcept{return a;}
    const u64 &value() const noexcept{return a;}
    runtime_modint &operator+=(const runtime_modint &rhs){
        a+=rhs.a;
        if (a>=get_mod()) a-=get_mod();
        return *this;
    }
    runtime_modint operator+(const runtime_modint &rhs) const{
        return runtime_modint(*this)+=rhs;
    }
    runtime_modint &operator-=(const runtime_modint &rhs){
        if (a<rhs.a) a+=get_mod();
        a-=rhs.a;
        return *this;
    }
    runtime_modint operator-(const runtime_modint &rhs) const{
        return runtime_modint(*this)-=rhs;
    }
    runtime_modint &operator*=(const runtime_modint &rhs){
        a=a*rhs.a%get_mod();
        return *this;
    }
    runtime_modint operator*(const runtime_modint &rhs) const{
        return runtime_modint(*this)*=rhs;
    }
    runtime_modint &operator/=(runtime_modint rhs){
        u64 exp=get_mod()-2;
        while(exp){
            if (exp&1) *this*=rhs;
            rhs*=rhs; exp>>=1;
        }
        return *this;
    }
    runtime_modint operator/(const runtime_modint &rhs) const{
        return runtime_modint(*this)/=rhs;
    }
    friend runtime_modint pow(runtime_modint rhs,long long exp) noexcept{
        runtime_modint res{1};
        while(exp){
            if (exp&1) res*=rhs;
            rhs*=rhs; exp>>=1;
        }
        return res;
    }
    friend ostream &operator<<(ostream &s,const runtime_modint &rhs){
        return s << rhs.a;
    }
    friend istream &operator>>(istream &s,runtime_modint &rhs){
        u64 a; rhs=runtime_modint{(s >> a,a)}; return s;
    }
};

using mint=runtime_modint;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    runtime_modint::set_mod(M);
    vector<vector<mint>> dp(3*N+1,vector<mint>(N+1,0));
    dp[0][0]=1;
    for (int i=0;i<3*N;++i){
        for (int j=0;j<=N;++j){
            dp[i+1][j]+=dp[i][j];
            if (i+2<=3*N&&j+1<=N) dp[i+2][j+1]+=dp[i][j]*(i+1);
            if (i+3<=3*N&&j+1<=N) dp[i+3][j+1]+=dp[i][j]*(i+2)*(i+1);
        }
    }
    mint ans=0;
    for (int j=0;j<=N;++j) ans+=dp[3*N][j];
    cout << ans << '\n';
}

Measured memory_bytes: 94336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long h = sc.nextLong();
		
		System.out.println((long)Math.pow(2,(int)(Math.log10(h)/Math.log10(2)) + 1) - 1);
	}

}


Measured memory_bytes: 23636
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize("Ofast,no-stack-protector")
#include <bits/stdc++.h>
#define res register ll
#define lowbit(x) (x&(-x))
#define N 200005
#define inf 0x3f3f3f3f
#define mod 1000000007
#define ll long long
using namespace std;
ll n,m,cnt,a[N],b[N],lisan[N],f[N],ans=1,sum,tot;
inline ll read(){
	res w=0,X=0;register char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){X=(X<<1)+(X<<3)+(ch^48);ch=getchar();}
	return w?-X:X;
}
namespace T{
	ll tr[N];
	inline void add(res x,res v){
		for(;x<=cnt;x+=lowbit(x))
		  (tr[x]+=v)%=mod;
	}
	inline ll ask(res x){
		res total=0;
		for(;x;x-=lowbit(x))
		  (total+=tr[x])%=mod;
		return total;
	}
}
struct papa{
	ll x,y;
	inline bool operator<(const papa&b) const{
		return (x==b.x&&y>b.y)||x<b.x;
	}
}p[N];
int main(){
	n=read(),m=read();
	for(res i=1;i<=n;i++)
	  a[i]=read();
	for(res i=1;i<=m;i++)
	  b[i]=read();
	for(res i=1,j=1;i<=n;i++){
		for(;j<=m;j++)
		  if(b[j]>a[i])
		    break;
		if(j==m+1||j==1|| b[j] == a[i]) continue;
		p[++tot].x=b[j]-a[i];
		p[tot].y=a[i]-b[j-1];
    }
	sort(p+1,p+tot+1);
	for(res i=1;i<=tot;i++)
	  lisan[i]=p[i].y;
	sort(lisan+1,lisan+tot+1);
	cnt=unique(lisan+1,lisan+n+1)-lisan-1;
	for(res i=1;i<=tot;i++)
	  p[i].y=lower_bound(lisan+1,lisan+cnt+1,p[i].y)-lisan;
	for(res i=1;i<=tot;i++){
		if(p[i].x==p[i-1].x&&p[i].y==p[i-1].y) continue;
		sum=(T::ask(p[i].y-1)+1)%mod;
		ans=(ans+sum)%mod;                     
		T::add(p[i].y,sum);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  bool a=(n%100==0||n%100>12),b=(n/100==0||n/100>12);
  if(a&&b)
    cout<<"NA";
  if(!a&&b)
    cout<<"YYMM";
  if(a&&!b)
    cout<<"MMYY";
  if(!a&&!b)
    cout<<"AMBIGUOUS";
  cout<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    bitset<4000000> dp;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp |= (dp << a[i-1]);
    }
    int odd = sum % 2;
    for (int i = sum / 2 + odd; i <= sum; ++i) {
        if (dp[i] == 1) {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
ll M = 1e9 + 7;
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} }


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	//int n,p; cin>>n>>p;
	string s; cin>>s;
	ll sum = 0, q=1, ans=0;
// 	if(p==2)
// 	{
// 	    for(int i=0;i<n;i++)
// 	    {
// 	        if( (s[i]-'0')%2 == 0 ) ans+=(i+1);
// 	    }
// 	    cout<<ans; return 0;
// 	}
// 	if(p==5)
// 	{
// 	    for(int i=0;i<n;i++)
// 	    {
// 	        if( (s[i]-'0')%5 == 0 ) ans+=(i+1);
// 	    }
// 	    cout<<ans; return 0;
// 	}
	ll m[2019]; memset(m,0,sizeof(m));
	m[0]++;
	for(int i=s.length()-1;i>=0;i--)
	{
	    sum = ( sum + (s[i]-'0')*q )%2019;
	    ans += m[sum];
	    m[sum]++;
	    q *= 10; q%=2019;
	    
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3788
import sys
input = sys.stdin.readline
import random
import copy
d = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(d)]
SORT = []
for i in range(d):
    for j in range(26):
        SORT.append([s[i][j]*c[j],i+1,j+1])
SORT.sort(reverse=True)
ans = []
now = [0]*26
for i in range(d):
    no = -1
    score = -10**10
    for j in range(26):
        count = s[i][j]
        for k in range(26):
            if j == k:
                continue
            count -= (i+1-now[k])*c[k]
        if count > score:
            no = j
            score = count
    ans.append(no+1)
    now[no] = i+1
score = [0]*26
for i in range(d):
    
    now[ans[i]-1] = i+1
    ind = ans[i]-1
    for j in range(26):
        if j == ind:
            score[j] += s[i][ind]
        else:
            x = (i+1-now[j])*c[j]
            score[j]-= x
SUM = sum(score)
roop = 0
while roop < 50000:
    q = random.randint(1,500)
    w,x,y = SORT[q-1]
    if ans[x-1] == y:
        continue
    be = ans[x-1]
    be -= 1
    now1 = 0
    now2 = 0
    nex = copy.deepcopy(ans)
    nex[x-1] = y
    y -= 1
    count1 = 0
    count2 = 0
    for j in range(d):
        if be == nex[j]-1:
            now1 = j+1
            count1 +=s[j][be]
        else:
            count1 -= (j+1-now1)*c[be]
        if y == nex[j]-1:
            now2 = j+1
            count2 +=s[j][y]
        else:
            count2 -= (j+1-now2)*c[y]
 
    count = SUM + count1+count2-score[be]-score[y]
    
    if count > SUM:
        score[be] = count1
        score[y] = count2
        ans = nex
        SUM = count
    roop += 1
for i in ans:
    print(i)


Measured memory_bytes: 90680
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i ,j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<n+1;i++){
    scanf("%hd",&A[i]);
  }
  
  for (i = 0;i<VMAX+1;i++){
    C[i] = 0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<VMAX+1;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i=1;i<n+1;i++){
    if(i == n)
      printf("%d\n",B[i]);
    else
      printf("%d ",B[i]);
  }
 
  return 0;
}



Measured memory_bytes: 9708
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
void solve() {
    int n,m;
    cin>>n>>m;
    if(n-2>0 and m-2>0) cout<<(n-2)*(m-2);
    else
    {
        if(n-2<0) {
           n=1;
        }
        else n-=2;
        if(m-2<0) {
            m=1;
        }
        else m-=2;
        cout<<n*m;
    }
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();

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

Measured memory_bytes: 3768
N=int(input())
a = [int(input()) for _ in range(N)]
b = [0]*N

if N%2==1:
  #最大値を中央に置くケース
  a.sort()
  m = N//2
  L,R = m,m
  b[m]=a[-1]
  for i in range(m):
    L -= 1
    R += 1
    if i%2==0:
      b[L]=a[i]
      b[R]=a[i+1]
    else:
      b[L]=a[-2-(i-1)]
      b[R]=a[-3-(i-1)]
  ans1=0
  for i in range(1,N):
    ans1 += abs(b[i]-b[i-1])
  #print(b)
  
  #最小値を中央に置くケース
  a.sort()
  m = N//2
  L,R = m,m
  b[m]=a[0]
  for i in range(m):
    L -= 1
    R += 1
    if i%2==0:
      b[L]=a[-1-i]
      b[R]=a[-2-i]
    else:
      b[L]=a[(i-1)+1]
      b[R]=a[(i-1)+2]
  ans2=0
  for i in range(1,N):
    ans2 += abs(b[i]-b[i-1])
  ans=max(ans1,ans2)
  #print(b)
  print(ans)

else:
  a.sort()
  m = N//2
  L,R = m-1,m
  b[L]=a[0]
  b[R]=a[-1]
  
  for i in range(m-1):
    L -= 1
    R += 1
    if i%2==0:
      b[L]=a[-2-i]
      b[R]=a[i+1]
    else:
      b[L]=a[i+1]
      b[R]=a[-2-i]
  ans=0
  for i in range(1,N):
    ans += abs(b[i]-b[i-1])
  #print(b)
  print(ans)  
  

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w; cin>>h>>w;
	string z;
	for(int i=0;i<w+2;++i)z+='0';
	vector<string>s(h+2);
	s.at(0)=z,s.at(h+1)=z;
	for(int i=1;i<=h;++i){
		string a;
		cin>>a;
		s.at(i)='0'+a+'0';
	}
	for(auto&i:s)for(auto&j:i)if(j=='.')j='0';
	vector<int>X={-1,-1,0,1,1,1,0,-1},Y={0,-1,-1,-1,0,1,1,1};
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			if(s.at(i).at(j)!='#')continue;
			for(int k=0;k<X.size();++k){
				int x=j+X.at(k),y=i+Y.at(k);
				if(s.at(y).at(x)!='#')++s.at(y).at(x);
			}
		}
	}
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cout<<s.at(i).at(j);
		}
		cout<<"\n"s;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}		
int a[114514],b[114514];
int x[114514],y[114514],c[114514];
signed main(){
	ic(a) ic(b)
	if(abs(a-b)<2)c("Brown")
	else c("Alice")
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

int main() {
	string s;
	string ans;
	cin >> s;
	rep(i, s.size()) {
		if(s[i] == '0') ans += '0';
		else if(s[i] == '1') ans += '1';
		else if(s[i] == 'B' && ans.size() != 0) ans.erase(ans.size()-1, 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
    int X,A;
    cin >> X >>A;
    if(X<A){
cout <<0<<endl;
    }
    else{
cout <<10<<endl;
    }

 return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 123450
#endif

int N,K,A[SIZE];

void solve() {
    cin>>N>>K;
    REP(i,N)cin>>A[i];
    sort(A,A+N);
    int ans = 0;
    REP(i,K) ans+=A[i];
    cout << ans << endl;
}



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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N) for (int i = (init); i < (int)(N); i++)

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

string s;
int N;

PII digit(int pos) {
    int res = 0;
    
    while (pos < (int)s.size() && isdigit(s[pos])) {
        res *= 10;
        res += s[pos] - '0';
        ++pos;
    }

    return MP(pos, res);
}

PII digit_m(int pos) {
    PII res = digit(pos);

    if (res.fst < (int)s.size() && s[res.fst] == '*') {
        PII res2 = digit_m(res.fst + 1);
        return MP(res2.fst, res.snd * res2.snd);
    } else {
        return res;
    }
}

PII dfs1(int pos0) {
    PII res0 = digit_m(pos0);
    int num = res0.snd;
    int pos = res0.fst;

    if (pos >= (int)s.size()) {
        return MP(pos, num);
    } else if (s[pos] == '+') {
        PII res = dfs1(pos + 1);
        return MP(res.fst, num + res.snd);
    } else {
        cout << pos << " " << s[pos] << endl;
        assert(!"dfs2 error" );
    }
}

PII dfs2(int pos0) {
    PII res0 = digit(pos0);
    int num = res0.snd;
    int pos = res0.fst;

    while (pos < (int)s.size()) {
        char ope = s[pos];
        PII dig = digit(pos + 1);
        
        if (ope == '*') {
            num *= dig.snd;
        } else if(ope == '+') {
            num += dig.snd;
        } else {
            assert(!"dfs2 error");
        }

        pos = dig.fst;
    }

    return MP(pos, num);
}

int main(void) {
    cin >> s >> N;

    int a = dfs1(0).snd; // normal
    int b = dfs2(0).snd; // left-right

//    cerr << a << " " << b << endl;

    if (a == N && b == N) cout << "U" << endl;
    else if (a == N) cout << "M" << endl;
    else if (b == N) cout << "L" << endl;
    else cout << "I" << endl;

	return 0;
}

Measured memory_bytes: 1204
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int s = scan.nextInt();
        boolean flag = false;
        List<Integer> list = new ArrayList<>();
        list.add(s);
        int idx = 0;
        int ans = 0;
        while (!flag) {
            int a = list.get(idx);
            if (a%2==0) {
                list.add(a/2);
            }else {
                list.add(a*3+1);
            }
            idx++;
            for (int i = 0; i < list.size()-1; i++) {
                if (list.get(i) == list.get(list.size()-1)) {
                    ans =list.size();
                    flag=true;
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>  
    using namespace std;  
    typedef unsigned long long int64; //ほりせんせいだいすきだよ！！  
    int main(){  
      int64 n, p[65005], j[65005];  
        
      while(cin >> n, n){  
      
        int64 all = 0;  
      
        for(int i = 0; i < n; i++){  
          cin >> p[i];  
          all += p[i];  
        }  
        for(int i = 0; i < n - 1; i++){  
          cin >> j[i];  
          all += j[i];  
        }  
        sort(j, j + n - 1);  
      
        int64 sanop = 1;  
        int64 ret = all * sanop;  
      
        for(int i = 0; i < n - 1; i++){ //取り除いてみる  
          if(all < j[i] * (1 + sanop)) break;  
          all -= j[i];  
          sanop++;  
          ret = max( ret, all * sanop);  
        }  
        cout << ret << endl;  
      }  
      
      return 0;  
    }  

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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int N;
  cin >> N;
  VI a(N),b(N),c(N);
  
  REP(i,N){
    cin >> a.at(i) >> b.at(i) >> c.at(i) ;
  }
  
  VI Dpa(N+1),Dpb(N+1),Dpc(N+1);
  
  REP(i, N){
    Dpa.at(i+1) = a.at(i) + max(Dpb.at(i),Dpc.at(i));
    Dpb.at(i+1) = b.at(i) + max(Dpc.at(i),Dpa.at(i));
    Dpc.at(i+1) = c.at(i) + max(Dpa.at(i),Dpb.at(i));
  }
  
  cout << max({ Dpa.at(N), Dpb.at(N), Dpc.at(N)}) << endl;
  
  return 0;
}


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

int h,w;
char A[102][102];
int main(){

  cin >> h >> w;

  for(int i=0;i<102;i++){
    for(int j = 0;j<102;j++){
      A[i][j]='#';
    }
  }
  
  for(int i =1;i<=h;i++){
    for(int j = 1;j<=w;j++){
      cin >> A[i][j];
    }
  }

  for(int i =0;i<=h+1;i++){
    for(int j = 0;j<=w+1;j++){
      cout << A[i][j];
    }
    cout << endl;
  }

  

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll a[n]; ll b[n];
    rep(i,n) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b,b+n);
    int ans = 0;
    rep(i,n){
        int c = lower_bound(b,b+n,a[i]) - b;
        if((i-c)%2) ans++;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class DWACON6TH_PRELIMSA
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var stList = Repeat(0, N).Select(_ => new { s = NS, t = NN }).ToArray();
            var X = NS;
            var ans = 0L;
            var now = false;
            foreach (var item in stList)
            {
                if (now) ans += item.t;
                if (X == item.s) now = true;
            }
            Console.WriteLine(ans);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 12896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  int A, B, ans=0;
  string str;

  cin >> A >> B;

  for(int i = A; i <= B; i++){
    bool flag = true;
    str = to_string(i);

    for(int j = 0; j < str.size(); j++){
      if(str.size()-j < j) break;
      if(str[j] != str[str.size()-1-j]){
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  }

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m,q;
string s;

int main(){
	cin >> s;
    int len = s.size();
  if(s[len - 1] == 's'){
  	s+="es";
  }
  else{
  	s+='s';
  }
  cout << s << endl;

	return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	h = min(h, 2 * q);
	s = min(s, 2 * h);

	ll ans = 0;
	if (2 * s <= d) {
		ans = 1LL * n * s;
	}
	else {
		ans = 1LL * (n / 2)*d;
		if (n % 2 == 1) {
			ans += s;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n;
  while(scanf("%d", &n) != EOF){
    int a,b,c,d;
    int combination = 0;
    for(a=0; a<10; a++){
      for(b=0; b<10; b++){
        for(c=0; c<10; c++){
          for(d=0; d<10; d++){
            if(a+b+c+d==n){
              ++combination;
            }
          }
        }
      }
    }

    printf("%d\n", combination);
  }

  return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<int>> a(M,vector<int>(2));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> a.at(i).at(j);
    }
  }
  int ans1 = 1;
  int ans2 = 100000;
  for (int i = 0; i < M; i++) {
    if (a.at(i).at(0) > ans1) {
      ans1 = a.at(i).at(0);
    }
    if (a.at(i).at(1) < ans2) {
      ans2 = a.at(i).at(1);
    }
  }
  if (ans2 - ans1 +1 < 0) {
    cout << 0 <<endl;
  }
  else {
  cout << ans2 - ans1 +1 <<endl;
  }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ARRAY_LEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  int ans;
  ans = max({a,b,c})*9 + a + b + c;
  cout << ans << endl;

}

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

int main() {
  int a,b,c,d ;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if (a+b == c+d) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int d;cin >> d; 
    if (d==25){
        cout << "Christmas" << endl;
    }
    else if (d==24){
        cout << "Christmas Eve" << endl;
    }
    else if (d==23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if (d==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=100000000000000007LL;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i;cin>>n;
	vector<int>A(n);
	for(i=0;i<n;i++){cin>>A[i];}
	vector<vector<int>>go(n);
	for(i=0;i<n-1;i++){
		int a,b;cin>>a>>b;a--;b--;
		if(A[a]>A[b]){go[a].pub(b);}
		if(A[b]>A[a]){go[b].pub(a);}
	}
	vector<int>kati(n);
	while(-1){
		bool mada=false;
		for(i=0;i<n;i++){
			if(kati[i]!=0){continue;}
			kati[i]=-1;
			for(auto it:go[i]){maxeq(kati[i],-kati[it]);}
			if(kati[i]==0){mada=true;}
		}
		if(!mada){break;}
	}
	for(i=0;i<n;i++){if(kati[i]>0){cout<<i+1<<" ";}}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
// AOJ Vol-3 0312: Net Cafe
// 2017.9.30

#include <stdio.h>

#define MAX 200005
#define N 16

int m;
int w[MAX], t[MAX];;
int sw[MAX], st[MAX];
int c[N], b[N];
int dp[N][32770];		// 32768 = 2^15

int bsch(int *a, int x)
{
	int h, l = 1, r = m;

    while (l < r) {
        h = (l + r) >> 1;
		if (a[h] == x) return h;
        if (a[h] < x) l = h + 1; else r = h;
    }
	return l-1;
}

int main()
{
	int n, i, j, k, x, y, lim, ans;

	scanf("%d%d", &m, &n); m++;
	for (sw[0] = st[0] = 0, i = 1; i < m; i++) {
		scanf("%d%d", w+i, t+i);
		sw[i] = sw[i-1] + w[i], st[i] = st[i-1] + t[i];
	}
	for (i = 0; i < n; i++) scanf("%d%d", c+i, b+i);

//	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++)	{
		x = bsch(sw, c[i]);
		y = bsch(st, b[i]);
		if (x > y) x = y;
		if (x == m-1) { ans = m-1; goto Done; }
		dp[0][1<<i] = x;
	}

	lim = 1 << n;
	for (k = 1; k < lim; k++) {
		for (i = 0; i < n; i++)	{			// this book shelf
			for (j = 0; j < n; j++) {		// last book shelf
				if (dp[j][k] && !(k & (1<<i))) {
					int ii = k | (1 << i);
					x = bsch(sw, sw[dp[j][k]] + c[i]);
					y = bsch(st, st[dp[j][k]] + b[i]);
					if (x > y) x = y;
					if (x == m-1) { ans = m-1; goto Done; }
					if (x > dp[i][ii]) dp[i][ii] = x;
				}
			}
		}
	}
	for (ans = 0, i = 0; i < n; i++) if (dp[i][lim-1] > ans) ans = dp[i][lim-1];
Done:
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6612