akhauriyash/Code-Regression huggingface dataset:
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=1000010;
char s[N];
int n,nxt[N],pre[N];
void init(){
	int j=0;nxt[1]=0;
	for(int i=2;i<=n;i++){
		while(j && s[j+1]!=s[i])j=nxt[j];
		if(s[j+1]==s[i])j++;
		nxt[i]=j;
	}
	j=n+1;pre[n]=n+1;
	for(int i=n-1;i;i--){
		while(j<=n && s[j-1]!=s[i])j=pre[j];
		if(s[i]==s[j-1])j--;
		pre[i]=j;
	}
}
bool check(int id){
	int flag1=(!nxt[id] || id%(id-nxt[id]));
	int flag2=(pre[id+1]==n+1 || (n-id)%(n-id-(n-pre[id+1]+1)));
	return (flag1&flag2);
}
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	init();
	if(!nxt[n] || n%(n-nxt[n]))return printf("1\n1\n"),0;
	if(nxt[n]==n-1)return printf("%d\n1\n",n),0;
	int sum=0;
	for(int i=1;i<n;i++)if(check(i))sum++;
	printf("2\n%d\n",sum);
	return 0;
}


Measured memory_bytes: 8448
#!/usr/bin/env python
# coding: utf-8

from collections import Counter

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k, q = rli()
    ca = Counter()
    for _ in range(q):
        a = ri()
        ca[a] += 1
    for a in range(1, n+1):
        if k + ca[a] - q > 0:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9448
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<ll>> value(3, vector<ll> (N));
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin >> value[j][i];
    }
  }
  ll ans = 0;
  for(int bit=0; bit<(1<<3); bit++){
    vector<ll> sum(N,0);
    for(int i=0; i<N; i++){
      for(int j=0; j<3; j++){
        if(bit & (1<<j)){
          sum[i] += value[j][i];
        }else{
          sum[i] -= value[j][i];
        }
      }
    }
    sort(sum.begin(),sum.end(),greater<ll>());
    ll res = 0;
    for(int i=0; i<M; i++){
      res += sum[i];
    }
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    ll n, m;   cin >> n >> m;
    vector<pair<ll, ll>> a(n);
    for(int i=0; i<n; i++)
        cin >> a.at(i).first >> a.at(i).second;
    sort(a.begin(), a.end());
    ll cnt, sum=0;
    for(int i=0; i<n; i++){
        sum += a.at(i).first*min(m, a.at(i).second);
        m -= min(m, a.at(i).second);
    }
    cout << sum <<  endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#define LL long long
using namespace std;

int main(){
 
  LL A, B, C, ans;
    
  scanf("%lld %lld %lld",&A, &B, &C);
  
  ans = B+C-A;
  if(ans<0){
   ans=0;
  }
  
  printf("%lld",ans);
  
     return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<map>
#include<cmath>
#include<set>
#include<queue>
#include<algorithm>

using namespace std;

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

const int MX = 200005;
const int MM = 1000000007;

int A[MX], B[MX];

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	for(int i = 1; i <= N; i++) scanf("%d%d", A+i, B+i);
	ll ans = 0;
	for(int i = 30; i >= -1; i--){
		if( i != -1 && ~K&1<<i ) continue;
		int X = K ^ (1<<i);
		X |= (1<<i)-1;
		if( i == -1 ) X = K;
		ll tot = 0;
		for(int j = 1; j <= N; j++){
			if( X == (A[j]|X) ) tot += B[j];
		}
		ans = max(ans, tot);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;

using ll = long long;
using boost::irange;

#define MOD 1000000007

int main(void){
    
    int N;
    ll K;
    cin >> N >> K;

    vector<vector<int>> A(2000);
    ll num1 = 0;
    ll num2 = 0;

    int a;
    for(ll i=0; i<N; i++){
        cin >> a;
        A[a-1].push_back(i);
    }

    for (const auto i : irange(1, 2000)){
        for (const auto ind : A[i]){
            for(const auto j : irange(0, i)){
                if (A[j].empty()) continue;
                int k = A[j].end() - upper_bound(A[j].begin(), A[j].end(), ind) ;
                //cout << k << endl;
                num1 += ((k * K) % MOD);
            }
        }
    }
    //num1 *= K;
    num1 %= MOD;


    ll larger_num = 0;
    for (const auto i : irange(1999,0,-1)){
        //cout << A[i+1].size() << " ";
        larger_num += A[i].size();
        num2 += (A[i - 1].size() * larger_num);
    }
    num2 *= ((K * (K - 1) / 2) % MOD);
    num2 %= MOD;

    //cout << num1 << endl;
    //cout << num2 << endl;

    ll ans = (num1 + num2) % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

struct Dish
{
    int time;
    int value;
};

int Solve(vector<Dish> &dishes, int limit)
{
    sort(dishes.begin(), dishes.end(), [](const Dish &a, const Dish &b) {
        if (a.time != b.time) {
            return a.time < b.time;
        }
        return a.value > b.value;
    });

    constexpr int kMaxTime = 6000;
    vector<int> best_value(kMaxTime + 1, 0);

    best_value[0] = 1;
    for (const auto &d : dishes) {
        for (int i = limit - 1; i >= 0; i -= 1) {
            if (best_value[i] == 0) {
                continue;
            }
            best_value[i + d.time] = max(best_value[i + d.time],
                                         best_value[i] + d.value);
        }
    }
    return *max_element(best_value.begin(), best_value.end()) - 1;
}

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

    vector<Dish> dishes(n);
    for (auto &d : dishes) {
        cin >> d.time >> d.value;
    }

    auto res = Solve(dishes, limit);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[110];
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int ans=0x7FFFFFFF;
	for (int i=1;i<=100;++i) {
		int ans1=0;
		for (int j=1;j<=n;++j) ans1+=(a[j]-i)*(a[j]-i);
		if (ans>ans1) ans=ans1; 
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from pprint import pprint
h,w = map(int, input().split())
m = []
for _ in range(h):
    line = [int(x) for x in input().split()]
    m.append(line)

ret = []
for i in range(h):
    j = 0
    while j<w:
        if m[i][j]%2==1:
            jj = j+1
            while jj<w and m[i][jj]%2==0:
                jj += 1
            if jj==w:
                jj = w-1
            for dj in range(j,jj):
                ret.append([i,dj,i,dj+1])
            if m[i][jj]%2==1:
                m[i][j] -= 1
                m[i][jj] += 1
            elif jj == w-1:
                m[i][j] -= 1
                m[i][jj] += 1
        j += 1

i = 0
while i<h:
    if m[i][w-1]%2==1:
        ii = i+1
        while ii<h and m[ii][w-1]%2==0:
            ii += 1
        if ii==h:
            ii = h-1
        for di in range(i,ii):
            ret.append([di,w-1,di+1,w-1])
        if m[ii][w-1]%2==1:
            m[i][w-1] -= 1
            m[ii][w-1] += 1
    i += 1

print(len(ret))
for r in ret:
    print(r[0]+1,r[1]+1,r[2]+1,r[3]+1)


Measured memory_bytes: 27516
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	if(b/a>=c)cout<<c<<endl;
	else cout<<b/a<<endl;

}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		writefln("%.8f",line.chomp.to!double.recurrence!((a,n)=>n%2?2*a[n-1]:a[n-1]/3).take(10).reduce!("a+b"));
	}
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,sum=0,max=0;
  cin>>N;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin>>p.at(i);
    sum+=p.at(i);
    if(max<p.at(i))max=p.at(i);
  }
  cout<<sum-max/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, n;
    cin >> x >> n;
    int a[109] = {};
    for(int i = 0; i < n; i++)
    {
       int tmp; cin >> tmp;
       a[tmp]++;
    }
    for(int i =0; ; i++)
    {
       if(!a[x-i] || x-i == 0)
       {
          cout << x-i;
          return 0;
       }
       if(!a[x+i])
       {
          cout << x+i;
          return 0;
       }

    }
}


Measured memory_bytes: 3640
#include"bits/stdc++.h"
using namespace std;

int main() {
	int K, S;
	cin >> K >> S;
	int count = 0;
	for (int i = 0;i <= K;++i) {
		for (int j = i;j <= K;++j) {
			for (int k = j;k <= K;++k) {
				if (i + j + k == S) {
					if (i == j && j == k) {
						count += 1;
					}
					else if (i != j && j != k) {
						count += 6;
					}
					else {
						count += 3;
					}
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}

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

int main(){
    ll n, m, t;
    vector<ll> a, b, c;
    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> t;
        a.push_back(t);
    }
    cin >> m;
    for(ll i = 0; i < m; i++){
        cin >> t;
        b.push_back(t);
    }
    set_intersection(a.begin(), a.end(), b.begin(), b.end(), back_inserter(c));
    for(auto i = c.begin(); i != c.end(); i++){
        cout << *i << endl;
    }
    return 0;
}



Measured memory_bytes: 7584
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n - 1; i++) {
    int tmp;
    cin >> tmp;
    a.at(--tmp)++;
  }
  for (int i = 0; i < n; i++) {
    cout << a.at(i) << endl;
  }
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
namespace Number {
    typedef long long int LL;
    // 求取 a, b 的最大公因數
    LL gcd(LL a, LL b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    // 求取 a, b 的最大公因數 gcd
    // 以及 x, y 使得 a*x + b*y = gcd
    LL gcd_extend(LL a, LL b, LL *x, LL *y) { 
        if (a == 0) { 
            *x = 0, *y = 1; 
            return b; 
        } 
    
        LL x1, y1; // To store results of recursive call 
        LL gcd = gcd_extend(b%a, a, &x1, &y1); 
    
        *x = y1 - (b/a) * x1; 
        *y = x1; 
    
        return gcd; 
    }
    // 求 a_inv 使得 (a * a_inv) % m = gcd(a, m)
    // 若 a, m 互質，即求 a 在 mod m 群的反元素 a_inv 
    LL mod_inv(LL a, LL m) { 
        LL x, y; 
        LL g = gcd_extend(a, m, &x, &y); 
        // 處理 x 爲負的情形 
        LL a_inv = (x%m + m) % m; 
        return a_inv;
    }
    // 求 x^n % m
    LL mod_pow(LL x, LL n, LL m) {
        if (n == 0) {
            return 1;
        } else if (n & 1) {
            LL half = mod_pow(x, n/2, m);
            return (half * half % m) * x % m;
        } else {
            LL half = mod_pow(x, n/2, m);
            return half * half % m;
        }
    }
    // 連乘
    LL mul(LL from, LL to, LL m) {
        LL ret = 1;
        for (LL i = from; i <= to; i++) {
            ret *= i;
            ret %= m;
        }
        return ret;
    }
    // 求 (C n 取 k) % m
    LL mod_comb(LL n, LL k, LL m) {
        LL mi = k < n-k ? k : n-k;
        LL up = mul(n - mi + 1, n, m);
        LL down = mul(1, mi, m);
        return (up * mod_inv(down, m)) % m;
    }
}
  

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int K; cin >> K;
    LL sum = 0;
    for (int i = 1; i <= K; ++i) {
        for (int j = i+1; j <= K; ++j) {
            for (int k = j+1; k <= K; ++k) {
                sum += Number::gcd(Number::gcd(i, j), k) * 6;
            }
        }
    }
    for (int i = 1; i <= K; ++i) {
        for (int j = i+1; j <= K; ++j) {
            sum += Number::gcd(i, j) * 6;
        }
    }
    for (int i = 1; i <= K; ++i) {
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		int len=0,p=i;
		while(p)++len,p/=10;
		ans+=len%2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
n, q = map(int, input().split())

edges = [[] for _ in range(n)]
for _ in range(n - 1):
    frm, to = map(int, input().split())
    # 0-index
    edges[frm - 1].append(to - 1)
    edges[to - 1].append(frm - 1)


scores = [0] * n
for _ in range(q):
    v, s = map(int, input().split())
    scores[v - 1] += s


stack = [0]
visited = [False] * n
visited[0] = True
while len(stack):
    frm = stack.pop()
    for to in edges[frm]:
        if not visited[to]:
            scores[to] += scores[frm]
            visited[to] = True
            stack.append(to)


print(" ".join([str(w) for w in scores]))

Measured memory_bytes: 71240
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end


def gcd(a,b)
	if(a>b)
		return gcd(b,a)
	end
	while(b%a != 0)
		tmp = a
		a = b%a
		b = tmp
	end
	return a
end
def lcm(a,b)
	a/gcd(a,b)*b
end


N,_=gets.chomp.split(' ').map{|n| n.to_i}

A=Array.new(N) { |i| Array.new(N) {1} }

P=Array.new(100001) {true}
P[0]=P[1]=false
for i in 2..(100000)
	if(P[i])
		(i+i).step(100000, i){|j|
			P[j] = false
		}
	end
end
@pi = 0
def get
	@pi += 1
	while(!P[@pi])
		@pi += 1
	end
	@pi
end

0.step(2*N-2,2){|n|
	val = get
	dputs "left down line #{val}"
	for i in 0..n
		j = n-i
		if(0<=i && i<N && 0<=j && j<N)
			A[i][j] *= val
		end
	end
}
val = get
dputs "right down line #{val}"
for i in 0..(N-1)
	j = i
	if(0<=i && i<N && 0<=j && j<N)
		A[i][j] *= val
	end
end
2.step(N-1,2){|d|
	val = get
	dputs "right down line #{val}"
	for i in 0..(N-1)
		j = i+d
		if(0<=i && i<N && 0<=j && j<N)
			A[i][j] *= val
		end
	end
	val = get
	dputs "right down line #{val}"
	for i in 0..(N-1)
		j = i-d
		if(0<=i && i<N && 0<=j && j<N)
			A[i][j] *= val
		end
	end
}
for i in 0..(N-1)
	for j in 0..(N-1)
		if(A[i][j]==1)
			nei = []
			nei << A[i-1][j] if(i>0)
			nei << A[i+1][j] if(i<N-1)
			nei << A[i][j-1] if(j>0)
			nei << A[i][j+1] if(j<N-1)
			A[i][j] = nei.inject(1){|a,sum| lcm(sum,a)} + 1
		end
	end
end
if(N==2)
	A[1][0] = (A[1][0] - 1) * 2 + 1
end

puts A.map{|a| a.join(" ")}.join("\n")


Measured memory_bytes: 15828
import itertools

N,M = map(int,input().split())
l = [ i for i in range(2,N+1)]

dist = {i:[] for i in range(1,N+1)}

for i in range(M):
  a,b = map(int,input().split())
  dist[a].append(b)
  dist[b].append(a)  

cnt = 0

for v in itertools.permutations(l):
  a = 1  
  for v1 in v:
    if a in  dist.get(v1):
      a = v1
      if a == v[-1]:
        cnt += 1
      continue
    else:
      break

print(int(cnt))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, _ := sc.NextInt()
	a, _ := sc.NextInts(n)
	fmt.Println(solve(n, a))
}

func solve(n int, a []int) (ans int) {
	count := map[int]int{}
	divisible := map[int]bool{}
	for _, ai := range a {
		count[ai]++
		divisible[ai] = false
	}

	sort.Ints(a)
	max := a[n-1]
	for _, ai := range a {
		if divisible[ai] {
			continue
		}
		for j := 2 * ai; j <= max; j += ai {
			if _, ok := divisible[j]; ok {
				divisible[j] = true
			}
		}
		if count[ai] == 1 {
			ans++
		}
	}
	return
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

// NextInts reads n integers from io stream.
func (sc *Scanner) NextInts(n int) (arr []int, e error) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		v, e := sc.NextInt()
		if e != nil {
			return nil, e
		}
		arr[i] = v
	}
	return arr, nil
}


Measured memory_bytes: 20756
import java.util.*;

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

        int N = sc.nextInt();
        String S = sc.next();
        int count = 0;
        char c = S.charAt(0);

        for (int i = 1; i < N; i++) {
            if (S.charAt(i) != c) {
                count++;
                c = S.charAt(i);
            }
        }

        System.out.println(count + 1);


    }
}


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

int main() {
  int n,d,x;
  cin>>n>>d>>x;
  int ans=x;
  d--;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ans+=d/a;
  }
  cout<<ans+n<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

int N;
size_t MASK;
vector<vector<int>> v;
vector<vector<int>> dp;

size_t get_mask()
{ 
  size_t mask = 0;
  for (int i = 0; i < N; ++i)
  { 
    mask |= (1 << i);
  }
  return mask;
}

inline size_t add(size_t res, size_t delta)
{ 
  return (res + delta) % 1000000007;
}

size_t solution(int i, size_t mask = 0)
{ 
  size_t res = 0; 
  for (int j = 0; j < N; ++j)
  { 
    if (v[i][j] && !(mask & (1<<j)))
    { 
      const size_t new_mask = mask | (1<<j);
      if (new_mask == MASK)
      { 
        res = add(res, 1);
        continue;
      }
      if (dp[i+1][new_mask] == -1)
      { 
        dp[i+1][new_mask] = solution(i+1, new_mask);
      }
      res = add(res, dp[i+1][new_mask]);
    }
  }
  return res;
}

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

  cin >> N;

  MASK = get_mask();

  v = vector<vector<int>>(N, vector<int>(N));
  dp = vector<vector<int>>(N+1, vector<int>(1<<N, -1));

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

  cout << solution(0);

  return 0;
}

Measured memory_bytes: 188800
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe





vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}
int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
string s,t;
cin >> s >> t;
for(int i=0;i<s.size();i++){
	s=s[s.size()-1]+s.substr(0,s.size()-1);
	if(s==t){
		cout << "Yes" << endl;
		return 0;
	}
}

cout << "No" << endl;
///////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
//queue
int main(){
    int n,q;
    cin >> n >> q;
    vector<string> name(n);
    vector<int> time(n);
    queue<int> queue;
    rep(i,n){
        cin >> name[i] >> time[i];
        queue.push(i);
    }
    int sum = 0;
    while( !queue.empty() ){
        int i = queue.front(); queue.pop();
        if( time[i] - q > 0){
            time[i] -= q;
            queue.push(i);
            sum += q;
        }else{
            cout << name[i] << " ";
            sum = sum + time[i];
            cout << sum << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6056
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 28;
const ll INF = 1ll << 60;
int h, w;

//(y,x)がh*wの升目内にあるかを返す
bool is_valid(int y, int x)
{
    return 0 <= y && y < h && 0 <= x && x < w;
}

int main()
{
    cin >> h >> w;
    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    // 0-indexedに直す
    sy--;
    sx--;
    gy--;
    gx--;

    vector<string> g(h);
    rep(i, h)
    {
        cin >> g[i];
    }
    VVI cost(h, VI(w, IINF));
    deque<pair<PII, int>> que;
    que.push_back({{sy, sx}, 0});
    int cur = 0;
    deque<PII> visited;
    vector<vector<bool>> used(h, vector<bool>(w, false));

    while (!que.empty())
    {
        while (!que.empty())
        {
            int cy = que.front().first.first;
            int cx = que.front().first.second;
            int cc = que.front().second;
            que.pop_front();
            if (cc >= cost[cy][cx])
                continue;
            visited.push_back({cy, cx});

            cost[cy][cx] = cc;
            int dy[4] = {1, -1, 0, 0};
            int dx[4] = {0, 0, 1, -1};
            rep(i, 4)
            {

                int ny = cy + dy[i];
                int nx = cx + dx[i];
                if (is_valid(ny, nx) && g[ny][nx] == '.' && cost[ny][nx] > cc && used[ny][nx] == false)
                {
                    que.push_back({{ny, nx}, cc});
                    used[ny][nx] = true;
                }
            }
        }
        int dy[5] = {-2, -1, 0, 1, 2};
        int dx[5] = {-2, -1, 0, 1, 2};
        cur++;

        while (!visited.empty())
        {
            int y = visited.front().first;
            int x = visited.front().second;
            visited.pop_front();
            rep(i, 5)
            {
                rep(j, 5)
                {
                    int ny = y + dy[i];
                    int nx = x + dx[j];
                    if (is_valid(ny, nx) && (g[ny][nx] == '.') && (cost[ny][nx] == IINF) && (used[ny][nx] == false))
                    {
                        que.push_back({{ny, nx}, cur});
                        used[ny][nx] = true;
                    }
                }
            }
        }
    }
    if (cost[gy][gx] == IINF)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << cost[gy][gx] << endl;
    }
    return 0;
}

Measured memory_bytes: 9744
#coding:utf-8
import math

A,B,H,M = map(int,input().split())

sec = H * 3600 + M * 60

arg = abs(math.pi * 11 * sec / (6 * 3600))

arg = min(arg, 2 * math.pi - arg)

cos = math.cos(arg)

x = (A ** 2 + B ** 2 - 2 * A * B * cos) ** 0.5

print("{}".format(x))

Measured memory_bytes: 9508
let words str =
  let len = String.length str in
  let buf = Buffer.create 3 in
  let rec aux i l =
    if i >= len then Buffer.contents buf :: l
    else 
      match str.[i] with
      | ' ' ->
        let s = Buffer.contents buf in
        Buffer.clear buf;
        aux (i+1) (s :: l)
      | c   ->
        Buffer.add_char buf c;
        aux (i+1) l
  in
  aux 0 []

let () =
  let _ = read_line () in
  let l = words (read_line ()) in
  print_endline (String.concat " " l)

Measured memory_bytes: 2032
n = int(input())
lines = [int(i) for i in input().split()]

l_max = max(lines)
ind_l_max = lines.index(l_max)
del lines[ind_l_max]

sum_remain = 0
for i in range(n-1):
    sum_remain += lines[i]

if l_max < sum_remain:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, X = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if N*500>=X:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Measured memory_bytes: 77564
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_three_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let (n, k) = input_tuple();
    let (r, s, p) = input_three_tuple();
    let t: String = input();
    let t: Vec<char> = t.chars().collect();

    let mut sum = 0;
    for i in 0..k {
        let mut j = 0;
        let mut pre_hand = ' ';
        while j * k + i < n {
            let idx = (j * k + i) as usize;
            let mut hand: char;
            if t[idx] == 'p' {
                hand = 's';
            } else if t[idx] == 'r' {
                hand = 'p';
            } else {
                hand = 'r'
            }

            if hand == pre_hand {
                hand = ' ';
            }

            // println!("{}: {}", idx, hand);

            if hand == 'r' {
                sum += r;
            } else if hand == 'p' {
                sum += p;
            } else if hand == 's' {
                sum += s;
            }
            pre_hand = hand;         
            j += 1;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
class EList(list):
    def accumulation_sum(self):
        if self.__len__() > 1:
            for i in range(self.__len__() - 1):
                self[i + 1] += self[i]
        return self

    def back_accumulation_sum(self):
        if self.__len__() > 1:
            for i in range(self.__len__() - 1, 0, -1):
                self[i - 1] += self[i]
        return self


if __name__ == '__main__':
    N = int(input())
    S = [i for i in input()]
    left = EList(1 if i == 'W' else 0 for i in S)
    right = EList(1 if i == 'E' else 0 for i in S)
    left.accumulation_sum()
    right.back_accumulation_sum()

    ans = min(map(lambda l, r:
                  l + r - 1
              , *(left, right)))
    print(ans)


Measured memory_bytes: 29464
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 n, k; std::string s;
    std::cin >> n >> k >> s;

    bool rev = false; u32 pos = 0;
    auto flip = [&](char& c) { c=c=='A'?'B':'A'; };
    auto collect = [&] {
        auto t = s;
        std::rotate(t.begin(), t.begin()+pos%n, t.end());
        if (rev) for (char& c: t) flip(c);
        return t;
    };
    auto move = [&] {
        if (rev^(s.at(pos%n)=='A')) flip(s.at(pos%n));
        else rev^=1, ++pos;
    };
    auto ans = [&] {
        for (; k; k--, move()) {
            if (pos==n) {
                if (k%2) k--, move();
                break;
            }
        }
        return collect();
    }();
    std::cout << ans << '\n';
}


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

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

map<int, int> mp;

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

    mp[1] = mp[3] = mp[5] = mp[7] = mp[8] = mp[10] = mp[12] = 1;
    mp[4] = mp[6] = mp[9] = mp[11] = 2;
    mp[2] = 3;

    int a,b; cin >> a >> b;

    if(mp[a] == mp[b]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
ll a[100200]={};
int main(void){
  ll n,q;
  string s;
  cin>>n>>q>>s;
  for(int i=1;i<n;i++){
    a[i]=a[i-1];
    if(s[i-1]=='A'&&s[i]=='C') a[i]++;
  }
  for(int i=0;i<q;i++){
    ll L,R;
    cin>>L>>R;
    L--,R--;
    if(L==0) cout<<a[R]<<endl;
    else{
      cout<<a[R]-a[L]<<endl;
    }
  }
}

Measured memory_bytes: 4496
#include <cstdio>
int main()
{
	int a = 0, b = 0, c = 0;
	scanf ("%d %d %d",&a,&b,&c);
	if (a == 5 && b == 5 && c == 7) printf("YES\n");
	else if (a == 5 && b == 7 && c == 5) printf("YES\n");
	else if (a == 7 && b == 5 && c == 5) printf("YES\n");
	else printf("NO\n");
	return 0;
	}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int order = 1, ok = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'a') {
      if (ok < A + B) {
        cout << "Yes" << endl;
        ok++;
      } else {
        cout << "No" << endl;
      }
    } else if (S[i] == 'b') {
      if (ok < A + B && order <= B) {
        cout << "Yes" << endl;
        ok++;
      } else {
        cout << "No" << endl;
      }
      order++;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 896
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N//R+1):
	n=N-r*R
	for g in range(n//G+1):
		n1=n-G*g
		if n1%B==0 and n1//B>=0:
			cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <set>
#include <cstdio>

using namespace std;

int main(void) {
    int x;
    scanf("%d", &x);

    set<int> s;
    s.insert(x);
    while(!s.empty()) {
        set<int> ns;
        for(auto n : s) {
            for(int i = 100; i <= 105; i++) {
                if(n - i == 0) {
                    printf("1\n");
                    return 0;
                } else if(n - i > 0) {
                    ns.insert(n - i);
                }
            }
        }
        s = ns;
    }
    printf("0\n");
    return 0;
}

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

int main(){

    int x, a, b;
    cin >> x >> a >> b;

    if(a - b >= 0)cout << "delicious\n";
    else if (x - (b-a) >= 0)cout << "safe\n";
    else cout << "dangerous\n";

    return 0;

}

Measured memory_bytes: 256
s=input()
ls=len(s)
c1=s[0]=="A"
c2=list(s[2:ls-1]).count("C")==1
if c1 and c2:
  s=s.replace("A", "a")
  s=s.replace("C", "c")
  if s.islower():
    print("AC")
  else:
    print("WA")
else:
  print("WA")

Measured memory_bytes: 3060
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    const int64_t mod = 1000000007;
    int n = input<int>();

    string s[2];
    s[0] = input<string>();
    s[1] = input<string>();

    int64_t ans = 1;
    int type = 0;

    auto f = [](int old, int nw) {
        if (old == 0) {
            if (nw == 1)
                return 3;
            else if (nw == 2)
                return 3 * 2;
        } else if (old == 1) {
            if (nw == 1)
                return 2;
            else if (nw == 2)
                return 2;
        } else if (old == 2) {
            if (nw == 1)
                return 1;
            else if (nw == 2)
                return 3;
        }

        assert(false);
        return -100500;
    };
    
    for (int i = 0; i != n;) {
        if (s[0][i] == s[1][i]) {
            ans = (int64_t(ans) * f(type, 1)) % mod;
            type = 1;
            i += 1;
        } else {
            ans = (int64_t(ans) * f(type, 2)) % mod;
            type = 2;
            assert(s[0][i] == s[0][i + 1]);
            assert(s[1][i] == s[1][i + 1]);
            i += 2;
        }
    }

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


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    ans = 0
    for i in range(1, N + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            ans += i
    print(ans)


if __name__ == '__main__':
    solve()


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int aaa=0;
    for(int i = 0; i <= N; i++){
        ans = 0;
        if(i%2 != 0){ //奇数
            for(int j = 1; j <= i; j++){
                if(i % j == 0)ans++;
            }
            if(ans == 8){
                aaa++;
            }
        }
    }
    cout<<aaa<<endl;
}

Measured memory_bytes: 256
N,K,C=map(int,input().split())
S=input()
day=[]
for i in range(len(S)):
  if S[i]=='o':
    day.append(i+1)
E=[day[0]]    
cur=day[0]
for i in range(1,len(day)):
  if day[i]>=cur+C+1:
    cur=day[i]
    E.append(cur)
F=[day[len(day)-1]]
cur=day[len(day)-1]
for i in range(len(day)-1,-1,-1):
  if day[i]<=cur-C-1:
    cur=day[i]
    F.append(cur)
if len(E)>K:
  while len(E)>K:
    E.pop()
if len(F)>K:  
  while len(F)>K:
    F.pop()
F.reverse()

for i in range(K):
  if E[i]==F[i]:
    print(E[i])

Measured memory_bytes: 20400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),A = in(),B = in();
    int ans = 0;
    REPS(i,N){
        int sum = 0;
        for (int l = i; l > 0; l/=10){
            sum += l%10;
        }
        if(A <= sum && sum <= B)ans+=i;
    }
    cout << ans << "\n";
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define mp make_pair
#define pb(x) push_back(x)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
// template <typename... Args>
// void dbg(Args... args) {
//     ((cout << args << " "), ...);
//     cout << endl;
// }

//--------------------------------------------------//
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({a, b, c}) - min({a, b, c});
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x[5] = {0};
    
    // 入力
    for(int i = 0; i < 5 ; i++){
        cin >> x[i];   
        // cout << x[i] << ", " << endl;
    }
    
    int save = 0;
    for(int i = 0; i < 5 ; i++){
        if(x[i] == 0)
        {
            save = i; 
        }
    }
    
    cout << save + 1 << endl; 
}


Measured memory_bytes: 3592
#include <stdio.h>
long long int m=1000000000+7;
long long int array[2001][2001];
long long int val=0;
long long int binom(long long int n,long long int k){
    if(n<k){
        return 0;
    }
	if(array[n][k]==0){
		k=(k>(n-k))?(n-k):k;
		if(k==0){
			val=1;
        }else if(k==1){
            val=n;
        }else{
			val=(binom(n-1,k)+binom(n-1,k-1))%m;
        }
		array[n][k]=val;
		return val;
	}else{
		return	array[n][k]%m;
	}
}
int main(){
    long long int N,K;
    scanf("%lld %lld",&N,&K);
    long long int i;
    long long int j;
    for(i=0;i<=N;i++){
        for(j=0;j<=N;j++){
            array[i][j]=0;
        }
    }
    for(i=1;i<=K;i++){
        printf("%lld\n",(binom(N-K+1,i)*(binom(K-1,i-1)))%m);
    }
}

Measured memory_bytes: 31488
using System;
class _0017
{
    public static void Main()
    {
        string str;
        while ((str = Console.ReadLine()) != null)
        {
            for (int i = 0; i < 26; i++)
            {
                str = Caesar(str);
                if (str.Contains("the") || str.Contains("this") || str.Contains("that"))
                {
                    Console.WriteLine(str);
                    break;
                }
            }
        }
    }
    public static string Caesar(string sentence)
    {
        char[] c = sentence.ToCharArray();
        for (int i = 0; i < c.Length; i++)
        {
            if (c[i] >= 'a' && c[i] <= 'z')
            {
                if (c[i] == 'z') c[i] = 'a';
                else c[i] += (char)1;
            }
        }
        return new string(c);
    }
}

Measured memory_bytes: 6124
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
   
   
public class Main {
	static int INF = 2 << 29;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] d = new int[n];
		for(int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		int[] c = new int[m];
		for(int i = 0; i < m; i++) {
			c[i] = sc.nextInt();
		}
		int[][] dp = new int[m+1][n+1];
		for(int i = 0; i < m+1; i++) {
			Arrays.fill(dp[i], INF);
			dp[i][0] = 0;
		}
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < n+1; j++) {
				dp[i+1][j]   = Math.min(dp[i+1][j], dp[i][j]);
				if(j != n)
				dp[i+1][j+1] = Math.min(dp[i+1][j+1], dp[i][j] + d[j]*c[i]);
			}
		}
		
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < m+1; i++) {
			min = Math.min(min, dp[i][n]);
		}
		System.out.println(min);
		
		
		
		
		
		
		
		
	}
}

Measured memory_bytes: 36652
import java.util.Scanner;

//Square Searching
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] a = new int[n][n];
			int[][] sum = new int[n+1][n+1];
			for(int i=0;i<n;i++){
				char[] s = sc.next().toCharArray();
				for(int j=0;j<n;j++)a[i][j]=s[j]=='.'?1:0;
			}
			sum[1][1] = a[0][0];
			for(int i=2;i<=n;i++){
				sum[1][i] = a[0][i-1]+sum[1][i-1];
				sum[i][1] = a[i-1][0]+sum[i-1][1];
			}
			for(int i=2;i<=n;i++){
				for(int j=2;j<=n;j++){
					sum[i][j] = a[i-1][j-1] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
				}
			}
			int max = 0;
			for(int k=1;k<=n;k++){
				boolean f = false;
				for(int i=k;i<=n;i++){
					for(int j=k;j<=n;j++){
						if(sum[i][j]-sum[i-k][j]-sum[i][j-k]+sum[i-k][j-k]==k*k){
							f = true;
							break;
						}
					}
					if(f)break;
				}

				if(f){
					max = k;
				}
				else break;
			}
			System.out.println(max);
		}
	}
}

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

int log2(int a, int y) {
  int yy = 0;
  while ((a&1) != 1) {
    yy+=1;
    a = a>>1;
    if (yy > y) {
      return y;
    }
  }
  return yy;
}

int main() {
  int n;
  cin >> n;
  int y = 30;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    int yy = log2(a, y);
    if (yy < y) {
      y = yy;
    }
  }
  cout << y << endl;
  return 0;
}

Measured memory_bytes: 256
n=gets.to_i
w=[]
for i in 0 ... n
  w << gets.chomp
end

ok = true
for i in 0 ... n
  for j in 0 ... i
    if w[i] == w[j]
      ok = false
    end
  end
end
for i in 0 ... n - 1
  if w[i][-1] != w[i+1][0]
    ok = false
  end
end
puts ok ?"Yes":"No"


Measured memory_bytes: 1788