akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int a[] = new int[20000],i=0;
		while((a[i]=Integer.parseInt(br.readLine()))!=0){
			i++;
		}
		int j;
		for(j=1;j<=i;j++){
			System.out.println("Case "+j+": "+a[j-1]);;
		}
	}
}

Measured memory_bytes: 32556
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll dp[25000010]; //つかったcost,生んだ価値
ll dp2[25000010]; //つかったcost,生んだ価値
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    ll ga,sa,ba,gb,sb,bb; cin>>ga>>sa>>ba>>gb>>sb>>bb;
    rep(i,25000005){
        if(i+ga<25000005) maxi(dp[i+ga],dp[i]+(gb-ga));
        if(i+sa<25000005) maxi(dp[i+sa],dp[i]+(sb-sa));
        if(i+ba<25000005) maxi(dp[i+ba],dp[i]+(bb-ba));
    }
    ll ans1=0;
    rep(i,N+1){
        maxi(ans1,dp[i]);
    }
    ans1+=N;
    rep(i,25000005){
        if(i+gb<25000005) maxi(dp2[i+gb],dp2[i]+(ga-gb));
        if(i+sb<25000005) maxi(dp2[i+sb],dp2[i]+(sa-sb));
        if(i+bb<25000005) maxi(dp2[i+bb],dp2[i]+(ba-bb));
    }
    ll ans=0;
    rep(i,ans1+1){
        maxi(ans,dp2[i]);
    }
    cout<< ans+ans1 <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 390912
s=input()
s=s[::-1]
w=['dream','dreamer','erase','eraser']
lenw=[5,7,5,6]
w=[i[::-1] for i in w]
i=0
n=len(s)
while i<n:
    flg=False
    for j in range(4):
        if s[i:min(i+lenw[j],n)]==w[j]:
            i=i+lenw[j]
            flg=True
    if flg==False:
        break

if i==n and flg:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }

int n,k;
int noof(int l,int r)
{
    int p1,p2;
    p1=l+1;
    p2=r-k-1;

    return (r-l+1)/(k+1);

}

void test()
{
    string s,t;
    cin>>s>>t;
    
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No";
            return ;
        }
    }
    
    if(t.size()-s.size()==1)
        cout<<"Yes";
    else
        cout<<"No";
    
}

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

        test();

    return 0;

}


Measured memory_bytes: 3488
n=int(input())
a=[]
r=[]
for i in input().split():
  a.append(int(i))
a.sort()
t=a.pop(-1)
b=a.pop(0)
for i in a:
  if i>=0:
    r.append([b,i])
    b=b-i
  else:
    r.append([t,i])
    t=t-i
print(t-b)
r.append([t,b])
for i in r:
  print(i[0],i[1])


Measured memory_bytes: 22364
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	int n, m;
	cin >> n >> m;
	vector<double> a(n);
	int all = 0;
	REP(i, n)
	{
		cin >> a[i];
		all += a[i];
	}
	int cnt = 0;
	REP(i, n)
	{
		if (a[i] < all / (4.0 * m))continue;
		cnt++;
	}
	if (m <= cnt)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int n;cin>>n;
	vector<string> s(n);
	vector<int> p(n);
	int i;
	rep(i,n) cin>>s[i]>>p[i];
	vector<tuple<string,int,int>> t(n);
	rep(i,n) t[i]=make_tuple(s[i],-p[i],i+1);
	sort(all(t));
	rep(i,n) cout<<get<2>(t[i])<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <vector>
#define ll long long
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

using namespace std;

string s;
int n;

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

    string ans;

    cin >> n;
    cin >> s;

    ans = s;
    int count = 0;
    
    REP(i,n){
        if(s[i] == ')'){
            if(count <= 0) ans.insert(ans.begin(),'(');
            else count--;
        }
        else count++;
    }

    REP(i,count) ans.push_back(')');
    
    cout << ans << "\n";
    

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    
    int p, q, r, res;
    cin >> p >> q >> r;


    if(r >= p && r >= q) {
        res = p + q;
    } else if (p >= r && p >= q) {
        res = r + q;
    }else if (q >= p && q>= r) {
        res = p + r;
    }
    
    cout << res << endl;
}   



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
	int N, T;
	int c;
	int t;
	int min = 1001;
	cin >> N >> T;

	for (int i = 0; i < N; i++) {
		cin >> c >> t;
		if (T >= t) {
			if (min > c) {
				min = c;
			}
		}
	}
	if (min == 1001)cout << "TLE" << endl;
	else cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
mountains = list(input())
stack1, stack2 = [], []

for i, grad in enumerate(mountains):
    if grad == '\\':
        stack1.append(i)
    elif grad == '/':
        if stack1:
          left = stack1.pop(-1)
          right = i
          space = right - left
          while stack2 and stack2[-1][0] > left:
            space += stack2.pop(-1)[1]
          stack2.append([left, space])
    else:
        pass
#print(stack2)
space_list = [space for index, space in stack2]
print(sum(space_list))
print(len(space_list), *space_list)


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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
#define int long long

using LL = long long;
using ULL = unsigned long long ;
using PII =  pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX;
const int INF = INT_MAX;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { 
	if (b > a) return absdiff(b, a);
	return (a - b);
}
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数

string S;
VI Sint;
int n, allsum = 0;
void dfs(int i, int sum, int part) {
	if (i == n) {
		allsum += sum + part;
	}
	else {
		// '+'を挿入しない
		dfs(i + 1, sum, part*10 + Sint[i]);

		// '+'を挿入する
		dfs(i + 1, sum + part, Sint[i]);
	}
}

signed main()
{	
	cin >> S;
	n = S.size();
	Sint.resize(n);
	rep(i, n) {
		Sint[i] = static_cast<int>(S[i] - '0');
	}

	dfs(1, 0, Sint[0]);

	COL(allsum);

	return 0;
}

Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    X = get_input(int)
    A5_cache = {}
    for A in range(10000000):
        A5 = A**5
        A5_cache[A5] = A

        B5 = A5 - X
        if B5 in A5_cache:
            B = A5_cache[B5]
            break
        elif -B5 in A5_cache:
            B = -A5_cache[-B5]
            break
    assert A**5 - B**5 == X
    print(A, B)

        

if __name__ == '__main__':
    main()


Measured memory_bytes: 27132
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;

int v1n[100000], v2n[100000];

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

	int nh = n / 2;

	for (size_t i = 0; i < nh; i++)
	{
		int tmp;

		cin >> tmp;
		tmp--;
		v1n[tmp]++;

		cin >> tmp;
		tmp--;
		v2n[tmp]++;
	}

	int v1_1 = -1;
	int v1_2 = -1;
	int v1_1n = 0;
	int v1_2n = 0;
	int v2_1 = -1;
	int v2_2 = -1;
	int v2_1n = 0;
	int v2_2n = 0;
	for (size_t i = 0; i < 100000; i++)
	{
		if (v1_1n < v1n[i])
		{
			v1_2 = v1_1;
			v1_2n = v1_1n;
			v1_1 = i;
			v1_1n = v1n[i];
		}
		else if(v1_2n < v1n[i])
		{
			v1_2 = i;
			v1_2n = v1n[i];
		}

		if (v2_1n < v2n[i])
		{
			v2_2 = v2_1;
			v2_2n = v2_1n;
			v2_1 = i;
			v2_1n = v2n[i];
		}
		else if (v2_2n < v2n[i])
		{
			v2_2 = i;
			v2_2n = v2n[i];
		}
	}

	if (v1_1 != v2_1)
	{
		cout << n - v1_1n - v2_1n << endl;
	}
	else
	{
		if ((n - v1_1n - v2_2n) < (n - v1_2n - v2_1n))
		{
			cout << n - v1_1n - v2_2n << endl;
		}
		else
		{
			cout << n - v1_2n - v2_1n << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#ifndef JHELPER_EXAMPLE_PROJECT_DEFINITION_HPP
#define JHELPER_EXAMPLE_PROJECT_DEFINITION_HPP

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

#endif //JHELPER_EXAMPLE_PROJECT_DEFINITION_HPP


class CSumOfGcdOfTuplesEasy {
public:
	void solve(std::istream& in, std::ostream& out) {
        int K; in >> K;
        ll ans = 0;
        for (int i = 1; i <= K; ++i)
            for (int j = 1; j <= K; ++j)
                for (int k = 1; k <= K; ++k) {
            ans += gcd(gcd(i, j), k);
        }
        out << ans << '\n';
	}
};


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

	CSumOfGcdOfTuplesEasy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int h,w; cin >> h >> w;
    vector<string> a(h);
    for(int i = 0;i < h;i ++){
        cin >> a.at(i);
    }

    for(int i = 0;i < a.size();i ++){
        int sum = 0;
        for(int j = 0;j < w;j ++){
            sum += a.at(i).at(j);
        }

        if(sum == '.' * w){
            a.erase(a.begin() + i);
            i --;
        }
    }

    for(int i = 0;i < a.at(0).size();i ++){

        bool hantei = true;
        for(int j = 0;j < a.size();j ++){
            if(a.at(j).at(i) == '#') hantei = false;            
        }

        if(hantei == true){
            for(int j = 0;j < a.size();j ++){
                a.at(j).erase(a.at(j).begin() + i);
            }
            i --;
        }
    }

    for(int i = 0;i < a.size();i ++){
        for(int j = 0;j < a.at(0).size();j ++){
            cout << a.at(i).at(j);
        }
        cout << endl;
    }
}



Measured memory_bytes: 256
let n = Scanf.scanf "%d\n" (fun x -> x)

let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x))

let total = Array.fold_left ( + ) 0 a

let () =
  let rec f i sumx tmp =
    if i = n then tmp
    else
      let next_sumx = sumx + a.(i) in
      let next_tmp = min tmp (abs (2 * sumx - total)) in
      f (i + 1) next_sumx next_tmp
  in
  f 1 a.(0) max_int |> Printf.printf "%d\n"

Measured memory_bytes: 5760
def has_duplicates(seq):
    return len(seq) != len(set(seq))

def onlya(n , a):

    ans = "YES"

#    for i in range(n):
#        for w in range(i + 1 , n):
#            if a[i] == a[w]:
#                return "NO"

    if has_duplicates(a):
        return "NO"

    return ans

def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(onlya(n , a))

if __name__ == '__main__':
    main()

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

int main(void){
    ll x;
    cin >> x;

    if(x == 7 || x == 5 || x == 3){
        puts("YES\n");
    }else{
        puts("NO\n");
    }

    return 0;
}


Measured memory_bytes: 256
s=input()
n,m=0,0
p,q=0,0
for i in range(len(s)):
    if i&1:
        if s[i]=='0':
            n+=1
        else:
            p+=1
    else:
        if s[i]=='0':
            m+=1
        else:
            q+=1
print(len(s)-max(n+q,m+p))

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

main() {
  int n;
  cin >> n;
  int m = n;
  for(int i = 0; i < 9; i++) {
    int mod;
    mod += n%10;
    n /= 10;
    if(i == 8 && m%mod == 0) 
     cout << "Yes" <<endl;
    else if (i == 8)
      cout << "No" <<endl;
  }
}
  

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


int main() {
    int n;
    cin >> n;
    int counter = 0;

    for (int i = 1; i < n; i++)
    {
        int p = n - i;
        for (int j = 1; j*j <= p; j++)
        {
            if(p%j) continue;
            else if(j*j == p) counter += 1;
            else counter += 2;
        }
        
    }
    cout << counter << endl;
    return 0;
}

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

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
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;
    }
}
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++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }

signed main() {
    int n;
    cin >> n;
    vector<int> as(n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> as[i];
        cnt[as[i]]++;
        cnt[as[i] - 1]++;
        cnt[as[i] + 1]++;
    }
    int max = 0;
    REP(i, 100000) {
        if (cnt[i] > max) {
            max = cnt[i];
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 5376
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	d := sc.NextIntArray()

	sort.Ints(d)

	fmt.Println(d[N/2] - d[N/2-1])

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6400
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	vector<int>Ans(S.size());
	for (int n = 0;n<S.size();++n) {
		if ('A' == S[n]||'C'==S[n]||'G'==S[n]||'T'==S[n]) {
			if (0 == n) {
				Ans[n] = 1;
			}
			else{
				Ans[n] = Ans[n-1] + 1;
			}
		}
		else {
			Ans[n] = 0;
		}
	}
	int ans = 0;
	for (int n = 0; n < S.size(); ++n) {
		ans = max(ans,Ans[n]);
	}
	cout << ans <<endl;
}

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

vector<ll> solve(int N, vector<int> X, vector<int> Y, vector<int> P){
    const ll inf = 1LL << 62;
    vector<vector<int>> xsel(1 << N, vector<int>(N));
    vector<vector<int>> ysel(1 << N, vector<int>(N));
    for(int i = 0; i < 1 << N; i++){
        for(int j = 0; j < N; j++){
            xsel[i][j] = abs(X[j]);
            ysel[i][j] = abs(Y[j]);
            for(int k = 0; k < N; k++){
                if((i >> k) & 1){
                    xsel[i][j] = min(xsel[i][j], abs(X[j] - X[k]));
                    ysel[i][j] = min(ysel[i][j], abs(Y[j] - Y[k]));
                }
            }
        }
    }
    vector<ll> ans(N+1, inf);
    for(int i = 0; i < 1 << N; i++){
        int cnt = 0;
        for(int j = 0; j < N; j++){
            if((i >> j) & 1) cnt++;
        }
        for(int j = i; j >= 0; j--){
            j &= i;
            ll cost = 0;
            for(int k = 0; k < N; k++){
                if(!((i >> k) & 1)){
                    cost += 1LL * min(xsel[j][k], ysel[i-j][k]) * P[k];
                }
            }
            ans[cnt] = min(ans[cnt], cost);
        }
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    vector<int> X(N), Y(N), P(N);
    for(int i = 0; i < N; i++){
        cin >> X[i] >> Y[i] >> P[i];
    }
    vector<ll> ans = solve(N, X, Y, P);
    for(int i = 0; i <= N; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
int main() {
  char vowel[] = {'a', 'i', 'u', 'e', 'o'};
  char s;
  cin >> s;
  for (int i=0; i<sizeof(vowel); i++) {
    if (s == vowel[i]) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

    a.sort_by(|a, b| b.cmp(a));
    let ans: usize = (1..n).map(|i| a[i / 2]).sum();
    println!("{}", ans);
}


Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n, m; cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    cin >> m;
    vector<bool> p(2020, false);
    rep(i, n) p[x[i]] = true;
    
    int a;
    rep(i, m){
        cin >> a;
        a--;
        if(x[a]==2019) continue;
        if(p[x[a]+1]) continue;
        swap(p[x[a]], p[x[a]+1]);
        x[a]++;
    }

    FOR(i, 0, n) cout << x[i] << endl;
    return 0;
}


Measured memory_bytes: 3100
N = int(input())
prime = []


def isPrime(n):  # nが素数か判定する
    if n == 0 or n == 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i == 0:
            return False
    return True


for i in range(2, 55555 + 1):
    if isPrime(i) and i % 5 == 1:
        prime.append(i)


print(*prime[:N], sep=" ")


Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int N = NI();
		int T = NI();
		long t[] = new long[N+1];
		for (int i = 0; i < N; i++) {
			t[i] = NI();
		}
		t[N] = 1L << 45;
		long ans = 0;
		long st = t[0];
		for (int i = 1; i <= N; i++) {
			if (t[i-1] + T < t[i]) {
				ans += T + t[i - 1] - st;
				st = t[i];
			}
		}
		System.out.println(ans);
	}

	static int NI() {
		try {
			int c = System.in.read(), r = 0;
			for (; c != '-' && (c < '0' || '9' < c);) {
				c = System.in.read();
			}
			if (c == '-')
				return -NI();
			for (; '0' <= c && c <= '9'; c = System.in.read()) {
				r = r * 10 + c - '0';
			}
			return r;
		} catch (Exception e) {
			return -1;
		}
	}

	static String next() {
		try {
			StringBuilder res = new StringBuilder("");
			int c = System.in.read();
			while (Character.isWhitespace(c))
				c = System.in.read();
			do {
				res.append((char) c);
			} while (!Character.isWhitespace(c = System.in.read()));
			return res.toString();
		} catch (Exception e) {
			return null;
		}
	}
}


Measured memory_bytes: 23380
#include <stdio.h>

void swap(int a[], int idx1, int idx2) {
    int tmp = a[idx1];
    a[idx1] = a[idx2];
    a[idx2] = tmp;
}
int main(void) {
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    if (a[0] > a[1]) {
        swap(a, 0, 1);
    }
    if (a[1] > a[2]) {
        swap(a, 1, 2);
    }
    if (a[0] > a[1]) {
        swap(a, 0, 1);
    }
    printf("%d %d %d\n", a[0], a[1], a[2]); 
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,a,b;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n>>a>>b;
      cout<<(n/(a+b))*a+min((n%(a+b)),a);
}

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

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

int N, X;
int m[100];

int main() {
  scanf("%d%d", &N, &X);

  REP(i,N) {
    scanf("%d", &m[i]);
    X -= m[i];
  }

  int count = N;
  sort(m, m+N);
  count += X / m[0];

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>


using namespace std;


int main(void)
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string pat = "";
    if (sy < ty)
        pat += "U";
    else
        pat += "D";

    if (sx < tx)
        pat += "R";
    else
        pat += "L";

    if (sy < ty)
        pat += "D";
    else
        pat += "U";

    if (sx < tx)
        pat += "L";
    else
        pat += "R";

    for (int i = 0; i < abs(ty - sy); i++)
        cout << pat[0];
    for (int i = 0; i < abs(tx - sx); i++)
        cout << pat[1];
    for (int i = 0; i < abs(ty - sy); i++)
        cout << pat[2];
    for (int i = 0; i < abs(tx - sx); i++)
        cout << pat[3];

    cout << pat[3];
    for (int i = 0; i <= abs(ty - sy); i++)
        cout << pat[0];
    for (int i = 0; i <= abs(tx - sx); i++)
        cout << pat[1];
    cout << pat[2];

    cout << pat[1];
    for (int i = 0; i <= abs(ty - sy); i++)
        cout << pat[2];
    for (int i = 0; i <= abs(tx - sx); i++)
        cout << pat[3];
    cout << pat[0];

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<vector<int>>A(2,vector<int>(N));
    rep(i, 2)rep(j,N)cin >> A[i][j];
    vector<int>C(N);
    C[0] = A[0][0];
    rep(i, N)C[0] += A[1][i];
    REP(i, N)C[i] = C[i - 1] + A[0][i] - A[1][i - 1];
    sort(C.begin(), C.end());
    cout << C[N - 1] << endl;
}

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


#define ll unsigned long long
#define FASTIO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

const ll maxn = 2e5+5;
const int MOD = 1e9+7;

int main(){
    FASTIO
	int n;cin >> n;
	int t1 = n/100;
	int t2 = n%100;
	
	if(1 <= t1 && t1 <= 12){
		
		if(1 <= t2 && t2 <= 12){
			cout << "AMBIGUOUS";
		}else{
			cout << "MMYY";
		}
	}
	else{
		
		if(1 <= t2 && t2 <= 12){
			cout << "YYMM";
		}else{
			cout << "NA";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  
  long long n;
  cin >> n;
  
  long long ans = n-1;
  for (long long i = 2; i*i <= n; ++i) {
    if (n % i == 0) {
    	ans = min(ans, i + n/i - 2);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

#define ll signed long long 

ll ok(ll n) {
  ll t = n % 10;
  ll cnt = 1;
  while (n > 0) {
    if (abs(t - (n % 10)) > 1) {
      return cnt;
    }
    t = n % 10;
    n /= 10;
    cnt *= 10;;
  }
  return -1;
}

ll inc(ll n) {
  ++n;
  while (true) {
    ll t = ok(n);
    if (t == -1) {
      break;
    }
    t /= 10;
    n /= t;
    ++n;
    n *= t;
  }
  return n;
}

int main() {
  ll K;
  cin >> K;

  ll ans = 0;
  for (int i = 0; i < K; ++i) {
    ans = inc(ans);
  }

  cout << ans << endl;
  return 0;
}


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

int N, M;
int64_t sum = 0;

int main(){
  cin >> N >> M;
  vector<int> vec(N+1);    //Mはint型に収まるため

  int v;
  for(int i = 1; i <= N; i++){
    cin >> v;
    vec[i] = (vec[i-1] + v)%M;
  }
  //累積和　vec内の2つの値の差が0ならば間のお菓子の数はMの倍数

  sort(vec.begin(), vec.end());      //時間はかかるがソート   O(nlogn)　ここが最大


  int64_t i = 1; int64_t j = 0;
  while(i <= N){
    while(vec[i] == vec[i+j] && i+j <= N) j++;            //jはある剰余の重複数
    if(vec[i] == 0) sum += (j+1) * j / 2;  //0は特別で、単独でも条件を満たす
    else sum += j * (j-1) / 2;                            //0でない場合は、2つ以上必要となる
    i += j; j = 0;
  }
  /*32bitじゃ足りないと言ってくれるやさしさを無下にするやつがいるらしい...*/
    
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    rep(i, 4) {
        int ti, ni;
        cin >> ti >> ni;
        if (ti == 1) {
            cout << (6000 * ni) << endl;
        } else if (ti == 2) {
            cout << (4000 * ni) << endl;
        } else if (ti == 3) {
            cout << (3000 * ni) << endl;
        } else if (ti == 4) {
            cout << (2000 * ni) << endl;
        }
    }
}


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

using namespace std;

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(int n) : n(n) {}
  void read_input(){
    for (int i = 0; i < n; i++){
      char buf[512];
      scanf("%s", buf);
      for (int j = 0; j < n; j++){
        grid[i][j] = buf[j] - '0';
      }
    }
  }
  int get_max(){
    int maxi = 0;
    int L = n - 1;
    for (int i = 0; i < n; i++){
      maxi = max(maxi, scan(0, i, 1, 0));
      maxi = max(maxi, scan(0, i, 1, 1));
      maxi = max(maxi, scan(0, i, 1,-1));
      maxi = max(maxi, scan(i, 0, 0, 1));
      maxi = max(maxi, scan(i, 0, 1, 1));
      maxi = max(maxi, scan(i, L, 1,-1));
    }
    return maxi;
  }
  int scan(int x, int y, int dx, int dy){
    int maxi = 0;
    int v = 0;
    while (0 <= x && x < n && 0 <= y && y < n){
      v = v * grid[y][x] + grid[y][x];
      maxi = max(maxi, v);
      x += dx;
      y += dy;
    }
    return maxi;
  }

  int grid[255][255];
  int n;
};

int main()
{
  int n;
  while (n = in()){
    Solver solver(n);
    solver.read_input();
    printf("%d\n", solver.get_max());
  }

  return 0;
}

Measured memory_bytes: 1444
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

ll cnt[maxn];
int fa[maxn];

void init(int n) {
    for (int i = 1; i <= n; i++) {
        fa[i] = i;
    }
}

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

void unio(int x, int y) {
    int fx = find(x);
    int fy = find(y);
    if (fx != fy) {
        fa[fx] = fy;
    }
}

int main(void) {
    FAST_IO;
    
    int n, tot = 0, m;
    ll ans = 0;
    cin >> n >> m;
    init(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        unio(x, y);
    }
    for (int i = 1; i <= n; i++) {
        int fx = find(i);
        if (fx == i) {
            tot++;
        }
        cnt[fx]++;
    }
    for (int i = 1; i <= n; i++) {
        ans = max(ans, cnt[i]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 10524
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>

int main() {
	int N;
	std::cin>>N;
	std::vector<double> p(N+1);
	for (int i = 1; i <= N; ++i) {
		double d;
		std::cin>>d;
		p[i] = d;
	}
	double dp[N+1][N+1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1.0;
	for (int i = 1; i <= N; ++i) {// play i round
		for (int j = 0; j <= i; ++j) { // and have j coins head
			int x = j, y = i - j ; // in all coins, x is head, y is tail
			if (x > 0) {
				dp[x][y] += dp[x-1][y] * p[i];
			}
			if (y > 0) {
				dp[x][y] += dp[x][y-1] * (1-p[i]);
			}
		}
	}
	double ans = 0.0;
	int l = N, r = 0;
	while (l > r) {
		ans += dp[l][r];
		l--;
		r++;
	}
	printf("%.10f\n",ans);

	return 0;
}


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

int main(){
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> ab(n);
	for (int i = 0; i < n; i++) {
		cin>>ab[i].first>>ab[i].second;
	}
	sort(
		ab.begin(),
		ab.end(),
		[](const pair<int,int> x,const pair<int,int> y){return x.first<y.first;}
	);
	long long int ans=0;
	int num=0;
	for (int i = 0; i < n; i++) {
		if (num+ab[i].second<=m) {
			ans+=(long long int)ab[i].first*ab[i].second;
			num+=ab[i].second;
		}else {
			ans+=(long long int)(m-num)*ab[i].first;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
import string

def main():
    n_a = dict(enumerate(string.ascii_uppercase))
    a_n = {v:k for k,v in n_a.items()}

    n = int(input())
    s = "".join(n_a[(a_n[c]+n)%26] for c in input())

    print(s)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3768
import numpy as np
import math as m

def main(**kwargs):
    c = {}
    maxc = 0

    for s in S:
        if s in c.keys():
            c[s] += 1

        else:
            c[s] = 1
        
        maxc = max(c[s], maxc)

    rs = []

    for ckey, cvalue in c.items():
        if cvalue == maxc:
            rs.append(ckey)

    rs.sort()
    r = "\n".join(rs)
    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n, *_ = cin
    S = []
    
    for i in range(n):
        cin = input()
        S.append(cin)
    
    cout = main(n=n, S=S)
    print(cout)

Measured memory_bytes: 44464
// 6/26 解き直し → 6/30
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000007;

// S = '034235??452'
// ? を変えて13で割って5余る数にする組み合わせ。

// dp[i][j]
// ?のi番目までを使ってj(mod13)となる数の組み合わせ。
// ?の個数をQとすると、最終的にdp[Q][5]が答え。

const int MOD = 1000000007;

const int mod = 13;
int dp[100010][15];

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

    int n = S.size();
    int now = 1;

    vector<int> A;  // 小さい方から数えてi番目の?の桁のmodを格納する
    int init = 0;  // 初めのmod

    for (int i = n-1; i >= 0; i--) {
        // cout << "here?" << endl;
        if (S[i] == '?') {
            A.push_back(now);
        } else {
            int x = S[i] - '0';
            init = (init + x * now) % mod;
        }
        now = (now * 10) % mod;
    }

    // printf("init, A.size() = %d, %d\n", init, A.size());
    // printf("%d\n", 2005 % mod);
    // for (auto a : A) cout << a << " ";
    // cout << endl;

    int q = A.size();

    rep(i, q+1) rep(j, mod) dp[i][j] = 0;
    // dp[0][0] = 1;
    dp[0][init] = 1;

    rep(i, q) {
        for (int j = 0; j < mod; j++) {
            // if (dp[i][j] == -1) continue;
            if (dp[i][j] == 0) continue;
            for (int k = 0; k < 10; k++) {
                int nj = (j + k * A[i]) % mod;
                dp[i+1][nj] += dp[i][j];
                dp[i+1][nj] %= MOD;
            }
        }
    }

    cout << dp[q][5] << endl;
    return 0;
}

Measured memory_bytes: 9708
#include <stdio.h>

int main(void)
{
  int a[3][3];
  int n;
  int b[100];

  int i, j, k;
  int c[3][3];
  int line[3], column[3], cross1, cross2;
  int bingo = 0;

  /*input*/
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++)
       scanf("%d ", &a[i][j]);
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) 
    scanf("%d", &b[i]);

  /*hit*/
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      c[i][j] = 0;
      for (k = 0; k < n; k++) {
	if (a[i][j] == b[k]) {
	  c[i][j] = 1; break;
	}
      }
    }
  }
  /*
  *bingo*
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      line[i] += c[i][j];
      column[j] += c[i][j];
      if (i == j)
	cross1 += c[i][j];
      if (i + j == 2)
	cross2 += c[i][j];
    }
  }

  *bingo or not*
  if (cross1 == 3 || cross2 == 3)
    bingo = 1;
  for (i = 0; i < 3; i++) {
    if (line[i] == 3 || column[i] == 3)
      bingo = 1;
  }

  if (bingo == 1)
    printf("Yes");
  else
    printf("No");
*/

  if (c[0][0] == 1 && c[0][1] == 1 && c[0][2] == 1) {
    printf("Yes\n");
  } else if (c[1][0] == 1 && c[1][1] == 1 && c[1][2] == 1) {
    printf("Yes\n");
  } else if (c[2][0] == 1 && c[2][1] == 1 && c[2][2] == 1) {
    printf("Yes\n");
  } else if (c[0][0] == 1 && c[1][0] == 1 && c[2][0] == 1) {
    printf("Yes\n");
  } else if (c[0][1] == 1 && c[1][1] == 1 && c[2][1] == 1) {
    printf("Yes\n");
  } else if (c[0][2] == 1 && c[1][2] == 1 && c[2][2] == 1) {
    printf("Yes\n");
  } else if (c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1) {
    printf("Yes\n");
  } else if (c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int o = 1;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int ans = 0;
	int tot = 2 * n;
	while (tot-- && o != 2)
	{
		ans++;
		o = a[o];
	}
	if (ans == 2 * n) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
start,end = map(int,input().split())
check1 = 0
check_array = []
count = 0

for i in range(start,end+1):
    check2 = i

    while not check2 == 0:
        check_array.append(check2 % 10)
        check2 = int(check2 / 10)

    if check_array[0] == check_array[4] and check_array[1] == check_array[3]:
        count += 1
    check_array = []

print(count)


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

using namespace std;

int main(){

    int N;//入力
    long long Y;
    cin >> N >> Y;

    for (int x = 0; x <= N; x++){
        for (int y = 0; y <= N; y++){
            if (0 <= N - (x + y) && N - (x + y) <= N){
                if (10000 * x + 5000 * y + 1000 * (N - (x + y)) == Y){
                    cout << x << " " << y << " " << N - (x + y) << endl;
                    return 0;
                }
                
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;

    return 0;
}

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

#define ll long long
#define mod 1000000007
#define pb push_back

ll check[100000]={0};
//vector<ll,pair<ll,vector<ll>>> mp;
int main()
{
  ll a;
  cin>>a;
  ll b[a],sum=0,maxm=INT_MIN,mini=INT_MAX;
  for(ll i=0;i<a;i++)
  {
    cin>>b[i];
    maxm=max(maxm,b[i]);
    mini=min(mini,b[i]);
  }
  ll d=sum/a,ans=0,at=INT_MAX;
//  cout<<d<<endl;
  for(ll i=mini;i<=maxm;i++)
  {
    ans=0;
    for(ll j=0;j<a;j++)
    {
      ll k=(i-b[j])*(i-b[j]);
      ans+=k;
    }
    at=min(at,ans);
  }

  cout<<at<<endl;

}


Measured memory_bytes: 256
n = int(input())
arr = []
def do(n):
    i = 1
    # check num
    while i <= n:
        x = i
        if x%3==0:
            arr.append(x)
        else:
            while x:
                if x%10==3:
                    arr.append(i)
                    break
                x //= 10
        i+=1
do(n)
print(" " + " ".join(map(str,arr)))


Measured memory_bytes: 5980
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{
    long int N, K, i, t=0;
    scanf("%ld %ld", &N, &K);
    int H[N];
    for(i=0; i<N; i++){
        scanf("%d", &H[i]);
    }
    if(N <= K) {
        printf("0\n");
        return 0;
    }

    qsort(H, N, sizeof(int), compare_int);

    for(i=N-1; i>=N-K; i--){
        H[i] = 0;
    }

    for(i=0; i<N; i++) {
        t += H[i];
    }

    printf("%ld\n", t);

    return 0;
}

Measured memory_bytes: 3096
n = input()

if(n[len(n)-1] == "3"):
    print("bon")
elif(n[len(n)-1] == "0" or n[len(n)-1] == "1" or n[len(n)-1] == "6" or n[len(n)-1] == "8"):
    print("pon")
else:
    print("hon")


Measured memory_bytes: 9108
if __name__=="__main__":
    length = int(input().replace("\n",""))
    numbers = list(map(int, input().replace("\n","").split(" ")))
    c_gusu = 0
    c_kisu = 0
    for number in numbers:
        if(number%2 == 0):
            c_gusu += 1
        else:
            c_kisu += 1
    if(c_kisu%2 == 0):
        print("YES")
    else:
        print("NO")

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int a, b;
    cin >> a >> b;

    int ans = (b - 1) / (a - 1);
    if ((b - 1) % (a - 1) != 0)
        ans += 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256