akhauriyash/Code-Regression huggingface dataset:
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int
var Max, Min int = 0, 1e9

func main() {
	reader.Split(bufio.ScanWords)
	S := read()
	T := read()
	for i := 0; i < len(S); i++ {
		if string(S[i]) == string(T[i]) {
			ans++
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int cont,pot;
    long double total=0.0;

    for(int i=1;i<=n;i++){
        cont = 0;
        pot = i;
        while (pot <=k-1){
            pot*=2;
            cont++;
        }

        total+=(pow(n,-1)*(pow(0.5,cont)));

    }

    printf("%.12Lf\n",total);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int T;
ll N,A,B,C,D;
map<ll,ll>mp;
ll solve(ll x){
	if(mp.find(x)!=mp.end()) return mp[x];
 	if(x==1)return mp[x]=D;
	ll lb=x/2,rb=(x+1)/2;
	mp[x]=min(solve(lb)+(x-lb*2)*D+A,solve(rb)+(rb*2-x)*D+A);
	lb=x/3,rb=(x+2)/3;
	mp[x]=min(mp[x],min(solve(lb)+(x-lb*3)*D+B,solve(rb)+(rb*3-x)*D+B));
	lb=x/5,rb=(x+4)/5;
	mp[x]=min(mp[x],min(solve(lb)+(x-lb*5)*D+C,solve(rb)+(rb*5-x)*D+C));
	if(x>=2e9)return mp[x];
	mp[x]=min(solve(x/2)+(x-x/2)*D,mp[x]);
	mp[x]=min(solve(x/3)+(x-x/3)*D,mp[x]);
	mp[x]=min(solve(x/5)+(x-x/5)*D,mp[x]);
	return mp[x];
}
int main(){
	cin>>T;
	while(T--){
		mp.clear();
		cin>>N>>A>>B>>C>>D;
		mp[0]=0;
		cout<<solve(N)<<"\n";
	}
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  map<ll, ll> mp1, mp2;
  for (int i = 0; i < n; ++i) {
    mp1[a[i] + i + 1]++;
    if (a[i] - i - 1 < 0) {
      mp2[abs(a[i] - i - 1)]++;
    }
  }
  ll ans = 0;
  for (auto a : mp1) {
    ans += a.second * mp2[a.first];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 29320
import java.util.*;
public class Main {
	static final Scanner stdin = new Scanner(System.in);
	static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		while(true){
			int m = stdin.nextInt(), n = stdin.nextInt();
			if((m|n) == 0)break;
			int[] t = new int[n+1];
			for(int i = 1; i <= n; ++i)t[i] = stdin.nextInt();
			int[][] P = new int[m][2];
			for(int i = 0; i < m; ++i) Arrays.fill(P[i], 0);
			List<Integer> ans = new LinkedList<Integer>();
			Queue<Integer> q = new LinkedList<Integer>();
			int r = 10;
			while(ans.size() < n){
				if(r%10 == 0 && 1 <= r/10 && r/10 <= n) q.add(r/10);
				for(int i = 0; i < m; ++i) for(int j = 0; j < 2; j++) if(P[i][j] > 0) t[P[i][j]]--;
				for(int i = 0; i < m; ++i){
					if(P[i][0] > 0 && t[P[i][0]] <= 0){
						ans.add(P[i][0]); P[i][0] = P[i][1]; P[i][1] = 0;
						if(P[i][0] > 0 && t[P[i][0]] <= 0){ //????????????????????????????¢????
							ans.add(P[i][0]); P[i][0] = 0; 
						}
					}
				}
				boolean flag = true;
				while(!q.isEmpty() && flag){
					flag = false;
					int dm = INF, um = INF, di = -1, ui = -1;
					for(int i = 0; i < m; i++){
						if(P[i][0] == 0){
							flag = true;
							P[i][0] = q.poll();
							break;
						}
						if(P[i][1]==0){
							if(t[P[i][0]] >= t[q.peek()]){
								if(t[P[i][0]]-t[q.peek()] < um){ um = t[P[i][0]]-t[q.peek()]; ui = i; }
							}else{
								if(t[q.peek()]-t[P[i][0]] < dm){ dm = t[q.peek()]-t[P[i][0]]; di = i; }
							}
						}
					}
					if(flag)continue;
					if(ui >= 0){
						P[ui][1] = P[ui][0]; P[ui][0] = q.poll(); flag = true;
					}else if(di >= 0){
						P[di][1] = P[di][0]; P[di][0] = q.poll(); flag = true;
					}
				}
				r++;
			}
			for(int i = 0; i < n; ++i) System.out.print(ans.get(i) + (i == n-1 ? "\n" : " "));
		}
	}
}

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

using namespace std;

typedef long long ll;

int main(){
	string s, t;
	cin >> s >> t;
	int dif = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]) dif++;
	}
	cout << dif << '\n';
}


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

int main()
{
    while(true){
        int n, m, t, p;
        cin >> n >> m >> t >> p;
        if(n == 0 && m == 0 && t == 0 && p == 0){
            break;
        }
        int d[35], c[35];
        for(int i = 0; i < t; i++){
            cin >> d[i] >> c[i];
        }
        int a[70][70];
        for(int i = 0; i < 70; i++){
            for(int j = 0; j < 70; j++){
                a[i][j] = 0;
            }
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = 1;
            }
        }
        for(int i = 0; i < t; i++){
            if(d[i] == 1){
                for(int j = c[i]; j < c[i] * 2; j++){
                    for(int k = 0; k < m; k++){
                        a[j][k] += a[c[i] * 2 - 1 - j][k];
                    }
                }
                for(int j = 0; j < 35; j++){
                    for(int k = 0; k < m; k++){
                        a[j][k] = a[j + c[i]][k];
                    }
                }
                for(int j = 35; j < 70; j++){
                    for(int k = 0; k < m; k++){
                        a[j][k] = 0;
                    }
                }
            }
            if(d[i] == 2){
                for(int j = c[i]; j < c[i] * 2; j++){
                    for(int k = 0; k < n; k++){
                        a[k][j] += a[k][c[i] * 2 - 1 - j];
                    }
                }
                for(int j = 0; j < 35; j++){
                    for(int k = 0; k < n; k++){
                        a[k][j] = a[k][j + c[i]];
                    }
                }
                for(int j = 35; j < 70; j++){
                    for(int k = 0; k < n; k++){
                        a[k][j] = 0;
                    }
                }
            }
        }
        int x[35], y[35];
        for(int i = 0; i < p; i++){
            cin >> x[i] >> y[i];
            cout << a[x[i]][y[i]] << endl;
        }
    }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[200005], v[200005];
signed main() {
  int n, k;
  cin>>n>>k;
  int i, j;
  for(i = 1; i <= n; i++)  cin>>a[i];
  for(i = 1, j = 1; !v[i] && k; i = a[i], j++, k--)
    v[i] = j; //timer at which you went to this city
  k = k % (j - v[i]); //mod k with loop length
  for(; k; i=a[i], k--);
  cout<<i<<"\n";
  return 0;
}

Measured memory_bytes: 6760
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W;
char A[505][505];
char buf[505];

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) scanf("%s", &(A[i]));

	for (int i = 0; i < H; ++i) {
		buf[W] = '\0';
		for (int j = 0; j < W; ++j) {
			if (i == 0 || (i >= 1 && i < H - 1 && j % 2 == 0) || A[i][j] == '#') buf[j] = '#';
			else buf[j] = '.';
		}
		puts(buf);
	}
	puts("");

	for (int i = 0; i < H; ++i) {
		buf[W] = '\0';
		for (int j = 0; j < W; ++j) {
			if (i == H - 1 || (i >= 1 && i < H - 1 && j % 2 == 1) || A[i][j] == '#') buf[j] = '#';
			else buf[j] = '.';
		}
		puts(buf);
	}

	return 0;
}


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

#define INFTY (1 << 30)

//???????????????
enum Color {
	WHITE,
	GRAY,
	BLACK,
};


//SSSP
void Dijkstra(vector<pair<int, int>> v_w_m[], int verNum) {

	//???????¨????
	priority_queue<pair<int, int>> pQ;
	int distance[10000];
	Color color[10000];
	int parent[10000];
	for (int i = 0; i < verNum; i++) {
		color[i] = WHITE;
		distance[i] = INFTY;
		parent[i] = -1;
	}
	distance[0] = 0;
	pQ.push(make_pair(0, 0));


	//SSSP??????
	while (!pQ.empty()) {

		//??°??¬????????????????????????????°?????????????????????¶
//		int min_cost = INFTY;
		int subScript;
		pair<int, int> wei_sub_map = pQ.top();
		pQ.pop();
		subScript = wei_sub_map.second;
		//for (int i = 0; i < verNum; i++) {
		//	if (color[i] != BLACK && distance[i] < min_cost) {
		//		min_cost = distance[i];
		//		subScript = i;
		//	}
		//}

		//?????????????????????
		color[subScript] = BLACK;

		////???????????????????????°??????????????????????????????????????????
		//if (distance[subScript] < wei_sub_map.first * -1)
		//	continue;

		//??£??\?????°??¬??????
		for (int i = 0; i < v_w_m[subScript].size(); i++) {
			int outV = v_w_m[subScript][i].first;
			if (color[outV] == BLACK) continue;
			if (distance[outV] < distance[subScript] + v_w_m[subScript][i].second) continue;

			distance[outV] = distance[subScript] + v_w_m[subScript][i].second;
			parent[outV] = subScript;
			color[outV] = GRAY;
			pQ.push(make_pair(distance[outV] * -1, outV));
		}
	}

	//??????
	int weight_sum = 0;
	for (int i = 0; i < verNum; i++) {
		cout << i << " " << distance[i] << endl;
	}
}


int main() {

	int verNum;
//	int verValWeight[100][100];
	vector<pair<int, int>> v_w_m[10000];
	int parent[100];

	//???????¨????
//	v_w_m = new vector<pair<int, int>>();
	cin >> verNum;
	//for (int i = 0; i < verNum; i++)
	//	for (int j = 0; j < verNum; j++)
	//		verValWeight[i][j] = INFTY;

	//??\?????????
	for (int i = 0; i < verNum; i++) {
		int verVal, outNum;
		cin >> verVal >> outNum;
		for (int j = 0; j < outNum; j++) {
			int outVerVal, weight;
			cin >> outVerVal >> weight;
//			v_w_m[verVal].push_back(make_pair(outVerVal, weight));
			v_w_m[verVal].push_back(make_pair(outVerVal, weight));
			//			verValWeight[i][outVerVal] = weight;
		}
	}

	//SSSP
	Dijkstra(v_w_m, verNum);

	return 0;
}

Measured memory_bytes: 7972
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

int dp[100000];
int h[100000];

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}

	dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		int cost = dp[i - 1] + abs(h[i - 1] - h[i]);
		for (int j = 2; j <= k; ++j) {
			if (i - j < 0) {
				continue;
			}
			int cost2 = dp[i - j] + abs(h[i - j] - h[i]);
			if (cost2 < cost) {
				cost = cost2;
			}
		}
		dp[i] = cost;
	}
	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1152
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        M: usize,
        AB: [(usize,usize); M],
    }
    let mut ans = vec![0;N];
    for i in 0..M{
        let (a,b) = AB[i];
        ans[a-1] += 1;
        ans[b-1] += 1;
    }
    for i in 0..N{
        println!("{}", ans[i]);
    }
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main(){
    int S;
    cin >> S;
    int h, m, s;
    h = S/3600 ;
    m = (S%3600)/60 ;
    s = (S%3600)%60;
    cout << h << ":"<< m << ":" << s << endl;
    return 0;
    
}

Measured memory_bytes: 3080
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    S = []
    for n in range(N):
        S_n = input()
        S.append(S_n)

    return N, S


def main(S: list) -> None:
    """
    メイン処理.

    Args:\n
        S (list): ジャッジ結果
    """
    # 求解処理
    for v in ["AC", "WA", "TLE", "RE"]:
        # 結果出力
        print(f"{v} x {S.count(v)}")


if __name__ == "__main__":
    # 標準入力を取得
    N, S = get_input()

    # メイン処理
    main(S)


Measured memory_bytes: 16300
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 998244353
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll H,W,K;
    cin>>H>>W>>K;
    vector<string> S(H);
    rep(i,0,H)cin>>S[i];

    vv sums(H,v(W));
    rep(i,0,H){
        if(S[i][0] == '1')sums[i][0] = 1;
        else sums[i][0] = 0;
    }
    rep(j,1,W){rep(i,0,H){
        if(S[i][j] == '1')sums[i][j] = sums[i][j-1]+1;
        else sums[i][j] = sums[i][j-1];
    }}
    ll ans = INF;
    ll cans = 0;
    ll n2;
    rep(i,0,512){
        ll cans =0;
        ll nows = 0;
        bool ok =true;
        rep(j,0,W){
            n2 = i;
            ll max_wh = 0;
            ll csum = 0;
            ll cur = 0;
            rep(k,0,H){
                if(nows == 0) {
                    csum += sums[k][j];
                    if(S[k][j] == '1')cur++;
                }
                else{
                    csum += sums[k][j]-sums[k][nows -1];
                    if(S[k][j] == '1')cur++;
                }
                if(n2 % 2 == 1 || k == H-1){
                    max_wh = max(max_wh,csum);
                    csum = 0;
                    if(cur > K)ok = false;
                    cur = 0;
                }
                n2 /= 2;
            }
            if(max_wh > K){
                cans++;
                nows = j;
            }
        }
        n2 = i;
        rep(j,0,H-1){
            if(n2%2 == 1)cans++; 
            n2/=2;
        }
        if(ok)ans = min(ans, cans);
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  let
    f :: Int -> Int
    f k = 10 * g k + (k `mod` 10)
    g :: Int -> Int
    g k | k < 10    = k
        | otherwise = g (k `div` 10)
    encode :: Int -> Int -> Int
    encode i j = 10 * i + j
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    counts = VU.accum (const . succ) (VU.replicate 100 0) . map (flip (,) () . f) $ [1..n] :: VU.Vector Int
    op :: Int -> Int -> Int
    op i j = counts VU.! encode i j * counts VU.! encode j i
  print . sum $ op <$> [0..9] <*> [0..9]

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

template <typename T>
using lim = numeric_limits<T>;

int arr[26];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i = 0; i < 26; i++) arr[i] = -1;
	string s; cin >> s;

	int n = s.size();

	int l, r;
	l = r = -1;
	for (int i = 0; i < n; i++){
		int x = s[i]-'a';
		if (arr[x] == -1) arr[x] = i;
		else {
			if (i-arr[x]+1 <= 3) {
				l = arr[x]+1;
				r = i+1;
				break;
			}
			arr[x] = i;
		}
	}

	cout << l << " " << r << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> num(n, 0);

	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int tmp;
			cin >> tmp;
			num[tmp - 1]++;
		}
	}

	int ans = 0;
	rep(i, n) ans += num[i] == 0;
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int M = 1000000007;
ll mod(ll x){
        return ((x%M + M)%M);
    }
ll add(ll a, ll b){
        return mod(mod(a)+mod(b));
    }
ll mul(ll a, ll b){
        return mod(mod(a)*mod(b));
    }
ll minu(ll a, ll b){
        return mod(mod(a)-mod(b));
    }
ll power(ll a, ll b){
    ll res=1;
    while(b>0){
        if(b&1) res=mul(res,a);
        b = b>>1;
        a=mul(a,a);
    }
    return res;
}
int main(){
    ll n;
    cin>>n;
    ll s=0,prev=0;
    for(ll i=0;i<n;++i){
        int x;
        cin>>x;
        if(x>prev)
        {
            prev=x;
            continue;
        }
        int diff = prev-x;
        s+=diff;
        x+=diff;
        prev=x;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class GreedyTakahashi
{
    static void Main(string[] args)
    {

        var input = Console.ReadLine().Split(' ');
        var takahashi = long.Parse(input[0]);
        var aoki = long.Parse(input[1]);
        var times = long.Parse(input[2]);

        var aoki_down = takahashi - times;

        if(aoki_down <= 0)
        {
            takahashi = 0;
            aoki = aoki + aoki_down;
        }
        else
        {
            takahashi = aoki_down;
        }

        if(aoki <= 0)
        {
            aoki = 0;
        }

        Console.WriteLine("{0} {1}",takahashi,aoki);
    }
}

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

int main(){
  int ans, count;
  int a, b, c;
  string str;

  cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  if(a==b)cout<<"Draw"<<endl;
  else if(a >b)cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
nu = gets.to_i
array = gets.chomp.split(" ").map(&:to_i)
count1 = []
count2 = []
for i in 0..nu - 1
  if i % 2 == 0
    count1.push(array[i])
  else
    count2.push(array[i])
  end
end
count3 = Array.new(10**5 + 1, 0)
count4 = Array.new(10**5 + 1, 0)

for i in 0..count1.length - 1
  count3[count1[i]] += 1
end
for i in 0..count1.length - 1
  count4[count2[i]] += 1
end

check1 = [0, 0]
check2 = [0, 0]
check3 = [0, 0]
check4 = [0, 0]
for i in 1..10**5
  if check1[1] < count3[i]
    check1[1] = count3[i]
    check1[0] = i
  end
  if check2[1] < count4[i]
    check2[1] = count4[i]
    check2[0] = i
  end
end
for i in 1..10**5
  if check3[1] < count3[i] && i != check1[0]
    check3[1] = count3[i]
    check3[0] = i
  end
  if check4[1] < count4[i] && i != check2[0]
    check4[1] = count4[i]
    check4[0] = i
  end
end

if check1[0] != check2[0]
  puts (count1.length - check1[1]) + (count2.length - check2[1])
  exit
end

if (check1[1] + check4[1]) > (check2[1] + check3[1])
  puts (count1.length - check1[1]) + (count2.length - check4[1])
else
  puts (count1.length - check3[1]) + (count2.length - check2[1])
end


Measured memory_bytes: 13216
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let av: Vec<u64> = read_vec();
    let bv: Vec<u64> = read_vec();
    let mut up: u64 = 0;
    let mut down: u64 = 0;
    for i in 0..n {
        let a = av[i];
        let b = bv[i];
        if a > b {
            down += a - b;
        } else {
            up += (b - a) / 2;
        }
    }
    if down > up {
        println!("No");
    } else {
        println!("Yes");
    }
}


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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	uint64_t x;cin>>x;
	uint64_t n=100;
	int ans=0;
	while(n<x){
		n+=n*0.01;
		ans++;
	}
	cout << ans;
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    int max1=max(a,max(b,c));
    max1*=3;
    int mod=max1%2;
    if(mod==(a+b+c)%2){
        ans=(max1-(a+b+c))/2;
    }
    else{
        ans=(max1-(a+b+c))/2+2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

string longestRepeatedSubstring(string str)
{
    int n = str.length();
    int LCSRe[n+1][n+1];

    // Setting all to 0
    memset(LCSRe, 0, sizeof(LCSRe));

    string res; // To store result
    int res_length  = 0; // To store length of result

    // building table in bottom-up manner
    int i, index = 0;
    for (i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            // (j-i) > LCSRe[i-1][j-1] to remove
            // overlapping
            if (str[i-1] == str[j-1] &&
                LCSRe[i-1][j-1] < (j - i))
            {
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1;

                // updating maximum length of the
                // substring and updating the finishing
                // index of the suffix
                if (LCSRe[i][j] > res_length)
                {
                    res_length = LCSRe[i][j];
                    index = max(i, index);
                }
            }
            else
                LCSRe[i][j] = 0;
        }
    }

    // If we have non-empty result, then insert all
    // characters from first character to last
    // character of string
    if (res_length > 0)
        for (i = index - res_length + 1; i <= index; i++)
            res.push_back(str[i-1]);

    return res;
}

int main() {

    fast

    int n;
    cin>>n;

    string s;
    cin>>s;



    s=longestRepeatedSubstring(s);
    cout<<s.size();

	return 0;
}







/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/


Measured memory_bytes: 97920
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 15
int length;
int ans;
char buf[NUM];

bool is_ok(int num){

	return num >= 0 && num <= 255;
}

void recursive(int num,int index,int num_decided){

	if(!is_ok(num))return;

	if(num_decided == 4){

		if(index == length){
			ans++;
		}

		return;
	}

	//今回の場所で区切る
	int next_num = 10*num+(buf[index]-'0');

	if(is_ok(next_num)){
		recursive(0,index+1,num_decided+1);
	}

	if(buf[index] == '0')return; //leading zeroは不可

	//続ける
	recursive(next_num,index+1,num_decided);
}

int main(){

	scanf("%s",buf);

	for(length = 0; buf[length] != '\0'; length++);

	ans = 0;

	recursive(0,0,0);

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 3220
s = input()
n = len(s) - 1
answers = []
sl = [s[i] for i in range(len(s))]
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    ll = ['*']*len(s)
    for k in tmp:
        ll[k] = '+'
    ans = []
    for k, _ in zip(sl, ll):
        ans.append(k)
        ans.append(_)
    ans = [_ for _ in ans if _ != '*']
    ans = ''.join(ans)
    ans = ans.split('+')
    ans = [int(_) for _ in ans if _ != '+']
    ans = sum(ans)
    answers.append(ans)
print(sum(answers))

Measured memory_bytes: 3064
n,a,b = map(int,input().split())
if (a % 2 + b % 2) % 2 == 0:
    print(abs(a - b) // 2)
    exit(0)

if n - b < a - 1:
    p = n - b + 1
    a += n - b
    b = n
    print(abs(a - b) // 2 + p)
else:
    p = a - 1 + 1
    b -= a - 1
    a = 1
    print(abs(a - b) // 2 + p)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    string S; cin >> S;
    S[K - 1] = (char)(S[K - 1] + 'a' - 'A');
    Out(S);

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


vector<pair<int, int>> edges[100000];
int ans[100000];

void dfs(int i, int par, int pc) {
	//毎回1から
	int c = 1;
	for (auto p : edges[i]) {

		int j = p.first, idx = p.second;

		//逆流防止
		if (j == par)continue;
		//親と同じ色ならスキップ
		if (c == pc)c++;
		//現在の頂点に塗る
		ans[idx] = c;

		//次の頂点へ
		dfs(j, i, c);

		//帰ってきたら次の色にする
		c++;
	}
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b; a--; b--;
		edges[a].emplace_back(b, i);
		edges[b].emplace_back(a, i);
	}

	dfs(0, -1, -1);

	//次数の最大値
	cout << *max_element(ans,ans+n-1)<<endl;
	for (int i = 0; i < n-1; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 9344
#include <iostream>
using namespace std;
int main(void){
    int N,M;
    cin>>N>>M;
    int H[100000];
    int result=0;
    bool good[100000];
    int A,B;
    for(int i=0;i<N;i++) {
        cin>>H[i];
        good[i]=true;
    }
    for(int j=0;j<M;j++){
        cin>>A>>B;
        if(H[A-1]>H[B-1]){
            good[B-1]=false;
        }
        else if(H[A-1]<H[B-1]){
             good[A-1]=false;
        }
        else{
            good[B-1]=false;
            good[A-1]=false;
        }
    }
    for(int k=0;k<N;k++){
        if(good[k]){
            result++;
        }
    }
    cout<<result<<endl;
}

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

int main() {
  string S;
  cin >> S;
  
  if (S.at(0) == S.at(1) && S.at(0) == S.at(2) && S.at(0) == S.at(3)) {
    
    cout << "No" << endl;
    
  } else {
    
    if (S.at(0) == S.at(1)) {
      
      if (S.at(2) == S.at(3)) {
        
        cout << "Yes" << endl;
        
      } else {
        
        cout << "No" << endl;
        
      }
      
    } else if (S.at(0) == S.at(2)) {
      
      if (S.at(1) == S.at(3)) {
        
        cout << "Yes" << endl;
        
      } else {
        
        cout << "No" << endl;
        
      }
      
    } else {
      
      if (S.at(1) == S.at(2)) {
        
        cout << "Yes" << endl;
        
      } else {
        
        cout << "No" << endl;
        
      }
      
    }
    
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  double x1,x2,y1,y2,d;
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    d=sqrt(pow(x2-x1,2)+pow(y2-y1,2));
   printf("%.8f\n",d);
  return 0;
}

Measured memory_bytes: 656
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for (int i=0; i< n; i++)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {//gcd a>b lcm(a,b)=a*b/gcd(a,b) ... a*b=gcd(a,b)*lcm(a,b)
	if (b) {
		return gcd(b, a%b);
	}
	else {
		return a;
	}
}

int main() {
	ll a, b;
	cin >> a >> b;
	cout << a / gcd(a, b)*b << endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;

using namespace std;
//
// Created by karayuu on 2019-3-28.
//

int main() {
    string s, p;
    cin >> s;
    cin >> p;

    string t = s + s;

    if (t.find(p) != -1) {
        P("Yes");
    } else {
        P("No");
    }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf 1000000000
#define gcd __gcd //最大公約数,gcd(x,y)
int lcm(int a, int b){return a/gcd(a, b)*b;} //(int)最小公倍数,lcm(x,y)
ll llcm(ll a, ll b){return a/gcd(a, b)*b;}//(ll)最小公倍数,lcm(x,y)


int main(){
  int N,i,j,maxi=0,tmp=0;
  cin >> N;
  int L[N];
  for(i=0 ; i<N ; i++){
    cin >> L[i];
    tmp += L[i];
    maxi = max(maxi,L[i]);
    if(maxi == L[i]){
      j = i;
    }
  }

  tmp -= L[j];

  if(tmp > maxi){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'


double arr[60];
int n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	sort(arr,arr+n);
	double an=(arr[0]+arr[1])/2.0;
	for(int i=2;i<n;i++)an=(an+arr[i])/2.0;
	cout<<setprecision(6)<<fixed<<an<<endl;
	return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll x,t;
	cin>>x>>t;
	cout<<max((ll)0,x-t)<<endl;
	ggr
}



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

signed main(void)
{
	int n;
	cin >> n;
	map<string, int> mp;
	mp["AC"] = mp["WA"] = mp["TLE"] = mp["RE"] = 0;
	rep(i, n)
	{
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	return 0;
}


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

ll dp[5005][5005];
ll N,L;
ll x[5005];
ll a[5005];

const ll mod = 1000000007LL;

void add( ll &a, ll b ){
  a += b;
  a %= mod;
}

ll solve(int id,int l){
  //cout << id << ", "<< l << " "<< x[id] << " "<<a[id] << endl;
  if( dp[id][l] != -1 ) return dp[id][l];
  ll ret = 0;  
  if( id == 0 ) return dp[id][l] = 1LL;
  if( x[id] > l ) return dp[id][l] = 0;
                    
  if( x[id] == l || (a[id] > 0 && (l - x[id])%a[id] == 0) ) add( ret, solve(id-1,l-1) );
  add( ret, solve( id, l-1 ) );
  return dp[id][l] = ret;
}

int main(){
  memset(dp,-1,sizeof(dp));
  cin >> N >> L;
  for(int i=0;i<N;i++){
    cin >> x[i+1]; x[i+1]++;
  }
  for(int i=0;i<N;i++)
    cin >> a[i+1]; 
  cout << solve( N, L ) << endl;
}

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

void solve()
{
    int a;
    cin >> a;
    cout << a+a*a+a*a*a;
}


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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"

const int mod = 998244353;

int mul(int a, int b) {
	int res = a*b;
	if(res > mod) {
		return res%mod;
	}
	return res;
}

int add(int a, int b) {
	int res = a + b;
	if(res > mod) return res%mod;
	return res;
}

int32_t main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	vector<vector<int>> dp(c+1, vector<int>(d+1, 1));
	for(int i = 0; i <= c; i ++) {
		for(int j = 0; j <= d; j ++) {
			if(i == 0 && j == 0) {
				dp[i][j] = 1;
				continue;
			}
			if(i == 0 || j == 0) {
				dp[i][j] = 0;
				continue;
			}
			if(i <= a && j <= b) {
				dp[i][j] = 1; 
				continue; 
			}
			if(i == a) {
				dp[i][j] = mul(dp[i][j-1],i);
			}
			if(j == b) {
				dp[i][j] = mul(dp[i-1][j],j);
			}
			if(i > a && j > b){
				dp[i][j] = add(mul(dp[i-1][j], j), mul(dp[i][j-1], i));
				dp[i][j] = dp[i][j] - mul(dp[i-1][j-1],(i-1)*(j-1));
				dp[i][j] = add(dp[i][j], mod);
			}
		}
	}
	cout << dp[c][d] << endl;
	return 0;
}

Measured memory_bytes: 73672
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

signed main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> kuma(n);
    fac[0] = 1;
    ifac[0] = 1;    
    kuma[0] = 1;
    FOR(i, 1, n) {
        kuma[i] = (m-1)*kuma[i-1] % mod;
    }
    //cout << kuma[n-1] << endl;
    FOR(i, 0, 250000) {
        fac[i+1] = fac[i]*(i+1) % mod;
        ifac[i+1] = ifac[i]*fpow(i+1, mod-2) % mod;
    }

    int ans = 0;
    rep(i,k+1) {
        int tmp = (m*comb(n-1,i))%mod;
        tmp *= (kuma[n-1-i] %mod);
        tmp %= mod;
        ans += tmp%mod;
        //cout << tmp << endl;
    }
    //cout << ans << endl;
    cout << ans%mod << endl;
    return 0;
}

Measured memory_bytes: 9596
#include <iostream>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int addm(int a, int b)
{
	return (0L + a + b) % MOD;
}

int subm(int a, int b)
{
	return addm(a, (MOD - b) % MOD);
}

int mulm(int a, int b)
{
	return (1LL * a * b) % MOD;
}

int powm(int a, long long n)
{
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return mulm(a, powm(a, n - 1));
	}
	else {
		return powm(mulm(a, a), n / 2);
	}
}

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

	int ans = powm(10, N);
	ans = subm(ans, powm(9, N));
	ans = subm(ans, powm(9, N));
	ans = addm(ans, powm(8, N));
	cout << ans << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Info{
	Info(int arg_head,int arg_tail){
		head = arg_head;
		tail = arg_tail;
	}
	int head,tail;
};

int H,W,K;
int POW[10];
int table[10][1005];
char buf[10][1005];

int main(){

	POW[0] = 1;
	for(int i = 1; i < 10; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d %d %d",&H,&W,&K);

	for(int row = 0; row < H; row++){

		scanf("%s",buf[row]);
		for(int col = 0; col < W; col++){
			table[row][col] = buf[row][col]-'0';
			if(col > 0){

				table[row][col] += table[row][col-1];
			}
		}
	}

	int ans = BIG_NUM;
	vector<Info> V;

	int head,tail;
	int left,right,mid,pre_col,next_col;
	int tmp;
	bool FLG;

	for(int state = 0; state < POW[H-1]; state++){
		V.clear();

		int tmp_ans = 0;
		head = 0;

		for(int loop = 0; loop < H-1; loop++){
			if(state & (POW[loop])){
				tail = loop;
				V.push_back(Info(head,tail));
				head = tail+1;
				tmp_ans++;
			}
		}
		V.push_back(Info(head,H-1));

		pre_col = 0;

		while(pre_col < W){

			left = pre_col,right = W-1,mid = (left+right)/2;
			next_col = -1;

			while(left <= right){

				FLG = true;

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

					head = V[i].head;
					tail = V[i].tail;

					tmp = 0;

					for(int row = head; row <= tail; row++){

						if(pre_col == 0){

							tmp += table[row][mid];
						}else{

							tmp += table[row][mid]-table[row][pre_col-1];
						}
						if(tmp > K){
							FLG = false;
							break;
						}
					}
					if(!FLG)break;
				}

				if(FLG){

					next_col = mid+1;
					left = mid+1;

				}else{

					right = mid-1;
				}
				mid = (left+right)/2;
			}

			if(next_col == -1){

				tmp_ans = BIG_NUM;
				break;
			}else{

				if(next_col != W){

					tmp_ans++;
				}
				pre_col = next_col;
			}
		}
		ans = min(ans,tmp_ans);
	}

	printf("%d\n",ans);

	return 0;
}


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

int main(){
  int n,m;
  std::cin >> n >> m;
  vt<int> ab(n);

  rep(i,m) {
      int a,b;
      std::cin >> a >> b;
      ++ab[a-1];
      ++ab[b-1];
  }

  rep(i,n) {
    std::cout << ab[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main() {
    int n, k, a[100000][3], dp[100000][3];
    memset(dp, -1, sizeof(dp));
    scanf("%d", &n);
    for (int i = 0; i < n; i += 1) {
        for (int j = 0; j < 3; j += 1) {
            scanf("%d", &a[i][j]);
        }
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for (int i = 1; i < n; i += 1) {
        for (int j = 0; j < 3; j += 1) {
            dp[i][j] = max((max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 1) % 3])), (max(dp[i - 1][(j + 2) % 3], dp[i - 1][(j + 2) % 3])))+a[i][j];
        }
    }
    printf("%d", max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]));
}

Measured memory_bytes: 2560
<?php
fscanf(STDIN, "%s", $S);
$able_key = array(0, 1, 'B');
$result = array();
if (strlen($S) < 0 || 10 < strlen($S)) {
    exit;
}
for ($i = 0; $i < strlen($S); $i++) {
    if (!in_array($S[$i], $able_key)) {
        exit;
    }
    if ($S[$i] != 'B') {
        $result[] = $S[$i];
    } else {
        array_pop($result);
    }
}

foreach ($result as $key) {
    echo $key;
}

?>

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] a){

		int[] arr = new int[]{0,0,0};
		String str;
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		try {
			while(null != (str = bf.readLine())){
				int tmp = Integer.parseInt(str);
				if(arr[0] < tmp){
					arr[0] = tmp;
					Arrays.sort(arr);
				}
			}
			for(int i = 1; i <= 3; i++){
				System.out.println(arr[3 - i]);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 9348
while 1 do
  h,w=gets.split.map(&:to_i)
  if h==0 and w==0 then
    break
  end
  for i in 1..h
    str=''
    for j in 1..w
      if i>1 and i<h and j>1 and j<w then
        str+='.'
      else
        str+='#'
      end
    end
    puts str
  end
  puts ''
end  



Measured memory_bytes: 7248
#include <iostream>
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)

using namespace std;

typedef long long unsigned int ll;

int main(void) {
    ll i, l, r, d, count;

    count = 0;
    cin >> l >> r >> d;
    FOR(i,l,r+1) {
        if (i % d == 0)
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3588