akhauriyash/Code-Regression huggingface dataset:
import java.math.BigDecimal;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
       
        String res = "Yes";
        for (char c='a'; c<='z'; c++){
            int count = 0;
            for (int i=0; i<w.length(); i++){
                if (w.charAt(i) == c){
                    count++;
                }
            }
            if (count%2 == 1){
                res = "No";
                break;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 22612
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>
#include <chrono>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    int diff = A - B;
    C -= diff;

    cout << max(0, C) << endl;

}





































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
int n;
int ans = 0;
    vector<vector<int>> graph;
    vector<bool> visited;
void dfs(int cur){
    visited[cur] = true;
    REP(i, n){
        if(visited[i] == false){
            break;
        }
        if (i == n - 1){
            ans++;
        }
    }
    for (int i = 0; i < graph[cur].size(); i++){
        if (visited[graph[cur][i]] == true){
            continue;
        }
        dfs(graph[cur][i]);
    }
    visited[cur] = false;
}

signed main() {
    int m;
    cin >> n >> m;
    graph.resize(n);
    visited.resize(n);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }
    dfs(0);
    cout << ans << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n, k, s;
  cin >> n >> k >> s;
  if (s < 1000000000) {
    for (int i = 0; i < k; i++) {
      cout << s << " ";
    }
    for (int i = k; i < n; i++) {
      cout << s + 1 << " ";
    }
    cout << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s << " ";
    }
    for (int i = k; i < n; i++) {
      cout << 1 << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

l = inp()
print((l/3.0)**3)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define N 100005

using namespace std;

int X, Y, A, B, C;
int p[N], q[N], r[N];

int main() {
	scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);
	for(int i = 1; i <= A; ++i)
		scanf("%d", &p[i]);
	for(int i = 1; i <= B; ++i)
		scanf("%d", &q[i]);
	for(int i = 1; i <= C; ++i)
		scanf("%d", &r[i]);
	sort(p + 1, p + A + 1);
	sort(q + 1, q + B + 1);
	sort(r + 1, r + C + 1, greater<int>());
	int pa = A - X + 1, pb = B - Y + 1;
	for(int i = 1; i <= C; ++i) {
		if(pa > A) {
			if(pb > B) break;
			if(r[i] <= q[pb]) break;
			q[pb] = r[i], ++pb;
		} else if(pb > B) {
			if(r[i] <= p[pa]) break;
			p[pa] = r[i], ++pa;
		} else {
			if(p[pa] < q[pb]) {
				if(r[i] <= p[pa]) break;
				p[pa] = r[i], ++pa;
			} else {
				if(r[i] <= q[pb]) break;
				q[pb] = r[i], ++pb;
			}
		}
	}
	
	long long ans = 0;
	for(int i = A - X + 1; i <= A; ++i)
		ans += p[i];
	for(int i = B - Y + 1; i <= B; ++i)
		ans += q[i];
	printf("%lld\n", ans);
	return 0;
}

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


int main()
{
  int n;
  cin >> n;
  vector<int> b(n - 1);
  rep(i, n - 1)
    cin >> b[i];
  int ans = b[0] + b.back();
  for (int i = 1; i < n - 1; i++)
    ans += min(b[i-1], b[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt()

	ans := 0

	for i := 1; i <= n; i++ {
		a := nextInt()
		if i%2 == 1 && a%2 == 1 {
			ans++
		}
	}

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

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

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

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}


Measured memory_bytes: 1808
'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const N = tmp[0][0], K = tmp[0][1];
  const h = tmp[1];
  const dp = Array(N).fill(Infinity);
  dp[0] = 0;
  for ( let i = 0; i < N-1; i++ ) {
    for ( let j = 1; j <= K; j++ ) {
      const cost = Math.abs( h[i] - h[i+j] ) + dp[i];
      if ( dp[i+j] > cost ) dp[i+j] = cost
      if ( i + j === N ) break;
    }
  }
  return dp[N-1].toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 27744
#include <iostream>
#include <string>

using namespace std;

int map[50][26]={0};

int main(){
  string str[50];
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> str[i];
    for(int j=0;j<str[i].size();j++){
      map[i][str[i][j]-'a']++;
    }
  }
  for(int i=0;i<26;i++){
    int min=100000;
    for(int j=0;j<n;j++){
      if(min>map[j][i]){
        min=map[j][i];
      }
    }
    char a='a';
    for(int j=0;j<min;j++){
      printf("%c",a+i);
    }
  }
  cout <<endl;
  return 0;
}


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

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

	int h, n; cin >> h >> n;
	vector<int> dp(h + 1, INT_MAX);
	dp[0] = 0;
	while (n--) {
		int a, b; cin >> a >> b;
		for (int i = 1; i <= h; i++)
			dp[i] = min(dp[i], max(dp[i-a], 0) + b);
	}
	cout << dp[h] << '\n';
}


Measured memory_bytes: 3676
N = gets.to_i
As, Bs = readlines.map{_1.split.map(&:to_i)}.transpose

m = ->(a){a.sort!; l = a.size; l.even? ? a[l/2 - 1, 2].sum/2r : a[(l - 1)/2]}
puts ((m[Bs] - m[As]) * (N.even? ? 2 : 1)).to_i + 1

Measured memory_bytes: 44020
import copy
def light(s,p,l,m):
    a = 0
    for i in range(m):
        k = list(s[i])
        del k[0]
        t = copy.copy(k)
        for j in range(len(k)):
            if l[(k[j]-1)] == "0":
                t.remove(k[j])
        if p[i] == ((len(t))%2):
            a = a + 1
    if a == m:
        return 1
    else:
        return 0
n,m = map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))
count = 0
for i in range(2**n):
    b = str(bin(i))
    b = b.lstrip("0b")
    c = b.zfill(n)
    l = list(c)
    count = count + light(s,p,l,m)
print(count)

Measured memory_bytes: 3572
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define P 1000000007

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int x[100000];
int y[100000];
int main(void){
	int n=nextint();
	int m=nextint();
	for(int i=0; i<n; i++){
		x[i]=nextint();
	}
	for(int i=0; i<m; i++){
		y[i]=nextint();
	}
	long a=0;
	for(int i=0; i<n; i++){
		a+=(i*2-n+1)*(long)x[i]%P;
	}
	a = (a%P+(long)n*P)%P;
	long b=0;
	for(int i=0; i<m; i++){
		b+=(i*2-m+1)*(long)y[i]%P;
	}
	b = (b%P+(long)m*P)%P;
	int ans = a*b%P;
	printf("%d\n", ans);
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);

int main(){
  sync;
  int t;
  cin >> t;
  while(t--){
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a<b||b>d) cout << "No\n";
    else if(b<=c) cout << "Yes\n";
    else{
      long long gcd=__gcd(b,d);
      if(b-gcd+a%gcd>c) cout << "No\n";
      else cout << "Yes\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

tmp = LI()

a,b,c,d = [tmp.pop(0) for i in range(4)]

s1 = a*b
s2 = c*d

if s1 < s2:
    print(s2)
else:
    print(s1)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();
		br.close();

		int mod = 1000000007;
		int n = s.length;
		long[][] dp = new long[n + 1][13];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			if (s[i] == '?') {
				for (int j = 0; j < 13; j++) {
					for (int d = 0; d < 10; d++) {
						int next = (j * 10 + d) % 13;
						dp[i + 1][next] += dp[i][j];
						dp[i + 1][next] %= mod;
					}
				}
			} else {
				int d = s[i] - '0';
				for (int j = 0; j < 13; j++) {
					int next = (j * 10 + d) % 13;
					dp[i + 1][next] += dp[i][j];
					dp[i + 1][next] %= mod;
				}
			}
		}
		System.out.println(dp[n][5]);
	}
}


Measured memory_bytes: 35668
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


long long a,b,c,d,e,f,g,h;
cin>>a;

cout<<(1000-a%1000)%1000;

return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  bool hanbetu = false;
  
  for(int i  = 0;i < N - 1;i++){
    if(vec.at(i) == vec.at(i+1))hanbetu = true;
  }
  
  if(hanbetu)cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
 
int main(){    
  int N,A,B;
  cin >> N >> A >> B;
  
  if(N*A < B){
    cout << N*A << endl;
  }
  else cout << B << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
numa = 0
numb = 0
num = sum(b)-sum(a)
for i in range(n):
    x = b[i] - a[i]
    if x > 0:
        numa += -(-x//2)
        if x % 2 == 1:
            numb += 1
    else:
        numb -= x
if (num-numa)*2 == num-numb and num >= numa:
    print("Yes")
else:
    print("No")

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
//  ull MAX_ull{1000000000000000};
//  cout << MAX_ull << '\n';
  ull N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  ull max_time {N/A+((N%A!=0)?1:0)};
  maxs(max_time, N/B+((N%B!=0)?1:0) );
  maxs(max_time, N/C+((N%C!=0)?1:0) );
  maxs(max_time, N/D+((N%D!=0)?1:0) );
  maxs(max_time, N/E+((N%E!=0)?1:0) );
  cout << max_time + 4 << '\n';
}


Measured memory_bytes: 384
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn combination(n: u64, mut m: u64) -> u64 {
    if n < m {
        return 0;
    }
    if m > n - m {
        m = n - m
    }

    let mut ret = 1u64;
    for i in 0..m {
        ret *= n - i;        
    }

    let mut div = 1u64;
    for i in 1..(m+1) {
        div *= i;
    }
    ret / div
}

fn main() {
    let n: usize = input();
    let a_vec = input_vec();
    let mut num_count = vec![0; n+1];
    for a in &a_vec {
        num_count[*a as usize] += 1;
    }

    let mut combination_sum = 0;
    for n in &num_count {
        combination_sum += combination(*n, 2);
    }

    for a in &a_vec {
        println!("{}", combination_sum - combination(num_count[*a as usize], 2) + combination(num_count[*a as usize] - 1, 2));
    }
}


Measured memory_bytes: 11760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7

template <typename T>
string printVector(const vector<T> &data)
{
    stringstream ss;
    ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, ans = 0, cur = 1;
    cin >> a >> b;
    while (cur < b) {
        ans++;
        cur += a - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    a-=b;if(k&1)a*=-1;
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/abc143/tasks/abc143_d
N = read_a_int()
L = read_ints()
L.sort()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        bigest_idx = bisect_left(L, a + b, lo=j + 1)
        smallest_idx = bisect_right(L, b - a, lo=j + 1)
        tmp = bigest_idx - smallest_idx
        # if smallest_idx <= i < bigest_idx:
        #     tmp -= 1
        # if smallest_idx <= j < bigest_idx:
        #     tmp -= 1
        ans += tmp
        # print(i, j, smallest_idx, bigest_idx, tmp)
print(ans)


Measured memory_bytes: 46684
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>

using namespace std;

int main(){

	int num,E,from,to,table[10000],tmp;
	vector<int> V[10000];
	queue<int> Q;

	for(int i = 0; i < 10000; i++)table[i] = 0;

	scanf("%d %d",&num,&E);

	for(int i = 0; i < E; i++){
		scanf("%d %d",&from,&to);
		V[from].push_back(to);
		table[to]++;
	}

	for(int i = 0; i < num; i++){
		if(table[i] == 0){
			Q.push(i);
		}
	}

	while(!Q.empty()){
		tmp = Q.front();
		Q.pop();
		printf("%d\n",tmp);
		for(int i = 0; i < V[tmp].size(); i++){
			table[V[tmp][i]]--;
			if(table[V[tmp][i]] == 0){
				Q.push(V[tmp][i]);
			}
		}
	}

	return 0;
}



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << ' ' << y << ' ' << z << endl;
}


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

bool kaibun(string s){
    int n = s.size();
    bool ok = true;
    for(int i=0;i<=(n-1)/2;i++){
        if(s[i]!=s[n-1-i]) ok = false; 
    }
    return ok;
}

int main(void){
    string s;
    cin >> s;
    int n = s.size();

    string s1 = s.substr(0,(n-1)/2);
    string s2 = s.substr((n+3)/2-1,n-(n+3)/2+1);

    if(kaibun(s) && kaibun(s1) && kaibun(s2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            string N = ReadLine();

            int total = 0;

            foreach (char c in N) 
            {
                total += int.Parse(c.ToString());
            }

            if (total % 9 == 0)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }

            return;
        }
    }
}


Measured memory_bytes: 21636
object Main extends App {
  val scanner = new java.util.Scanner(System.in)
  scanner.useDelimiter("")

  val input = Iterator.continually(scanner.hasNext())
    .takeWhile(identity)
    .map(_ => scanner.next())
    .filter(s => ('A' to 'z').contains(s.head))

  val outputs = input.foldLeft(List.fill('z' - 'a' + 1)(0)) { (list, c) =>
    val lower = c.head.toLower
    val index = lower - 'a'

    list.updated(index, list(index) + 1)
  }.zipWithIndex

  outputs.foreach { t =>
    println(s"${('a' + t._2).toChar} : ${t._1}")
  }
}

Measured memory_bytes: 49532
#include <iostream>
using namespace std;
int main() {
  char c;
  cin >> c;
  if(c == 'a'|| c == 'o' || c == 'e' || c == 'i' || c == 'u'){
    cout << "vowel";
  }
  else{
    cout << "consonant";
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char S[1001], T[1001];
	scanf("%s", S);
	scanf("%s", T);
	
	int i, j, k, l, min, tmp;
	for (k = 0; S[k] != 0; k++);
	for (l = 0; T[l] != 0; l++);
	for (i = 0, min = l; i <= k - l; i++) {
		for (j = 0, tmp = 0; j < l; j++) if (S[i+j] != T[j]) tmp++;
		if (tmp < min) min = tmp;
	}
	printf("%d\n", min);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);


int main() {
    int n, m, a, b;
    cin >> n >> m;
    unordered_map<int, vector<int>> out_deg;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        out_deg[a].push_back(b);
    }
    vector<int> deepest(n+1, -1);
    auto dfs = [&](auto& self, int cur) -> int {
        if (deepest[cur] >= 0)
            return deepest[cur];
        if (out_deg.count(cur) == 0) {
            deepest[cur] = 0;
        } else {
            int res = 0;
            for(int child: out_deg[cur]) {
                res = max(res, self(self, child)+1);
            }
            deepest[cur] = res;
        }
        return deepest[cur];
    };
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        ans = max(ans, dfs(dfs, i));
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 10660
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] count = new int[num];

    int kind = sc.nextInt();
    for (int i = 0 ;kind > i ;i ++) {
      int haveCount = sc.nextInt();
      for (int j = 0 ;haveCount > j ;j ++) {
        int haveIndex = sc.nextInt();
        count[haveIndex -1 ]++;
      }
    }

    int resultCount = 0;
    for (int i = 0; i < num ;i++) {
      if (count[i] == 0) resultCount++;
    }
    
    System.out.println(resultCount);    

  }

}


Measured memory_bytes: 46432
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);

        String in = sc.next();
        int x = in.length();
        String out = "";
        for(int i = 0; i < x; i++)
            out+= "x";
        pw.println(out);

        pw.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}




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

int main() {
    string s; cin >> s; 
    string t; cin >> t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#if 1
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <list>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const LD eps = 1e-9;
const LD pi = acos(-1.0);
const LL inf = 1e+9;

#define mp make_pair
#define pb push_back
#define X first
#define Y second

#define dbg(x) { cerr << #x << " = " << x << endl; }

// extended template
#pragma comment(linker, "/STACK:36777216")
typedef vector<int> vi;
typedef vector<vi> vvi;

#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template<typename T> istream & operator >> (istream &, vector<T> &);
template<typename T> ostream & operator << (ostream &, const vector<T> &);

#define START clock_t _clock = clock();
#define END cerr << endl << "time: " << (clock() - _clock) / LD(CLOCKS_PER_SEC) << endl;

#define NAME "angle1"


void solve()
{
	string s;
	cin >> s;
	LL a = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '+')
			a++;
		else
			a--;
	}
	cout << a << endl;
}

int main()
{

	//START
	//freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout);
	//freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout);
	solve();


	//END		 
	return 0;
}
/*******************************************
*******************************************/

template<typename T> istream & operator >> (istream &is, vector<T> &v)
{
	forn(i, v.size())
		is >> v[i];
	return is;
}
template<typename T> ostream & operator << (ostream &os, const vector<T> &v)
{
	forn(i, v.size())
		os << v[i] << " ";
	return os;
}
#endif

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}    


signed main()
{
    showoff;
   	int n;
   	string s,t,ans = "";
   	cin >> n >> s >> t;
   	FOR(i,0,n)ans += s[i],ans += t[i];
   	cout << ans;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

const int N = 2005;
int dp[N];

int add(int& a, int b){
    a = (a + b)%M;
}

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

    int S; cin >> S;

    dp[0] = 1;

    for(int i=1;i<=S;i++){
        for(int j=3;j<=S;j++){
            if(i-j>=0){
                dp[i] = (dp[i] + dp[i-j])%M;
                //add(dp[i], dp[i-j]);
            }
        }
    }

    cout << dp[S] << "\n";


}


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

int main(){
  int x;
  cin >> x;
  
  if(x < 600){
    cout << 8 << endl;
  }
  else if( x < 800){
    cout << 7 << endl;
  }
  else if( x < 1000){
    cout << 6 << endl;
  }
  else if( x < 1200){
    cout << 5 << endl;
  }
  else if( x < 1400){
    cout << 4 << endl;
  }
  else if( x < 1600){
    cout << 3 << endl;
  }
  else if( x < 1800){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}



Measured memory_bytes: 3616
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T> &v) {
	T ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


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

ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}

bool sortreverse(ll a, ll b) {
	return a > b;
}

bool kansu(pll a, pll b) {
	return a.first < b.first;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll dp[12];
ll n, m, k;

bool check(vl& p, vvl& sto) {
	rep(i, 0, m) {
		ll check = 0;
		rep(j, 0, sto[i].size()) {
			check += dp[sto[i][j]];
		}
		if (check % 2 != p[i])return false;
	}
	return true;
}

ll solv(vl& p, vvl& sto, ll i) {
	if (i == 0) {
		/*rep(o, 0, 12) {
			printf("%lld ", dp[o]);
		}
		printf("\n");*/
		if (check(p, sto))return 1;
		return 0;
	}
	dp[i] = 0;
	ll ans = 0;
	ans = solv(p, sto, i - 1);
	dp[i] = 1;
	ans += solv(p, sto, i - 1);
	return ans;
}

int main() {
	
	cin >> n >> m;
	vvl sto(m);
	vl p(m);
	rep(i, 0, m) {
		cin >> k;
		sto[i] = vl(k);
		rep(j, 0, k) {
			cin >> sto[i][j];
		}
	}
	rep(i, 0, m) {
		cin >> p[i];
	}
	cout << solv(p, sto, n) << '\n';
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N, X, Y;
	cin >>N >>X >>Y;
	vector<vector<int>> S(N+1, vector<int> (N+1, INF));
	for (int i=1; i<=N; i++) // Self
		S.at(i).at(i)=0;
	for (int i=1; i<=N; i++) // Initial
		for (int j=1; j<=N; j++)
			S.at(i).at(j)=S.at(j).at(i)=abs(i-j);
	S.at(X).at(Y)=S.at(Y).at(X)=1; // New
	for (int i=1; i<=N; i++)
		for (int j=1; j<=N; j++)
			S.at(i).at(j) =min(S.at(i).at(j), S.at(i).at(X)+S.at(X).at(j));
	for (int i=1; i<=N; i++)
		for (int j=1; j<=N; j++)
			S.at(i).at(j) =min(S.at(i).at(j), S.at(i).at(Y)+S.at(Y).at(j));
	vector<int> ss(N, 0);
	for (int i=1; i<=N; i++)
		for (int j=1; j<=N; j++)
			ss.at(S.at(i).at(j))++;
	for (int i=1; i<N; i++)
		cout <<ss.at(i)/2 <<endl;
	return 0;
}



Measured memory_bytes: 16000
from bisect import bisect_left

N = int(input())
d = list(map(int, input().split()))
d.sort()

to_take = N // 2

cnt = 0
for x in range(d[0], d[-1] + 1):
    idx = bisect_left(d, x)
    # ABC用の問題数
    if idx == to_take:
        cnt += 1
print(cnt)


Measured memory_bytes: 53172
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;

//* Author :- Amey :P *//
void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}
 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}






int main(){

//   #ifndef ONLINE_JUDGE
//      freopen("input.txt", "r", stdin);
//   #endif
    ll n,k;
   cin>>n>>k;
   ll c= 0;
   while(n){
    c++;
    n /= k;
   }
   cout<<c<<endl;



}


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

int main() {
	int n; cin >> n;
    ll ans = 0;
    ll high = 0;
  rep(i, n){
    ll a; cin >> a;
    ans += max(high - a, ll(0));
    high = max(a, high);
  }
  
  cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3576
input()
nums = [int(i)-1 for i in input().split()]
c = 0

for i, j in enumerate(nums):
	if i == j and i != len(nums) - 1:
		nums[i], nums[i+1] = nums[i+1], nums[i]
		c += 1
	elif i == j and i == len(nums) - 1:
		nums[i], nums[0] = nums[0], nums[i]
		c += 1
print(c)



Measured memory_bytes: 13880
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  ll n,a,b;
  cin>>n>>a>>b;
  vi x(n);
  rep(i,n)
    cin>>x[i];
  ll ans=0;
  rep(i,n-1)
    if((ll)(x[i+1]-x[i])*a<b)
      ans+=(ll)(x[i+1]-x[i])*a;
    else
      ans+=b;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
L, R = map(int, input().split())
mn = 2020

for i in range(L, R):
    for j in range(i+1, R+1):
        if R - L >= 2019:
            mn = 0
            break
        elif mn > (i*j)%2019:
            mn = (i*j)%2019
        elif mn == 0:
            break
    if R - L >= 2019:
            break
    elif mn == 0:
            break
print(mn)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int M;
int A[9];
int m[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[10001];
char res[10001];
int ress;
int main(){
  int i, j, k;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<M;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  sort(A, A+M);
  for(i=0;i<M;i++){
    m[i] = m[A[i]];
  }
  for(i=1;i<N+1;i++){
    dp[i] = -1073709056;
  }
  for(i=0;i<M;i++){
    for(k=m[i];k<N+1;k++){
      chmax(dp[k], dp[k-m[i]] + 1);
    }
  }
  k = 0;
  while(N){
    for(i=M-1;i>=0;i--){
      if(N-m[i]>=0 && dp[N]==dp[N-m[i]]+1){
        res[ress++] = '0' + A[i];
        N -= m[i];
        break;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, M, A[9];
// 
// int m[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
// int dp[10001];
// 
// char res[10001]; int ress;
// 
// {
//   int i, j, k;
//   rd(N,M,A(M));
//   
//   sort(A, A+M);
//   rep(i,M) m[i] = m[A[i]];
// 
//   rep(i,1,N+1) dp[i] = -int_inf;
//   rep(i,M) rep(k,m[i],N+1) dp[k] >?= dp[k-m[i]] + 1;
// 
//   k = 0;
//   while(N){
//     for(i=M-1;i>=0;i--) if(N-m[i]>=0 && dp[N]==dp[N-m[i]]+1){
//       res[ress++] = '0' + A[i];
//       N -= m[i];
//       break;
//     }
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	string divide[4] = { "dream", "dreamer", "erase", "eraser" };
	string S;
	cin >> S;
 
	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());
 
	bool can = true;
	for (int i = 0; i < S.size();) {
		bool can2 = false;
		for (int j = 0; j < 4; ++j)
		{
			string d = divide[j];
			if (S.substr(i, d.size()) == d) {
				can2 = true;
				i += d.size();
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}
 
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main() {
    string s[3];
    int num[3];
    for(int i = 0; i < 3; i++){
        cin >> s[i];
        num[i] = s[i].length();
    }
    for(int i = 0; i < 2; i++){
        if(s[i][num[i]-1] != s[i+1][0]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

int main(){
    int n,m;cin>>n>>m;
    string s;cin>>s;
    vector<int> dp(n+1);
    int r = n;
    for(int i = n-1; i >= 0; i--){
      if(s[i] == '1'){
        dp[i] = -1;
        continue;
      }
      while(r>i+m) r--;
      while(dp[r] == -1) r--;
      if(i == r){
        cout<<-1;
        return 0;
      }
      dp[i] = dp[r]+1;
    }

    vector<int> ans;
    int curr = 0;
    for(int i = 0; i < n+1; i++){
      if(dp[i] == -1) continue;
      if(dp[i]!=dp[curr]){
        ans.push_back(i-curr);
        curr = i;
      }
    }
    for(int i = 0; i < (int)ans.size(); i++) cout<<ans[i]<<" ";
    
}


Measured memory_bytes: 1528
#include <iostream>
#include <queue>
#include <cstdlib>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 100000
using namespace std;

struct process {
  char name[10];
  int t;
};

int main () {
  int n, q, i, sum = 0;
  queue<process> Q;
  process qu;
  
  // input
  cin >> n >> q;
  rep(i,n) {
    cin >> qu.name >> qu.t;
    Q.push(qu);
  }

  // process
  while (!Q.empty()) {
    qu = Q.front();
    Q.pop();
    if (qu.t <= q) {
      sum += qu.t;
      cout << qu.name << " " << sum << endl;
    } else {
      sum += q;
      qu.t -= q;
      Q.push(qu);
    }
  }
  return 0;
}

Measured memory_bytes: 1932
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	string s;
	cin >> s;
	bool ab=0;
	bool bb=0;
	bool cb=0;
	int count=0;
	if(s[0]=='A') ab=1;
	SREP(i,s){
		if(i>=2&&i<s.size()-1&&s[i]=='C') bb=1;
		if(s[i]>'Z') count++;
	}
	if(count==s.size()-2) cb=1;
	//cout << ab << bb << cb << count << endl;
	cout << (ab&&bb&&cb ? "AC" : "WA") << endl;
/////////////////////////////////////////////
}


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

int main(){
  string S;
  cin>>S;
  if(S.size()%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i*2<S.size();i+=2)
    if(S.at(i)!='h' || S.at(i+1)!='i'){
      cout<<"No"<<endl;
      return 0;
    }
  cout<<"Yes"<<endl;
}

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

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x1 = getInt(sc);
		int y1 = getInt(sc);
		int x2 = getInt(sc);
		int y2 = getInt(sc);

		int difx = x2 - x1; // 正方形の縦方向の長さ
		int dify = y2 - y1;// 正方形の横方向の長さ

		int x3 = x2 - dify;
		int y3 = y2 + difx;
		int x4 = x1 - dify;
		int y4 = y1 + difx;

		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);

	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	long x;
	long tmpCoins;

	public Status(long x, long tmpCoins) {
		this.x = x;
		this.tmpCoins = tmpCoins;
	}
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int p(int a,int b,int c){
        if(a+b>c&&a+c>b&&b+c>a){
            return 1;
        }
    return 0;
}
    
int main(){
    int n,a[100001];
    cin>>n;
    for(int i=1;i<n+1;i++){
        cin>>a[i];
    }
    int ans=0;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int it=lower_bound(a+1, a+n+1, a[i]+a[j])-a-2;
            if(it-j+1>0){
                ans+=it-j+1;
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
vector<vector<int>> s;
vector<int> p;
int N, M;

bool judge(int bit){
  int cnt = 0;
  for(int i=0; i<M; i++){
    int state = 0;
    for(int j=0; j<s[i].size();j++){
      if (bit & (1<<s[i][j])) state += 1;
    }
    if (p[i] == (state %2)) cnt++;
  }
  return cnt==M;
}

int main() {
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int k;
    cin >> k;
    vector<int> s_tmp;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      s_tmp.push_back(tmp-1);
    }
    s.push_back(s_tmp);
  }
  for(int i=0;i<M;i++){
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  int ans =0;
  for(int bit=0; bit<(1<<N);++bit) if(judge(bit)) ans++;
  cout << ans;
  return 0;
}

Measured memory_bytes: 3644