akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations

def int0(s):
    return int(s) - 1

def main():
    N, M = map(int, input().split())
    edges = [tuple(map(int0, input().split())) for _ in range(M)]

    to = [[False]*N for _ in range(N)]
    for a, b in edges:
        to[a][b] = True
        to[b][a] = True
    
    ans = 0
    for p in permutations(range(1, N)):
        if to[0][p[0]] and all(to[p[i]][p[i+1]] for i in range(N-2)):
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;


int N, K;

signed main()
{
	cin >> N >> K;

	if (N > K)
	{
		int a = N / K;
		N %= (a * K);
	}

	int b = abs(N - K);

	cout << min(b, N) << endl;

}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n; cin >> n;
	vector<ll> v(n);
	for (ll &i : v)cin >> i;
	ll cur = 0;
	for (ll i : v)cur ^= i;
	for (ll i : v) {
		ll ans = cur;
		ans ^= i;
		cout << ans << ' ';
	}

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 4752
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let a: usize = sc.cin();
    let b: usize = sc.cin();
    put!(
        min!(a, b),
        if a + b >= n { a + b - n } else { 0 }
        );
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
def test():

	n = int(input())

	Taro = 0
	Hanako = 0

	for i in range(n):

		cards = input().split()

		cards[0] = cards[0].upper()
		cards[1] = cards[1].upper()
		
		if cards[0] == cards[1]:
			Taro += 1
			Hanako += 1
		elif cards[0] > cards[1]:
			Taro += 3
		else:
			Hanako += 3
		
	print(f"{Taro} {Hanako}")

if __name__ == "__main__":
	test()


Measured memory_bytes: 5612
#include<stdio.h>
void insertionSort(int *,int);
int main(){
  int n;
  int i;
  int A[101];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  insertionSort(A,n);

  return 0;
}

void insertionSort(int A[],int N){
  int i,j,key,k;
  for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1) printf(" ");
  }
  printf("\n");
  for(j=1;j<N;j++){
    key=A[j];
    i=j-1;
    while(i>=0 && key < A[i]){
      A[i+1]=A[i];
      i--;
    }
    A[i+1]=key;
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1) printf(" ");
    }
    printf("\n");
  }
}
  



Measured memory_bytes: 2060
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n, x;

    while (cin >> n >> x)
    {
        ll count (0);

        if (n == 0 && x == 0)
            break;

        for (ll i=n; i>=1; i--)
        {
            for (ll j=i; j>=1; j--)
            {
                for (ll k=j; k>=1; k--)
                {
                    ll ans = i + j + k;
                    if ( i != j && j != k && ans == x)
                    {
                        //cout << i << j << k << ans << endl;
                        count++;
                    }
                }    
            }    
        }

       cout << count << endl;

    }

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
  int n;
  cin >> n;
  n=(1000-(n%1000))%1000;
  cout << n <<endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	int N,M;
	cin>>N>>M;
	int arr[4];
	memset(arr,-1,sizeof(arr));
	int FLAG=0;
	while(M--)
	{
		int x,y;
		cin>>x>>y;
		if(arr[x]==-1)
		{
			arr[x]=y;
		}
		else if(arr[x]!=-1)
		{
			if(arr[x]!=y)
			{
				FLAG=1;
			}
		}
	}
	if(FLAG==1)
	cout<<-1;
	else
	{
		if(arr[1]==-1 && N==1)
		{
			cout<<0;
			return 0;
		}
		else if(arr[1]==-1 && N>1)
		{
			cout<<1;
		}
		else if(arr[1]!=-1)
		{
			if(arr[1]==0 and N!=1)
			{
				cout<<-1;
				return 0;
			}
			else if(arr[1]==0 and N==1)
			{
				cout<<0;
				return 0;
			}
			else
				cout<<arr[1];
		}
		if(N!=1)
		{
		for(int i=2;i<=N;i++)
		{
			if(arr[i]!=-1)
			{
				cout<<arr[i];
			}
			else
			{
				cout<<0;
			}
		}
		}
	}
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Set<String> set = new HashSet<>();
        for(int i=0; i<n; i++) {
            String s = in.next();
            set.add(s);
        }
        System.out.println(set.size());
    }
}


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

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

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<vector<ll>> graph(n);
    for(i = 0;i < n-1;++i){
        ll a,b;
        cin >> a >> b;
        --a;    --b;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }
    vector<ll> c(n);
    for(i = 0;i < n;++i){
        cin >> c.at(i);
    }
    sort(all(c), greater<ll>());
    ll ans = 0;
    
    queue<ll> que;
    vector<ll> vdis(n,-1);
    ll top = 0;
    vdis.at(top) = 0;
    que.emplace(top);
    ll nc = 0;
    vdis.at(nc) = c.at(nc);
    while(!que.empty()){
        ll now = que.front();
        que.pop();
        for(i = 0;i < graph.at(now).size();++i){
            ll next = graph.at(now).at(i);
            if(vdis.at(next) == -1){
                ++nc;
                vdis.at(next) = c.at(nc);
                ans += c.at(nc);
                que.emplace(next);
            }
        }
    }
    cout << ans << endl;
    for(i = 0;i < n;++i){
        cout << vdis.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
# coding: utf-8
from itertools import combinations as combs

H,W,K = list(map(int, input().split()))
arr = []
for i in range(H):
  arr.append(list(map(int, list(input()))))

def cut_sum(arr, x1, x2, y):
  ret = 0
  for i in range(x1, x2):
    ret += arr[i][y]
  return ret

row_idxes = list(range(1,H))
min_val = float('inf')

for n_rows in range(H):
  for row_set in combs(row_idxes, n_rows):
    count = len(row_set)
    row_lines = [0] + list(row_set)+ [H]
    col1, col2 = 0, 1
    sums = [0] * (len(row_lines) - 1)
    while col2 <= W:
      row1 = 0
      for box, row2 in enumerate(row_lines[1:]):
        sums[box] += cut_sum(arr, row1, row2, col2-1)
        if sums[box] > K:
          if (col2 - col1) == 1:
            count = float('inf')
            break
          count += 1
          col1 = col2 - 1
          col2 -= 1
          sums = [0] * (len(row_lines) - 1)
          break
        row1 = row2
      if count >= min_val:
        break
      col2 += 1
    
    if min_val > count:
      min_val = count
print(min_val)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define N 260
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define mset(x,y) memset(x,y,sizeof(x))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
using namespace std;
int cnt,n,mod;
struct qwq{ int val,id; }a[N*2];
ll f[N*2][N];
int g[N];
bool cmp(const qwq &x,const qwq &y){ return x.val==y.val?x.id>y.id:x.val<y.val; }
ll solve(int k){
	mset(f,0);int tmp=0;
	f[0][0]=1;
	For(i,1,cnt){
		if(a[i].id>=n) tmp++;
		For(j,0,i-tmp){
			if(a[i].id>=n) f[i][j]=f[i-1][j]*(1ll*a[i].val-(j+tmp-2)+mod)%mod;
			else{
				if(j!=i-tmp) (f[i][j]+=f[i-1][j]*(1ll*g[a[i].id]-(n+k-1+(i-1-tmp-j))+mod)%mod)%=mod;
				if(j) (f[i][j]+=f[i-1][j-1]*(1ll*a[i].val-(j-1+tmp-1)+mod)%mod)%=mod;
			}
		}
	}
	return f[cnt][k];
}
int main(){
	ll ans=0;
	scanf("%d%d",&n,&mod);
	For(i,0,n-1){
		a[++cnt]=(qwq){(int)sqrt(n*n-1-i*i),i};
		g[i]=(int)sqrt(4*n*n-i*i);
		g[i]=min(g[i],2*n-1);
	}
	For(i,n,2*n-1)
		a[++cnt]=(qwq){(int)sqrt(4*n*n-i*i),i};
	sort(a+1,a+cnt+1,cmp);
	For(i,0,n){
		if(i&1) (ans+=mod-solve(i))%=mod;
		else (ans+=solve(i))%=mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define FOR(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";

//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

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

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{
 string s;
 cin>>s;
 ll ans  = 0 ; 
 ll cnt  = 0; 
 for(int i = 0 ;i<s.length();i++){
     if(s[i]=='R')
     cnt++;
     else 
     ans = max(ans,cnt),cnt = 0 ;
 }
 if(cnt>0)
 ans = max(ans,cnt);
 cout<<ans<<endl;
}
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=100005;
LL foo[N];
LL too[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%I64d",&foo[i]);
    }
    sort(foo,foo+n);
    for(int i=0;i<n;i++)
    {
        if(i)
        {
            too[i]+=(too[i-1]+foo[i]);
        }
        else
        {
            too[i]=foo[i];
        }
    }
    too[0]=foo[0];
    int h=1;
    for(int i=n-2;i>=0;i--)
    {
        if(2*too[i]>=foo[i+1])
        {
            h++;
        }
        else
        {
            break;
        }
    }
    printf("%d\n",h);
    return 0;
}


Measured memory_bytes: 1664
#145_C
from itertools import permutations
from math import factorial
n=int(input())
xy=[tuple(map(int,input().split())) for _ in range(n)]

res=0
for l in permutations(range(n)):
    res+=sum([((xy[l[i+1]][0]-xy[l[i]][0])**2+(xy[l[i+1]][1]-xy[l[i]][1])**2)**0.5 for i in range(n-1)])
print(res/factorial(n))

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

int main(){
    unsigned long long n;
    unsigned long long k;
    cin>>n>>k;

    unsigned long long min1=n;
    if(k>n){
        if(k-n<n)
        cout<<k-n;
        else cout<<n;
        return 0;
    }

        if(n>=k)
        n=n%k;
        if(k>n){
        if(k-n<n)
        cout<<k-n;
        else cout<<n;
        }

        return 0;

}


Measured memory_bytes: 256
def read_key():
    a, _ = map(int, input().split())
    m = 0
    for c in map(int, input().split()):
        m |= 1 << (c - 1)
    return (a, m)


INF = float('inf')

N, M = map(int, input().split())
keys = [read_key() for _ in range(M)]

dp = [INF] * (1 << N)

dp[0] = 0
for i in range(M):
    a, m = keys[i]
    for j in range((1 << N)-1, -1, -1):
        if dp[j] == INF:
            continue
        if dp[j] + a < dp[j | m]:
            dp[j | m] = dp[j] + a

if dp[(1 << N) - 1] == INF:
    print(-1)
else:
    print(dp[(1 << N) - 1])


Measured memory_bytes: 3300
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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


int main(void) {
	long long int n;
	long long int x[101], y[101], h[101];
	bool flag = true;
	long long int H = LLINF;

	cin >> n;
	FOR(i, 1, n) {
		cin >> x[i] >> y[i] >> h[i];
	}

	FOR(cx, 0, 100) {
		FOR(cy, 0, 100) {
			flag = true;
			H = LLINF;
			FOR(i, 1, n) {
				if (flag == true) {
					if (h[i] != 0) {
						if (H < h[i] + abs(x[i] - cx) + abs(y[i] - cy)) {
							break;
						}
						H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
						flag = false;
					}
					else {
						H = min(abs(x[i] - cx) + abs(y[i] - cy), H);
					}
				}
				else {
					if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), (long long int)0)) {
						break;
					}
				}

				if (i == n) {
					cout << cx << " " << cy << " " << H << endl;
					goto end;
				}
			}
		}
	}
	
end:;

	return 0;
}

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

public class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        System.out.println((A-1)*(B-1));
    }
}


Measured memory_bytes: 23120
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define sort(v) sort(v.begin(),v.end()) 
#define pb push_back
/*
ll ar[1000000+9]={0}; 
vector<ll>v;
void seiv() { 
ll n=1000000,i,j; 
ar[1]=1; 
for(i=4;i<=n;i+=2)ar[i]=1; 
for(i=3;i<=n;i+=2) 
{ if(ar[i]==0) 
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
                
 } 
    for(i=2;i<=2244;i++){if(ar[i]==0)v.pb(i);}}*/
int main()
 {
   map<ll,ll>m;
   int a,b,c,d,i,j,k,l;
    for(i=1;i<=100;i++)
    {
   for(j=1;j<=100;j++)
   {
for(k=1;k<=100;k++)
{
b=(i*i)+(j*j)+(k*k)+(i*j)+(i*k)+(j*k);m[b]++;
}
   }
    }
cin>>a;
        for(i=1;i<=a;i++)
      {cout<<m[i]<<endl;}
 }

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

int main() {
	int N, M;
	cin >> N >> M;
	bool a[40][40];
	for (int i = 0; i < 40; i++) {
		for (int j = 0; j < 40; j++) {
			a[i][j] = false;
		}
	}
	for (int i = 1; i <= N; i++) {
		int n, tmp;
		cin >> n;
		for (int j = 1; j <= n; j++) {
			cin >> tmp;
			a[tmp][i] = true;
		}
	}
	int ans = 0;
	for (int i = 1; i <= M; i++) {
		int cnt = 0;
		for (int j = 1; j <= N; j++) {
			if (a[i][j]) cnt++;
		}
		if (cnt == N) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;

int main(){
    string s1,s2;cin >> s1 >> s2;
    int olen = s1.size(),tlen = s2.size();
    int dp[1010][1010] = {};
    rep(i,olen+1){
        // if(!i)continue;
        rep(j,tlen+1){
            if(!i){
                dp[i][j] = j;
                continue;
            }
            if(!j){
                dp[i][j] = i;
                continue;
            }
            if(s1[i-1] == s2[j-1]) dp[i][j] = dp[i-1][j-1];
            else{
                dp[i][j] = min(dp[i-1][j],min(dp[i][j-1],dp[i-1][j-1])) + 1;
            }
        }
    }
    // rep(i,olen+1){
    //     rep(j,tlen+1){
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }
    cout << dp[olen][tlen] << endl;
    return 0;
}


Measured memory_bytes: 7160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k>>x>>y;
    rrep(i,1,n+1){
        if(i<=k)ans+=x;
        else ans+=y;
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
count = 0
count2 = 0


for i in range(N):
    if S[i] == "c":
        print("No")
    elif S[i] == "a":
        
        if count < A+B:
            print("Yes")
            count += 1
        else:
            print("No")
    elif S[i] == "b":
        
        if count < A+B and count2 < B:
            print("Yes")
            count += 1
            count2 += 1
        else:
            print("No")

Measured memory_bytes: 52824
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, a, ans = 1;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++){
        cin >> P.at(i);
    }
    a = P.at(0);
    for (int i = 1; i < N; i++){
        if (a >= P.at(i)){
            ans++;
            a = P.at(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;

#define maxn 10000
#define nil -1

struct node{
	int p;
	int l;
	int r;
}t[maxn];

int n;

void preparse(int u){
	if(u==nil)
		return;
	cout<<" "<<u;
	preparse(t[u].l);
	preparse(t[u].r);
}

void inparse(int u){
	if(u==nil)
		return;
	inparse(t[u].l);
	cout<<" "<<u;
	inparse(t[u].r);
}

void postparse(int u){
	if(u==nil)
		return;
	postparse(t[u].l);
	postparse(t[u].r);
	cout<<" "<<u;
}
int main(){
	ios::sync_with_stdio(false);
	int i,v,l,r,root;
	cin>>n;
	for(int i=0;i<n;i++)
		t[i].p=nil;
	
	for(int i=0;i<n;i++){
		cin>>v>>l>>r;
		t[v].l=l;
		t[v].r=r;
		if(l!=nil)
			t[l].p=v;
		if(r!=nil)
			t[r].p=v;
	}
	
	for(int i=0;i<n;i++)
		if(t[i].p==nil)
			root=i;
	cout<<"Preorder"<<endl;
	preparse(root);
	cout<<endl;
	cout<<"Inorder"<<endl;
	inparse(root);
	cout<<endl;
	cout<<"Postorder"<<endl;
	postparse(root);
	cout<<endl;
	return 0;
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e12;
const int MOD = 1e9 + 7;

#define MAX_N 200000

int n;
ll k;
ll a[MAX_N],f[MAX_N];

bool isOK(ll m){
    ll cnt[n] = {};
    REP(i,n){
        cnt[i] += m / f[i];
    }
    ll use = 0;
    REP(i,n){
        use += max((ll)0, a[i] - cnt[i]);
    }
    if(use > k){
        return false;
    }else{
        return true;
    }
}

signed main(){
    cin >> n >> k;
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n){
        cin >> f[i];
    }
    sort(a, a + n);
    sort(f, f + n);
    reverse(f, f + n);
    ll ng = -1, ok = INF + 1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}

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

int main(){
  int n, k, r, s, p, h;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  h = 0;
  for(int i = 0; i < k; i++){
    if(t[i] == 'r')
      h = h + p;
    if(t[i] == 's')
      h = h + r;
    if(t[i] == 'p')
      h = h + s;
  }
  for(int i = k; i < n; i++){
    if(t[i] == 'r'){
      if(t[i - k] == 'r')
        t[i] = 'o';
      else
        h = h + p;
    }
    if(t[i] == 's'){
      if(t[i - k] == 's')
        t[i] = 'o';
      else
        h = h + r;
    }
    if(t[i] == 'p'){
      if(t[i - k] == 'p')
        t[i] = 'o';
      else
        h = h + s;
    }
  }
  cout << h << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 096 B / Link: http://abc096.contest.atcoder.jp/tasks/abc096_b  ----- */


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

	LL a, b, c, K; cin >> a >> b >> c >> K;
	
	LL ans = a + b + c + max({a,b,c})* pow(2, K) - max({ a,b,c });
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 384
import java.io.*;
 
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line1 = br.readLine().split(" ");
		int N = Integer.parseInt(line1[0]);
		int K = Integer.parseInt(line1[1]);
		int[] array = new int[N+1];
		
		line1 = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			array[i+1] = Integer.parseInt(line1[i]);
		}
		System.out.println(metodo(N, K, array));
	}
	
	public static int metodo(int N, int K, int[] array) {
		int[] array1 = new int[N+1];
		for(int i = 2; i <= N; i++) {
			array1[i] = array1[i-1] + Math.abs(array[i-1] - array[i]);
			for(int j = i-2; j >= i-K && j > 0; j--) {
				array1[i] = Math.min(array1[i], array1[j] + Math.abs(array[j]-array[i]));
			}
		}
		
		return array1[N];
	}
}

Measured memory_bytes: 41144
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

//INSERT ABOVE HERE
signed main(){
  int n,k;
  cin>>n>>k;
  using P = pair<int, int>;
  vector<P> vp;
  for(int i=0;i<min(8,n);i++)
    for(int j=0;j<n;j++)
      if(i!=j&&((j>>i)&1)) vp.emplace_back(min(i,j),max(i,j));

  vp=compress(vp);
  cout<<vp.size()<<endl;
  for(auto p:vp) cout<<p.first+1<<" "<<p.second+1<<endl;
  for(int i=0;i<k;i++){    
    int res=0;
    auto ask=
      [&](int k){
        if(res<0) return ""s;
        cout<<k+1<<endl;
        string s;
        cin>>s;
        if(s=="Yes"s) res=-1;
        return s;
      };
    for(int i=0;i<min(8,n);i++){
      auto s=ask(i);
      if(s=="Near"s) res|=(1<<i);      
    }
    ask(res);
  }  
  return 0;
}



Measured memory_bytes: 3356
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

ll a[102345];

int main(){
	int n;
	
	cin >> n;
	
	int cnt = 0;
	int cnt_t = 0;
	
	REP(i,n){
		cin >> a[i];
		
		if (a[i]%4 == 0) cnt++;
		else if (a[i]%2 == 0) cnt_t++;
	}
	
	if (cnt_t >= 2){
		n -= cnt_t;
		n++;
	}
	
	if (n/2 <= cnt) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

int  main()
{
    char s[100];
    gets(s);
    int i,t = strlen(s);
    int flag = 1;
    for(i=0 ;i < (t-1)/2; i++)
    {
    	if(s[i] != s[i+(t+1)/2])
    	{
    		flag = 0;
    		break;
		}
	}
	if(flag)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
import heapq

n, m = map(int, input().split())
a = list(map(lambda s: -int(s), input().split()))

heapq.heapify(a)

for i in range(m):
    heapq.heappush(a, (heapq.heappop(a)+1) // 2)

print(-sum(a))


Measured memory_bytes: 14180
#include <iostream>
#include <cmath>

using namespace std;

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


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

int main()
{
    int n;
    cin >> n;
    vector<long long> a;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    long long mn = 1e9, mx = -1e9, sm = 0;
    for (int i = 0; i < n; i++) {
        if (mn > a[i]) {
            mn = a[i];
        }
        if (mx < a[i]) {
            mx = a[i];
        }
        sm += a[i];
    }
    cout << mn << " " << mx << " " << sm << endl;
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<vl> node(n,vl(3));
  REP(i,n){
    node[i][0] = i;
    cin >> node[i][1];
    cin >> node[i][2];
  }
  vector<vl> edge(n,vl(0));
  sort(node.begin(),node.end(),[](vl a,vl b){return a[1]<b[1];});
  REP(i,n-1){
    edge[node[i][0]].push_back(node[i+1][0]);
    edge[node[i][0]].push_back(node[i+1][1]-node[i][1]);
    edge[node[i+1][0]].push_back(node[i][0]);
    edge[node[i+1][0]].push_back(node[i+1][1]-node[i][1]);
  }
  sort(node.begin(),node.end(),[](vl a,vl b){return a[2]<b[2];});
  REP(i,n-1){
    edge[node[i][0]].push_back(node[i+1][0]);
    edge[node[i][0]].push_back(node[i+1][2]-node[i][2]);
    edge[node[i+1][0]].push_back(node[i][0]);
    edge[node[i+1][0]].push_back(node[i+1][2]-node[i][2]);
  }

  // construct minimum spanning tree
  vector<bool> incl(n,false);
  auto cp = [](vl a,vl b){return a[1]>b[1];};
  ll ans = 0;
  ll cnt = 1;
  priority_queue<vl,vector<vl>,decltype(cp)> cand(cp);
  incl[0] = true;
  REP(j,edge[0].size()/2){
    cand.push({edge[0][2*j],edge[0][2*j+1]});
  }

  while(cnt<n){
    vl eg = cand.top();
    cand.pop();
    if(!incl[eg[0]]){
      incl[eg[0]] = true;
      cnt ++;
      REP(i,edge[eg[0]].size()/2){
        cand.push({edge[eg[0]][2*i],edge[eg[0]][2*i+1]});
      }
      ans += eg[1];
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
    string s;
    cin >>s;
    int ans ;
    if (s == "SUN")
    {
        ans = 7 ;
    }else if (s =="MON")
    {
        /* code */
        ans = 6 ;
    }else if (s == "TUE")
    {
        /* code */
        ans = 5 ;
    }else if (s == "WED")
    {
        /* code */
        ans = 4;
    }else if (s == "THU")
    {
        /* code */
        ans = 3 ;
    }else if (s == "FRI")
    {
        /* code */
        ans = 2 ;
    }else if (s == "SAT")
    {
        /* code */
        ans = 1; 
    }
    
    cout << ans << endl ;
    
    
    
    
        
}


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

int main() {
	string s;
	cin >> s;
	string k = "None";
	set<char> a;
	for(int i = 0;i < s.size();i++)
	{
		a.insert(s.at(i));
	}
	if(a.size() < 26)
	{
		char ca = 'a';
		for(int i = 0;i < 26;i++)
		{
			if(a.find(ca) == a.end())
			{
				k = ca;
				break;
			}
			else
			{
				ca += 1;
			}
		}
	}
    cout << k << endl;
	return 0;
}


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

static const int SIZE = 8;

class Bomb{
public:
	Bomb() : count( 0 ){
		for ( int i = 0; i < ( SIZE + 2 ) * ( SIZE + 2 ); ++i ){
			field[ i ] = -1;
		}
	}

	void input( string& s, int row ){
		for ( int i = 1; i < SIZE + 1; ++i ){
			field[ row * ( SIZE + 2 ) + i ] = static_cast< int >( s[ i - 1 ] - '0' );
		}
	}
	void output(){
		cout << "Data " << ++count << ":" << endl;

		for ( int i = 1; i < SIZE + 1; ++i ){
			for ( int j = 1; j < SIZE + 1; ++j ){
				cout << field[ i * ( SIZE + 2 ) + j ];
			}
			cout << endl;
		}
	}
	void trigger( int x, int y ){
		if ( field[ y * ( SIZE + 2 ) + x ] == 1 ){
			field[ y * ( SIZE + 2 ) + x ] = 0;
		}
		for ( int i = 0; i < 4; ++i ){
			explode( x, y, i, 3 );
		}
	}
	void explode( int x, int y, int def, int roop ){
		if ( field[ y * ( SIZE + 2 ) + x ] == 1 ){
			trigger( x, y );
			return;
		}
		if ( roop && !field[ y * ( SIZE + 2 ) + x ] ){
			switch ( def ){
				case 0: explode( x, y-1, def, roop-1 ); break;
				case 1: explode( x+1, y, def, roop-1 ); break;
				case 2: explode( x, y+1, def, roop-1 ); break;
				case 3: explode( x-1, y, def, roop-1 ); break;
			}
		}
	}

	int count;
	int field[ ( SIZE + 2 ) * ( SIZE + 2 ) ];
};

int main(){
	int n, x, y;
	string s;
	Bomb bm;

	cin >> n;
	for ( int r = 0; r < n; ++r ){
		for ( int i = 1; i < SIZE + 1; ++i ){
			cin >> s;
			bm.input( s, i );
		}
		cin >> x >> y;

		bm.trigger( x, y );

		bm.output();
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ecnt=0;
		for(int i=0;i<n;i++){
			if(sc.nextInt()%2==0){
				ecnt++;
			}
		}
		System.out.println((int)Math.pow(3, n)-(int)Math.pow(2,ecnt));
	}

}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	string s;
	cin >> s;
	int l = s.size();
	map<char, int> angle;
	rep(i, l) {
		angle[s[i]]++;
	}
	bool ns = (angle['N']&&angle['S']) || (!angle['N']&&!angle['S']);
	bool ew = (angle['E']&&angle['W']) || (!angle['E']&&!angle['W']);
	if (ns && ew) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bits/stdc++.h>
const int INF = 1000000010;
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,q;
    int ans=INF;
    cin>>n>>k>>q;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        vector<int>v;
        int l=0,r=0;
        while(l<n){
                priority_queue<int,vector<int>,greater<int> >que;
            while(r<n&&a[i]<=a[r]){
                que.push(a[r]);
                r++;
            }
            while((int)que.size()>=k){
                v.push_back(que.top());
                que.pop();
            }
            r++;
            l=r;
        }
            if((int)v.size()<q) continue;
            sort(v.begin(),v.end());
            ans=min(ans,v[q-1]-a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=0;
	int w=1;
	int i=1;
	w=a*b;
	i=c*d;
	ans=max(w,i);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

# nCr
def nCr(n,r):
  if n<r:
    return 0
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

# 方針
# 素因数が74個同じ数をもつ数字は七五数になる
# 素因数が24個同じ数をもち、2個同じ数を持つ数字も七五数になる
# …
# 素因数が4個同じ数をもち、4個同じ数を持ち、2個同じ数を持つ数字も七五数になる
# n!を素因数分解して上記を何パターン作れるか考える

# 手順
# n!を素因数分解する
# 74個もち・24個もち・14個持ち・4個持ち・2個もちに分類
# 上記で挙げたパターンを全て数え上げて足す

# 注意
# 例えば、24個持ち・2個持ちを取る場合
# 24個持ちから取った数字は2個持ちと重複できないので引いておくこと
# また、2個持ちなどは引数が2個のものからだけでなく
# それ以上の個数を持つものからも取れる
# つまり、24個持ちも14個持ち・4個持ち・2個持ちとして扱える

# n=1 のときはバグるので return 0 するようにした
# 最大・最小パターンはチェックする癖をつけたい

def main():
  n=I()

  if n==1:
    return 0

  l1=[]
  for i in range(2,n+1):
    l1+=getPrimeList(i)

  l1=summarize_list(l1)

  l1=sorted(l1,key=lambda x:x[1],reverse=True)

  # print(l1)

  # print(l)

  ans=[]

  # 75・25・15・5・3
  l2=[0]*5
  for x in l1:
    if x[1]>=74:
      l2[0]+=1
    elif x[1]>=24:
      l2[1]+=1
    elif x[1]>=14:
      l2[2]+=1
    elif x[1]>=4:
      l2[3]+=1
    elif x[1]>=2:
      l2[4]+=1

  # print(l2)

  # 75
  ans.append(l2[0])

  # 25・3
  ans.append(sum(l2[:2])*(sum(l2[:5])-1))

  # 15・5
  ans.append(sum(l2[:3])*(sum(l2[:4])-1))

  # 5・5・3
  ans.append(nCr(sum(l2[:4]),2)*(sum(l2[:5])-2))

  return sum(ans)

# main()
print(main())


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

using namespace std;

#define debug(x) cout << #x << "::" << x << endl;
#define debug2(x, y) cout << #x << "::" << x << " " << #y << "::" << y << endl;
#define debug3(x, y, z) cout << #x << "::" << x << " " << #y << "::" << y <<" "<< #z << "::" << z << endl;

#define For(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
const ll mod = 1e9 + 7;
const int MAX = 5 * 1e3 + 5;
typedef pair<int, int> pii;

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

int main() {

    int n,w;
    cin>>n>>w;

    vector<vector<int>> v(n+1,vector<int>(2));

    ll sum = 0;
    for(int i=1;i<=n;i++){
        cin>>v[i][0]>>v[i][1];
        sum+=v[i][1];
    }

    vector<vector<ll>> dp(sum+1,vector<ll>(n+1,mod));
    
    For(j,0,n+1) dp[0][j] = 0;
    
    
    for(int i=1;i<=sum;i++){
        For(j,1,n+1){
            if(v[j][1] <= i){
                dp[i][j] = min(v[j][0]+dp[i-v[j][1]][j-1],dp[i][j-1]);
            }else {
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    
    /*For(i,1,sum+1){
        For(j,1,n+1) cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    
    for(int i=sum;i>=1;i--) {
        if(dp[i][n] <= w){
            cout<<i<<endl;
            break;
        }
    }

    return 0;

}

Measured memory_bytes: 82304
n = int(input())
a = list(map(int,input().split()))
i = 0
p = 1

if 0 in a:
    print("0")
else:
    while i < n:
        p *= a[i]
        if p > 10**18:
            break
        i += 1
    if p <= 10**18:
        print(p)
    else:
        print("-1")

Measured memory_bytes: 21644
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


int main() {
	ll a, b, c, x, y, ans = 0;
	cin >> a >> b >> c >> x >> y;
	if (a + b > c*2) {
		if (x >= y) {
			ans += c*2*y;
			ans += a*(x - y);
		}
		else {
			ans += c*2*x;
			ans += b*(y - x);
		}
	}
	else {
		ans += a*x + y*b;
	}
	ans = min(ans, c*2*max(x, y));
	cout << ans << endl;
}

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  if ((10 * g + b) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3508
#include <iostream> 
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int count=0;
  int val;
  for(int i=1;i<=n;i++){
    cin>>val;
    if(i%2==1 && val%2==1)
      count++;
  }
  cout<<count;
  
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, K, x;	//N:ボールの個数 K:タイプBのロボットの位置 x;ボールの位置
	int min = 0;	//移動距離の最小値

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> x;	//ボールの位置を入力

		if (x < (K - x)) {
			min = min + (x * 2);
		}

		else {
			min = min + ((K - x) * 2);
		}

	}
	cout << min << endl;

}

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

using namespace std;

int n , a[111111] , b[111111] , c[111111] , dp[111111][3];

int main() {
	scanf("%d" , &n);
	for (int i = 1; i <= n; i++) scanf("%d %d %d" , &a[i] , &b[i] , &c[i]);
	for (int i = 1; i <= n; i++) {
		dp[i][0] = max(dp[i-1][1] , dp[i-1][2])+a[i];
		dp[i][1] = max(dp[i-1][0] , dp[i-1][2])+b[i];
		dp[i][2] = max(dp[i-1][0] , dp[i-1][1])+c[i];
	}
	
	printf("%d\n" , max(dp[n][0] , max(dp[n][1] , dp[n][2])));
	
	return 0;
}

Measured memory_bytes: 6140
#include <stdio.h>
#define Max 10000

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

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

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

int main(){
  int H,i,A[Max+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, bool> D;

    string command;
    string target;
    for (int i = 0; i < n; i++) {
        cin >> command >> target;
        if (command == "insert") {
            D[target] = true;
        } else {
            if (D.find(target) != D.end()) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
}



Measured memory_bytes: 36920
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;
    string s; cin >> s;

    ll ans0 = 0;
    REP(i, n) {
        if (s[i] == 'L') {
            if (i-1 >= 0 && s[i-1] == 'L') {
                ans0++;
            }
        } else {
            if (i+1 < n && s[i+1] == 'R') {
                ans0++;
            }
        }
    }
    ll ans = -1;
    REP(flag, 2) {
        ll cand = ans0;
        ll l = 0;
        ll r = n-1;
        ll f = flag;
        ll rem = k;
        while (l < r) {
            char c = f ? 'L' : 'R';
            while (l+1 <  n && !(s[l] == c && s[l+1] != c)) l++;
            while (r-1 >= 0 && !(s[r] == c && s[r-1] != c)) r--;
            if (l >= r) break;
            DUMP(l);
            DUMP(r);
            cand += 2;
            f = !f;
            if (--rem == 0) break;
        }
        // 特殊ケース /^L+R+$|^R+L+/
        if (rem == k) {
            cand = n-1;
        } else if (rem > 0 && s.front() != s.back()) {
            cand++;
        }
        chmax(ans, cand);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){

	int num1,num2;
	char op;

	scanf("%d %c %d",&num1,&op,&num2);

	if( op == '+' ){
		printf("%d\n",num1+num2);
	}else{
		printf("%d\n",num1-num2);
	}

	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = readInts()
b = readInts()
b.append(0)
b.append(0)

s = sum(a)

for i in range(n+1):
  if a[i]>=b[i]:
    a[i]-=b[i]
  else:
    b[i]-=a[i]
    a[i] = 0
    a[i+1] = max(0,a[i+1]-b[i])

print(s-sum(a))

Measured memory_bytes: 24468