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



int main(){
	int N,K;
	cin>>N>>K;
	string S;
	cin>>S;
	vector<int> sum[2];
	sum[0].push_back(0);
	sum[1].push_back(0);
	for(int i=0;i<N;i++){
		int a = S[i]-'0';
		if(i==0){
			sum[a].push_back(1);
			continue;
		}
		if(S[i]!=S[i-1]){
			sum[a].push_back(1);
		}
		else{
			sum[a][sum[a].size()-1]++;
		}
	}
	for(int i=0;i<2;i++){
		for(int j=1;j<sum[i].size();j++){
			sum[i][j]+=sum[i][j-1];
		}
	}
	if(sum[0].size()<=K){
		cout<<N<<endl;
		return 0;
	}
	
	int ans = 0;
	for(int i=K;i<sum[0].size();i++){
		int t = sum[0][i]-sum[0][i-K];
		if(S[0]=='0'){
			int a = i;
			if(a>=sum[1].size())a=sum[1].size()-1;
			if(i-K-1>=0){
				t+=sum[1][a]-sum[1][i-K-1];
			}
			else{
				t+=sum[1][a];
			}
		}
		else{
			int a = i+1;
			if(a>=sum[1].size())a=sum[1].size()-1;
			t+=sum[1][a]-sum[1][i-K];
		}
			
		ans=max(t,ans);
	}
	cout<<ans<<endl;
		
	
	
	return 0;
}


Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<climits>

#define MAX_V 101
#define INF 10000000

using namespace std;


struct edge{int to, cost; };
typedef pair<int, int> P;

int V,mincost[MAX_V];
vector<edge>G[MAX_V];

int Prim(int s){
  priority_queue<P, vector<P>, greater<P> >que;
  fill(mincost, mincost+V, INF);

  vector<bool> visited(V);
  fill(visited.begin(),visited.end(),false);

  mincost[s]=0;
  que.push(P(0,s));
  int res=0;

  while(!que.empty()){
    P p = que.top();
    que.pop();
    
    int v = p.second;
    if(visited[v])continue;
    visited[v]=true;
    res+=mincost[v];

    for(int i=0; i < G[v].size(); i++){
      edge e = G[v][i];
      if(mincost[e.to] > e.cost && !visited[e.to]){
	mincost[e.to] = e.cost;
	que.push(P(mincost[e.to], e.to));
      }
    }
  }
 
  return res;
}


int main(void){
  int m,a,b,c;
  char ch1,ch2;
  edge e;

  while(cin >> V,V){
    for(int i=0;i<V;i++)G[i].clear();
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> a >> ch1 >> b >> ch2 >> c;
      e.to=b,e.cost=c/100-1;
      G[a].push_back(e);
      e.to=a;
      G[b].push_back(e);
    }
      cout << Prim(0) << endl;
  }

  return 0;
}

Measured memory_bytes: 1340
#include "bits/stdc++.h"

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

const double PI = 3.14159265358979323846;

vector<vector<int64_t>> data1;

void search(vector<int64_t> data, int depth)
{
}


int main()
{
	double a, b;
	int h, m;

	cin >> a >> b >> h >> m;

	double tyousin = (h * 30.0 + m * 0.5) * (PI/180);
	double tansin = (m * 6) * (PI/180);

	auto a_pos_x = a * cos(tansin);
	auto a_pos_y = a * sin(tansin);
	auto b_pos_x = b * cos(tyousin);
	auto b_pos_y = b * sin(tyousin);

	auto x = a_pos_x - b_pos_x;
	auto y = a_pos_y - b_pos_y;

	cout << fixed;
	cout << setprecision(20)<<sqrt(pow(x, 2) + pow(y, 2)) << endl;
	
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int H, W, N;
	cin >> H >> W >> N;
	int ans = 1;
	int tmp = max(H, W);
	for (int i = 0; i < 100; i++){
		if (tmp < N) {
			ans++;
			tmp += max(H, W);
		}
		else {
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.rbegin(),A.rend());
    int cnt = 0;
    ll a1 = -1,a2 = -1;
    rep(i,N-1){
        if(A[i] == A[i+1] && cnt == 0){
            a1 = A[i];
            cnt++;
            i++;
        }
        else if(A[i] == A[i+1] && cnt == 1){
            a2 = A[i];
            break;
        }
    }
    cout << (a2==-1?0:a1*a2) << endl;
}
    



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    string S;
    cin >> S;
    vector<ll> L, R;
    ll N = S.size();
    rep(i, N) {
        if (S[i] == 'R') {
            R.push_back(i);
        } else {
            L.push_back(i);
        }
    }
    vector<ll> ans(N);
    rep(i, N) {
        if (S[i] == 'R') {
            ll j = *lower_bound(L.begin(), L.end(), i);
            if (abs(j - i) % 2) {
                ans[j - 1]++;
            } else {
                ans[j]++;
            }
        } else {
            ll j = R[lower_bound(R.begin(), R.end(), i) - R.begin() - 1];
            if (abs(j - i) % 2) {
                ans[j + 1]++;
            } else {
                ans[j]++;
            }
        }
    }
    rep(i, N) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

typedef long long int ll; // 長い名前を省略する。
char a[11]; // 配列10＋最後の\0分
ll as(int b, ll c, ll sum){
// b；カウンタ、c；左の数字、sum；合計値
	if(a[b]=='\0') return c+sum; // 最後だったら左を全て合計値に
	
    return (as(b+1, c*10+a[b]-'0',sum) + as(b+1,a[b]-'0',sum+c));
}

int main(){
	scanf("%s",a); //%sは文字列
	printf("%lld\n",as(1,a[0]-'0',0));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int l[10];
	int v[2];
	while(~scanf("%d",&l[0]))
	{
		for(int i = 1; i < 10; ++i)
		{
			scanf(",%d", &l[i]);
		}
		scanf(",%d,%d", &v[0], &v[1]);
		int sum = 0;
		for(int i = 0; i < 10; ++i)
		{
			sum += l[i];
		}
		double pos = sum * (double)v[0] / (v[0] + v[1]);
		sum = 0;
		int count = 0;
		while(pos > sum)
		{
			sum += l[count];
			count++;
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;
int N, A, B;
int a[50], b[50], c[50];
const int inf=1001001;
int memo[41][401][401];

int rec(int i, int _a, int _b){

   if(memo[i][_a][_b]!=inf) return memo[i][_a][_b];
   if(_a==0&&_b==0) return 0;
   if(i==N) return inf;
   int ret=inf;
   ret=min(ret, rec(i+1, _a, _b));
   if(_a-a[i]>=0&&_b-b[i]>=0) ret=min(ret, rec(i+1, _a-a[i], _b-b[i])+c[i]);

   return memo[i][_a][_b]=ret;
}

int main(){

   cin>> N>> A>> B;
   for(int i=0; i<N; i++){
      cin>> a[i]>> b[i]>> c[i];
   }

   for(int i=0; i<41; i++){
      for(int j=0; j<401; j++){
         for(int k=0; k<401; k++){
            memo[i][j][k]=inf;
         }
      }
   }
   int mi=inf;
   for(int k=1; k<9; k++){
      mi=min(mi, rec(0, k*A, k*B));
   }

   if(mi==inf){
      cout<< -1<< endl;
   }else{
      cout<< mi<< endl;
   }

   return 0;
}


Measured memory_bytes: 25984
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: i64 = 1000000007;
const INF: i64 = std::i64::MAX / 4;

fn mod_pow(mut base: i64, mut exp: i64, modulus: i64) -> i64 {
    if modulus == 1 { return 0 }
    let mut result = 1;
    base %= modulus;
    while exp > 0 {
        if exp % 2 == 1 {
            result = result * base % modulus;
        }
        exp >>= 1;
        base = base * base % modulus
    }

    return result;
}

fn main() {
    input! {
        N: i64,
        K: i64,
    }

    let mut ans: i64 = 0;
    let mut V = vec![0; (K + 1) as usize];

    for a in (1..K+1).rev() {
        let M = K / a;
        let mut cnt = mod_pow(M, N, MOD);

        let mut mul = a + a;
        while mul <= K {
            cnt -= V[mul as usize];
            if cnt < 0 {
                cnt += MOD;
            }
            mul += a;
        }

        cnt %= MOD;
        ans += cnt * a;
        ans %= MOD;
        V[a as usize] = cnt;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2712
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

ll getGcd(ll a, ll b) {
	if (a < b) {
		ll temp = b;
		b = a;
		a = temp;
	}

	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int main() {

	int N; cin >> N;

	vector<int>buka(N, 0);
	for (int i = 0; i < N-1;++i) {
		ll a; cin >> a; --a;
		buka[a]++;
	}
	for(int i =0;i<N;++i)cout << buka[i] << endl;
}



Measured memory_bytes: 6428
package main

import "fmt"

func main() {
	var n, k, x, y int
	fmt.Scan(&n)
	fmt.Scan(&k)
	fmt.Scan(&x)
	fmt.Scan(&y)

	if n > k {
		fmt.Println(x*k + y*(n-k))
	} else {
		fmt.Println(x * n)
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> M(H);

  int h_ = 0;
  int flag = 1;
  int n = 0;
  
  for(int h=0; h<H; h++) {
    cin >> M[h_];
    
    for(int w=0; w<W; w++) {
      if(M[h_][w] == '.') {
        flag = 1;
      } else {
        flag = 0;
        h_++;
        break;
      }
    }
    if(flag == 1) {
      n++;
    }
  }
  
  flag = 1;
  int w_ = 0;
  
  for(int w=0; w<W; w++) {
    for(int h=0; h<H-n; h++) {
      if(M[h][w_] == '.') {
        flag = 1;
      } else {
        flag = 0;
        w_++;
        break;
      }
    }
    if(flag == 1) {
      for(int h=0; h<H-n; h++) {
        M[h].erase(w_,1);
      }
    }
  }
    
  for(int h=0; h<M.size()-n; h++) {
    cout << M[h] << endl;
  }
  
  return 0;
}

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

class class_BellmanFord{
public:
	class_BellmanFord(){};
	virtual ~class_BellmanFord(){};
	void Init(int N);
	void Set_1Way(int a,int b, ll d);
	bool Search(int startPoint, int endPoint, ll infVal);
	double Distance(int targetPoint){return DistanceFormStart[targetPoint];}
protected:
	int PointNum=0;
	vector< multimap<int,ll> > Connect; // 相手の点番号と距離
	vector<int> BeforePoint;
	vector<ll> DistanceFormStart;
};

void class_BellmanFord::Init(int N){
	Connect.clear();
	Connect.resize(N);
	DistanceFormStart.clear();
	DistanceFormStart.resize(N);
	BeforePoint.clear();
	BeforePoint.resize(N);

	PointNum = N;
}

void class_BellmanFord::Set_1Way(int a, int b, ll d){
	Connect[a].emplace(b,d);
}

bool class_BellmanFord::Search(int startPoint, int endPoint, ll infVal){
	for(int i=0;i<PointNum;i++){
		DistanceFormStart[i] = infVal;
		BeforePoint[i] = -1;
	}
	DistanceFormStart[startPoint] = 0;

	for(int i=0;i<PointNum-1;i++){
		for(int u=0;u<PointNum;u++){
			if (DistanceFormStart[u]==infVal){continue;}
			for(auto c : Connect[u]){
				double newScore = DistanceFormStart[u] + c.second;
				if (newScore < DistanceFormStart[c.first]){
					DistanceFormStart[c.first] = newScore;
					BeforePoint[c.first] = u;
				}
			}
		}
	}

	vector<char> nega(PointNum);
	for(int i=0;i<PointNum;i++){
		for(int u=0;u<PointNum;u++){
			if (DistanceFormStart[u]==infVal){continue;}
			for(auto c : Connect[u]){
				double newScore = DistanceFormStart[u] + c.second;
				if (newScore < DistanceFormStart[c.first]){
					DistanceFormStart[c.first] = newScore;
					nega[c.first]=1;
				}

				if (nega[u]==1){
					nega[c.first]=1;
				}
			}
		}
	}
	// endPoint に届かない所の負ループは無視！

	if (nega[endPoint]==1){return false;}
	return true;
}


int main(int , char **)
{
	int N,M;
	cin >> N >> M;

	class_BellmanFord graph;
	graph.Init(N);

	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--; 	// 入力は１始点、これを 0 始点とする
		graph.Set_1Way(a,b,-c);
	}

	if (graph.Search(0,N-1,LLONG_MAX) == false){printf("inf\n");return 0;}
	double ans = graph.Distance(N-1);
	printf("%ld\n", (ll)(ans * -1.0) );

	return 0;
}


Measured memory_bytes: 384
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10031
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;

void InputSet(std::vector<int> & a) {
	int n;
	cin >> n;
	a.resize(n,0);
	for(int i=0;i<n;++i) {
		cin >> a.at(i);
	}
	sort(a.begin(),a.end());
}
int main(){
	std::vector<int> S,T;
	::InputSet(S);
	::InputSet(T);
	std::vector<int> intersect = std::vector<int>(min(S.size(),T.size()));
	vector<int>::iterator it = set_intersection(S.begin(),S.end(),T.begin(),T.end(),intersect.begin());

	cout << int(it - intersect.begin()) << std::endl;
	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;

    vector<int> h(n);

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

    int count = 1;

    int maxHeight = h[0];
    for (int i = 1; i < n; i++) {
        if (maxHeight <= h[i]) {
            count++;
        }

        maxHeight = max(maxHeight, h[i]);
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

//関数の宣言
void sort(int mountain[10]);

int main(){
	
	const int a = 10;
	int mountain[a];
	
	for (int i = 0; i < 10; ++i){
		std::cin >> mountain[i];
	}
	sort(mountain);

	for (int i = 0; i < 3; i++){
		std::cout << mountain[i] << std::endl;
	}
	return 0;
}


//関数の定義
void sort(int mountain[10]){
	for (int i = 0; i < 9; ++i){
		for (int j =i+1; j < 10; ++j){
			if (mountain[i] < mountain[j]){
				int tmp = mountain[i];
				mountain[i] = mountain[j];
				mountain[j] = tmp;
			}
		}
	}
}


Measured memory_bytes: 3052
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
count = 0
(a+1).times do |i|
  (b+1).times do |j|
    (c+1).times do |k|
      count += 1 if 500*i + 100*j + 50*k == x
    end
  end
end
puts count

Measured memory_bytes: 14228
use std::io::*;
use std::str::FromStr;

fn main() {
    let mut a: Vec<i64> = (0..5).map(|_| read()).collect();
    let k: i64 = read();
    a.sort();
    println!("{}", 
        if a[4] - a[0] > k { ":("}
        else {"Yay!"}
        );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    int k;cin>>k;
    string s;s="ACL";
    for (int i = 0; i < k; ++i) {
        cout <<s;
    }
    cout <<endl;
}

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

int main(){
  int n;
  string sou;
  char temp;
  int ans;
  int sugo[6];
  while(cin>>n){
    if(!n)break;
    ans=1;
    sugo[0]=1;
    sugo[1]=2;
    sugo[2]=3;
    sugo[3]=4;
    sugo[4]=5;
    sugo[5]=6;
      while(n--){
        cin>>sou;
        if(sou=="North"){
          temp=sugo[0];
          sugo[0]=sugo[1];
          sugo[1]=sugo[5];
          sugo[5]=sugo[4];
          sugo[4]=temp;
          ans+=sugo[0];
        }
        else if(sou=="East"){
          temp=sugo[0];
          sugo[0]=sugo[3];
          sugo[3]=sugo[5];
          sugo[5]=sugo[2];
          sugo[2]=temp;
          ans+=sugo[0];
        }
        else if(sou=="West"){
          temp=sugo[0];
          sugo[0]=sugo[2];
          sugo[2]=sugo[5];
          sugo[5]=sugo[3];
          sugo[3]=temp;
          ans+=sugo[0];
        }
        else if(sou=="South"){
          temp=sugo[0];
          sugo[0]=sugo[4];
          sugo[4]=sugo[5];
          sugo[5]=sugo[1];
          sugo[1]=temp;
          ans+=sugo[0];
        }
        else if(sou=="Right"){
          temp=sugo[1];
          sugo[1]=sugo[2];
          sugo[2]=sugo[4];
          sugo[4]=sugo[3];
          sugo[3]=temp;
          ans+=sugo[0];
        }
        else if(sou=="Left"){
          temp=sugo[1];
          sugo[1]=sugo[3];
          sugo[3]=sugo[4];
          sugo[4]=sugo[2];
          sugo[2]=temp;
          ans+=sugo[0];
        }
      }
      cout<<ans<<endl;
  }
}

Measured memory_bytes: 1208
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()            
A = [INT() for i in range(M)]

dp = [INF] * (N + 1)
dp[0] = 1
dp[1] = 1
for a in A:
    dp[a] = 0

for i in range(1, N+1):
    if dp[i] == 0:
        continue
    if i-2 >= 0:
        dp[i] = min(dp[i], dp[i-1] + dp[i-2])
    elif i - 1 >= 0:
        dp[i] = min(dp[i], dp[i-1])
# print(dp)
print(dp[N] % mod)
    






Measured memory_bytes: 478284
# input
s = input()
S = s.split('/')

if int(S[0]) < 2019:
    print('Heisei')
elif int(S[0]) > 2019:
    print('TBD')
else:
    if int(S[1]) <= 4:
        print('Heisei')
    else:
        print('TBD')


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;
int gcd(int a, int b)
{
	while (b)
	{
		a %= b;
		swap(a, b);
	}
	return a;
}
signed main()
{
	fastio();
	int n;
	cin >> n;
	int gc = 0;
	int x;
	cin >> x;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		gc = gcd(gc, abs(a - x));
	}
	cout << gc;
	system("pause");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int M = 1e9+7;
const int N = 50;

struct matrix {
    int m[N][N], r, c;

    matrix(int _r = N, int _c = N, bool iden = false) {
        r = _r; c = _c;
        memset(m, 0, sizeof(m));
        if (iden) while (_c--) m[_c][_c] = 1;
    }

    matrix operator * (const matrix &B) {
        matrix C(r, B.c);
        for(int i = 0; i < r; i++)
            for(int k = 0; k < c; k++) if (m[i][k])
                for(int j = 0; j < B.c; j++)
                    C.m[i][j] = (1ll*C.m[i][j] + 1ll*m[i][k]*B.m[k][j]) % M;
        return C;
    }
};

matrix pow(matrix A, ll e) {
    matrix ANS(A.r, A.c, true);
    while (e) {
        if (e&1) ANS = ANS * A;
        A = A * A;
        e /= 2;
    }
    return ANS;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n;
    ll k;
    cin >> n >> k;
    
    matrix A(n, n);
    forn(i, 0, n) {
        forn(j, 0, n) {
            cin >> A.m[i][j];
        }
    }
    A = pow(A, k);
    
    int ans = 0;
    forn(i, 0, n) {
        forn(j, 0, n) {
            ans = (ans + A.m[i][j]) % M;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        K_Stones solver = new K_Stones();
        solver.solve(1, in, out);
        out.close();
    }

    static class K_Stones {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni(), k = in.ni();
            int[] a = in.na(n);
            boolean[] won = new boolean[k + 1];
            for (int num = 0; num <= k; num++) {
                if (!won[num]) {
                    for (int i = 0; i < n; i++) {
                        if (num + a[i] <= k) {
                            won[num + a[i]] = true;
                        }
                    }
                }
            }
            if (won[k]) {
                out.println("First");
            } else
                out.println("Second");

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

        public int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

    }
}



Measured memory_bytes: 25044
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    if (B < A)
        swap(A, B);
    bool b = A < C && C < B;
    writeln(b ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>

const int MOD = 998244353;
const int MAXVAL = 1100000;

int N, A[210000];
int mu[MAXVAL], f[MAXVAL];
int cnt[MAXVAL];
int is_comp[MAXVAL], prime[MAXVAL], size = 0;

void euclid (const long long &a, const long long &b, long long &x, long long &y) {
    if (b == 0) x = 1, y = 0;
    else euclid (b, a % b, y, x), y -= a / b * x; }
long long inverse (long long x, long long m) {
    long long a, b; euclid (x, m, a, b); return (a % m + m) % m; }

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) scanf("%d", &A[i]), ++cnt[A[i]];
    mu[1] = 1; f[1] = 1;
    for (int i = 2; i < MAXVAL; ++i) {
        if (!is_comp[i]) {
            prime[size++] = i;
            mu[i] = MOD - 1;
            f[i] = MOD - i + 1;
        }
        for (int j = 0; j < size && 1ll * i * prime[j] < MAXVAL; ++j) {
            is_comp[i * prime[j]] = true;
            if (i % prime[j] == 0) {
                mu[i * prime[j]] = 0;
                f[i * prime[j]] = f[i];
                break;
            } else {
                mu[i * prime[j]] = MOD - mu[i];
                f[i * prime[j]] = 1ll * f[i] * f[prime[j]] % MOD;
            }
        }
    }
    int res = 0;
    for (int t = 1; t < MAXVAL; ++t) {
        int sum = 0;
        for (int i = t; i < MAXVAL; i += t) {
            sum = (sum + 1ll * i * cnt[i]) % MOD;
        }
        res = (res + 1ll * sum * sum % MOD * f[t] % MOD * inverse(t, MOD)) % MOD;
    }
    for (int i = 0; i < N; ++i) res = (res - A[i] + MOD) % MOD;
    res = 1ll * res * inverse(2, MOD) % MOD;
    printf("%d\n", res);
    return 0;
}


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

int par[100001];
struct edge { int cost, from, to; };
void init(int x) {
	rep(i, x) par[i] = i;
}
int find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}
bool same(int x, int y) {
	return find(x) == find(y);
}
void unit(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	else par[y] = x;
}

int s, t, w, v, e, ans;
vector<edge> edges;
int main() {
	cin >> v >> e;
	rep(i, e) {
		cin >> s >> t >> w;
		edges.push_back(edge{ w, s, t });
	}
	sort(edges.begin(), edges.end(), [](edge x, edge y) { return x.cost < y.cost; });
	init(v);
	rep(i, e) {
		int x = edges[i].from, y = edges[i].to, z = edges[i].cost;
		if (!same(x, y)) {
			ans += z;
			unit(x, y);
		}
	}
	cout << ans << endl;
	return 0;
}


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

typedef pair<int, int> P;


int main() {
    int AN, BN, R, x, y, d2, i, j, dx, dy, res;
    while (cin >> AN >> BN >> R, AN, BN, R) {
        P A[100001];
        P B[100001];
        vector<P> sp[300][300];
        vector<P> blo_el;
        res = 0;

        for (i=0; i<AN; i++) {
            cin >> A[i].first >> A[i].second;
        }

        for (i=0; i<BN; i++) {
            cin >> B[i].first >> B[i].second;
            sp[B[i].second/40][B[i].first/40].push_back(P(B[i].first, B[i].second));
        }

        for (i=0; i<AN; i++) {
            int block_x = A[i].first / 40;
            int block_y = A[i].second / 40;
            for (dx=-1; dx<=1; dx++) {
                for (dy=-1; dy<=1; dy++) {
                    if (block_x+dx<0||block_x+dx>=250||block_y+dy<0||block_y+dy>=250) continue;
                    blo_el = sp[block_y+dy][block_x+dx];
                    for (j=0; j<blo_el.size(); j++) {
                        d2 = (A[i].first - blo_el[j].first) * (A[i].first - blo_el[j].first)
                            + (A[i].second - blo_el[j].second) * (A[i].second - blo_el[j].second);
                        if (d2 <= 16*R*R) {
                            res += 1;
                        }
                    }
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;


int main()
{
	int a,b,c;
	int t[105];	
	scanf("%d %d %d",&a,&b,&c);
		int y=0;
		t[y++] = a;
		t[y++] = b;
		t[y++] = c;
		sort(t,t+3);
		printf("%d\n",t[0]+t[1]);
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 4

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

int huri(){

  int x,y ,i,j,sum=0;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(puzz[i][j] == 0)continue;

      x=(puzz[i][j]-1)%N-j;
      y=(puzz[i][j]-1)/N-i;
      x=abs(x);
      y=abs(y);
      
      sum+=x;
      sum+=y;
    }
  }
  return sum;
}

int DFS(int iof0,int jof0,int lim,int dpt,int n){

  int i,j,h,x,y,tmp,ans=-1;

  h = huri();
  if(h == 0) return dpt;
  if(h+dpt > lim) return -1;

  for(i=0;i<4;i++){
    if(abs(i-n) == 2)continue;
    
    x = iof0 + dx[i];
    y = jof0 + dy[i];

    if(x >= N || x < 0) continue;
    if(y >= N || y < 0) continue;

    tmp = puzz[x][y];
    puzz[x][y] = puzz[iof0][jof0];
    puzz[iof0][jof0] = tmp;

    ans = DFS(x,y,lim,dpt+1,i);

    if(ans != -1) return ans;
    tmp = puzz[x][y];
    puzz[x][y] = puzz[iof0][jof0];
    puzz[iof0][jof0] = tmp;
  }
  return -1;
}

int main(){

  int i,j,iof0,jof0,ans;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%d",&puzz[i][j]);
      if(puzz[i][j] == 0){
	iof0 = i;
	jof0 = j;
      }
    }
  }

  for(i=1;i<101;i++){
    ans = DFS(iof0,jof0,i,0,100);
    if(ans != -1) {
      printf("%d\n",ans);
      break;
    }
  }

  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> shop(N);
  
  for (int i = 0; i < N; i++) {
    cin >> get<0>(shop.at(i)) >> get<1>(shop.at(i));
    get<2>(shop.at(i)) = i+1;
  }
  for (int i = 0; i < N; i++) {
    get<1>(shop.at(i)) = 100 - get<1>(shop.at(i));
  }
  
  sort(shop.begin(), shop.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(shop.at(i)) << endl;
  }
}

Measured memory_bytes: 256
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    h_list = li()

    max_step = 0
    tmp_step = 0
    for index, hi in enumerate(h_list[1:]):
        # print(tmp_step)
        if h_list[index] >= hi:
            tmp_step = tmp_step + 1
        else:
            if max_step < tmp_step:
                max_step = tmp_step
            tmp_step = 0
    if max_step < tmp_step:
        max_step = tmp_step

    print(max_step)


Measured memory_bytes: 63856
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    map<string,ll> mp;
    string s[n];
    rep(i,n) cin >> s[i];
    rep(i,n){
        if(mp.find(s[i]) != mp.end()){
            puts("No");
            return 0;
        }
        mp[s[i]]++;
        if(i > 0){
            //cout << s[i-1].back() << endl;
            if(s[i-1].back() != s[i][0]){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}


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

int main()
{
    long long a, b, c, d, ans;

    cin >> a >> b >> c >> d;

    ans = max(a * c, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
	
	int a,b,c,d,e,ans;
	
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a < 40){
		a = 40;
	}
	if(b < 40){
		b = 40;
	}
	if(c < 40){
		c = 40;
	}
	if(d < 40){
		d = 40;
	}
	if(e < 40){
		e = 40;
	}
	ans = a + b + c + d + e;
	
	ans = ans / 5;
	
	printf("%d\n",ans);
	
	return 0;
	
}

Measured memory_bytes: 1028
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int Q = sc.nextInt();
        
        
        int[] point = new int[N];
        int[] answer = new int[Q];
    
        for(int i=0;i<Q;++i){
            answer[i] =sc.nextInt();
            point[answer[i] -1]++;
            
        }
        for(int j=0;j<N;j++){
            if(K-Q+point[j]>=1){
                System.out.println("Yes");
            }
            else if(K-Q+point[j]<=0){
                System.out.println("No");
            }
        }
        
        
    }
}

Measured memory_bytes: 60160
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);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 VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	string S;
	cin>>S;
	REP(i,(int)S.length()) 
		if(S[i]==',') S[i]=' ';
	cout<<S<<endl;
	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define forl(a,b,i) for(int i=a;i<=b;i++)
#define _fast_ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
using namespace std;

signed main(){
    _fast_;
    
    int l;
    cin>>l;
    cout<<fixed<<setprecision(12)<<(double)l*l*l/27;
    
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	char c;
	while((c = getchar()) != EOF)
		putchar(toupper(c));
	return 0;
}

Measured memory_bytes: 0
n,k,*h=map(int,open(0).read().split())
a=[0]*n
for i in range(1,n):
    j=max(0,i-k)
    HH=h[i]
    a[i]=min(A+abs(HH-H) for A,H in zip(a[j:i],h[j:i]))
print(a[-1]) 

Measured memory_bytes: 13876
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <functional>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin, n, m, q;
    vector<int> a(q), b(q), c(q), d(q);
    REP(i, 0, q) {
        cin, a[i], b[i], c[i], d[i];
        a[i]--;
        b[i]--;
    }
    vector<int> arr(n, 0);
    function<ll(int, int)> dfs = [&](int pos, int prev) {
        if (pos == n) {
            ll res = 0;
            REP(i, 0, q) {
                if (arr[b[i]] - arr[a[i]] == c[i]) {
                    res += d[i];
                }
            }
            return res;
        } else {
            ll res = 0;
            REP(i, prev, m + 1) {
                arr[pos] = i;
                chmax(res, dfs(pos + 1, i));
                arr[pos] = 0;
            }
            return res;
        }
    };
    cout << dfs(0, 1) << endl;
    return 0;
}


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

using ll = long long;
const int INF = 1001001001;

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

int main()
{
    ll k, n;
    cin >> k >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vector<ll> dis;
    rep(i, n-1) {
        dis.push_back(a[i+1] - a[i]);
    }
    dis.push_back(a[0] + k - a[n-1]);

    ll result = INF;
    rep(i, dis.size()) {
        result = min(result, k - dis[i]);
    }
    cout << result << endl;
}


Measured memory_bytes: 4084
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

// numの10乗を計算する
int pow_10(int num)
{
	int pow = 1;
	for (int i = 0; i < num; i++) {
		pow *= 10;
	}
	return pow;
}

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

	int digit = log10(b) + 1; // bの桁数をもとめる
	int num = a * pow_10(digit) + b; //判定する数

	// cout << "bの桁数は" << digit << "です。\n";
	// cout << "数字abは" << num << "です。\n";

	for(int i=1; i * i <= 100100; i++){
		if (num == i * i) {
			cout << "Yes\n";
			return 0;
		}
	}

	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(void){
    ll n,m;cin>>n>>m;
    map<int,int> mp;
    for(int i=2;i<=sqrt(m);i++){
        while(m%i==0){
            m/=i;
            mp[i]++;
        }
    }
    combination c(200000);
    if(m>=2)mp[m]++;
    mint res=1;
    for(auto&p:mp){
        int y=p.second;
        res*=c(y+n-1,n-1);
        //cout<<y<<" "<<c(y+n-1,y).x<<endl;
    }
    cout<<res.x<<endl;
}

Measured memory_bytes: 3328
X, Y, Z, K = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)
Bs = gets.split.map(&:to_i)
Cs = gets.split.map(&:to_i)
xy_array = []

X.times{|x|
    Y.times{|y|
        xy_array.push(As[x] + Bs[y])
    }
}
xy_array.sort!.reverse!
xy_cut = xy_array[0...K]

xyz_array = []
Z.times{|z|
    xy_cut.size.times{|k|
        xyz_array.push(Cs[z] + xy_cut[k])
    }
}
xyz_array.sort!.reverse!
xyz_cut = xyz_array[0...K]

puts xyz_cut



Measured memory_bytes: 70000
// 1756
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int t;
    cin >> t;
    int a = 1, b = 1;

    while(t--) {
        int x, y; cin >> x >> y;
        int per = max(a / x, b / y);
        while(true) {
            if(per * x >= a and per * y >= b) break;
            ++per;
        }
        a = per * x;
        b = per * y;
    }
    cout << a + b;
    
    
    
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int r,g;
  cin >> r >> g;
  cout << 2*g-r << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int N = sc.nextInt();
			String str = sc.next();
			char[] chars =str.toCharArray();
			int p1 = 0, p2 = N-1;
			int op = 0;
			while(p1 < p2){
				while(p1 < p2 && chars[p1] =='R'){
					p1++;
				}
				while(p2 > p1 && chars[p2] =='W'){
					p2--;
				}
				if(p1 < p2){
					op++;
					p1++;
					p2--;
				}
			}
			System.out.println(op);
		}
	}
}

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

int main()
{
  int n;
  std::cin>>n;
  int i,j;
  int a[n]={0};
  int cnt=0,cnt2=0;

  for(i=0; i<n; i++){
    std::cin>>a[i];
  }

  for(i=0; i<n; i++){
    cnt=0;
    for(j=2; j<sqrt(a[i])+1; j++){
      if(a[i]%j==0){
	cnt+=1;
      }
    }
    if(a[i]==2 or cnt<1){
      cnt2++;
    }
  }
  std::cout<<cnt2<<'\n';
  return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>

int main(void) {
  int N, n, i, j, temp, nobori, ori;
  scanf("%d", &N);

  for(i = 0; i < N; i++) {
    scanf("%d", &n);

    int block[n];

    nobori = ori = 0;

    for(j = 0; j < n; j++) {
      scanf("%d", &block[j]);
    }

    for(j = 0; j < n - 1; j++) {
      if(block[j] < block[j + 1]) {
	temp = block[j + 1] - block[j];
	if(temp > nobori) nobori = temp;
      } else {
	temp = block[j] - block[j + 1];
	if(temp > ori) ori = temp;
      }
    }

    printf("%d %d\n", nobori, ori);

  }

  return 0;
}


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


vector<int> G[MAX_V];
int f[MAX_V];
int temp[MAX_V];
int N, M;
string s;

bool foo(int x){
	// cout<<x<<" "<<f[x]<<" "<<s[x]<<endl;
	
	 if(f[x] == 2) return false;
	
	f[x] = 1;
	
	
	
	for(int y : G[x]){
		// cout<<y<<endl;
		// if(y == x) continue;
		if(s[y] == s[x]){
			if(f[y] == 2)continue;
			// f[y] = 1;
			for(int z : G[y]){
				// if(z == x)continue;
				if(f[z] == 2)continue;
				if(s[y] == s[z])continue;
				else {
					if(f[z] == 1) return true;
					if(foo(z)) return true;
				}
			}
			// f[y] = 2;
		}
	}
	 f[x] = 2;
	return false;
}


signed main(){
	int A, B;
	bool fl = false;

	
	cin>>N>>M;
	cin>>s;
	
	rep(i, M){
		cin>>A>>B;A--,B--;
		G[A].push_back(B);
		G[B].push_back(A);
		// if(A==B)temp[A] = true;
	}
	
	rep(i, N){
		 // cout<<i<<" -----"<<endl;
		if(foo(i)){
			fl = true;
			// cout<<"ture"<<endl;
			break;
		}
	}
	// rep(i, N)
		// cout<<"f "<<i<<" "<<f[i]<<endl;
	
	cout<<(fl?"Yes":"No")<<endl;
	
	
	return 0;
}

Measured memory_bytes: 16644