akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
char s[1001], t[1001], k[1001];
int l;
bool check() {
	for (int i = 0 ; i < l; i++) {
		if (s[i] != t[i]) return false;
	}
	return true;
}
int main() {
	cin>>s;
	cin>>t;
	l = strlen(t);
	for (int i = 1; i <= l; i++) {
		if (check()) {
			cout<<"Yes\n";
			return 0;
		}
		char x = s[l - 1]; 
		for (int j = 0; j < l - 1; j++) {
			k[j + 1] = s[j];
		}
		for (int j = 1; j < l; j++) {
			s[j] = k[j] ;
		}
		s[0] = x;
	}
	cout<<"No\n"<<endl;
  return 0;
}


Measured memory_bytes: 256
s, t = input(), input()

n = len(s)
delta = len(t)
ans_list = []

for i in range(n-delta+1):
	for j in range(delta):
		if s[i+j] == '?' or s[i+j] == t[j]:
			pass
		else:
			break
	else:
		ans_list.append((s[:i]+t+s[i+j+1:]).replace('?', 'a'))

ans_list.sort()

if ans_list:
	print(ans_list[0])
else:
	print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)
#define ll long long
#define MOD 1000000007

bool pair_comp(pair<ll,ll> a, pair<ll,ll> b) {
  if(a.first == b.first) return a.second > b.second;
  else return a.first > b.first;
}

int main(int argc, char *argv[]) {
  int n,k;
  cin >> n >> k;

  if(n == 1) {
    cout << 1 << endl;
    return 0;
  }
  
  vector<pair<ll,ll> > g;
  pair<ll,ll> p;
  for(int i = 1; i*i <= n; i++) {
    p.first = n/i; p.second = n/p.first - n/(p.first+1);
    g.push_back(p);
    if(n/i - n/(i+1)) {
      p.first = i; p.second = n/i - n/(i+1);
      g.push_back(p);
    }
  }
  g.erase(unique(g.begin(),g.end()),g.end());
  sort(g.begin(),g.end(),pair_comp);
  //rep(i,0,g.size()) cout << g[i].first << " " << g[i].second << endl;
  

  
  ll **a = new ll*[g.size()];
  ll *ruiseki = new ll[g.size()];
  rep(i,0,g.size()) {a[i] = new ll[k];}
  rep(i,0,g.size()) {a[i][0] = 1;}
  rep(l,1,k) {
    ruiseki[0] = a[0][l-1];
    rep(i,1,g.size()) {
      ruiseki[i] = ruiseki[i-1] + a[i][l-1]*g[i].second;
      ruiseki[i] %= MOD;
    }
    rep(i,0,g.size()) {
      a[i][l] = ruiseki[g.size()-i-1];
    }
  }
  
  
  
  ll answer = 0;
  rep(i,0,g.size()) {
    answer = (answer + a[i][k-1]*g[i].second)%MOD;
  }
  cout << answer << endl;
  
  

  
  return 0;
}


Measured memory_bytes: 52596
#include <iostream>

using namespace std;
//2つの数字が等しければ2倍 違えば大きい方*2-1

int main(){

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

	if (a == b)cout << a * 2 << endl;
	else cout << (a > b ? a : b) * 2 - 1 << endl;

	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
m = []
m_sum = 0
for i in range(n-k+1):
    if i == 0:
        p_sum = sum(p[:k])
    else:
        p_sum -= p[i-1]
        p_sum += p[i+k-1]
    if p_sum > m_sum:
        m_sum = p_sum
print((m_sum+k)/2)



Measured memory_bytes: 25060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()
	key := "keyence"
	s := nextStr()

	for i := 0; i < len(key)+1; i++ {
		if  strings.HasPrefix(s, key[:i]) == true &&
			strings.HasSuffix(s, key[i:]) == true {
			fmt.Println("YES")
			return
		}
	}

	fmt.Println("NO")
	return
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var K = cin.ReadInt;
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var ans = false;

            for (int i = A; i <= B; i++)
            {
                if (i % K == 0) 
                {
                    ans = true;
                    break;
                }
            }

            WriteLine(ans ? "OK" : "NG");
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 27820
def main():
    d=int(input())
    c=list(map(int,input().split()))
    s=[list(map(int,input().split())) for _ in range(d)]
    last=[0]*27
    srate=[]
    a=0
    for i in range(1,d+1):
        t=int(input())
        last[t]=i
        a+=s[i-1][t-1]
        for j in range(1,27):
            a-=c[j-1]*(i-last[j])
        srate.append(a)
    for i in srate:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9368
L, R = gets.split.map(&:to_i)

min = 2020

L.upto(R - 1) do |i|
  (L + 1).upto(R) do |j|
    mod = i * j % 2019
    if mod == 0
      puts 0
      exit
    end
    min = mod < min ? mod : min
  end
end

puts min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define pii pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

void out(bool ok) {
	puts(ok? "YES" : "NO");
	exit(0);
}

int n;
multiset<int> e[MAXN];
queue<pii> q;

inline void AddEdge(int u, int v) {
	if (u == v) return;
	if (u > v) swap(u, v);
	if (e[u].find(v) != e[u].end()) {
		q.push(MP(u, v));
	}
	e[u].insert(v);
	e[v].insert(u);
}

void init() {
	read(n);
	for (int i = 1, m = n * 2 - 2, u, v; i <= m; ++i) {
		read(u); read(v);
		AddEdge(u, v);
	}
}

void solve() {
	for (int i = 1; i < n; ++i) {
		while (871) {
			if (q.empty()) out(0);
			int u = q.front().fi, v = q.front().se;
			q.pop();
			if (e[u].find(v) == e[u].end()) continue;
			if (e[u].size() < e[v].size()) swap(u, v);
			for (auto p : e[v]) {
				e[p].erase(e[p].find(v));
				AddEdge(u, p);
			}
			e[v].clear();
			break;
		}
	}
	out(1);
}

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


Measured memory_bytes: 24064
(format t "~d~%"
	(let ((l '(1 1 1 2 1 2 1 5 2 2 1 5 1 2 1 14 1 5 1 5 2 2 1 15 2 2 5 4 1 4 1 51)))
	  (elt l (1- (read)))))

Measured memory_bytes: 11104
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a>=b && a>=c)
    printf("%d\n",a*10+b+c);
  else if(b>=a && b>=c)
    printf("%d\n",b*10+a+c);
  else
    printf("%d\n",c*10+a+b);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N;
  cin >> N >> A;
 
  if ((N % 500 == 0) || ((N % 500) <= A)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;

  }
 }

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

bool isprime(int x) {
    bool ans = true;
    rep(i,(x+1)/2) {
        if (x % i == 0) ans = false;
    } 
    return ans;
}

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

    while (! isprime(x)) {
        x++;
    }

    cout << x << endl;
}

Measured memory_bytes: 256
s = open(0).read()

a = [0]
streak = 0
# mx = 0
for c in s:
    if c == '<':
        streak += 1
#         mx = max(mx, streak)
    else:
        streak = 0
    a.append(streak)
#     a.append(mx)

b = [0]
streak = 0
# mx = 0
for c in s[::-1]:
    if c == '>':
        streak += 1
#         mx = max(mx, streak)
    else:
        streak = 0
#     b.append(mx)
    b.append(streak)
b = b[::-1]

print(sum([max(x, y)for x, y in zip(a, b)]))

Measured memory_bytes: 142384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    string s;
    int ans = 0;
    cin>>s;

    int ss = 0;
    REPALL(i,s) {
        char c = s[i];
        if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
            ss++;
        } else {
            ss = 0;
        }
        ans = max(ans, ss);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#[derive(Debug)]
#[allow(dead_code)]
struct BiCoef{
    size: usize,
    modv: u64,
    inv: Vec<u64>,
    fact: Vec<u64>,
    invfact: Vec<u64>,
}

#[allow(dead_code)]
impl BiCoef{
    fn new(n: usize, modv : u64) -> Self {
        let mut inv = vec![0; n + 1];
        let mut fact =  vec![0; n + 1];
        let mut invfact =  vec![0; n + 1];
        inv[0] = 0 as u64;
        inv[1] = 1 as u64;
        for i in 2..(n+1) {
            inv[i] = inv[modv as usize % (i as usize)] * (modv - modv / i as u64)  as u64 % modv;
        }
        fact[0] =  1 as u64;
        invfact[0] = 1 as u64;
        for i in 1..(n+1) {
            fact[i] = i as u64 * fact[i - 1] % modv;
            invfact[i] = invfact[i - 1] * inv[i] % modv;
        }

        return BiCoef {size:n, modv:modv, inv:inv , fact:fact, invfact:invfact};
    }
    fn comb(&self, n : usize, r : usize) -> u64{
        if r > n{
            return 0;
        }
        return self.fact[n] * self.invfact[n - r] % self.modv * self.invfact[r] % self.modv;
    }
}

#[allow(dead_code)]
fn pow_mod(x:u64, y:u64, modv : u64) -> u64{
    let mut ret :u64 = 1;
    let mut xx = x;
    let mut yy = y;
    while yy > 0{
        if (yy&1) != 0 {
            ret = ret * xx % modv;
        }
        yy >>= 1;
        xx = xx * xx % modv;
    }
    return ret;
}

fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

fn main() {
    let modv : u64 = 1000000007;
    let line = getline();

    let vec: Vec<&str> = line.split_whitespace().collect();
    let n:i32  = vec[0].parse().unwrap_or(0);
    let a:i32  = vec[1].parse().unwrap_or(0);
    let b:i32  = vec[2].parse().unwrap_or(0);
    let c:i32  = vec[3].parse().unwrap_or(0);
    
    let comb = BiCoef::new(std::cmp::max(100, 2 * n) as usize , modv);

    let ab = a+b;
    let mut ans : u64 = 0;

    let wt = a as u64 * comb.inv[ab as usize] % modv;
    let wa = b as u64 * comb.inv[ab as usize] % modv;

    // takahashi
    let wint = pow_mod(wt, n as u64, modv);
    let mut w_a : u64 = 1;

    for i in 0..n{
        ans += w_a * wint % modv * comb.comb((n + i - 1) as usize, i as usize) % modv * (n + i) as u64 % modv;
        w_a *= wa;
        w_a %= modv;
    }

    //aoki
    let wina = pow_mod(wa, n as u64, modv);
    let mut w_t : u64 = 1;    
    for i in 0..n{
        ans += w_t * wina % modv * comb.comb((n + i - 1) as usize, i as usize) % modv * (n + i) as u64 % modv;
        w_t *= wt;
        w_t %= modv;
    }

    ans %= modv;
    ans *= 100;
    ans %= modv;
    ans *= comb.inv[(100 - c) as usize ];
    ans %= modv;

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


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
    int a,b,c;cin>>a>>b>>c;
    int ans=3;
    if (a==b)
    {
        /* code */
        ans--;
    }
    if (b==c)
    {
        /* code */
        ans--;
    }
    if (c==a)
    {
        /* code */
        ans--;
    }
    if (ans==0)
    {
        /* code */
        ans++;
    }
    cout<<ans<<endl;
    
    
    
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), p(n), q(n), r;
    for (int i = 0; i < n; ++i)
        a[i] = i + 1;
    for (int i = 0; i < n; ++i)
        cin >> p[i];
    for (int i = 0; i < n; ++i)
        cin >> q[i];

    int i = 0;
    do {
        if (a == p)
            r.push_back(i);
        if (a == q)
            r.push_back(i);
        i++;
    } while(next_permutation(a.begin(), a.end()));

    cout << abs(r[0] - r[1]) << endl;

    return 0;
}

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

#define inf 0x7f7f7f7f

int Fuck(int x) {
	int sum=1;
	while(x>0) {
		if(x%10<2) return inf;
		sum*=x%10;
		x/=10;
	}
	return sum;
}

int main() {
	int A,B,ans=0;
	cin>>A>>B;
	for(int i=22;i<=B;i++) {
		if(Fuck(i)<=A)  {
			//cout<<Fuck(i)<<'-'<<i<<endl;
			ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    int n,ans=0;
    cin >> n;
    rp(i,4){
        if(n%10==2){
            ans++;
        }
        n/=10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	a, _ := strconv.Atoi(Scanner())
	b, _ := strconv.Atoi(Scanner())
	a -= b
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i], _ = strconv.Atoi(Scanner())
	}
	ng, ok := 0, int(1e9)
	for {
		mid := (ok + ng) / 2
		c, d := 0, b*mid
		for _, i := range h {
			x := larger((i - d), 0)
			c += (x + a - 1) / a
		}
		if c > mid {
			ng = mid
		} else {
			ok = mid
		}
		if ok-ng == 1 {
			fmt.Println(ok)
			break
		}
	}
}
func larger(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>

constexpr size_t MOD = 1'000'000'007;

using Graph = std::vector<std::vector<size_t>>;

size_t permutation(size_t n, size_t r) {
  size_t m = 1;
  for (size_t i = 0; i < r; ++i) {
    m *= n - i;
    m %= MOD;
  }
  return m;
}

size_t dfs(const Graph& g, size_t k, size_t vc, size_t vp) {
  const auto r = g[vc].size();
  auto m = (vc == 0) ? k * permutation(k - 1, r) : permutation(k - 2, r - 1);
  m %= MOD;

  for (auto&& vi : g[vc]) {
    if (vi != vp) {
      m *= dfs(g, k, vi, vc);
      m %= MOD;
    }
  }

  return m;
}

int main() {
  size_t n, k;
  std::cin >> n >> k;

  Graph g(n);
  for (size_t i = 0; i < n - 1; ++i) {
    size_t a, b;
    std::cin >> a >> b;
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }

  std::cout << dfs(g, k, 0, -1) << std::endl;
}

Measured memory_bytes: 11520
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main extends App {
  def solve: Unit = {
    val sc = new Scanner(System.in)
    val N = sc.next.toLong
    var divisor = new ArrayBuffer[Int]
    for (i <- 1 to 100000) {
      if (N % i == 0) {
        divisor += i
      }
    }
    var ans = 1000000
    for (i <- divisor) {
      ans = math.min(ans, math.max(i.toString.length, (N / i).toString.length))
    }
    println(ans)
  }

  solve
}


Measured memory_bytes: 25660
#include<iostream>
#include<cstdio>
using namespace std;
int s[100010];
int n;
const long long md=1e9+7;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		s[x]++;
	}
	if(n&1 && !s[0])
	{
		printf("0");return 0;
	}
	for(int i=n-1;i>0;i-=2)
	{
		if(s[i]!=2)
		{
			printf("0");
			return 0;
		}
	}
	long long res=1;
	for(int i=1;i<=n/2;i++)
	{
		res*=2LL;
		if(res>md)res-=md;
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int N = 4000;
typedef long long ll;

// array to store inverse of 1 to N 
ll factorialNumInverse[N + 1]; 
  
// array to precompute inverse of 1! to N! 
ll naturalNumInverse[N + 1]; 
  
// array to store factorial of first N numbers 
ll fact[N + 1]; 
  
// Function to precompute inverse of numbers 
void InverseofNumber(ll p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
// Function to precompute inverse of factorials 
void InverseofFactorial(ll p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    // precompute inverse of natural numbers 
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
  
// Function to calculate factorial of 1 to N 
void factorial(ll p) 
{ 
    fact[0] = 1; 
  
    // precompute factorials 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
// Function to return nCr % p in O(1) time 
ll Binomial(ll N1, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N1] * factorialNumInverse[R]) % p * factorialNumInverse[N1 - R]) % p; 
    return ans; 
} 

void solve(){
	InverseofNumber(MOD); 
    InverseofFactorial(MOD); 
    factorial(MOD); 
	int s;
	cin >> s;
	int d = s/3;
	int ans = 0;
	for(int i = 1; i <= d; ++i){
		int n = s - (i * 3);
		ans = (ans + Binomial(n + i -1, i - 1, MOD)) % MOD;
	}
	cout << ans << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3744
k = int(input());
i= list(map(int,input().split()));

a = int(i[0]);
b = int(i[1]) ;
flag = False;


while(a <= b):
    if a % k == 0:
        flag = True;
        break;
    else:
        a += 1;

if(flag):
    print("OK");
else: print("NG");



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

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

int main(){
  int h,w;
  cin >> h >> w;

  vector<vector<char>> grid(h, vector<char>(w));
  rep(i,h)rep(j,w) cin >> grid.at(i).at(j);

  vector<int> h_check(h,0);
  vector<int> w_check(w,0);
  rep(i,h){
    bool check=true;
    rep(j,w){
      if(grid.at(i).at(j)=='#'){check=false; break;}
    }
    if(check) h_check.at(i)=1;
  }

  rep(j,w){
    bool check=true;
    rep(i,h){
      if(grid.at(i).at(j)=='#'){check=false; break;}
    }
    if(check) w_check.at(j)=1;
  }

  rep(i,h){
    rep(j,w){
      if(h_check.at(i)||w_check.at(j)) continue;
      cout << grid.at(i).at(j);
    }
    if(!h_check.at(i)) cout << endl;
  }
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (n == 2) {
    cout << a[1] - a[0] << endl;
    return 0;
  }
  int ans = 0;
  int res = 0;
  int count = 1;
  int left = a[0], right = a[0];
  for ( ; count < n; count++) {
    if (count % 4 == 1) {
      res += abs(left - a[n - 1 - count / 2]);
      left = a[n - 1 - count / 2];
    } else if (count % 4 == 2) {
      res += abs(right - a[n - 1 - count / 2]);
      right = a[n - 1 - count / 2];
    } else if (count % 4 == 3) {
      res += abs(left - a[count / 2]);
      left = a[count / 2];
    } else {
      res += abs(right - a[count / 2]);
      right = a[count / 2];
    }
  }
  ans = max(ans, res);
  sort(a, a + n, greater<int>());
  res = 0;
  count = 1;
  left = a[0], right = a[0];
  for ( ; count < n; count++) {
    if (count % 4 == 1) {
      res += abs(left - a[n - 1 - count / 2]);
      left = a[n - 1 - count / 2];
    } else if (count % 4 == 2) {
      res += abs(right - a[n - 1 - count / 2]);
      right = a[n - 1 - count / 2];
    } else if (count % 4 == 3) {
      res += abs(left - a[count / 2]);
      left = a[count / 2];
    } else {
      res += abs(right - a[count / 2]);
      right = a[count / 2];
    }
  }
  ans = max(ans, res);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
signed main(){
  vector<pair<string,int> > a,b;
  int c,d;
  string e;
  cin>>c;
  for(int i=0;i<c;i++){
    cin>>e>>d;
    a.push_back(make_pair(e,100-d));
    b.push_back(make_pair(e,100-d));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
      if(a[i].fi==b[j].fi){
        if(a[i].se==b[j].se) cout<<j+1<<"\n";
      }
    }
  }
}

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


int main()
{
    int N; 
    cin >> N;
    
    int cumsum[N];
    cin >> cumsum[0];
    for (int i = 1; i < N; i++)
    {
        int w;
        cin >> w;
        cumsum[i] = cumsum[i - 1] + w;
    }

    int ans = 100 * 100;
    for (int i = 0; i < N - 1; i++)
    {
        int s1 = cumsum[i];
        int s2 = cumsum[N - 1] - cumsum[i];

        ans = min(ans, abs(s2 - s1));
    }
    cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

    long long a;
    double b;
    scanf("%lld %lf", &a, &b);

    long long  b2, ans;
    //   9.999の場合は切り捨てで崩れるから+0.5する
    b2 = (long long)(b*100+0.1);
    ans = a * b2 / 100;

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

    return 0;
}

Measured memory_bytes: 3824
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define INF 1e9

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> a;
  a.push_back(0);
  for(int i=0;i<n-1;i++){
    if(s[i] != s[i+1]){
      a.push_back(i+1);
    }
  }
  a.push_back(n);
  int m = 1;
  int na;
  na = a.size()-1;
  for(int i=0;i<a.size();i++){
    if(s[a[i]] == '1'){
      m = max(m,a[min(na,i+2*k+1)] - a[i]);
    }
    else{
      m = max(m,a[min(na,i+2*k)] - a[i]);
    }
  }

  cout << m << endl;



  return 0;
}


Measured memory_bytes: 1020
program test
implicit none
character*100000 :: s
integer :: i,j,k,n,score_a

read(*,*) s

n = LEN_TRIM(s)

score_a = 0

do i=1,n
	if(s(i:i) .eq. "g") then
		score_a = score_a + 1
	endif
enddo

score_a = score_a - (n+1)/2

write(*,*) score_a

end program

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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000]{ 1 }, cnt = 1;
char b[200000], ok[100000]{ 1 };
deque<int>que;

void bfs(int u, char t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)writeln(ans[i]);
}

Measured memory_bytes: 13592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    while(a>=b){
        b*=2;
        k--;
    }
    while(b>=c){
        c*=2;
        k--;
    }
    if(k>=0) cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long R, G, B, N;
	cin >> R >> G >> B >> N;

	long long ans = 0;
	long long val;
	for (long long r = 0; r <= N / R; r++) {
		for (long long g = 0; g <= ((N - r * R) / G); g++) {
			val = N - R*r - G*g;
			if (val % B == 0) {
				ans += 1;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
ll a[N],ct[N],cs[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;cin>>n>>p;
    string s;cin>>s;
    for(ll i=1;i<=n;i++)a[i]=(s[i-1]-'0');
    if(p==2||p==5){
        ll ans=0;
        for(ll i=1;i<=n;i++)if(a[i]%p==0)ans+=i;
        cout<<ans<<"\n";
        return 0;
    }
    ct[0]++;
    ll cur=1,ans=0;
    for(ll i=n;i>=1;i--){
        cs[i] = (cur*a[i] + cs[i+1])%p;
        ans+=ct[cs[i]];
        ct[cs[i]]++;
        cur=(cur*10)%p;
    }
    cout<<ans<<"\n";
}


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

int main(){
  int N,M;
  cin >> N >> M;
  int sum=0;
  for(int i=0; i<M; i++){
    int A;
    cin >> A;
    sum+=A;
  }
  if (sum<=N) {cout << N-sum << endl;}
  else {cout << -1 << endl;}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int maxn=88;
int a[maxn][maxn];
int b[maxn][maxn];
int dp[maxn][maxn*maxn*2];
int c[maxn*maxn*2];
int main()
{
    int x, y;
    cin>>x>>y;
    for(int i=1; i<=x; i++)
        for(int j=1; j<=y; j++)
            cin>>a[i][j];
    for(int i=1; i<=x; i++)
        for(int j=1; j<=y; j++)
        {
            cin>>b[i][j];
            a[i][j]=abs(a[i][j]-b[i][j]);
        }
    for(int i=1; i<=x; i++)
    {
        for(int j=1; j<=y; j++)
        {
            for(int k=0; k<=(x+y)*80; k++)
            {
                if(dp[j][k]==1) c[k+a[i][j]]=1, c[abs(k-a[i][j])]=1;
                if(dp[j-1][k]==1) c[k+a[i][j]]=1, c[abs(k-a[i][j])]=1;
                dp[j][k]=0;
            }
            if(i==1 && j==1) c[a[1][1]]=1;
            for(int k=0; k<=(x+y)*80; k++) if(c[k]==1) {dp[j][k]=1; c[k]=0;}
        }
    }
    for(int i=0; i<=(x+y)*80; i++)
        if(dp[y][i]==1)
        {
            cout<<i<<endl;
            break;
        }
    return 0;
}


Measured memory_bytes: 4864
#include <bits/extc++.h>
using namespace std;
using i64=int64_t;

struct union_find
{
    union_find(const size_t n = 0) : link(n, -1) {}

    size_t find(size_t x)
    {
        assert(x < size());
        return link[x] < 0 ? x : (link[x] = find(link[x]));
    }

    size_t size() const { return link.size(); }

    size_t size(const size_t x)
    {
        assert(x < size());
        return -link[find(x)];
    }

    bool same(const size_t x, const size_t y)
    {
        assert(x < size() && y < size());
        return find(x) == find(y);
    }

    bool unite(size_t x, size_t y)
    {
        assert(x < size() && y < size());
        x = find(x), y = find(y);
        if(x == y) return false;
        if(link[x] > link[y]) std::swap(x, y);
        link[x] += link[y];
        link[y] = x;
        return true;
    }

protected:
    std::vector<int> link;
}; // class union_find


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

    int n; cin>>n;
    bool chkd[1<<20]={};
    bool pw=1;
    bool sw=1;
    int cnt[1<<20]={};
    for(int i=0; i<n; ++i)
    {
        int a; cin>>a;
        cnt[a]++;
    }
    for(int d=2; d<1<<20; ++d)
    {
        if(chkd[d])
        {
            continue;
        }
        int sum=0;
        for(int x=d; x<1<<20; x+=d)
        {
            sum+=cnt[x];
        }
        if(sum>1) pw=0;
        if(sum==n) sw=0;
    }
    if(pw)
    {
        puts("pairwise coprime");
    }
    else if(sw)
    {
        puts("setwise coprime");
    }
    else
    {
        puts("not coprime");
    }
}


Measured memory_bytes: 7740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
  string S;
  cin >> S;

  ll cnt0 = 0;
  ll cnt1 = 0;
  rep(i,0,S.size()){
    if(S[i] == '0') cnt0++;
    if(S[i] == '1') cnt1++;
  }
  cout << 2*min(cnt0,cnt1) << endl;
  return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;// 1000000007;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int p[5];
    int diff[5];
    int k;

    for (int i = 0; i < 5; i++) {
        cin >> p[i];
    }
    cin >> k;

    if (p[4] - p[0] <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

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

const int mod=1e9+7;
const int maxn=1e6+5;
#define ll long long

int f[maxn],g[maxn],r[maxn];

void init()
{
    f[0]=g[0]=f[1]=g[1]=r[1]=1;
    for(int i=2;i<maxn;i++)
    {
        f[i]=(ll)f[i-1]*i%mod;
        r[i]=(ll)(mod-mod/i)*r[mod%i]%mod;
        g[i]=(ll)g[i-1]*r[i]%mod;
    }
}

inline int nCm(int n,int m)
{
    if(m<0 || m>n) return 0;
    return (ll)f[n]*g[m]%mod*g[n-m]%mod;
}

ll qpow(ll a,ll b)
{
    ll res=1;
    for(;b;b>>=1,a=(a*a)%mod) if(b&1) res=(res*a)%mod;
    return res;
}

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

    init();
    int n;cin>>n;

    ll ans=0;
    for(int i=2;i<=n;i++)
    {
        ll res=nCm(n,i);
        res=(res*qpow(8,n-i))%mod;
        res=(res*((qpow(2,i)-2+mod)%mod))%mod;
        ans=(ans+res)%mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 15364
#include<cstdio>
using namespace std;
bool check(int n){
	for(int i = 2; i * i <= n; i++){
		if(n % i == 0) return false;
	}
	return true;
}
int main(){
	int n;
	scanf("%d",&n);
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int a;
		scanf("%d",&a);
		if(check(a)){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

struct SegmentTree{
  ll n=1;
  vll node;

  SegmentTree(vll a){
    ll N=a.size();
    while(n<N)
      n*=2;

    node=vll(2*n-1, -LLINF);
    REP(i, a.size())
      node[n-1+i]=a[i];

    for(ll i=n-2; i>=0; i--)
      node[i]=max(node[2*i+1], node[2*i+2]);
  }


  void update(ll index, ll value){
    ll cur = index+n-1;
    node[cur] = value;
    while(cur>0){
      cur = (cur-1)/2;
      node[cur]=max(node[2*cur+1], node[2*cur+2]);
    }
  }

  ll find(ll qs, ll qe, ll index=0, ll l=0, ll r=-1){
    if(r<0)
      r=n;
    if(r<=qs || qe<= l)
      return -LLINF;
    else if(qs<=l && r<=qe)
      return node[index];

    ll vl = find(qs,qe,2*index+1,l,(l+r)/2);
    ll vr = find(qs,qe,2*index+2,(l+r)/2,r);
    return max(vl, vr);
  }
};


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

  ll n;
  cin>>n;
  vll a(n),h(n);
  REP(i,n)cin>>h[i];
  REP(i,n)cin>>a[i];

  vll dp(n+1,0);
  SegmentTree sg(dp);
  REP(i,n){
    ll now = sg.find(0,h[i]);
    dp[h[i]] = max(dp[h[i]], now+a[i]);
    sg.update(h[i], dp[h[i]]);
  }

  ll ans = sg.find(0,n+1);
  cout<<ans<<endl;

}



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

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

    if (n % 2l == 1l)
    {
        cout << 0 << endl;
    }
    else
    {
        long long answer = 0l;
        n /= 2;
        while (n)
        {
            answer += n / 5;
            n /= 5;
        }

        cout << answer << endl;
    }
}

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

using namespace std;

#define mem(a,i) memset(a,i,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
typedef long long ll;

int main() {
    int a,b;
    while(~scanf("%d%d",&a,&b)) {
        if(b%a==0) printf("%d\n",a+b);
        else printf("%d\n",b-a);
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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 main() {
	string s;cin>>s;
    string ss = s.substr(0,3);
    cout<<ss<<endl;
    }

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<deque>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef deque<int> di;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int i,j;
    int n,m;
    cin >> n >> m;
    vi v(m);
    int ans = 0;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        v[i] = max(0LL,(b-a)/2);
    }
    sort(all(v));
    rep(i,m-1)ans += v[i];
    cout << ans << endl;
}



Measured memory_bytes: 3148
// https://qiita.com/pinokions009/items/1e98252718eeeeb5c9ab
// 「0以上N以下の整数で、いずれかの桁に3を含むものの個数を求めよ」

#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, Q;
	cin >> N >> Q;
	multiset<int> se;
	vector<pair<P, int>> vec;
	int a, b, c;
	rep(i,N){
		cin >> a >> b >> c;
		vec.push_back({P(a-c, 0), c});
		vec.push_back({P(b-c, -1),  c});
	}
	rep(i,Q){
		cin >> a;
		vec.push_back({P(a, 1), i});
	}
	int res[Q];
	sort(vec.begin(), vec.end());
	for(auto v : vec){
		int time = v.first.first;
		int query = v.first.second;
		int place = v.second;
		if(query == 0) se.insert(place);
		else if(query == -1) se.erase(place);
		else res[place] = (se.empty() ? -1 : *(se.begin()));
	}
	for(auto v : res){
		cout << v << endl;
	}

}

Measured memory_bytes: 26984
S = input()
MM = ["01", "02", "03", "04", "05","06", "07", "08", "09", "10", "11", "12"]

type = 0;
if(S[0:2] in MM):
  type += 1
if(S[2:] in MM):
  type += 2

if(type == 0):
  print("NA")
elif(type == 1):
  print("MMYY")
elif(type == 2):
  print("YYMM")
else:
  print("AMBIGUOUS")

Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            array.add(sc.nextInt());
        }
        int max = 0;
        for (int i = 0; i < n - 1 ; i++) {
            if ((array.get(i + 1) - array.get(i)) > max){
                max = (array.get(i + 1) - array.get(i));
            }
        }
        int b = array.get(0) + (k - array.get(n - 1));
        max = max < b ? b : max;
        System.out.println(k - max);
    }
}

Measured memory_bytes: 88360
#include <iostream>
#include <map>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <cstdio>
#include <set>

using namespace std;

typedef long long ll;

inline int getInt(){ int s; scanf("%d", &s); return s; }
inline ll getLL(){ ll s; scanf("%lld", &s); return s; }

int main(){
  const int n = getInt();
  const ll k = getLL();
  vector<int> a(n);
  REP(i,n) a[i] = getInt();

  map<int, int> m;
  vector<int> next(n);
  REP(_,2){
    REP(j,n){
      const int i = n - 1 - j;
      next[i] = m[a[i]];
      m[a[i]] = i;
    }
  }

  vector<ll> dp(n, -1);
  int index = 0;
  ll loop = 0;

  while(true){
    // printf("!%d %d\n", loop, index);
    if(loop == k - 1){
      break;
    }
    if(dp[index] != -1){
      const ll lastLoop = dp[index];
      const ll diff = loop - lastLoop;
      loop += diff * ((k - 1 - loop) / diff);
      while(loop < k - 1){
	const int i = next[index];
	if(i <= index || i == n - 1) loop++;
	if(i == n - 1 && index == n - 1) loop++;
	index = (i + 1) % n;
      }
      break;
    }else{
      dp[index] = loop;

      const int i = next[index];
      if(i <= index || i == n - 1) loop++;
      if(i == n - 1 && index == n - 1) loop++;
      index = (i + 1) % n;
    }
  }

  set<int> s;
  vector<int> ans;
  if(loop != k){
    for(int i = index; i < n; i++){
      if(s.count(a[i])){
	while(true){
	  const int t = ans.back();
	  ans.pop_back();
	  s.erase(t);
	  if(t == a[i]) break;
	}
      }else{
	ans.push_back(a[i]);
	s.insert(a[i]);
      }
    }
  }

  REP(i,ans.size()){
    if(i) printf(" ");
    printf("%d", ans[i]);
  }
  puts("");

  return 0;
}

Measured memory_bytes: 24180
s=input()
x=s[0]
for i in range(1,len(s)):
    if(s[i]==x):
        print(i,i+1)
        exit()
    elif(s[i-2]==s[i] and i-2>=0):
        print(i-1,i+1)
        exit()
    x=s[i]
print(-1,-1)

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

int main()
{
	int number;
	while(scanf("%d",&number)!=EOF)
	{
		int a=number/1000;//千位
		int b=(number/100)%10;//百位
		int c=(number/10)%10;//十位
		int d=number%10;//个位
		if(a+b+c+d==7)
		{
			printf("%d+%d+%d+%d=7\n",a,b,c,d);	
		} 
		else if(a-b+c+d==7)
		{
			printf("%d-%d+%d+%d=7\n",a,b,c,d);	
		}
		else if(a+b-c+d==7)
		{
			printf("%d+%d-%d+%d=7\n",a,b,c,d);	
		}
		else if(a+b+c-d==7)
		{
			printf("%d+%d+%d-%d=7\n",a,b,c,d);	
		}
		else if(a-b-c+d==7)
		{
			printf("%d-%d-%d+%d=7\n",a,b,c,d);	
		}
		else if(a-b+c-d==7)
		{
			printf("%d-%d+%d-%d=7\n",a,b,c,d);	
		}
		else if(a+b-c-d==7)
		{
			printf("%d+%d-%d-%d=7\n",a,b,c,d);	
		}
		else if(a-b-c-d==7)
		{
			printf("%d-%d-%d-%d=7\n",a,b,c,d);	
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a = n % 10 * 100 + n / 10 % 10 * 10 + n / 100;
    if(n == a){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  rep(i, 0, N) { cin >> w[i] >> v[i]; }
  vector<int> dp(W + 1, 0);
  rep(i, 0, N) {
    rrep(j, w[i], W + 1) { chmax(dp[j], dp[j - w[i]] + v[i]); }
  }
  cout<<dp[W]<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
string change(char x){
    if(x == 'T')return "a";
    if(x == 'L')return "i";
    if(x == 'U')return "u";
    if(x == 'R')return "e";
    if(x == 'D')return "o";
}
int main(){
    char str[1024]={0};
    scanf("%s",str);
    int len = strlen(str);
    char con[] = {'w',' ','k','s','t','n','h','m','y','r'};
    string ans = "";
    for(int i = 0;i < len;i+=2){
        if(str[i] == '1'){
           ans += change(str[i+1]); 
        }
        else if(str[i] == '0' && str[i+1] == 'U')ans += "nn";
        else{
            ans += con[str[i]-48];
            ans += change(str[i+1]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1208