akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

//グラフ firstがedgeの重さ、secondがto
vector<P> graph[100005];
//キュー firstが現時点での最短距離、secondがv_num
priority_queue<P, vector<P>, greater<P>> q;
//始点からの距離
int dist[100005];
int parent[100005];

void dijkstra(int r)
{
    q.push(P(0, r));
    dist[r] = 0;
    while (!q.empty())
    {
        P p = q.top();
        int v = p.second;
        q.pop();
        if (dist[v] < p.first)continue; //こうすることで同一ノードの古い(重複する)データは捨てられる。
        for (auto &i : graph[v])
        {
            int w, to;
            w = i.first;
            to = i.second;
            if (dist[to] > dist[v] + w)
            {
                dist[to] = dist[v] + w;
                parent[to] = v;
                q.push(P(dist[to], to));
            }
        }
    }
}
int main()
{
    int n,m;cin >> n >> m;
    rep(i, 100005) dist[i] = INF;
    rep(i, 100005) parent[i] = -1;
    rep(i, m)
    {
        int s, t, d;
        cin >> s >> t;
        s--; t--; 
        d = 1;
        graph[s].push_back(P(d, t));
        graph[t].push_back(P(d, s));
    }
    parent[0] = 0;
    dijkstra(0);
    
    rep(i,n)
    {
        if(i==0)continue;
        if(parent[i]==-1)
        {
            cout << "No" << endl;
            return 0;
        }
        parent[i]++;
    }
    cout << "Yes" << endl;
    rep(i, n)
    {
        if (i == 0) continue;
        cout << parent[i] << endl;
    }
}

Measured memory_bytes: 13520
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n+1),pos(n+1);
	for(int i = 1; i <= n; i++){
		cin >>a[i];
		pos[a[i]] = i;
	}

	set<ll> s_pos,s_neg;
	s_neg.insert(0);
	s_pos.insert(n+1);
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		ll l = -1* *s_neg.lower_bound(-pos[i]);
		ll r = *s_pos.upper_bound(pos[i]);

		ans += i*(pos[i]-l)*(r-pos[i]);
		//cout << "l = " << l << " r = " << r << " ans = " << ans << endl;
		s_pos.insert(pos[i]);
		s_neg.insert(-pos[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
	fastio;
	ll a=0,b=0;
	cin>>a>>b;
	if(a==1 || b==1)
		cout<<"1";
	else
	{
		a*=b;
		if(a%2==0)
			cout<<a/2;
		else
			cout<<a/2+1;
	}
return 0;
}

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

int main(){
    int  N,K; cin >> N >> K;

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

    int num = 0;

    for(int i = 0; i < N; ++i){
        if(h[i] >= K){
            num++;
        }
    }

    cout << num << endl;
    return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
	int n;
	int a;
	double b = 0, c;
	double ans;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a;
		b +=(float) 1 / a;
	}
	ans = 1 / b;
	cout << ans << endl;

	return 0;
}


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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

int n,m,u,v,dp[100005];
vector<int> g[100005];
int dfs(int x){
    for(int y : g[x] ){
        dp[x] = max(dp[x],dp[y]?dp[y]:dfs(y));
    }
    dp[x]++;
    return dp[x];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i =0; i<m; ++i){
        cin>>u>>v;
        u--,v--;
        g[u].push_back(v);
    }
    int ans = 0;
    for(int i = 0; i<n; ++i){
        if(!dp[i]){
            ans = max(ans,dfs(i));
        }
    }
    cout<<ans-1<<"\n";
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,total=0,temp=0,dup=0,temp2=0,who=0;
  bool judge = false;
  cin >> N;
  vector<int> vec(N);
  vector<int> human{0,0};
  
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  for(int i = 0 ; i < N; i++){
    if(temp <= vec.at(i)){
     temp = vec.at(i);
    }
  }
  
  while(true){
    for(int i = 0; i < N; i++){
      if(temp == vec.at(i)) dup++;
    }
    if(dup == 1 || dup%2 == 1){
      human.at(who) += temp;
      who = (who+1)%2;
    }
    
    for(int i = 0; i < N; i++){
      if(temp > vec.at(i) && temp2 <= vec.at(i)){
        temp2 = vec.at(i);
      }
    }
    if(temp == temp2) judge = true;
    temp = temp2;
    dup = 0;
    temp2 = 0;
    if(judge){
    cout << human.at(0) - human.at(1) << endl;
    break;
    }
  }
}

Measured memory_bytes: 256
N, K = map(int,input().split())
MOD = 10**9+7
ans = 0

for i in range(K, N + 2):
    MIN = (i * (i - 1))//2
    MAX = (N * i) - MIN #例えば10,9,8なら(10-0),(10-1),(10-2)
    ans += MAX - MIN + 1
    ans %= MOD
print(ans)

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

unordered_map<long long, long long> rko;
long long H, W, N, a, b, ans[10];

bool isin(int i, int j){
    return 0 <= i && i + 2 < H && 0 <= j && j + 2 < W;
}

int main(){
    scanf("%lld%lld%lld", &H, &W, &N);
    *ans = (H - 2) * (W - 2);
    for(int i = 0; i < N; ++i){
        scanf("%lld%lld", &a, &b);
        for(int j = -3; j < 0; ++j)
            for(int k = -3; k < 0; ++k)if(isin(a + j, b + k))++rko[((a + j) << 32) + (b + k)];
    }
    for(auto i : rko){
        --*ans;
        ++ans[i.second];
    }

    for(auto i : ans)cout << i << endl;
}

Measured memory_bytes: 36624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;

#define ll long long int
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)

#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)

#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount



// typedef __int128 bign;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define MD          1000000007
#define M 			3000
#define LN 			14
#define fftmod      998244353
#define EPS         (double)1e-10

ll md=MD;
ll inf=1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 


inline ll exp(ll a,ll b){ll r=1LL;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}

using cd=complex<double>;
const double PI=acos(-1);

inline ll rand(ll l,ll r){
	return l+rng()%(r-l+1);
}



ll fa[M],iv[M];
ll chose(ll n,ll k){
    if(k>n)return 0;
    ll r=fa[n];r%=md;
    r*=iv[k]%md;r%=md;
    r*=iv[n-k]%md;r%=md;
    return r;
}
int main(){


    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p,T;string s1,s2;ll q;ll x,y;
    fa[0]=iv[0]=1;
    lp(1,M-1){
        fa[i]=fa[i-1]*i%md;fa[i]%=md;
        iv[i]=iv[i-1]*exp(i,md-2)%md;iv[i]%=md;
    }
    cin>>n>>k;
    for(i=1;i<=k;++i){
        p=chose(k-1,i-1)%md;
        p=p*chose(n-k+1,i)%md;p%=md;
        cout<<p<<"\n";
    }





    return 0;
}


Measured memory_bytes: 384
import sys
count = []
cnt = 0
N,M = map(int,input().split())
for _ in range(N):
    A = input().split()
    count.extend(A[1:])
for _ in range(M+1):
    c = count.count('%d' %_)
    if c == N:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
import numpy as np
n, k = map(int, input().strip().split())
as_ = np.array(list(map(int, input().strip().split())))
as_ -= 1


first_visited = [-1] * n

now = 0
num_teleport = 0
while True:
    if first_visited[now] == -1:
        first_visited[now] = num_teleport
    else:
        # ループを発見した
        loop_length = num_teleport - first_visited[now]
        loop_start_point = now
        time_to_start_point = first_visited[now]
        break

    now = as_[now]
    num_teleport += 1


now2 = 0
if k > time_to_start_point:
    k -= time_to_start_point
    k %= loop_length
    now2 = loop_start_point

for i in range(k):
    now2 = as_[now2]

print(now2 + 1)




Measured memory_bytes: 51016
#include<bits/stdc++.h> 
using namespace std;
char a[51],b[51];
int l,i;
int main(){
    scanf("%s%s",a,b);
    l=strlen(b);
    for(i=0;i<l;i++)printf("%c%c",a[i],b[i]);
    if(strlen(a)>l) printf("%c\n",a[l]);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	k, n := r.nextInt(), r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()

	m := k - a[n-1] + a[0]
	for i := 1; i < n; i++ {
		w := a[i] - a[i-1]
		if m < w {
			m = w
		}
	}
	fmt.Fprintln(stdout, k-m)
}


Measured memory_bytes: 11588
import sys


def slove():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, k = list(map(int, input().rstrip('\n').split()))
    for i in range(k):
        if i % 2 == 0:
            if a % 2 != 0:
                a -= 1
            b += a // 2
            a -= a // 2
        else:
            if b % 2 != 0:
                b -= 1
            a += b // 2
            b -= b // 2
    print(a, b)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#!/usr/local/bin/python3.5 -tt

import random
import sys

if __name__ == '__main__':
    def _(f):
        for l in f:
            for i in l.split():
                yield(int(i))

    g = _(sys.stdin)

    N = next(g)

    a = []

    for i in range(N):
        a.append(next(g))

    a.sort()

    S = 1

    for i in a:
        S *= i

        if S == 0:
            print(0)
            sys.exit(0)
        elif S > 10 ** 18:
            print(-1)
            sys.exit(0)

    print(S)


Measured memory_bytes: 24812
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	s := scanString(sc)
	ex := map[byte]struct{}{}
	for i := range s {
		ex[s[i]] = struct{}{}
	}
	_, nOk := ex['N']
	_, sOk := ex['S']
	if nOk != sOk {
		fmt.Println("No")
		return
	}
	_, wOk := ex['W']
	_, eOk := ex['E']
	if wOk != eOk {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int a,b;
    cin>>a>>b;
    int c=a*b;
    cout<<a*b<<endl;
}


return 0;
}





Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
using namespace std;
 
void PUNKS_NOT_DEAD() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    while (a.size() && k) {
        a.pop_back();
        k--;
    }
    int sum = 0;
    for (auto x : a) sum += x;
    cout << sum;
}
 
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    PUNKS_NOT_DEAD();
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <stdio.h>

int R; // n. requisitos
int TMP; // tempo total
long long int solMelhor;

int T[101]; //tempo para execução do requisito
long long int V[101]; //valor adquirido


long long int memo[101][100001];

long long int max(long a, long b){
  if(a>b)
    return a;
  else
    return b;
}

void inicializar(){

  std::cin >> R >> TMP;

  for(int i=1; i<R+1; i++){
    std::cin >> T[i] >> V[i];
  }
  for(int i=0; i<R+1; i++)
    for(long long int j=0; j<TMP+1;j++)
      memo[i][j]=0;
}

void imprimeResultados(){
  for(int i = 0;i<=R;i++){
    for(long long int j = 0;j<=TMP;j++){
      std::cout<<memo[i][j]<<"|";
    }
    std::cout<<std::endl;
  }
  std::cout << solMelhor;    
}

long long int v1,v2;
long long int nrp(){
  for(int i = 1;i<=R;i++){
    for(long long int j = 1;j<=TMP;j++){
      //v1 = memo[i][j-1];
      if(T[i]>j)
        memo[i][j] = memo[i-1][j];
      else{
        v1=memo[i-1][j-T[i]]+V[i];
        v2=memo[i-1][j];
        memo[i][j] = max(v1,v2);
      }
    }
  }
  return memo[R][TMP];
}

int main() {
  inicializar();
  
  solMelhor = nrp();

 std::cout << solMelhor;  
}

Measured memory_bytes: 79104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1000000007;

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

//********************************template END****************************************//

int dp[16][8][2];

void solve(void)
{
	string S;
	cin >> S;

	int l = S.size();

	string a = "357";

	rep(l, n)
	{
		dp[n][0][min(n,1)] = 1;
		rep(8, bit) rep(2, f) rep(3, i)
		{
			 if (!f)
			 {
				 if (S[n] < a[i]) break;
				 if (S[n] == a[i])
				 {
					dp[n + 1][bit | 1 << i][0] += dp[n][bit][0];
				 }
				 else
				 {
					dp[n + 1][bit | 1 << i][1] += dp[n][bit][0];
				 }
			 }
			 else
			 {
				 dp[n + 1][bit | 1 << i][1] += dp[n][bit][1];
			 }
		}

	}

	cout << dp[l][7][0] + dp[l][7][1] << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()

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

    int k, x;
    cin >> k >> x;
    int p = max(-1000000, x - k + 1);
    int q = min(1000000, x + k - 1);

    for (int i = p; i <= q; ++i)
        cout << i << " ";

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

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

int N;
long su[200005];

int main() {
  cin >> N;
  su[0] = 0;
  rep(i, N) {
    long a;
    cin >> a;
    su[i+1] = su[i]+a;
  }

  long s = su[N];

  long ans = LONG_MAX;
  for(int i=1; i<N; i++) {
    ans = min(ans, abs(su[i] - (s-su[i])));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  x <- getInt
  let n500 = x `div` 500
      n5 = (x - 500 * n500) `div` 5
      ans = 1000 * n500 + 5 * n5
  print ans

Measured memory_bytes: 380
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>

int main(){
	int N,M,K;
	//std::cin >> N;
    //std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
    std::vector<int> c(15);
    std::vector<int> v(15);
 	
 	//stack<int> sta;   
    //queue<int> que;
    
 	
    // 入力
    // 入力
    for(int i=0; i<5; i++){
		std::cin >> c[i];
	}
    int work;
    for(int i=0; i<5; i++){
		v[i]=c[i]%10;
		
	}
	int min;
	int min_inde;
	min_inde=0;
	min=1000;
	
	for(int i=0; i<5; i++){
		if(v[i]!=0 && v[i]<=min){
			min=v[i];
			min_inde=i;
		}
		
	}
	
	//printf("min=%d",min);
	//std::sort(v.begin(),v.end(),std::greater<int>());//降順ソート
	int sum;
	sum =0;
	for(int i=0; i<5; i++){
		if(i!=min_inde){
		if(v[i]!=0){
		sum+=c[i]+(10-v[i]);
		}
		else{
			sum+=c[i];
		}
		}
	}
    printf("%d",sum+c[min_inde]);
    //printf("%d",N*M);
	return 0;
}

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

int main(){
    string s;
    int k;
    cin >> k;
    cin >> s;
    if(s.size() <= k) cout << s << endl;
    else {
        s = s.substr(0,k);
        cout << s << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <sstream>
#include <stdlib.h>
#include <vector>
#include <iomanip>
#include <ctime>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <cassert>

#define nl "\n"
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define p_un(a) ((void)a)
#define p_st(a) string(a)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define naj ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define NL cout << endl;
#define sqr(x) (sqrt(x) * 1LL)
#define pcnt(i) __builtin_popcount(i)
#define lcm(a,b) (a * b) / __gcd(a, b)
#define E 2.718281828459045
#define PI 3.141592653589793
#define up_b upper_bound
#define low_b lower_bound
#define FILE_NAME "A"
#define show(x) cout << (#x) << ": " << x << endl

using namespace std;

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;
typedef vector <llong> vl;
typedef vector <bool> vb;
typedef vector <char> vc;
typedef vector <int> vi;
typedef vector <string> vs;
typedef pair <llong, llong> pll;
typedef map <llong, llong> mll;
typedef set <llong> sl;
typedef set <char> sc;
typedef map <string, llong> msl;
typedef map <string, bool> msb;
typedef map <char, llong> mcl;
typedef map <string, string> mss;

const llong MXN = 1e6 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const ldouble EPS = 1e-9;

#define int int64_t

//int dx[]= {1,0,-1,0}; int dy[]= {0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1}; int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2}; int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={-1,-1,+0,+1,+1,+0}; int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction

string y, m, d;

signed main() {

    naj;
#ifdef LOL
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
    int x = 4;
    char c;
    while(x --) {cin >> c; y += c;}
    cin >> c;
    x = 2;
    while(x --) {cin >> c; m += c;}
    cin >> c;
    x = 2;
    while(x --) {cin >> c; d += c;}
    if(y <= "2019") {
        if(m <= "04") {
            if(d <= "30") {
                cout << "Heisei";
            } else {
                cout << "TBD";
            }
        } else {
            cout << "TBD";
        }
    } else {
        cout << "TBD";
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderC
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        Dictionary<long, long> dic = new Dictionary<long, long>();

        long current = 2;
        double sqrt = Math.Sqrt(n);
        while (current <= sqrt)
        {
            if (n % current == 0)
            {
                n /= current;
                if (dic.ContainsKey(current))
                {
                    dic[current]++;
                }
                else
                {
                    dic.Add(current, 1);
                }
            }
            else
            {
                current++;
            }
        }
        if (n != 1)
        {
            dic.Add(n, 1);
        }

        long answer = 0;

        foreach (var item in dic)
        {
            long num = item.Value;
            for (long i = 1; i <= num; i++)
            {
                answer++;
                num -= i;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27832
#include<iostream>
#include<queue>

using namespace std;

int main(){
    class vertex{
        public:
        char color;
        int flag;
        int distance;
    };

    vertex a[2500];

    int H,W;
    cin>>H>>W;

    int white=0;
    for(int i=0;i<H*W;i++){
        cin>>a[i].color;
        if(a[i].color=='.'){white++;}
    }

    for(int i=0;i<H*W;i++){
        a[i].flag=0;
        a[i].distance=2500;
    }
    a[0].flag=1;
    a[0].distance=0;

    
    queue<int> q;
    q.push(0);
    int u;
    while(!q.empty()){
        u=q.front();
        q.pop();
        //左端でない場合かつ左隣接かつ未訪問
        if(!(u%W==0)){
            if(a[u-1].color=='.' && a[u-1].flag==0){
                a[u-1].flag=1;
                a[u-1].distance=a[u].distance+1;
                q.push(u-1);
            }
        }
        //右端ではないかつ右隣接かつ未訪問
        if(!(u%W==W-1)){
            if(a[u+1].color=='.' && a[u+1].flag==0){
                a[u+1].flag=1;
                a[u+1].distance=a[u].distance+1;
                q.push(u+1);
            }
        }
        //上端ではないかつ上隣接かつ未訪問
        if(W<=u){
            if(a[u-W].color=='.' && a[u-W].flag==0){
                a[u-W].flag=1;
                a[u-W].distance=a[u].distance+1;
                q.push(u-W);
            }
        }
        //下端ではないかつ下隣接かつ未訪問
        if(u<W*(H-1)){
            if(a[u+W].color=='.' && a[u+W].flag==0){
                a[u+W].flag=1;
                a[u+W].distance=a[u].distance+1;
                q.push(u+W);
            }
        }
        a[u].flag=1;
    }
    if(a[H*W-1].distance<2500){
        cout<<white-a[H*W-1].distance-1<<endl;
    }else{cout<<-1<<endl;}

    return 0;
}

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

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int N;
vector<vector<int>> E(10);
vector<bool> V(10,false);
int dfs(int s, int d) {
    if (V[s]) return 0;
    if (d == N-1) return 1;
    int res = 0;
    V[s] = true;
    for (auto i: E[s]) {
        if (!V[i]) res += dfs(i,d+1);
    }
    V[s] = false;
    return res;
}

int main(void) {
    int M;
    cin >> N >> M;
    vector<int> a(30), b(30);
    for (int i=0;i<M;i++) cin >> a[i] >> b[i];
    // set<pair<int,int>> E;
    // for (int i=0;i<M;i++) {
    //     E.emplace(a[i],b[i]);
    // }
    for (int i=0;i<M;i++) {
        E[a[i]].push_back(b[i]);
        E[b[i]].push_back(a[i]);
    }

    cout << dfs(1,0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

long long a, b, c;

signed main() {
	cin >> a >> b >> c;
	
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0 << endl;
	else cout << min(a * b, min(b * c, c * a)) << endl;
	
	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

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

        while(true){
            int a = sc.nextInt();
            String s = sc.next();
            int b = sc.nextInt();
            if(s.equals("?")){
                return;
            }
            switch(s){
                case("+"):
                System.out.println(a + b);
                break;
                case("-"):
                System.out.println(a - b);
                break;
                case("*"):
                System.out.println(a * b);
                break;
                case("/"):
                System.out.println(a / b);
                break;
        }
    }
    }    
}



Measured memory_bytes: 26276
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

vector <vector <bool> > vec;
vector <int> p;

int bit_search( int i, int N, int M ){
	rep( j, 0, M ){
		int cnt = 0;
		rep( k, 0, N ){
			if (i & ( 1 << k )){
				if (vec[j][k])
					cnt++;
			}
		}
		if (cnt % 2 != p[ j ]){
			return 0;
		}
	}
	return 1;
}

int main( void ){
	int N, M;
	cin >> N >> M;
	vec = vector <vector <bool> >( M, vector <bool>( N, false ));
	rep( i, 0, M ){
		int k;
		cin >> k;
		rep( j, 0, k ){
			int s;
			cin >> s;
			vec[ i ][ s-1 ] = true;
		}
	}
	p = vector <int>( M, 0 );
	rep( i, 0, M ){
		cin >> p[ i ];
	}
	int ans = 0;
	int lim = ( 1 << N );
	rep( i, 0, lim ){
		ans += bit_search( i, N, M );
	}
	cout << ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    char s[6] = {};
    int flag = 0;
    

    scanf("%s", s);

    if(s[2] == s[3]){
        if(s[4] == s[5]){
            flag = 1;
        }       
    }

    if(flag == 0){
        printf("No");
    } else {
        printf("Yes");
    }

    return 0;

}

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

int main() {
    ll h, w, n, sr, sc;
    string s, t;
    cin >> h >> w >> n >> sr >> sc >> s >> t;
    ll lx = 1, hx = h, ly = 1, hy = w;
    for (ll i = n - 1; i >= 0; i--) {
        if (t[i] == 'R') ly = max(ly - 1, 1ll);
        if (t[i] == 'D') lx = max(lx - 1, 1ll);
        if (t[i] == 'L') hy = min(hy + 1, w);
        if (t[i] == 'U') hx = min(hx + 1, h);

        if (s[i] == 'R') hy--;
        if (s[i] == 'D') hx--;
        if (s[i] == 'L') ly++;
        if (s[i] == 'U') lx++;

        if (hx < lx || hy < ly) return cout << "NO", 0;
    }
    if (hx < sr || sr < lx || hy < sc || sc < ly) return cout << "NO", 0;
    cout << "YES";
}


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

int main() {
	int n;
	float t;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	sort(a,a+n);
	t=(a[0]+a[1])/2.0;
	for(int i=2;i<n;i++){
	    t=(t+a[i])/2.0;
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {	
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String a = sc.next();
		
		int c = 0;
		if(s.charAt(0)==a.charAt(0))c++;
		if(s.charAt(1)==a.charAt(1))c++;
		if(s.charAt(2)==a.charAt(2))c++;
		
		System.out.println(c);
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll a,b,x;
    cin>>a>>b>>x;
    ll ansa=a/x,ansb=b/x;
    if(a%x==0) cout<<ansb-ansa+1;
    else cout<<ansb-ansa;
}

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int left(int i) {
    return 2 * i;
}

int right(int i) {
    return 2 * i + 1;
}

int parent(int i) {
    return i / 2;
}

int maxHeapify(int A[], int i, int H) {
    /*
    for(int i = 1; i <= H; ++i){
        printf(" %d", A[i]);
    }
    cout << endl;
    */
    int l, r, largest;
    l = left(i);
    r = right(i);

    if (l <= H and A[l] > A[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= H and A[r] > A[largest]) {
        largest = r;
    }

    if (largest != i) {
        int kari;
        kari = A[i];
        A[i] = A[largest];
        A[largest] = kari;
        maxHeapify(A, largest, H);
    }

    return 0;
}

int buildMaxHeap(int A[], int H) {
    for (int i = H / 2; i >= 1; --i) {
        //cout << i << endl;
        maxHeapify(A, i, H);
    }
    return 0;
}

int insert(int A[], int H, int n) {
    A[H] = n;
    int tmp = H;
    while (tmp/2 != 0) {
        if (A[tmp] > A[tmp / 2]) {
            swap(A[tmp], A[tmp / 2]);
            tmp = tmp / 2;
        } else {
            break;
        }
    }
    return 0;
}

int extract(int A[], int H) {
    cout << A[1] << endl;
    A[1] = A[H];
    maxHeapify(A, 1, H - 1);
    return 0;
}

int main() {
    string com;
    int H = 1, tmp;
    int A[2000000];
    cin >> com >> tmp;
    A[1] = tmp;
    while (true) {
/*
        cout << "::";
        for (int i = 1; i <= H; ++i) {
            cout << A[i] << " ";
        }
        cout << endl;
*/
        cin >> com;
        if (com == "insert") {
            cin >> tmp;
            ++H;
            insert(A, H, tmp);
        } else if (com == "extract") {
            extract(A, H);
            --H;
        } else {
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 7048
//============================================================================
// Name        : 140C.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> B(N - 1);
	vector<int> A(N);

	for(int i = 0; i < N - 1; ++i){
		cin >> B[i];
	}


	long long sum = 0;
	sum += B[0];

	for(int i = 1; i < N - 1; ++i){
		sum += min(B[i], B[i - 1]);
	}

	sum += B[N - 2];


	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10);
int n,a[maxn];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	vector<int> v;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(v.size()==0)
		{
			++cnt;
			v.push_back(a[i]);
			continue;
		}
		if(a[i]<=v[0])
		{
			++cnt;
			v.insert(v.begin(),a[i]);
			continue;
		}
		int tmp=lower_bound(v.begin(),v.end(),a[i])-v.begin();
		--tmp;
		v.erase(v.begin()+tmp);
		v.insert(v.begin()+tmp,a[i]);
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1276
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto S = readln.chomp;
    auto T = readln.chomp;
    int r = 1000;
    foreach (i; 0..S.length - T.length + 1) {
        int rr;
        foreach (j, t; T) if (S[i+j] != t) ++rr;
        r = min(r, rr);
    }
    writeln(r);
}

Measured memory_bytes: 2580
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            while(sc.hasNext()) {
                int m=sc.nextInt();
                int n=sc.nextInt();
                if(m+n==0) break;
                int[] book=new int[n+1];
                int max = 0;
                int sum = 0;
                for(int i=0; i<n; i++) {
                    book[i]=sc.nextInt();
                    if(max < book[i])
                    	max = book[i];
                    	sum += book[i];
                }
                
                int g=0;
                for(int i=max;i<=sum;i++) {
                	int h = m;
                	int[] each = new int[n+1];
	                int end = 0;
	                for(int j=0; j<n; j++) {
	                    	if(each[h]+book[j] >i && h==1) {
	                    		end = 1;
	                    		break;
	                    	}
	                    	if(each[h]+book[j] >i)h--;
	                    	each[h] += book[j];
	                    }
	                	g = i;
	                	if(end==0)break;
                }
                System.out.println(g);
            }
        }
    }
}


Measured memory_bytes: 435876
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
 
/*
  int main(){
  while(1){
  string str,str1;
  int f,cnt=-1,numer=0,denom=1;
  cin>>str;
  if(str=="#")break;
  for(int i=0;i<str.size();i++){
  if(str[i]=='n' && f==0)f=1;
  else if(str[i]=='w' && f==0) f=2;
  if(f==1 && str[i]=='h'){cnt++,f=0,str1+='n';}
  else if(f==2 && str[i]=='t'){cnt++,f=0,str1+='w';}
  }
  denom=pow(2,cnt);
  if(str1.size()>1){
  for(int i=0;i<str1.size()-1;i++){
  if(str1[i]=='n') numer-=(90*pow(2,i));
  else numer+=(90*pow(2,i));
  }
  }
  if(str1[str1.size()-1]=='w') numer+=(90*pow(2,cnt));
  numer=abs(numer);
  for(int i=2;numer%i==0 && denom/i>0;i*=2) numer/=2,denom/=2;
  if(denom<=1) cout<<numer<<endl;
  else cout<<numer<<"/"<<denom<<endl;
  }
  return 0;
  }
*/

int main(){
  while(1){
    string str,str1;
    int f=0,cnt=-1,numer=0,denom=1;
    cin>>str;
    if(str=="#")break;
    for(int i=0;i<str.size();i++){
      if(str[i]=='n' && f==0)f=1;
      else if(str[i]=='w' && f==0) f=2;
      else if(f==1 && str[i]=='h'){
	cnt++;
	f=0;
	str1+='n';
      }
      else if(f==2 && str[i]=='t'){
	cnt++;
	f=0;
	str1+='w';
      }
    }
       denom=(1<<cnt);
    if(str1.size()>1)
      for(int i=0;i<str1.size()-1;i++)
	if(str1[i]=='n') numer-=(90*(1<<i));
	else numer+=(90*(1<<i));
    
    if(str1[str1.size()-1]=='w') numer+=(90*(1<<cnt));
    numer=abs(numer);
    
    for(int i=2;numer%i==0 && denom/i>0;i*=2) numer/=2,denom/=2;

    if(denom<=1) cout<<numer<<endl;
    else cout<<numer<<"/"<<denom<<endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int cost = 0;
    cost += min(a,b);
    cost += min(c,d);
    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Mobile Computing
public class Main{

	double r, best;
	int n;
	int[] ws, w;
	Set<String>[] trees;
	
	class M{
		double x;
		boolean leaf;
		int w;
		M left, right;
		public M(double x, boolean leaf, int w) {
			this.x = x;
			this.leaf = leaf;
			this.w = w;
			left = right = null;
		}
		int get(){
			if(leaf)return w;
			return left.get()+right.get();
		}
		void val(){
			if(leaf){
				min = Math.min(min, x); max = Math.max(max, x); return;
			}
			int w1 = left.get(), w2 = right.get();
			double a = w2*1.0/(w1+w2);
			left.x = x-a;
			right.x = x+1-a;
			left.val();
			right.val();
		}
	}
	
	double min, max;
	boolean[] used;
	int[] order;
	void dfs(int k){
		if(k==n){
			for(String t:trees[n]){
				s = (t+"$").toCharArray();
				id = 0;
				int a = 0;
				for(int i=0;i<s.length;i++){
					if(s[i]=='?'){
						s[i] = (char)(order[a++]+'0');
					}
				}
				M root = exp();
				min = max = 0;
				if(!root.leaf){
					root.x = 0;
					root.val();
				}
				double res = max-min;
				if(res<r)best = Math.max(best, res);
				root.val();
			}
			return;
		}
		for(int i=0;i<n;i++){
			if(used[i])continue;
			used[i]=true;
			order[k] = i;
			dfs(k+1);
			used[i]=false;
		}
	}
	
	char[] s;
	int id;
	char get(){
		return s[id++];
	}
	M exp(){
		char ch = get();
		if(ch=='('){
			M res = new M(0, false, 0);
			res.left = exp();
			get();
			res.right = exp();
			get();
			return res;
		}
		M res = new M(0, true, ws[ch-'0']);
		return res;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		trees = new Set[7];
		for(int i=1;i<=6;i++)trees[i] = new HashSet<String>();
		trees[1].add("?");
		for(int i=2;i<=6;i++){
			for(int j=1;j<i;j++){
				for(String left:trees[j])for(String right:trees[i-j])trees[i].add("("+left+","+right+")");
			}
		}
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			r = sc.nextDouble(); n = sc.nextInt();
			ws = new int[n];
			for(int i=0;i<n;i++)ws[i]=sc.nextInt();
			w = new int[1<<n];
			for(int i=0;i<1<<n;i++){
				int s = 0;
				for(int j=0;j<n;j++)if(((i>>j)&1)>0)s+=ws[n-1-j];
				w[i] = s;
			}
			best = -1;
			used = new boolean[n];
			order = new int[n];
			dfs(0);
			System.out.printf("%.8f\n", best);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	ll res=0;
	cin>>n;
	for(int i=1;i<n;i++){
		int u=n-i;
		float t = sqrt(u);
		for(int j=1;j<=t;j++){
			if(u%j==0){
				if(j==t){
					res++;
				}
				else{
					res+=2;
				}
			}
		}
	}
	cout<<res<<endl;
}

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

using namespace std;

int main() {

    string S;
    cin >> S;

    for (int i = 0; i < S.length(); ++i) {
        char C1, C2;
        C1 = S[i];
        C2 = S[i + 1];
        if (C1 == C2) {
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void)
{
  int n;
  scanf("%d", &n);
  
  for (int i = 1; i < 10; i++)
    for (int j = 1; j < 10; j++)
      if (n == i*j) {
        puts("Yes");
        return 0;
      }
  
  puts("No");
  
  return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    vector<vector<ll>> cnt(26, vector<ll>(n,0));
    rep(i, 0, n) {
        rep(j, 0, s[i].size()) cnt[s[i][j]-'a'][i]++;
    }
    string ans;
    rep(i, 0, 26) {
        ll mn = *min_element(cnt[i].begin(), cnt[i].end());
        rep(j, 0, mn) ans.push_back(i+'a');
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632