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

using namespace std;

set<int> s;

bool check(int n)
{
	while (n > 0)
	{
		if (!s.count(n % 10))
			return false;
		n /= 10;
	}

	return true;
}

signed main()
{
	int n, k, temp;
	cin >> n >> k;
	for (int i = 0; i  < 10; i++)
		s.insert(i);

	for (int i = 0; i < k; i++)
	{
		cin >> temp;
		s.erase(temp);
	}

	while (!check(n))
		n++;
	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;
int main()
{
	//unsigned long long int a, b, c, d, e, ans = 0,n,x[19],c[19],v[19];
	int a, b, c, d, e, f = 0, ans = 0, n,m;
	// 整数の入力
	int num[100000];
	unsigned long long x, y;
	// 文字列の入力
	//	string s;
	cin >> n ;
	b = 0;
	while (1)
	{
		if (n>=3&&n<=5)
		{
			b++;
			break;
		}
		else if (n>=6)
		{
			n -= 3;
			b++;
		}
		else
		{
			break;
		}

	}
	cout << b << endl;


	
	// 出力
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int cnt = 0;
  rep(i,N){
    cin >> A.at(i);
    if(i%2 == 0 && A.at(i)%2 == 1){
      cnt++;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3628
// problem: "https://atcoder.jp/contests/abc154/tasks/abc154_a"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s1,s2;
    cin>>s1>>s2;

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

    string s3;
    cin>>s3;

    if(s3 == s1)
        cout<<a-1<<' '<<b;
    else
        cout<<a<<' '<<b-1;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.blood", "r", stdin);
	string str = "";
	map<string, int> B;

	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		while (str.find(',') != string::npos ){
			str = str.replace(str.find(','), 1, " ");
		} // end while
		stringstream ss(str);
		int n;
		string blood;
		ss >> n >> blood;
		++B[blood];		
	} // end loop
	vector <int> res (4, 0);
	map <string, int>::iterator it = B.begin();
	int i;

	for (i = 0; it != B.end(); ++it, ++i){
		res[i] = (*it).second;
	} // end for
	
	swap (res[1], res[2]);
	for (i = 0; i < 4; ++i){
		cout << res[i] << endl;	
	} // end for

	return 0;
}

Measured memory_bytes: 0
#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 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; 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
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int k,n;
string s;
signed main(){
	
	cin>>s>>n;
	rep(i,s.size()){
		if(s[i]!='a'&& n-(int)('z'-s[i]+1)>=0){
			n-='z'-s[i]+1;
			s[i]='a';
		}
	}
	s[s.size()-1]+=n%26;
	cout<<s<<endl;
}


Measured memory_bytes: 512
"""
 // Author : snape_here - Susanta Mukherjee
 // Date : 27/07/2019

"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading


# For getting input from input.txt file 
#sys.stdin = open('input.txt', 'r')  
  
# Printing the Output to output.txt file 
#sys.stdout = open('output.txt', 'w') 

def ii(): return int(input())
def fi(): return float(input())
def si(): return str(input())
def mi(): return map(int,input().split())
def li(): return list(mi())

def main():
    
    n=ii()
    p=li()
    l=sorted(p)
    c=0
    for i in range(n):
        if p[i]==l[i]:
            c+=1
    if c==n or c==n-2:
        print("YES")
    else:
        print("NO")
    
    
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

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

int main()
{
  int64_t n, a, b;
  cin >> n >> a >> b;
  
  int64_t d = n / (a + b);
  int64_t m = n % (a + b);
  
  if (m >= a) m = a;
  
  cout << d * a + m;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;cin>>N;
    bool ans=false;
    for(long long h=N/4+1;h<=(3*N)/4;h++){
        for(long long n=h;n<=(2*N*h)/(4*h-N);n++){
            if((4*h*n-N*n-N*h)>0 && (N*h*n)%(4*h*n-N*n-N*h)==0 && (N*h*n)/(4*h*n-N*n-N*h)<3501){
                cout<<h<<' '<<n<<' '<<(N*h*n)/(4*h*n-N*n-N*h)<<endl;
                ans=true;
                break;
            }
        }
        if(ans)break;
    }
}

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

using namespace std;

int main(){

  int a[10];
  while(cin>>a[0]){
    for(int i=1;i<10;i++)cin>>a[i];
    sort(a,a+10,greater<int>());
    for(int i=0;i<3;i++)
      cout<<a[i]<<endl;
  }
  

  return 0;
}

Measured memory_bytes: 1180
import copy
def change(k):
  if k==0:
    return int(1)
  else:
    return int(0)
t=0
m=0
S=list(map(int,list(input())))
M=copy.copy(S)
T=copy.copy(S)
N=len(S)
for i in range(N):
  if i==0:
    if T[i]==0:
      t+=1
      T[0]=1
    else:
      m+=1
      M[0]=0
  else:
    if T[i]==T[i-1]:
      T[i]=change(T[i])
      t+=1
    if M[i]==M[i-1]:
      M[i]=change(M[i])
      m+=1
print(min(t,m))

Measured memory_bytes: 11476
#include <iostream>                                             
using namespace std;
 
int late[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
int colors[9] = {0};
int N;
 
int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    int tmp;
    bool flag = true;
    cin >> tmp;
    for(int j = 0; j < 8; j++){
      if(tmp < late[j]){
        colors[j]++;
        flag = false;
        break;
      }   
    }   
    if(flag) colors[8]++;
  }
  int count = 0;
  for(int i = 0; i < 8; i++)
    if(colors[i]>0) count++;
  if(count > 0) cout << count << ' ' << count+colors[8] << endl;  else cout << 1 << ' ' << colors[8] << endl;
  return 0;
}


Measured memory_bytes: 256
def f(x):
  r=[0,0]
  n=x
  while x%2==0:
    r[0]+=1
    x//=2
  while x%5==0:
    r[1]+=1
    x//=5
  return r

N=int(input())
A=[input() for i in range(N)]
for i in range(N):
  if not('.' in A[i]):
    A[i]=int(A[i])*10**9
  else:
    A[i]=list(A[i].split('.'))
    A[i]=int(A[i][0])*10**9+int(A[i][1])*10**(9-len(A[i][1]))
for i in range(N):
  A[i]=f(A[i])
X=[[0]*50 for i in range(50)]
for i in range(N):
  X[A[i][0]][A[i][1]]+=1
C=[[0]*51 for i in range(51)]
for i in range(50):
  for j in range(50):
    C[i+1][j+1]=C[i+1][j]+C[i][j+1]-C[i][j]+X[i][j]
P=0
for i in range(N):
  A[i]=[max(18-A[i][0],0),max(18-A[i][1],0)]
  P+=C[-1][-1]-C[-1][A[i][1]]-C[A[i][0]][-1]+C[A[i][0]][A[i][1]]
  if max(A[i])<=9:
    P-=1
print(P//2)


Measured memory_bytes: 135308
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int L, R, d; cin >> L >> R >> d;
    cout << R/d - (L-1)/d;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
char h[1000][1000];
int s[1000],ans1[1000],ans2[1000];
int main(){
	int n,flag = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%s",h[i]);
		s[i] = strlen(h[i]);
	}
	for(int i = 49;i <=74;i++)
		ans2[i] = 10000000;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < s[i];j++)
	    	ans1[h[i][j] - '0']++;
		for(int k = 49;k <= 74;k++)
			ans2[k] = min(ans1[k],ans2[k]);
		memset(ans1,0,sizeof(ans1));
	}
	char p;
	for(int i = 49;i <= 74;i++)
		if(ans2[i] != 0)
			for(int j = 1;j <= ans2[i];j++){
				flag = 1;
				printf("%c",i + '0');
			}
	if(flag == 0) printf("\n");
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define f first
#define s second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, a[N], b[N], p[N], d[N], c[N], A[N], B[N];
bool used[N];                     
vector <int> v[N], ord;

void dfs(int u){
	if(used[u])
		return;
	used[u] = 1;
	for(auto to : v[u])
		dfs(to);
	ord.pb(u);
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	//cout << setprecision(2) << fixed;
	
	cin >> n;

	for(int i = 1; i <= n; ++i)
		cin >> p[i];

	for(int i = 1; i < n; ++i){
			v[p[i]].pb(p[i + 1]);
	}	
	
	for(int i = 1; i <= n; ++i)
		dfs(i);

	reverse(all(ord));

	for(int i = 1; i <= n; ++i){
		c[ord[i - 1]] = i;
	}
		               
   	for(int i = 1; i <= n; ++i){
   		d[i] = c[i] - c[i - 1];
   	}

   	for(int i = 1; i <= n; ++i){
   		if(d[i] == 0){
			A[i] = 1, B[i] = 1;
   		}else if(d[i] < 0){
   			A[i] = 1, B[i] = 1 - d[i];
   		}else if(d[i] > 0){
   			A[i] = d[i] + 1, B[i] = 1;
   		}
   	}

   	a[1] = 1;

   	for(int i = 2; i <= n; ++i){
   		a[i] = a[i - 1] + A[i];
	}


	b[n] = 1;

   	for(int i = n - 1; i >= 1; --i){
   		b[i] = b[i + 1] + B[i + 1];
	}

	for(int i = 1; i < n; ++i){
		if(a[p[i]] + b[p[i]] >= a[p[i + 1]] + b[p[i + 1]]){
			cout << "OK" << endl;
		}
	}

	for(int i = 1; i <= n; ++i)
		cout << a[i] << " ";
	cout << endl;

   	for(int i = 1; i <= n; ++i)
   		cout << b[i] << " ";
	     	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}

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

int main(void){
  int x, b, p, max = 0;
  cin >> x;
  if(x == 1 || x == 2 || x == 3){
    cout << 1 << endl;
    return 0;
  }

  for(b = 2; b < x; b++){
    for(p = 2; pow(b, p) <= x; p++){
      if(max < pow(b, p)) max = pow(b, p);
    }
  }
  cout << max << endl;
  return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<vector<int>> A(N,vector<int>(2));
  rep(i,N) {
    A[i][1]=i+1;//出席番号
    cin>>A[i][0];//その人が何番目に来たか
  }
  sort(A.begin(),A.end());
  rep(i,N){
    cout<<A[i][1];
    if(i<=N-2) cout<<' ';
    else cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int A,B;cin >> A >> B;
    int tmp1,tmp2,tmp3;   
    tmp1 = A+B;
    tmp2 = A-B;
    tmp3 = A*B;
    int ans = max(tmp1,tmp2);
    ans = max(ans,tmp3);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
static const double EPS = 1e-7;

int main()
{
  int T;
  scanf("%d", &T);
  double maxE = 0.0;
  while (T-- > 0) {
    int N, M;
    scanf("%d %d", &N, &M);
    vector<double> vs(M), rs(M);
    double R = 0.0;
    for (int i = 0; i < M; i++) {
      scanf("%lf %lf", &vs[i], &rs[i]);
      R += rs[i];
    }
    maxE = max(maxE, inner_product(vs.begin(), vs.end(), rs.begin(), 0.0) / R);
  }

  int P, Q;
  scanf("%d %d", &P, &Q);
  vector<double> vs(Q), rs(Q);
  double R = 0.0;
  for (int i = 0; i < Q; i++) {
    scanf("%lf %lf", &vs[i], &rs[i]);
    R += rs[i];
  }

  const double E = inner_product(vs.begin(), vs.end(), rs.begin(), 0.0) / R;
  if (maxE - E > EPS) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int color[9] = { 0 };
	for (int i = 0; i < n; i++) {
		if (a[i] < 400)
			color[0]++;
		else if (a[i] < 800)
			color[1]++;
		else if (a[i] < 1200)
			color[2]++;
		else if (a[i] < 1600)
			color[3]++;
		else if (a[i] < 2000)
			color[4]++;
		else if (a[i] < 2400)
			color[5]++;
		else if (a[i] < 2800)
			color[6]++;
		else if (a[i] < 3200)
			color[7]++;
		else
			color[8]++;
	}
	int ans = 0;
	for (int i = 0; i < 8; i++)
		if (color[i] > 0)
			ans++;
	if (ans == 0) {
		cout << 1 << " " << color[8] << endl;
		return 0;
	}
	cout << ans << " " << ans + color[8] << endl;
	return 0;
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System
Module C
    Sub Main(ByVal args() As String)
        Dim s As String
        Dim n, i, maxcnt As Integer
        Dim list As List(Of String)
        Dim item As String
        Dim dict As New Dictionary(Of String, Integer)
        Dim kvp As KeyValuePair(Of String, Integer)
        n = Integer.Parse(Console.ReadLine())
        maxcnt = 0
        For i = 1 To n
            s = Console.ReadLine()
            If dict.ContainsKey(s) Then
                dict(s) += 1
            Else
                dict.Add(s, 1)
            End If
            maxcnt = Math.Max(maxcnt, dict(s))
        Next
        If maxcnt > 1 Then
            List = New List(Of String)
            For Each kvp In dict
                If kvp.Value = maxcnt Then list.Add(kvp.Key)
            Next
        Else
            List = New List(Of String)(dict.Keys)
        End If
        list.Sort(StringComparer.Ordinal)
        For Each item In List
            Console.WriteLine(item)
        Next
    End Sub
End Module

Measured memory_bytes: 40796
#関数リスト
import sys
input = sys.stdin.readline


def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))

def main():
    A, B, C, X, Y = MI()
    result = float('inf')
    result = min(result,int(A*X+B*Y))
    temp = min(X,Y)
    result = min(result,int(C*temp*2+(X-temp)*A+(Y-temp)*B))
    result = min(result, int(max(X, Y)*C*2))
    print(result)
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 62072
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = a[1]
for i in range(1, n-1):
  if abs(a[0]/2 - a[i]) > abs(a[0]/2 - a[i+1]):
    ans = a[i+1]
  else:
    break
print(a[0], ans)

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

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

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  string s;
  cin>>s;
  
  int year=stoi(s.substr(0,4));
  int mon=stoi(s.substr(5,7));
  int day=stoi(s.substr(8,10));
  string ans="Heisei";
  if(year>2019)ans="TBD";
  else if(year==2019){
    if(mon>4)ans="TBD";
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 125568
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int n,m;
        scanf("%d %d",&n,&m);
        int a[n][m];
        int b[m];
        for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                        scanf("%d",&a[i][j]);
                }
        }
        for(int i=0;i<m;i++){
                scanf("%d",&b[i]);
        }
        for(int i=0;i<n;i++){
                int ans=0;
                for(int j=0;j<m;j++){
                        ans+=a[i][j]*b[j];
                }
                printf("%d\n",ans);
        }
        return 0;
}

Measured memory_bytes: 1212
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class B {
        long a = 0;
        long b = 0;
        long x = 0;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            a = Long.parseLong(in.next());
            b = Long.parseLong(in.next());
            x = Long.parseLong(in.next());
            long ans = 0;

            ans = f(b) - f(a - 1);
            out.println(ans);
        }

        public long f(long n) {
            long res = 0;
            if (n >= 0) {
                res = n / x + 1;
            }
            return res;
        }

    }
}



Measured memory_bytes: 24020
N, L = map(int, input().split())

apple_azi = [L + (x + 1) - 1 for x in range(N)]

original_pai = sum(apple_azi)

test = []
for i in apple_azi:
    # print(original_pai - i)
    test.append(abs(original_pai - (original_pai - i)))

tabeta_azi = min(test)

if original_pai >= 0:
    print(original_pai - tabeta_azi)
else:
    print(original_pai + tabeta_azi)

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

using namespace std;

int main() {
    long long d, n, m;
    cin >> n >> m >> d;

    double y = 0;
    if(d == 0) {
        y = n-d;
    } else {
        y = 2*(n-d);
    }

    double x = y / (n * n);
    double ans = 0;
    for(int i = 0; i < m-1; i++) {
        ans += x;
    }
    printf("%.12lf\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  double sum=0.0;
  
  vector<double> nums(N);
  vector<double> revs(N);
  
  for(int i=0; i<N; i++){
  	cin >> nums[i];
    revs[i] = 1 / nums[i];
    sum += revs[i];
  }
  
  cout << 1 / sum;
  
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program
{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        bool[,] adja = new bool[n, n];
        for (int i = 0; i < n; i++)
        {
            int[] inputs = Console.ReadLine().Split(' ')
                                        .Select(val => int.Parse(val))
                                        .ToArray();
            for (int j = 0; j < inputs[1]; j++)
            {
                adja[inputs[0] - 1, inputs[2 + j] - 1] = true;
            }
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if(j != 0) Console.Write(" ");
                Console.Write(adja[i, j] ? 1 : 0);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9720
n, m = map(int, input().split())
xy = [[int(x) - 1 for x in input().split()] for _ in range(m)]
a = [[1, 0] for _ in range(n)]
a[0][1] = 1
for x, y in xy:
    if a[x][1] == 1:
        a[y][1] = 1
        if a[x][0] == 1: a[x][1] = 0
    a[x][0] -= 1
    a[y][0] += 1
print(sum([int(i[1]) for i in a]))

Measured memory_bytes: 32264
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int A, B, C;
  cin>>A>>B>>C;

  Yes(A==B and B==C);

  return 0;
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

constexpr int mod = 1e9 + 7;

// mを法とするaの逆元
// O(log a)
inline LL invMod(LL a, LL m = mod) {
	LL b = m, u = 1, v = 0;
	while (b) {
		LL t = a / b;
		swap(a -= t * b, b);
		swap(u -= t * v, v);
	}
	return (u % m + m) % m;
}


// 階乗
// O(n)
constexpr int SZ = 1123456;
LL fact[SZ];
LL rfact[SZ];
struct fact_ {
	fact_() {
		fact[0] = 1;
		for (int i = 1; i<SZ; i++)
			fact[i] = fact[i - 1] * i%mod;
		rfact[SZ - 1] = invMod(fact[SZ - 1]);
		for (int i = SZ - 1; i>0; i--) {
			rfact[i - 1] = rfact[i] * i%mod;
		}
	}
}fact_init;


// 組み合わせnCk (mod mod)
// O(1)
LL Comb(LL n, LL k) {
	LL u = fact[n];
	LL d = (rfact[k] * rfact[n - k]) % mod;
	return u * d%mod;
}

//O(1)
LL Perm(LL n, LL k) {
	LL u = fact[n];
	LL d = rfact[n - k] % mod;
	return u * d%mod;
}

LL f(int a, int b) {
	b -= a;
	a--;
	if (a < 0 || b < 0 || b > a)return 0;
	else return Comb(a, b);
}

int main() {
	int N;
	while (cin >> N) {
		LL ret = 0;
		for (int k : range(1, N)) {
			LL x = f(k, N - 1) * fact[k] % mod;
			LL y = f(k - 1, N - 1) * fact[k - 1] % mod;
			y = y * (N - k) % mod;
			x = (x - y + mod) % mod;
			x = x * fact[N - 1 - k] % mod;
			ret += k * x%mod;
		}
		ret %= mod;
		cout << ret<< endl;
	}
	return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VL> VVL;

VI tsort(int N, int M, VL &x, VL &y, VVI &graph, VI &v) {
    stack<int> no_input_node;
    REP(i, N) {
        if(!v[i]) no_input_node.push(i);
    }
    VI ans;
    while(no_input_node.size()) {
        int node = no_input_node.top();
        no_input_node.pop();
        ans.push_back(node);
        for (auto &j : graph[node]) {
            v[j]--;
            if(!v[j]) no_input_node.push(j);
        }
    }
    return ans;

}

ll Main(int N, int M, VL &x, VL &y) {
    VVI graph(N, VI(0, 0));
    VI v(N, 0);
    REP(i, M) {
        graph[x[i]-1].push_back(y[i]-1);
        v[y[i]-1]++;
    }
    VI tsorted = tsort(N, M, x, y, graph, v);
    VL dp(N, 0);
    ll mx = 0;
    for (auto &i : tsorted) {
        for (auto &j : graph[i]) {
            dp[j] = max(dp[j], dp[i] + 1);
            mx = max(mx, dp[j]);
        }
    }
    return mx;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    VL x(M), y(M);
    REP(i, M) cin >> x[i] >> y[i];
    cout << Main(N, M, x, y) << endl;
    return 0;
}

Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

int main(){
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    a1 *= t1; 
    a2 *= t2;
    b1 *= t1;
    b2 *= t2;
    if (a1 + a2 == b1 + b2){
        cout << "infinity" << endl;
        return 0;
    }else if (a1 + a2 < b1 + b2){
        swap(a1, b1);
        swap(a2, b2);
    }

    if (a1 < b1){
        ll c = b1 - a1;
        ll d = (a1 + a2) - (b1 + b2);
        ll ans = (c / d) * 2;
        if (c % d != 0) ans++;
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3512
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
        int N;
        scanf("%d", &N);
        if ( N <= 999){
                printf("ABC\n");
        }
        else if (N >= 1000) {
                printf("ABD\n");
        }
        return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int32_t main(){
    fast;
    int N{},sum{};    cin>>N;
    int T[N]{};       for(int i=0;i<N;i++){cin>>T[i]; sum+=T[i];}
    int M{};          cin>>M;
    while(M--){
        int i{},t{},temp{};    cin>>i>>t;
        temp = sum;
        temp = temp - T[i-1] + t;
        cout<<temp<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int	x,a,b,c,d,e,f;
	scanf("%d",&x);
	c=x%500;
	if(x%500==0){
		a=x/500;
		b=a*1000;
		printf("%d\n",b);
	}
	else if(c%5<5){
		a=x/500;
		b=a*1000;
		d=c/5;
		e=d*5;
		f=b+e;
		printf("%d\n",f);
	}
	return 0;
}

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

int main() {

  string s;
  cin>> s;
  
  int c=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='x'){
      c++;
    }
  }
  
  if(c<8){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		// 読み込み
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		N = N-1;
		long div = N;
		int mod = 0;
		
		List<Integer> list = new ArrayList<>();
		
		while(true) {
			mod = (int) (div % 26);
			div = div / 26;
			
			list.add(mod);
			
			if(div == 0) {
				break;
			}
			else {
				div = div -1;
			}
		}
		
		Collections.reverse(list);
				
		StringBuilder sb = new StringBuilder();
		
		for(int i : list) {
			char c = (char) (97 + i);
			sb.append(c);
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 27056
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    string s,s1;cin>>s>>s1;
    int i=0,j=0;
    while(i<s.size() and j<s1.size())
    {
    	cout<<s[i++]<<s1[j++];
    }
    if(s.size()>s1.size()){
    	cout<<s.back();
    }
    else if(s.size()<s1.size()){
    	cout<<s1.back();
    }
    return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
	d=a;
	for(register int i=1;i<=100000;++i){
		if(a%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
		a+=d;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define LL long long

int N,W;
LL dp[100005],ans;

int main()
{
	
	cin>>N>>W;
	for(int i=1;i<=N;i++)
	{
		int w,v;
		cin>>w>>v;
		for(int j=W-w;j>=0;j--)
			dp[j+w]=max(dp[j+w],dp[j]+v);
	}
	for(int i=0;i<=W;i++)
		ans=max(ans,dp[i]);
	cout<<ans<<'\n';
	
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,K;
    cin >> N >> K;
    vl A(N);
    rep(i, N){
        cin >> A[i];
    }
    vl ac(N+1, 0);
    // 累積和の各要素で１ずつ引くとindex分だけ引ける
    rep(i, N) ac[i + 1] = (ac[i] + A[i] - 1) % K;

    map<ll,ll> m;
    ll ans = 0;
    rep(i,N+1){
        if (i >= K) m[ac[i - K]]--;
        ans += m[ac[i]]++;
    }

    cout << ans << endl;
    
    

    



    

}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

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

	fx(S.size()) {
		S[x] += N;
		if (S[x]>'Z') {
			S[x] -= 'Z' - 'A' + 1;
		}
	}
	ce(S)

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct Circle {
    double x, y, r;
};


int CommonTangent(Circle c1, Circle c2) {
    double x1, y1, r1, x2, y2, r2;
    x1 = c1.x, y1 = c1.y, r1 = c1.r;
    x2 = c2.x, y2 = c2.y, r2 = c2.r;
    double d = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
    if (d > (r1 + r2) * (r1 + r2)) return 4;
    if (d == (r1 + r2) * (r1 + r2)) return 3;
    if (d > (r1 - r2) * (r1 - r2)) return 2;
    if (d == (r1 - r2) * (r1 - r2)) return 1;
    return 0;
}

int main() {
    cout << fixed << setprecision(20);
    Circle c1, c2;
    cin >> c1.x >> c1.y >> c1.r;
    cin >> c2.x >> c2.y >> c2.r;
    cout << CommonTangent(c1, c2) << endl;
}


Measured memory_bytes: 3228
import sys
n1 = int(input())
n2 =  [int(i) for i in input().split()]

t1 = 0
for i1 in range(n1):
    if i1 == 0:
        if n2[i1] == 1:
            t1 = 1
        else:
            t1 = n2[i1] - 1
    else:
        if n2[i1] < t1:
            print("No")
            sys.exit()
        else:
            t1 = max(t1, (n2[i1] - 1))
print("Yes")

Measured memory_bytes: 14396
#include <iostream>//
#include <cstdio>
#include <cmath>

using namespace std;
int a, b, x, max_cap;
long double bound;

bool c(long double ang) {
    if (ang < bound) {
        long double h = a * tan(ang);
        long double cap = h * a * a * 0.5;
        cap = max_cap - cap;

 

        if (x > cap) {
            return false;
        } else return true;
    } else {
        long double h = b / tan(ang);
        long double cap = a * b * h * 0.5;



        if (x > cap)
            return false;
        else return true;
    }
}

int main() {
    cin >> a >> b >> x;
    max_cap = a * a * b;

    long double lb = 0.0, ub = M_PI / 2;
    bound = atan((long double)b / a);
    for (int i = 0; i < 100; ++i) {
        long double mid = (lb + ub) / 2.0;
        if (c(mid)) lb = mid;
        else ub = mid;
    }

    printf("%.10Lf\n", 180 * ub / M_PI);

    return 0;
}// Created by Kevin Weng on 2019/10/30.
//



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

string s[110];
int n;
map<string, int> mp;
int main(){
  cin >> n;
  cin >> s[0];
  mp[s[0]]++;

  for(int i = 1;i < n;i++){
    cin >> s[i];
    if(s[i-1][s[i-1].size()-1] != s[i][0] || mp[s[i]] == 1){
      cout << "No" << endl;
      return 0;
    }
    mp[s[i]]++;
  }

  cout << "Yes" << endl;
  return 0;
}


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

int n,x,y,z;
typedef long long ll;
const int N = 41, MAXM = (1 << 18) + 50, mod = (int)1e9 + 7;

map<vector<int>, int> mp;

int cnt = 0;
int dp[N][MAXM];
int nxt[MAXM][11];
bool haiku[MAXM];

//vector<vector<int> > seqs;

int cumul(vector<int> &V, int cur, int sum) {
    while(cur < V.size() && sum > 0) sum -= V[cur], cur++;
    if(sum != 0) return -1;
    return cur;
}

bool is_haiku(vector<int> &V) {
    int sum = 0;
    for(int x : V) sum += x;
    if(sum != x + y + z) return false;
    int cur = 0;
    if((cur = cumul(V, cur, x)) == -1) return false;
    if((cur = cumul(V, cur, y)) == -1) return false;
    return cumul(V, cur, z) != -1;
}

int get(vector<int> &V) {
    if(!mp.count(V)) {
        haiku[cnt] = is_haiku(V);
//        seqs.push_back(V);
        mp[V] = cnt++;
    }
    return mp[V];
}

void add(int &to, int x) {
    to += x;
    if(to >= mod) to -= mod;
}

string tostr(vector<int> &V) {
    string s;
    for(int x : V) s.push_back((char)(x + '0'));
    return s;
}

int main() {
    cin >> n >> x >> y >> z;
    int mn = max(x, max(y, z));
    vector<int> V;
    int id0 = get(V);
    for(int i = 1; i <= mn; i++) {
        vector<int> nV(1, i);
        nxt[id0][i] = get(nV);
    }
    for(int len = 1; len <= x + y + z; len++) {
        for(int i = 0; i < (1 << (len-1)); i++) {
            vector<int> sV;
            int cur = 1;
            bool bad = false;
            for(int j = 0; j < len - 1; j++) {
                if((i >> j) & 1) {
                    if(cur > mn) {
                        bad = true;
                        break;
                    }
                    sV.push_back(cur), cur = 1;
                }
                else cur++;
            }
            if(cur > mn || bad) continue;
            sV.push_back(cur);

            int c_id = get(sV);
            for(int k = 1; k <= mn; k++) {
                vector<int> nV;
                nV.push_back(k);
                nV.insert(nV.end(), sV.begin(), sV.end());
                int sum = len + k;
                while(!nV.empty() && sum > x + y + z) {
                    sum -= nV.back();
                    nV.pop_back();
                }
                nxt[c_id][k] = get(nV);
            }
        }
    }

//    for(int i = 0; i < cnt; i++) {
//        for(int x : seqs[i]) cout << x << " ";
//        cout << endl;
//    }

//    cout << cnt << endl;
//    for(int i = 0; i < cnt; i++) {
//        cout << "nxts of " << tostr(seqs[i]) << endl;
//        if(haiku[i]) cout << "is haiku" << endl;
//        for(int k = 1; k <= 10; k++) cout << k << ": " << tostr(seqs[nxt[i][k]]) << endl;
//    }

    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < cnt; j++) {
            if(haiku[j]) continue;
            for(int k = 1; k <= 10; k++) add(dp[i][nxt[j][k]], dp[i-1][j]);
        }
    }
    ll res = 1;
    for(int i = 0; i < n; i++) res *= 10, res %= mod;
    int f_res = 0;
    for(int i = 0; i < cnt; i++) if(!haiku[i]) add(f_res, dp[n][i]);
    cout << (res - f_res + mod) % mod << endl;

}

Measured memory_bytes: 65024
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

template <typename T>
struct hash_map_t {
    vector <T> v, val, nxt;
    vector <int> head;
    int mod, tot, lastv;
    T lastans;
    bool have_ans;

    hash_map_t (int md = 0) {
        head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;
        nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);
        have_ans = 0;
    }

    void clear() { *this = hash_map_t(mod); }

    bool count(int x) {
        int u = x % mod;
        for(register int i = head[u]; i; i = nxt[i]) {
            if(v[i] == x) {
                have_ans = 1;
                lastv = x;
                lastans = val[i];
                return 1;
            }
        }
        return 0;
    }

    void ins(int x, int y) {
        int u = x % mod;
        nxt.push_back(head[u]); head[u] = ++tot;
        v.push_back(x); val.push_back(y);
    }

    int qry(int x) {
        if(have_ans && lastv == x) return lastans;
        count(x);
        return lastans;
    }
};

int n, ans;

inline int calc(int x) {
    int res = 0;
    while(x) {
        ++res;
        x /= 10;
    }
    return res;
}

int main() {
    read(n);
    for(register int i = 1; i <= n; i++) {
        if(calc(i) & 1) ++ans;
    }
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  int n;
  cin >> n;
  string s;
  cin >> s;
  
  int ans = 0;
  int c = 0;
  for(int i = 0; i < n; i++) {
    if(s.at(i) == 'I') {
      c++;
    } else {
      c--;
    }
    ans = max(ans,c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}
bool cmp(pair < int , string >   a , pair < int , string >   b){
  if(a.first < b.first ) return true;
  else return false;
}
int ans=0;
void solve(int n , int val , int r , int x  , int y){
  //cout << n << " " << val << "++\n";
  if(val > r) return;
  if(n == -1) {
    int k = val&x;
    int kk = val&y;
    //cout << val << " " << k << " " << kk  << "+++\n";
    if(((val&x) !=0) && ((val&y)!=0)){
      if(ans==0) ans =val;
      else if(log(ans&x) + log(ans&y) < log(val&x) + log(val&y)) ans=val;
      else if(log(ans&x) + log(ans&y) == log(val&x) + log(val&y)){
       // cout << ans << " " << val << "++\n";
        if(ans > val) ans=val;
      }
    }
    return;
  }
  int m = val + (1LL<<n);
  solve(n-1,m,r , x,y);
  solve(n-1,val,r,x,y);
}
int32_t main(){  
  string s,t;
  cin >> s >> t;
  t = t.substr(0,s.size());
  if(t == s) cout << "Yes";
  else cout << "No";
}
/*
10010
01011
11000

16+
*/

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
using namespace std;
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(){
  int N; cin >> N;
  int h[N];
  reps(i,N) cin >> h[i];
    
  // 無限大の値
  const long long INF = 1LL << 60;

  // DP テーブル
  long long dp[100010];

  // DP テーブル全体を初期化 (最小化問題なので INF に初期化)
  for (int i = 0; i < 100010; ++i) dp[i] = INF;

  dp[0] = dp[1] = 0;
  dp[2] = abs(h[2]-h[1]);
  for(int i=3;i<=N;i++){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[N] << endl;
}

Measured memory_bytes: 1408