akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    string x; cin >> x;
    int n = x.length();
    stack<char> st;
    REP(i,n) {
        if(x[i]=='S') st.push(x[i]);
        else {
            if(!st.empty() && st.top()=='S') st.pop();
            else st.push(x[i]);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 644
#include<stdio.h>
int main(){
    int N,d,num[101]={},count=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&d);
        num[d]++;
    }
    for(int i=1;i<=100;i++){
        if(num[i]>0)    count++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a < b){
            System.out.println("a < b");
        }
        if(a == b){
            System.out.println("a == b");
        }
        if(a > b) {
            System.out.println("a > b");
        }
    }
}



Measured memory_bytes: 26148
//ABC121B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	for(int i=0;i<m;i++){
		cin >> b.at(i);
	}
	vector<vector<int>> a(n,vector<int>(m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> a.at(i).at(j);
		}
	}
	long long int count = 0;
	for(int i=0;i<n;i++){
		long long int sigma = 0;
		for(int j=0;j<m;j++){
			sigma += a.at(i).at(j)*b.at(j);
		}
		if(sigma+c > 0){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input());t,x,y=[],[],[]
for _ in range(n):
  a,b,c=map(int,input().split())
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  if i==0:
    r1,r2=t[i],x[i]+y[i]
  else:
    r1,r2=t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if not (r1>=r2 and r1%2==r2%2):
    print('No');break
else:
  print('Yes')

Measured memory_bytes: 17672
#include<stdio.h>
#include<ctype.h>

int main(void){

	char str[1200];
	int i;
	for(i=0;i<1200;i++)str[i]='\n';
	scanf("%[^\n]",str);
	i=0;
	while(1){
		if(str[i]=='\n'){break;}
		if(islower(str[i])){str[i]=toupper(str[i]);}
		else if(isupper(str[i])){str[i]=tolower(str[i]);}
		i++;

	}printf("%s\n",str);


	return 0;
}

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

int main() {
  int N, sum;

  cin >> N;

  sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;

    sum += 1 + (r - l);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

k = int(input())

q = []

for i in range(9):
    heappush(q, i+1)

for _ in range(k - 1):
    x = heappop(q)
    if x % 10 != 0:
        heappush(q, 10 * x + (x % 10) - 1)
    if x % 10 != 9:
        heappush(q, 10 * x + (x % 10) + 1)
    heappush(q, 10 * x + (x % 10))

print(heappop(q))

Measured memory_bytes: 11712
#include <stdio.h>

int main(void){
	int i,n,k;
	
	while(scanf("%d%d",&n,&k),n,k){
		int max=0,temp=0;
		int val[100000]={0};
		
		for(i=0;i<n;i++){
			scanf("%d",&val[i]);
			temp+=val[i];
			if(i>=k)temp-=val[i-k];
			if(i>k-1 && temp>max)max=temp;
		}
		
		printf("%d\n",max);
		
	}
	return 0;
}

Measured memory_bytes: 0
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
rs = [0]
for i in range(n):
    rs.append(rs[-1] + a[n - 1 - i])

ans = 0
for i in range(n - 1):
    ans += a[i] * rs[n - 1 - i] % MOD
print(ans % MOD)

Measured memory_bytes: 31420
#include <stdio.h>
int main(){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    int sum = 0;
    for(int i = 1;i <= n; i++){
        int num = i;
        int temp = 0;
        while(num > 0){
            temp += num % 10;
            num /= 10;
}
        if(temp >= a && temp <= b){
        sum += i;
        }
 
    }
    printf("%d", sum);
    return 0;}

Measured memory_bytes: 1704
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 1e9+10
using namespace std;
map <char,int>leta;
map <char,int>letb;
string s,t;
int num=1,sn[200005],tn[200005],yes=1;
int main(){
    cin>>s;
    cin>>t;
    for(int i=0;i<s.size();i++){
        if(!leta[s[i]])
            leta[s[i]]=num++;
        sn[i]=leta[s[i]];
    }
    num=1;
    for(int i=0;i<t.size();i++){
        if(!letb[t[i]])
            letb[t[i]]=num++;
        tn[i]=letb[t[i]];
    }
    for(int i=0;i<s.size();i++){
        if(sn[i]!=tn[i]||s.size()!=t.size()){
            yes=0;
            break;
        }
    }
    if(yes)
        printf("Yes");
    else
        printf("No");

}


Measured memory_bytes: 5008
package main

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

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

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	a, b := next(), next()
	// 最大で1M程度?
	n, _ := strconv.Atoi(a + b)
	flag := false
	for i := 1; i <= int(math.Sqrt(float64(n))); i++ {
		if n%i == 0 {
			if (n/i)*(n/i) == n {
				flag = true
				break
			}
		}
	}
	if flag == false {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

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

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

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

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

// Genericsがないので筋肉で...
// interfaceでの取扱がようわからんし
func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// mapからkeysとvaluesを返す感じのやつ
// なんかしらんけどmap[interface{}]interface{}しか受け付けない。なんのためのinterface{}やねん
// なので呼ぶときのmapはmap[int]stringとかじゃダメ
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
	return
}


Measured memory_bytes: 640
n, x = map(int, input().split())
p, q = [1] + [0] * n, [1] + [0] * n

for i in range(1, n+1):
    p[i] = p[i-1] * 2 + 1
    q[i] = q[i-1] * 2 + 3    

def rec(i, x):
    if i == 0: return 1 if x >= 1 else 0
    mid = q[i-1] + 2
    if x < mid:
        return rec(i-1, x-1)
    else:
        return p[i-1] + 1 + rec(i-1, x-mid)

print(rec(n, x))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	vector<int> heights;
	cin >> n;
	vector<int> dp(n + 1, INT_MAX);

	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		heights.push_back(x);
	}
	dp[0] = 0;
	dp[1] = abs(heights[1] - heights[0]);
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(heights[i] - heights[i-1]),
					dp[i - 2] + abs(heights[i] - heights[i-2]));
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 1276
#include<cmath>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<cstdio>
#include<set>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define per(i,a,b) for(long long int i=a;i<=b;++i)
#define inf 0xf3f3f3f
#define ll long long 
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%b!=0) cout<<a/b+1;
	else 
	cout<<a/b; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int m,int n){
	int r;
	r=m%n;
	if(r==0) return n;
	else return gcd(n,r);
}
int main(){
	long long a,b,n;
	cin>>a>>b;
	n=a*b/gcd(a,b);
	cout<<n<<endl;
	return 0;
} 

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

int main() {
	
	int n, m, cnt=0;
	cin >> n;
	int a[n];
	
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	sort(a,a+n);
	
	cin >> m;
	for(int i=0; i<m; i++){
		int v;
		scanf("%d", &v);
		if(binary_search(a, a+n, v)) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3528
from collections import deque


S = list(input())
T = list(input())



dqS = deque(S)
dqT = deque(T)

cnt = 0

while dqS:
    tempS = dqS.popleft()
    tempT = dqT.popleft()
    if tempS != tempT:
        cnt += 1

print(cnt)

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

int main() {
 int K,X; cin >> K >> X;
 for(int i = X - K + 1;i < X + K;i++){
   cout << i << endl;
 }
}

Measured memory_bytes: 256
m[100][100];D(x,y,n){if(n<4){
	m[x][y]=1;
	if(n>1)m[x][y-1]=1;
	if(n==2)m[x+1][y-1]=1;
	if(n>2)m[x][y-2]=1,m[x+1][y-2]=1,m[x+2][y-2]=1,m[x+2][y-1]=1,m[x+2][y]=1;
}else{
	int i=0,j=0;
	for(;j<n;j++)m[x+i][y-j]=1;j--;
	for(;i<n;i++)m[x+i][y-j]=1;i--;
	for(;j>=0;j--)m[x+i][y-j]=1;j++;
	for(;i>=2;i--)m[x+i][y-j]=1;j++;
	if(n-4)m[x+2][y-1]=1,D(x+2,y-2,n-4);
}}
main(d,n,i,j){for(scanf("%d",&d);d;d--){
	memset(m,0,sizeof(m));scanf("%d",&n);D(0,n-1,n);
	for(i=0;i<n;puts(""),i++)for(j=0;j<n;j++)putchar(m[j][i]?'#':' ');
	if(d>1)puts("");
}exit(0);}

Measured memory_bytes: 628
import collections
N=int(input())
D=list(map(int,input().split(' ')))
M=int(input())
T=list(map(int,input().split(' ')))
cd = collections.Counter(D)
ct = collections.Counter(T)
ans = 'YES'
for t in list(ct.keys()):
	if ct[t]>cd[t]:
		ans = 'NO'
		break
print(ans)

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>s(m);
  vector<int>c(m);
  vector<int>ans(n,10);
  for(int i = 0;i < m;i++){
    cin >> s[i] >> c[i];
    if(ans[s[i]-1] != 10 && ans[s[i]-1] != c[i]){
      cout << -1 << endl;
      return 0;
    }
    else{
      ans[s[i]-1] = c[i];
    }
  }
  if(n == 1 && ans[0] == 0){
    cout << 0 << endl;
    return 0;
  }
  else if(ans[0] == 0){
    cout << -1 << endl;
    return 0;
  }
  for(int i = 0;i < n;i++){
    if(i == 0 && ans[i] == 10){
      if(n == 1){
        ans[i] = 0;
      }
      else{
        ans[i] = 1;
      }
    }
    else if(ans[i] == 10){
       ans[i] = 0;
    }
    cout << ans[i];
  }
  cout << "" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
table = [0] * (N + 1)
res = 0
for a in A:
  if a <= N:
    table[a] += 1
  else:
    res += 1
for i in range(N + 1):
  if table[i] < i:
    res += table[i]
  else:
    res += table[i] - i
print(res)

Measured memory_bytes: 14692
n,k= list(map(int,input().split()))

sign = k%2

if sign == 0:
  temp = 0
  for i in range(1,n+1):
    if i%k == k//2:
      temp = temp + 1  
  ans = (n//k)**3 + temp**3
elif sign == 1:
  ans = (n//k)**3
  
print(int(ans))

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//整数型を宣言して読み込む
		int A = sc.nextInt();
		int B = sc.nextInt();		
		//整数型配列の宣言と初期化	
		int ans=0;
		ans=(3*A+B)/2;
		System.out.println(ans);
	}
}

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

int main()
{
	int n = 0;
	cin >> n;
	vector<int> list(3 * n);
	for (int i = 0; i < 3 * n; i++)
	{
		cin >> list[i];
	}
	sort(list.begin(), list.end(), greater<int>());
	long ans = 0;
	for (int i = 1; i < 2 * n; i += 2)
	{
		ans += list[i];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
const int opst[27][3] = {
	{0,0,0},
	{0,0,1},
	{ 0,0,2 },
	{ 0,1,0 },
	{ 0,1,1 },
	{ 0,1,2 },
	{ 0,2,0 },
	{ 0,2,1 },
	{ 0,2,2 },
	{ 1,0,0 },
	{ 1,0,1 },
	{ 1,0,2 },
	{ 1,1,0 },
	{ 1,1,1 },
	{ 1,1,2 },
	{ 1,2,0 },
	{ 1,2,1 },
	{ 1,2,2 },
	{ 2,0,0 },
	{ 2,0,1 },
	{ 2,0,2 },
	{ 2,1,0 },
	{ 2,1,1 },
	{ 2,1,2 },
	{ 2,2,0 },
	{ 2,2,1 },
	{ 2,2,2 },
};

ll calc(vector<ll> num, vector<int> op, int pri) {
	REP(n,3)
	REP(i,op.size()) {
		if (opst[pri][op[i]] == n) {
			if (op[i] == 0) {
				num[i] += num[i + 1];
			}
			else if (op[i] == 1) {
				num[i] -= num[i + 1];
			}
			else {
				num[i] *= num[i + 1];
			}
			FOR(j, i + 1, num.size() - 1)
				num[j] = num[j + 1];
			num.resize(num.size() - 1);
			FOR(j, i, op.size() - 1)
				op[j] = op[j + 1];
			op.resize(op.size() - 1);
			i--;
		}
	}
	return num[0];
}
ll saiki(string s, int &idx, int pri) {
	vector<ll> num;
	vector<int> op;
	while ((size_t)(idx) < s.length()) {
		if (s[idx] == '(') {
			idx++;
			num.push_back(saiki(s, idx, pri));
			continue;
		}
		if (s[idx] == ')') {
			idx++;
			return calc(num, op, pri);
		}
		if (isdigit(s[idx])) {
			ll num2 = 0;
			while ((size_t)idx < s.length() && isdigit(s[idx])) {
				num2 *= 10;
				num2 += s[idx] - '0';
				idx++;
			}
			num.push_back(num2);
			continue;
		}
		int opn=0;
		if (s[idx] == '-')
			opn = 1;
		if (s[idx] == '*')
			opn = 2;
		op.push_back(opn);
		idx++;
	}
	return calc(num, op, pri);
}

int main() {
	string s;
	cin >> s;
	ll ma = 1;
	ma <<= 63;
	ma *= -1;
	REP(i, 27) {
		int idx = 0;
		ma = max(ma,saiki(s, idx, i));
	}
	cout << ma << endl;
}

Measured memory_bytes: 3204
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, L;
    cin >> N >> L;

    string S[N];
    rep(i, N){
        cin >> S[i];
    }

    sort(S, S + N);

    rep(i, N){
        cout << S[i];
    }
    cout << endl;

    return 0;
}

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

int main() {
	int n; cin >> n; string s; cin >> s; 
	int wcnt = 0; int rcnt = 0; for (int i =0 ; i < n; i ++) {if (s[i] == 'W') wcnt++; else rcnt++;}
	int ans = min(wcnt, rcnt); int curred = 0;
	for (int i = 0; i < n; i ++) {
		if (s[i] == 'R') curred++;
		int needed_red = i+1;
		if (needed_red == curred) {
			int extra_red = rcnt - curred;
			ans = min(ans, extra_red);
		} else if (needed_red > curred) {
			if (needed_red <= rcnt) {
				int ans2 = rcnt - curred; ans = min(ans, ans2);
			} else {
				int ans2 = needed_red - curred; ans = min(ans, ans2);
			}
		} 
	} cout << ans << endl;

}

Measured memory_bytes: 3736
#include<stdio.h>
#include<math.h>


double A,B,H,M;
double k,C;
int main(){
  scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
  H=30*H+30*M/60;
  M=6*M;
  k=fabs(H-M);
  C=A*A+B*B-2*A*B*(cos(k*M_PI/180));
  C=sqrt(C);
  printf("%.20lf\n",C);
  return(0);
}


Measured memory_bytes: 2548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            String[] values = line.split(" ");
            int c1 = Integer.parseInt(values[0]);
            int c2 = Integer.parseInt(values[1]);
            int c3 = Integer.parseInt(values[2]);
            boolean[] opens = new boolean[10];
            opens[c1 - 1] = true;
            opens[c2 - 1] = true;
            opens[c3 - 1] = true;
            int count = 0;
            String result = "NO";
            for (int i = 0; i < Math.min(20 - (c1 + c2), 10); i++) {
                if (!opens[i]) {
                    count++;
                    if (count == 4) {
                        result = "YES";
                        break;
                    }
                }
            }
            out.println(result);
        }
    }
}

Measured memory_bytes: 9160
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=set([0]+f);Y=set(X);R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):a,b,c=I();R+=[((a,b),c)];Y.add(c);X.add(a);X.add(b)
for i in r(m):a,b,c=I();H+=[(a,(b,c))];X.add(a);Y.add(b);Y.add(c)
s=dict(enumerate(sorted(X)));K=len(s);t=dict(enumerate(sorted(Y)));L=len(t);h=dict(zip(s.values(),s.keys()));w=dict(zip(t.values(),t.keys()));V=[[0]*-~K for i in r(L+1)];U=[i[:]for i in V];v=[i[:]for i in V]
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(L+1):
 for j in r(K):U[i][j+1]+=U[i][j]
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for j in r(K+1):
 for i in r(L):V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)

Measured memory_bytes: 551412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

    
    int n,m,c;
    cin>>n>>m>>c;
    
    int arr[m];
    
    for(int i=0;i<m;++i)
       cin>>arr[i];
    
    int arr1[n][m];
    
    for(int i=0;i<n;++i)
      for(int j=0;j<m;++j)
        cin>>arr1[i][j];
        
    int ct=0;
    for(int i=0;i<n;++i){
        int sum=0;
      for(int j=0;j<m;++j){
          sum+=arr[j]*arr1[i][j];
      }
      if(sum+c>0)
        ct++;
    }
      cout<<ct;
	return 0;
}

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

int fac(int x) {
  int cnt = 0;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      cnt++;
      if (x / i != i) cnt++;
    }
  }
  return cnt;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    if (fac(i) == 8) ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

#include<cstdio>

using namespace std;

#define LMAX 1000
#define LMIN 1

double L;

const double eps = 10e-6;

int main(void){
	cin >> L;
	const double edge = L / 3.0;
	const double max = edge * edge * edge;
	printf("%.12f\n", max);
	//cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) x.begin() , x.begin()
#define ll long long 
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int>v(5);
    for(int& i : v)cin>>i;
    int k;
    cin>>k;
    for(int i = 0 ; i < 5 ; ++i){
      for(int j = i + 1; j < 5; ++j){
        if(abs(v[i] - v[j]) > k)return cout<<":(",0;
      }
    }
    cout<<"Yay!";

}


Measured memory_bytes: 256
from heapq import *

n,m,s,t=map(int,input().split())
s-=1
t-=1
INF=10**19
Gyen=[[]for i in range(n)]
Gsnu=[[]for i in range(n)]
for i in range(m):
  u,v,a,b=map(int,input().split())
  u-=1
  v-=1
  Gyen[u].append([v,a])
  Gyen[v].append([u,a])
  Gsnu[u].append([v,b])
  Gsnu[v].append([u,b])

def dijkstra(G,s):
  que=[]
  d=[INF]*n
  d[s]=0
  visited={s}
  heappush(que,[0,s])
  while(que):
    p=heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heappush(que,[d[node],node])
  return d

yen=dijkstra(Gyen,s)
snu=dijkstra(Gsnu,t)
ans=10**15
ans_list=[]
for i in reversed(range(n)):
  ans=min(ans,yen[i]+snu[i])
  ans_list.append(10**15-ans)
print(*ans_list[::-1], sep='\n')


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

bool same(string s,int n){
	FOR(i,1,n){
		if(s[i] != s[0]) return false;
	}
	return true;
}

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

	string s;
	cin >> s;

	if(same(s,s.size())){
		cout << 0 << endl;
		return 0;
	}

	int mn = 200;
	rep(i,s.size()){
		char t = s[i];
		char cs[s.size()];
		rep(i,s.size()) cs[i] = s[i];

		int j = s.size();
		while(!same(cs,j)){
			rep(k,j-1){
				if(cs[k+1] == t) cs[k] = t;
			}
			j--;
		}
		mn = min(mn,(int)s.size()-j);
	}

	cout << mn << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using lint = long long;
using P = pair<int, int>;

#define rep(i, n) for (lint i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)
#define rep_inv(i, n) for (lint i = (n); i >= 0; --i)
#define rep_inv1(i, n) for(lint i = (n); i >= 1; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n")

//constexpr lint mod = 998'244'353LL;
constexpr lint Mod = 1000'000'007LL;
constexpr lint Inf = 4'500'000'000'000'000'007LL; //4.5e18+7
constexpr double Pi = 3.141592653589793;

template<class T> using prique     = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b; return true;
	}
	return false;
}
template<class T> bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b; return true;
	}
	return false;
}
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << "(" << rhs.first << ", " << rhs.second << ")"; }
template<class InputIterator> void arrin(InputIterator first, InputIterator last) { for (; first != last; ++first) cin >> (*first); }
template<class InputIterator> void arrout(InputIterator first, InputIterator last) {
	for (; first != last; ++first) {
		cout << (*first) << ((first + 1) != last ? " " : "\n");
	}
}

template<class T, class U> void print(const T& a, const U& b, bool f) {
	if (f) cout << a << "\n";
	else cout << b << "\n";
}

bool pri(lint x) { 
	for (lint i = 2; i * i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return 1 < x; 
}

lint fact[3000000];
void fact_init(lint n, lint m = Mod) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1] % m;
	}
}

lint modpow(lint x, lint n, lint m = Mod) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r, lint m = Mod) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], m - 2, m) % m * modpow(fact[r], m - 2, m) % m;
	return res < 0 ? res + m : res;
}

map<lint, lint> factring(lint n) {
	map<lint, lint> res;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++res[i];
		}
	}
	if (n != 1) ++res[n];
	return res;
}

lint n, k, ans;
lint memo[100010];
int main() {
	cin >> n >> k;

	const lint cnt1 = modpow(k, n);

	rep_inv1(i, k) {
		lint cnt2 = modpow(k / i, n);

		for (lint j = 2 * i; j <= k; j += i) {
			cnt2 -= memo[j];
			cnt2 %= Mod;
		}

		if (cnt2 < 0) cnt2 += Mod;

		ans += i * cnt2;
		ans %= Mod;

		memo[i] = cnt2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4372
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
h = Array.new(10**5+1,0)
sum = 0
a.each do |num|
  h[num] += 1
  sum += num
end

q = gets.chomp.to_i

q.times do
  b,c = gets.chomp.split.map(&:to_i)
  sum += (c-b)*h[b]
  puts sum 
  h[c] += h[b]
  h[b] = 0
end

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  map<int, int> m;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    m[a]++;
  }
  int ans = 0;
  for (pair<int, int> t : m)
  {
    if (t.first < t.second)
      ans += t.second - t.first;
    else if (t.second < t.first)
      ans += t.second;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
int main(){
  int n;
  std::cin>>n;
    std::vector<int>a(70100,0);
    for(int i=1;i<100;i++){
      for(int j=1;j<100;j++){
        for(int k=1;k<100;k++){
          int b=i*i+j*j+k*k+i*j+j*k+k*i;
          a[b]++;
        }
      }
    }
  for(int i=1;i<=n;i++)
    std::cout<<a[i]<<std::endl;
  return 0;
}

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

int main(){
  	int cnt = 0;
	string s;
  	bool flag = true;
  cin >> s;
  if(s[0] != 'A'){
    flag = false;
  }
  
  rep(i,s.size()){
    if(i > 1 && i < (s.size() - 1) && s[i] == 'C'){
      cnt++;
    }
  }
  
  if(cnt != 1){
    flag = false;
  }
  
  cnt = 0;
  
  rep(i,s.size()){
    if(s[i] >= 97 && s[i] <= 122){
      cnt++;
    }
  }
  
  if(cnt != s.size() - 2){
    flag = false;
  }
  
  if(flag){
    cout << "AC" << endl;
  }
  else{
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

x = ii()

i = 0
m = 100
while m < x:
    m = int(1.01 * m)
    i += 1

print(i)


Measured memory_bytes: 9472
a,b,c,d,e,f = tuple(map(int,input().split()))

a = 100 * a
b = 100 * b

max_w = 0
max_sugar_w = 0
max_c = 0
for i in range(31):
    for j in range(31):
        water = a * i + b * j
        if 0 < water <= f:
            for k in range(50):
                for l in range(50):
                    sugar = c * k + d * l
                    if water + sugar <= f:
                        con = 100 * sugar /(sugar+water)
                        if sugar <= water/100*e:
                            if con >= max_c:
                                max_w = water + sugar
                                max_sugar_w = sugar
                                max_c = con
print(str(int(max_w))+" "+str(int(max_sugar_w)))


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

using namespace std;

const int iINF = INT_MAX;

template <typename Monoid>
struct LazySegment {
    using F = function<Monoid(Monoid, Monoid)>;

    int size = 1;
    vector<Monoid> node, lazy;
    vector<bool> lazyFlag;

    const F f;
    const Monoid &M1;

    LazySegment(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        while (size < n) size <<= 1;
        node.assign(2 * size - 1, M1);
        lazy.assign(2 * size - 1, M1);
        lazyFlag.assign(2 * size - 1, false);

        for (int i = size - 2; i >= 0; i--) {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    LazySegment(vector<Monoid> vec, const F f, const Monoid &M1) : f(f), M1(M1) {
        int n = (int)vec.size();
        while (size < n) size <<= 1;
        node.assign(2 * size - 1, M1);
        lazy.assign(2 * size - 1, M1);
        lazyFlag.assign(2 * size - 1, false);

        for (int i = 0; i < n; i++) {
            node[i + size - 1] = vec[i];
        }

        for(int i = n - 2; i >= 0; i--) {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void set(int i, const Monoid &x) {
        node[i + size - 1] = x;
    }

     void lazyEvaluate(int i, int l, int r) {
        if(lazyFlag[i]) {
            node[i] = lazy[i];
            if(r - l > 1) {
                lazy[i * 2 + 1] = lazy[i * 2 + 2] = lazy[i];
                lazyFlag[i * 2 + 1] = lazyFlag[i * 2 + 2] = true;
            }
            lazyFlag[i] = false;
        }
    }

    void update(int a, int b, const Monoid &x, int i = 0, int l = 0, int r = -1) {
        if(r < 0) r = size;

        lazyEvaluate(i, l, r);

        if(b <= l || r <= a) return;

        if(a <= l && r <= b) {
            lazy[i] = x;
            lazyFlag[i] = true;
            lazyEvaluate(i, l, r);
        } else {
            update(a, b, x, 2 * i + 1, l, (l + r) / 2);
            update(a, b, x, 2 * i + 2, (l + r) / 2, r);
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    Monoid query(int a, int b, int i = 0, int l = 0, int r = - 1) {
        if (r < 0) r = size;

        lazyEvaluate(i, l, r);

        if(b <= l || r <= a) return M1;

        if(a <= l && r <= b) return node[i];

        Monoid xl = query(a, b, 2 * i + 1, l, (l + r) / 2);
        Monoid xr = query(a, b, 2 * i + 2, (r + l) / 2, r);

        return f(xl, xr);
    }
};

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

    LazySegment<int> seg(n, [] (int a, int b) { return min(a, b); }, iINF);

    for(int i = 0; i < q; i++) {
        int com;
        cin >> com;

        if(com == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            seg.update(s, t + 1, x);

        } else {
            int s, t;
            cin >> s >> t;

            cout << seg.query(s, t + 1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4952
import java.util.Scanner;
public class Main{
	int x;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		x=sc.nextInt();
		System.out.println(x*x*x);
	}
		
    public static void main(String args[]){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17352
#include <stdio.h>
#define N 10

main() {
  int paper[N][N], x, y, size, n=0, deep=0, i, j;

  for(i=0 ; i<N ; i++) {
    for(j=0 ; j<N ; j++) {
      paper[i][j] = 0;
    }
  }

  while((scanf("%d,%d,%d", &x ,&y, &size)) == 3) {
    if(size == 1 || size == 2 || size == 3) {
      paper[y][x]++;
      for(i=-1 ; i<2 ; i+=2) {
	if((0 <= y+i && y+i < 10) && (0 <= x && x < 10)) paper[y+i][x]++;
	if((0 <= y && y < 10) && (0 <= x+i && x+i < 10)) paper[y][x+i]++;
      }
      if(size == 2 || size == 3) {
	for(i=-1 ; i<2 ; i+=2) {
	  if((0 <= y-1 && y-1 < 10) && (0 <= x-i && x-i < 10)) paper[y-1][x-i]++;
	  if((0 <= y+1 && y+1 < 10) && (0 <= x+i && x+i < 10)) paper[y+1][x+i]++;
	}
	if(size == 3) {
	  for(i=-2 ; i<3 ; i+=4) {
	    	if((0 <= y+i && y+i < 10) && (0 <= x && x < 10)) paper[y+i][x]++;
	    	if((0 <= y && y < 10) && (0 <= x+i && x+i < 10)) paper[y][x+i]++;
	  }
	}
      }
    }
  }

 for(i=0 ; i<N ; i++) {
   for(j=0 ; j<N ; j++) {
     if(paper[i][j] == 0) n++;
     if(deep < paper[i][j]) deep = paper[i][j];
    }
  }

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

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,a[100000],i;
    cin >> n >> m;
    long long s=0;
    for(i=0;i<m;i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    if(s>n)
        cout << "-1" << endl;
    else
        cout << n-s << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

struct Edge {
  int src, dst, cost;
  Edge(int s, int d, int c = 1) : src(s), dst(d), cost(c) {}
  bool operator<(const Edge &e){ return cost < e.cost;}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

class SCC {
  public:
  SCC(int n, Graph g) : n(n), g(g), used(n, -1), components(n) {
    rg.resize(n);
    for(int i = 0; i < n; ++i)
      for(Edge e : g[i])
        rg[e.dst].emplace_back(e.dst, e.src, e.cost);

    for(int i = 0; i < n; ++i) if(used[i] == -1) dfs1(i);
    for(int i = (int)order.size() - 1; i >= 0; --i) if(!used[order[i]]) dfs2(order[i], k++);
  }
  int size() { return k; }
  bool same(int x, int y) { return components[x] == components[y]; }

  private:
  int n, k;
  vector<int> used, order, components;
  Graph g, rg;

  void dfs1(int v) { used[v] = 0; for(Edge e : g[v]) if(!!used[e.dst]) dfs1(e.dst); order.push_back(v); }
  void dfs2(int v, int k) { used[v] = 1; components[v] = k; for(Edge e : rg[v]) if(!used[e.dst]) dfs2(e.dst, k); }

};

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int V, E, x, y, q; cin >> V >> E;

  Graph g(V);
  REP(i, E) {
    cin >> x >> y;
    g[x].emplace_back(x, y);
  }
  SCC scc(V, g);

  cin >> q;
  REP(i, q) {
    cin >> x >> y;
    cout << scc.same(x, y) << '\n';
  }
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    size_t n; 
    n = s.size();
    bool flag = true;
    int ans = 0;
    int cnt = 0;
    rep(i,n){
        if(s[i]=='R'){
            if(flag==true) cnt++;
            else {flag = true;
                cnt++;}
        }
        if(s[i]=='S'){
            flag = false;
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    ans = max(ans,cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>

int main(void) {

  char n[200];
  scanf("%s", n);
  int length = strlen(n);
  int k;
  scanf("%d", &k);
  long dp0[length][4],dp1[length][4];
  dp0[0][0] = 1;
  dp0[0][1] = n[0]-'0'-1;
  dp0[0][2] = 0;
  dp0[0][3] = 0;
  dp1[0][0] = 0;
  dp1[0][1] = 1;
  dp1[0][2] = 0;
  dp1[0][3] = 0;
  for (int i = 1; i < length; i++) {
    dp0[i][0] = 1;
    dp0[i][1] = dp0[i-1][0]*9+dp0[i-1][1];
    dp0[i][2] = dp0[i-1][1]*9+dp0[i-1][2];
    dp0[i][3] = dp0[i-1][2]*9+dp0[i-1][3];
    dp1[i][0] = 0;
    dp1[i][1] = 0;
    dp1[i][2] = 0;
    dp1[i][3] = 0;
    if (n[i]-'0' > 1) {
      dp0[i][1] += dp1[i-1][0]*(n[i]-'0'-1);
      dp0[i][2] += dp1[i-1][1]*(n[i]-'0'-1);
      dp0[i][3] += dp1[i-1][2]*(n[i]-'0'-1);
    }
    if (n[i]-'0' != 0) {
      dp0[i][1] += dp1[i-1][1];
      dp0[i][2] += dp1[i-1][2];
      dp0[i][3] += dp1[i-1][3];
      dp1[i][1] += dp1[i-1][0];
      dp1[i][2] += dp1[i-1][1];
      dp1[i][3] += dp1[i-1][2];
    } else {
      dp1[i][1] += dp1[i-1][1];
      dp1[i][2] += dp1[i-1][2];
      dp1[i][3] += dp1[i-1][3];
    }
  }
  printf("%ld\n", dp0[length-1][k]+dp1[length-1][k]);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(iinclude<snt i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

typedef pair<int, P> speP;

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

#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}

struct edge2 {
	int to, cost,d;
};
vector<edge2> g[200],rg[200];

int dists[200],distt[200];

void solve() {
	int n, m, s, t; cin >> n >> m >> s >> t; s--; t--;
	rep(i, m) {
		int a, b, c,d; cin >> a >> b >> d >> c;
		a--; b--;
		g[a].push_back({ b,c,d });
		rg[b].push_back({ a,c,d });
	}
	fill(dists, dists + n, mod);
	fill(distt, distt + n, mod);
	dists[s] = 0, distt[t] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push({ 0,s });
	while (!q.empty()) {
		P p = q.top(); q.pop();
		int id = p.second;
		rep(j, g[id].size()) {
			int to = g[id][j].to;
			int nc = g[id][j].d + dists[id];
			if (nc < dists[to]) {
				dists[to] = nc; q.push({ nc,to });
			}
		}
	}
	q.push({ 0,t });
	while (!q.empty()) {
		P p = q.top(); q.pop();
		int id = p.second;
		rep(j, rg[id].size()) {
			int to = rg[id][j].to;
			int nc = rg[id][j].d + distt[id];
			if (nc < distt[to]) {
				distt[to] = nc; q.push({ nc,to });
			}
		}
	}
	int len = dists[t];
	rep(i, n) {
		rep(j, g[i].size()) {
			int to = g[i][j].to;
			int sum = dists[i] + g[i][j].d + distt[to];
			if (sum == len) {
				add_edge(i, to, g[i][j].cost);
			}
		}
	}
	cout << max_flow(s, t) << endl;
}

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


Measured memory_bytes: 5704
#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;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 1000000007
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/
ll times=0;
ll a[(ll)2e5+5];
ll d[(ll)2e5+5];
pii cycle={0,0};
ll fuc;
vector<ll>path;
void dfs(ll v)
{
    if(times==0)
    {
        fuc=v;
        return;
    }
    if(d[a[v]]==0)
    {
        times--;
        d[a[v]]=d[v]+1;
        dfs(a[v]);
    }
    else 
    {
        // times--;
        // if(times==0)
        // {
        //     fuc=a[v];
        //     return ;
        // }
        cycle={v,a[v]};
        return ;
    }
}
void dfs2(ll v)
{
    if(v==cycle.fi)
    {
        
        // path.pb(v);
        return ;
    }
    else 
    {
        path.pb(v);
        dfs2(a[v]);
    }
}
signed main()/*question galat mat padhna yr*/
{
    fast;   
    ll n,k;
    cin>>n>>k;
    k++;
    // ll a[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    d[1]=1;
    times=k;
    times--;
    dfs(1);
    if(cycle.fi==0&&cycle.se==0)
    {
        For(i,n+1)
        {
            if(d[i]==k)
            {
                // cout<<131<<endl;
                cout<<i<<endl;
                return 0;
            }
        }
    }
    // if(times==0)
    // {
    //     cout<<"x"<<endl;
    //     cout<<fuc<<endl;
    //     return 0;
    // }
    // For(i,n+1)cout<<d[i]<<" ";
    // what_is(k)
    // what_is(cycle.fi);
    // what_is(cycle.se)
    
    k-=d[cycle.fi];
    // what_is(d[cycle.fi])
    ll len=d[cycle.fi]-d[cycle.se]+1;
    k%=len;
    // ll index=(k)%len;
    path.pb(cycle.fi);
    // what_is(cycle.fi)
    // path.pb(cycle.se);
    // what_is(len)
    dfs2(cycle.se);
    // what_is(k)
    cout<<path[k]<<endl;
    // for(auto x:path)cout<<x<<" ";
    // // for(auto x:path)cout<<d[x]<<" ";
    // cout<<endl;
}   

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif


signed main(){

  int H,W; cin >> H >> W;
  static int table[501][501];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> table[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      ans += table[i][j] * ((i+1) * (H-i)) * ((j+1) * (W-j));
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5060
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(void) {
	int n;cin >> n;
    cout << n*n*n << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    int count = 0;
    int now = 0;
    for(i=0;i<n;i++){
        if(a[i] - now == 1){
            now = a[i];
        }else{
            count++;
        }
    }
    if(count == n){
        count = -1;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 896
h,w,k=map(int,input().split())
c=[input() for i in range(h)]
ans=0
for h_1 in range(1<<h):
  for w_1 in range(1<<w):
    black=0
    for i in range(h):
      for j in range(w):
        if (h_1>>i)&1==0 and (w_1>>j)&1==0 and c[i][j]=='#': #該当マスが最初の時点で黒く、そのマスが属する行と列が赤く塗られていないとき
          black+=1
    if black==k:
      ans+=1
print(ans)

Measured memory_bytes: 9192