akhauriyash/Code-Regression huggingface dataset:
H, W, K = map(int, input().split())
C = [input() for i in range(H)]

ans = 0
cnt = 0

for i in range(2 ** H):
    for j in range(2 ** W):
        cnt = 0
        for k in range(H):
            for l in range(W):
                if ((i >> k) & 1) and ((j >> l) & 1):
                    if C[k][l] == '#':
                        cnt += 1

        if cnt == K:
            ans += 1

print(ans)

Measured memory_bytes: 8816
N = int( input() )
D = list ( int(x) for x in input().split() )

if D[0] != 0:
    ans = 0
else:
    Ds = [ 0 for i in range( max(D) + 1 ) ]

    for i in range( N ):
        Ds[ D[i] ] += 1

    ans = 1

    if Ds[ 0 ] != 1:
        ans = 0
    else:
        for i in range( 1 , max(D) + 1 ):
            ans *= Ds[ i-1 ] ** Ds[i]

            if ans == 0:
                break


print( ans % 998244353 )

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

  int N,K; cin >> N >> K;
  long long ans = 0;
  for(int i = 0;i < N;i++){
    int x; cin >> x;
    ans += min(2 * x,2 * (K-x));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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>>;

#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--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline 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);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[200000];

int main() {
    init();
    ll N;
    cin >> N;
    rep(i,N){
        ll a;
        cin >> a;
        A[a - 1] = i;
    }

    ll ans = 1, M = 0, ni = -1;
    rep(i,N){
        if(A[i]>ni)
            M++, ni = A[i];
        else
            chmax(ans, M), M = 1, ni = A[i];
    }
    chmax(ans, M);

    cout << N - ans << endl;
}

Measured memory_bytes: 1920
program abc157c
      implicit none
      integer::N,M,i,j
      integer,parameter::k=10
      integer,allocatable,dimension(:)::A
      integer,allocatable,dimension(:)::S,C

      read *,N,M
      if (N==1.and.M==0) then
         print *,'0'
         stop
      end if
      allocate(A(N))
      A=k
      allocate(S(M),C(M))

      do i=1,M
         read *,S(i),C(i)
         if (S(i)==1.and.C(i)==0.and.N/=1) then
            print *,'-1'
            stop
         end if
      end do

      do i=1,M
         do j=i+1,M
            if (S(i)==S(j).and.C(i)/=C(j)) then
               print *,'-1'
               stop
            end if
         end do
      end do

      do i=1,N
         do j=1,M
            A(S(j))=C(j)
         end do
         if (i==1.and.A(i)==k) A(i)=1
         if (i>1.and.A(i)==k) A(i)=0
         write(*,'(I1)',advance='no') A(i)
      end do

      stop

   end program abc157c

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e18
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int maxn = 405;
ll dp[maxn][maxn];
ll sum[maxn][maxn];

void solve() {
	ll n;
	cin >> n;
	vl a(n);
	rep(i, n) cin >> a[i];

	rep(i, n)
		FOR(j, i, n - 1)
			sum[i][j] = (j == 0? 0 : sum[i][j-1]) + a[j];

	FOR(len, 1, n)
		rep(i, n - len + 1) {
			int j = i + len - 1;
			if (len == 1) dp[i][j] = 0;
			else {
				dp[i][j] = inf;
				FOR(k, i, j - 1) 
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sum[i][j]);
			}
		}

	cout << dp[0][n-1] << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod1 998244353
#define mod2 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define FILL(name,val) memset(name , val , sizeof(name))
#define repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 2e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const ll inf = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;

void solve(){
    //
    int n , k;
    cin >> n >> k;
    vector<ll> dp(n+10 , inf) , v(n);
    rep(n){
        cin >> v[i];
    }
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    repo(i,2,n){
        repo(j , 1 , min(i,k)+1){
            dp[i] = min(abs(v[i-j] - v[i]) + dp[i-j] , dp[i]);
        }
    }
    cout << dp[n-1] << endl;
    //
    return;
}



int main(){
    FIO;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

const int N = 1e5+11;
const int M = 1e6+11;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int inff = 0x3f3f3f3f3f3f3f3f;


/*-----------------------------------------*/


int main(){
 	LL a,b;char s[10];
 	scanf("%lld%s%lld",&a,s,&b);
 	if(s[0]=='+') cout<<a+b<<endl;	
 	else if(s[0]=='-')  cout<<a-b<<endl;

return 0;
}

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

int main(void){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++){
        string s; cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}

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

using namespace std;
 
int main(){
    string S;
    cin >> S;
    int a=0,b=0,c=0;
    if(S.at(0) == 'A')
        a=1;
    
    for(int i = 2;i < S.size() -1;i++){
        if(S.at(i) == 'C'&& b == 0)
            b = 1;
        else if(S.at(i) == 'C'){
            b = 0;
            break;
        }
    }

    for(int i = 1;i < S.size();i++){
        if(S.at(i) == 'A' || S.at(i) == 'B' || S.at(i) == 'D' || S.at(i) == 'E' || S.at(i) == 'F' || S.at(i) == 'G' || S.at(i) == 'H'
         || S.at(i) == 'I' || S.at(i) == 'J' || S.at(i) == 'K' || S.at(i) == 'L' || S.at(i) == 'M' || S.at(i) == 'N' || S.at(i) == 'O' || S.at(i) == 'P'
          || S.at(i) == 'Q' || S.at(i) == 'R' || S.at(i) == 'S' || S.at(i) == 'T' || S.at(i) == 'U' || S.at(i) == 'V' || S.at(i) == 'W' || S.at(i) == 'X'
           || S.at(i) == 'Y' || S.at(i) == 'Z'){
               c = 0;
               break;
           }
        else {
            c = 1;
        }
    }   

    if (a == 1 && b == 1 && c == 1)
        cout << "AC" << endl;
    else 
        cout << "WA" << endl;  
}


Measured memory_bytes: 256
from copy import deepcopy
def main():
    K = int( input())
    T = [[1,2,3,4,5,6,7,8,9]]
    for i in range(10):
        S = T[i]
        R = []
        for s in S:
            t = s%10
            if t == 0:
                R.append(s*10)
                R.append(s*10+1)
            elif t%10 == 9:
                R.append(s*10+9)
                R.append(s*10+8)
            else:
                R.append(s*10+t)
                R.append(s*10+t+1)
                R.append(s*10+t-1)
        T.append(R)
    ANS = []
    for t in T:
        ANS.extend(t)
    ANS.sort()
    print(ANS[K-1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 34332
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int A[N], B[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B, B + N);
    for (int i = 0; i < N; i++)
    {
        auto itr = lower_bound(B, B + N, A[i]);
        if (itr - B == N - 1)
        {
            --itr;
            cout << *itr << endl;
        }
        else
        {
            cout << B[N - 1] << endl;
        }
    }
}

Measured memory_bytes: 3200
N=int(input())
A=list(map(int,input().split()))
sum=0
for i in range(N):
    sum = sum+A[i]
ans = 0
if sum%N <= N//2:
    for i in range(N):
        ans = ans+ (A[i]-(sum//N))**2
    print(ans)
else:
    for i in range(N):
        ans = ans+ (A[i]-1-(sum//N))**2
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  if (n % 1110 <= 9 || n % 1000 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var n, m, l int

	fmt.Scanf("%d%d%d", &n, &m, &l)

	var A, B, C [][]int

	A = make([][]int, n)
	B = make([][]int, m)
	C = make([][]int, n)

	for i := 0; i < n; i++ {
		A[i] = make([]int, m)
		C[i] = make([]int, l)
	}

	for i := 0; i < m; i++ {
		B[i] = make([]int, l)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &A[i][j])
		}
	}

	for i := 0; i < m; i++ {
		for j := 0; j < l; j++ {
			fmt.Scanf("%d", &B[i][j])
		}
	}

	for i := 0; i < n; i++ {

		for j := 0; j < l; j++ {

			for k := 0; k < m; k++ {
				C[i][j] += A[i][k] * B[k][j]
			}
		}

	}

	for i := 0; i < n; i++ {

		for j := 0; j < l; j++ {
			if j != 0 {
				fmt.Print(" ")
			}
			fmt.Printf("%d", C[i][j])
		}

		fmt.Println("")
	}

}



Measured memory_bytes: 2636
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		if(a==1 && b!=1)System.out.println("Alice");
		else if(a==1 && b==1)System.out.println("Draw");
		else if(a!=1 && b==1)System.out.println("Bob");
		else if(a<b)System.out.println("Bob");
		else if(a>b)System.out.println("Alice");
		else System.out.println("Draw");
	}
}

Measured memory_bytes: 23764
#include<iostream>
//#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include <iomanip>
#include <set>
#include<cmath>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
#define int long long
#define mp make_pair
#define error(x) cout<<#x<<"="<<(x)<<endl;
void sp(double y,int x){cout<<fixed<<setprecision(x)<<y;}
int inf=1e9+10;
int const M=2e5+10;
int const M2=1e6+10;
int const M3=1e3+10;
int mod=1e9+7;
int a[M];
int cnt[M];
int sa(int x,int y){if(x%y==0)return x/y;return x/y+1;}
int binp(int x,int y){int ans=1;int t=x;while(y!=0){if(y%2==1){ans*=t;ans;}y/=2;t*=t;t;}return ans;}
main(){
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
        cin>>a[i],cnt[a[i]]++,cnt[a[i]-1]++,cnt[a[i]+1]++;
    int ans=0;
    for(int i=0;i<=1e5;i++)
        ans=max(ans,cnt[i]);
    cout<<ans;
}


Measured memory_bytes: 1792
q, h, s, d = map(int, input().split())
n = int(input())

mi = min(q*4, h*2, s)
if n % 2 == 0:
    mi = min(mi*2, d)
    print(n//2 * mi)
else:
    ans = 0
    ans += mi
    n -= 1
    mi = min(mi*2, d)
    print(n//2 * mi + ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n,in;
	cin >> n;
	vi x;
	rep(i, n) {
		cin >> in;
		x.push_back(in);
	}
	int a = *max_element(all(x));
	int maxnum = 0,maxx=0;
	rep(i, n) {
		if (min(a - x[i], x[i]) > maxx) {
			maxx = min(a - x[i], x[i]);
			maxnum = x[i];
		}
	}
	cout << a << " " << maxnum << endl;
}

Measured memory_bytes: 892
from collections import deque


def doublylink(n):
    l = deque([])
    for _ in range(n):
        f = input().split()

        if f[0] == 'insert':
            l.appendleft(f[1])
        elif f[0] == 'delete':
            if f[1] in l:
                l.remove(f[1])
        elif f[0] == 'deleteFirst':
            l.popleft()
        elif f[0] == 'deleteLast':
            l.pop()

    print(' '.join(map(str, l)))


if __name__ == '__main__':
    N = int(input())
    doublylink(N)




Measured memory_bytes: 69740
lst = []
for i in range(3):
    s = list(map(int, input().split()))
    lst.append(s)
N = int(input())
for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == lst[j][k]:
                lst[j][k] = 0

for i in range(3):
    cnt = 0
    for j in range(3):
        if lst[i][j] == 0:
            cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        if lst[j][i] == 0:
            cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

cnt = 0
for i in range(3):
    if lst[i][i] == 0:
        cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

if lst[0][2] == 0 and lst[1][1] == 0 and lst[2][0] == 0:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3192
a,b,c,d = map(int,input().split())
x = b//c - -(-a//c) + 1
y = b//d - -(-a//d) + 1

import fractions
cd = c * d // fractions.gcd(c,d)
z = b//(cd) - -(-a//(cd)) + 1

print((b-a+1) - (x+y-z))

Measured memory_bytes: 5048
# -*- coding: utf-8 -*-

N = int(input())

A = [1]
i = 1
while 6 ** i <= 100000:
    A.append(6 ** i)
    i += 1
j = 1
while 9 ** j <= 100000:
    A.append(9 ** j)
    j += 1
A.sort()  # 引き出せる金額のリスト

table = [1000000 for _ in range(N + 1)]  # i円を引き出す最小の操作回数をメモ、参照するのは常に前の値なのでループを回せる
table[0] = 0

for i in range(1, N+1):
    a = 0
    while 6 ** a <= i:
        table[i] = min(table[i], table[i - 6 ** a] + 1)  # 1円,6円,36円,...を使って操作回数を減らす
        a += 1
    b = 0
    while 9 ** b <= i:
        table[i] = min(table[i], table[i - 9 ** b] + 1)  # 1円,9円,81円,...を使って操作回数を減らす
        b += 1

print(table[N])


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
   string s,t;cin>>s>>t;
   int n=s.length();
   int cnt=0;
   rep(i,0,n){
       if(s[i]!=t[i])cnt++;
   } 
   cout<<cnt;
 
return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
//pow(x,n)
//cout << fixed << setprecision(桁数);

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

    int even = 0;
    int odd = 0;

    vector<int> vec(n);
    rep(i,n){
        cin >> vec.at(i);
        vec.at(i)%2 == 0 ? ++even : ++odd;
    }
    //cout << even << odd << endl;

    //cout << odd << endl;
    if(odd%2==0) cout << "YES";
    else cout << "NO" << endl;
}


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

using namespace std;

#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)

typedef long long ll;
int N, A[1000005], hd, tl;
ll Ans;

int main() {
  //  freopen("a.in", "r", stdin);
  //  freopen("a.out", "w", stdout);
  scanf("%d", &N), hd = 1, tl = (N *= 3);
  foru(i, 1, N) scanf("%d", &A[i]);
  sort(A + 1, A + N + 1);
  while (tl - hd + 1 >= 3) Ans += A[(tl -= 2) + 1], hd++;
  printf("%lld\n", Ans);
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>

using namespace std;

typedef struct Dice
{
    int top,front,right;
    Dice()
    {
        top=1;
        front=2;
        right=3;
    }
    void roll(char ch)
    {
        int temp=top;
        switch(ch)
        {
        case 'E':
            top=7-right;
            right=temp;
            break;
        case 'W':
            top=right;
            right=7-temp;
            break;
        case 'N':
            top=front;
            front=7-temp;
            break;
        case 'S':
            top=7-front;
            front=temp;
        }
    }
}Dice;


int main()
{
    int a[7];
    Dice d;

    for(int i=0;i<6;i++)
    {
        cin>>a[i+1];
    }

    string s;

    cin>>s;

    for(int i=0;i<s.length();i++)
    {
        d.roll(s[i]);
    }

    cout<<a[d.top]<<endl;

    return 0;

}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

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

    int m = 0; //桁数
    int tmp = n;
    while (tmp > 0) {
        m++;
        tmp /= 10;
    }
    
    int ans = 0;
    rep(i, m) {
        if ((m-i)%2 == 0) continue;
        else {
            if (i != 0) {
                ans += 9*pow(10, m-i-1);
            }
            else {
                ans += n - pow(10, m-i-1) + 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
using namespace std;

using ll = long long;
const int N = 1e5+5;
int a[N], n, k;

int main(){
	scanf("%d%d", &n, &k);
	for(int i=0;i<n;++i) scanf("%d", a+i);
	int o = lower_bound(a, a+n, 0) - a;
	int l = max(0, o-k+(o<n&&a[o]==0?1:0));
	int r = min(l+k-1, n-1);
	int mr = min(n, o+k);
	ll ans = -1;
	while(r<mr){
		int al = l<o?a[l]:0;
		int ar = r>=o?a[r]:0;
		ll x = min(-al*2+ar, 2*ar-al);
		if(ans < 0 || x < ans) ans = x;
		l++; r++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

using namespace std;

int main()
{
  int N;
  cin >> N;
  int H, preH = 0;
  REP(i,N) {
    cin >> H;
    if (preH > H) {
      cout << "No" << endl;
      return 0;
    }
    if (preH == H) continue;
    if (preH < H) preH = H-1;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
# B
N = int(input())
C_list = [0]*N
for i in range(N):
    C_list[i] = int(input()) - 1
    
LARGE = 10**9+7

T = 1
DP = [0]*(max(C_list) + 1)

for i in range(N):
    c = C_list[i]
    if i > 0:
        if C_list[i] == C_list[i-1]:
            pass
        else:
            T, DP[c] = (T + DP[c]) % LARGE, (DP[c] + T) % LARGE
    else:
        T, DP[c] = (T + DP[c]) % LARGE, (DP[c] + T) % LARGE
print(T)

Measured memory_bytes: 49496
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    ll H;
    cin >> H;
    int res = __builtin_clzll(H);
    cout << (1LL << (64-res)) - 1 << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
    cin>>n;
    n=(n%10);
    if(n==3)
      cout<<"bon";
  	else if(n==0 or n==1 or n==6 or n==8)
      cout<<"pon";
  else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  
  int arr[100],N,i,j,temp=0,count=0,minj;
  
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&arr[i]);

  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(arr[j]<arr[minj]){
	minj=j;  
      }
	
    }
    if(arr[i]!=arr[minj]){  temp=arr[i];
    arr[i]=arr[minj];
    arr[minj]=temp;
    count++;
    }
  }
  for(i=0;i<N;i++){
    printf("%d",arr[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

template <typename T>
inline bool chmin(T& a, T b){
    if(b < a){ a = b; return true;}
    return false;
}

template <typename T>
inline bool chmax(T& a, T b){
    if(a < b){ a = b; return true;}
    return false;
}

inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

inline lli gcd(lli a, lli b){ while(b != 0){ a %= b; std::swap(a, b);} return a; }
// LCM(a, b) ; a, bの最小公倍数を求める関数
inline lli lcm(lli a, lli b){ return (a / gcd(a, b)) * b;}

std::vector<int> A;

int main(void){
    int n, m; scanf("%d%d", &n, &m);
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    lli LCM = A[0] / 2;
    for(int i = 1; i < n; ++i){
        LCM = lcm(LCM, A[i] / 2);
        if(LCM > m){puts("0"); return 0;}
    }

    REP(i, n){
        lli t = LCM / (A[i] >> 1);
        if(t % 2 == 0){puts("0"); return 0;}
    }
    printf("%lld\n", (m / LCM + 1) / 2);

    
    


    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

string mul(char c, ll n)
{
        string res;
        rep(i, 0, n) {
                res += c;
        }
        return res;
}

int main()
{
        ll sx, sy, tx, ty;
        cin >> sx >> sy >> tx >> ty;
        ll xd = tx - sx;
        ll yd = ty - sy;

        string ans = "";
        
        ans += mul('U', yd);
        ans += mul('R', xd);
        ans += mul('D', yd);
        ans += mul('L', xd);
        ans += 'L';
        ans += mul('U', yd+1);
        ans += mul('R', xd+1);
        ans += 'D';
        ans += 'R';
        ans += mul('D', yd+1);
        ans += mul('L', xd+1);
        ans += 'U';

        cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int num[10],cou;
int num1,num2;
int main(void)
{
    int i;
    scanf("%d",&cou);
    for(;cou>0;cou--)
    {
        num1=num2=0;
        for(i=0;i<10;i++)
        {
            scanf("%d",&num[i]);
        }
        func(0);
    }
    return 0;
}
int func(int dep)
{
    if(num1<num[dep])
    {
        num1=num[dep];
        if(dep==9)
        {
            printf("YES\n");return 0;
        }

        func(dep+1);
    }
    else if(num2<num[dep])
    {
        num2=num[dep];
        if(dep==9)
        {
            printf("YES\n");return 0;
        }

        func(dep+1);
    }
    else printf("NO\n");
}

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

int main(){
  int N,A[3]; cin>>N>>A[0]>>A[1]>>A[2];
  int L[N]; rep(i,N) cin>>L[i];
  int NN=1;
  rep(i,N) NN*=4;
  int ans=1e9;
  rep(bit,NN){
    vector<vector<int>> V(4);
    int bi=bit;
    rep(i,N){
      V[bi%4].push_back(L[i]);
      bi/=4;
    }
    int cost=0,AA[3]={},flag=0;
    rep(i,3){
      if(V[i].size()==0){
        flag=1;
        break;
      }
      AA[i]+=V[i][0];
      for(int j=1;j<V[i].size();j++){
        cost+=10;
        AA[i]+=V[i][j];
      }
      cost+=abs(A[i]-AA[i]);
    }
    if(flag) continue;
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vll path; vl D;
//***********//
int main() {
	cin >> N;
	vl A(N+1);
	for (i = 0; i < N+1; i++) {
		cin >> A[i];
	}
	vl sum(N + 2);
	sum[N+1] =0;
	for (i = N; i >= 0; i--) {
		sum[i] = sum[i + 1] + A[i];
	}
	vl D(N + 1);
	D[0] = 1;
	if (N == 0 && A[0] == 1) {
		cout << 1;
		exit(0);
	}
	if (A[0] != 0) {
		cout << -1;
		exit(0);
	}
	for (i = 0; i < N; i++) {
		D[i + 1] = min(sum[i + 2], D[i] * 2 - A[i + 1]);
		if (i+1 != N && D[i + 1]<=0) {
			cout << -1;
			exit(0);
		}
		if (i + 1 == N && D[i + 1]!=0) {
			cout << -1;
			exit(0);
		}
	}
	for (i = 0; i <= N; i++) {
		ans += A[i] + D[i];
	}
	//debug(A);
	//debug(D);
	//debug(sum);
	cout << ans;
}

Measured memory_bytes: 5780
n=int(input())
a=list(map(int,input().split()))
ct=[0]*n
cmb=[0]*n
s_cmb=0
for i in range(0,n):
  a[i]-=1
  ct[a[i]]+=1
for i in range(0,n):
  cmb[i]=ct[i]*(ct[i]-1)//2
  s_cmb+=cmb[i]
for i in range(0,n):
  print(s_cmb-cmb[a[i]]+(ct[a[i]]-1)*(ct[a[i]]-2)//2)

Measured memory_bytes: 84684
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int A, P; cin >> A >> P;
    cout << (3 * A + P)/2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
NM = list(map(int, input().split()))

sumi = set()

correct = 0
penalty = 0

dic = dict()

for i in range(NM[1]):
    s = input().split()
    if (s[0] in sumi):
        continue
    else:
        if (s[1] == "WA"):
            if (s[0] in dic.keys()):
                dic[s[0]] = dic[s[0]] + 1
            else:
                dic[s[0]] = 1
        else:
            correct += 1
            sumi.add(s[0])

for i in sumi:
    if (i in dic.keys()):
        penalty += dic[i]

print(correct,penalty)

Measured memory_bytes: 14052
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;	cin >> N;
	vector<char> S(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}
	bool isY = false;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'Y') {
			isY = true;
		}
	}
	if (isY) {
		cout << "Four" << endl;
		cin >> N;
		return 0;
	}
	cout << "Three" << endl;
	cin >> N;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 1e4+10;
const int MAX_N = 1e3+10;
const ll INF = 1e18;

ll H, N, A[MAX_N], B[MAX_N];
ll dp[MAX];

int main() {
    cin >> H >> N;
    REP (i, N) cin >> A[i] >> B[i];
    REP (i, MAX) dp[i] = INF;
    dp[0] = 0;
    REP (n, N) {
        FOR (h, 1, H+1) {
            dp[h] = min(dp[h], dp[max(h-A[n], 0ll)] + B[n]);
        }
    }
    cout << dp[H] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x, p=100;
    cin >> x;
    for(int i = 0; i < 4000; i++)
    {
        if(p>=x)
        {
            cout << i << endl;
            break;
        }
        p+=p/100;
    }
}


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

using namespace std;

int main(){
        int a, b, c, x;
        cin>>a>>b>>c>>x;
        int res=0;
        for(int i=0;i<=a;i++){
                for(int j=0;j<=b;j++){
                        for(int k=0;k<=c;k++){
                                if(i*500+j*100+k*50==x){
                                        res++;
                                }
                        }
                }
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			
			long[] array = new long[N];
			for(int i = 0; i < N; i++){
				array[i] = sc.nextLong();
			}
			
			long answer = Long.MAX_VALUE;
			for(int i = 0; i < (1 << N); i++){
				if(Integer.bitCount(i) != K){ continue; }
				
				long price = 0;
				long max = 0;
				for(int j = 0; j < N; j++){
					if(max >= array[j] && ((i & (1 << j)) != 0)){
						price += (max + 1) - array[j];
						max = max + 1;
					}else{
						max = Math.max(max, array[j]);
					}
				}
				
				answer = Math.min(answer, price);
			}
			
			System.out.println(answer);
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23252
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;
    set<string> ans;
    while(n--){
        string s; cin>>s;
        ans.emplace(s);
    }

    cout << ans.size() << endl;

    return 0;
}

Measured memory_bytes: 19196
N,A=map(int,input().split())
x=list(map(int,input().split()))
dp=[[[0]*(2501) for i in range(N+1)] for k in range(N+1)]
dp[0][0][0]=1
for j in range(N):
  for k in range(N):
    for i in range(2501):
      if dp[j][k][i]==0:
        continue
      dp[j+1][k][i]+=dp[j][k][i]
      dp[j+1][k+1][i+x[j]]+=dp[j][k][i]
ans=0
for j in range(N+1):
    ans+=dp[N][j][j*A]
print(ans-1)

Measured memory_bytes: 69148
#include<bits/stdc++.h>
using namespace std;
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; }

int main(){
  int N, K;
  cin >> N >> K;

  int ans = N - K + 1;
  cout << ans << endl;
  return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define llMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

//Union-find
vector<ll> parent, size, depth;
void init(ll n){
  for(ll i = 0; i < n; i++){
    parent.push_back(i);
    depth.push_back(0);
    size.push_back(1);
  }
}

ll root(ll x){
  if(parent[x] == x)return x;
  else return root(parent[x]);
}

void unite(ll x, ll y){
  x = root(x);
  y = root(y);
  if(x == y) return; //一緒の連結成分であった時
  if(depth[x] < depth[y]){
    parent[x] = y; //yの方が深いので，xの親をyに変更
    size[y] += size[x];
  }else{
    parent[y] = x;
    size[x] += size[y];
    if(depth[x] == depth[y])depth[x]++; //xとyの深さが同じ時は，xの下にyを付け加えることに
  }
}
ll treesize(ll x){
  return size[root(x)];
}

//Union-find部分ここまで
ll n, m;
int main(){
  cin >> n >> m;
  vector<ll> a(m), b(m);
  vector<ll>ans(m);
  for(ll i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--; //グラフの頂点は0からn-1なので，デクリメント
  }
  ans[m-1] = n * (n-1) / 2;
  init(n); // union-findの定義
  for(ll i = m-1; i>=1; i--){ //m-1から0まで繰り返す
    if(root(a[i]) == root(b[i])){
      ans[i-1] = ans[i];
    }else{
      ll tmp = treesize(a[i]) * treesize(b[i]);
      ans[i-1] = ans[i] - tmp;
      unite(a[i], b[i]);
    }
  }
  for(ll i=0; i<m; i++)cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 6240
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
s=input()
if(n%2):
    print("No")
elif(s[:n//2]==s[n//2:]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38484
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string S, T;
	cin >> S >> T;
	if ((int) S.size() + 1 != (int) T.size()) {
		cout << "No" << endl;
	} else {
		for (int i = 0; i < (int) S.size(); i++) {
			if (S[i] != T[i]) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	
}



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

int mt[50][50], mod = 1e9+7;
int olddp[5000000], newdp[5000000];

int main(){
    int n; cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> mt[i][j];
    olddp[0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) if(mt[i][j])
            for(int k = 0; k < (1 << n); k++)
                if( !(k & (1 << j)) )
                    newdp[k | (1 << j)] = (newdp[k | (1 << j)]+olddp[k])%mod;
        for(int k = 0; k < (1 << n); k++){
            olddp[k] = newdp[k];
            newdp[k] = 0;
        }
    }
    int res = 0;
    for(int k = 0; k < (1 << n); k++)
        res = (res+olddp[k])%mod;
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 20736
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, x = 0;

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

    for(int i = a; i <= b; i++)
        {
            if(c % i == 0)
                {
                     x++;
                }
        }
    cout << x << endl;
}


Measured memory_bytes: 3120
s = input()
s = s[:len(s)-1]

for i in range(len(s)):
    if len(s)%2 == 1:
        s = s[:len(s)-1]
        continue

    s1 = s[:int(len(s)/2)]
    s2 = s[int(len(s)/2):]
    if s1 == s2:
        print(len(s))
        exit()

    s = s[:len(s)-1]

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

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N, K, C;
  std::cin >> N >> K >> C;
  std::string S;
  std::cin >> S;
  std::vector<int> work;
  for (int i: range(0, N)) {
    if (S[i] == 'o') {
      work.push_back(i);
    }
  } 
  int W = work.size();
  std::vector<int> L(K);
  {
    int l = 0, r = 0;
    for (int i: range(0, K)) {
      L[i] = work[l];
      if (i + 1 == K) {
        break;
      }
      while (work[r] < work[l] + C + 1) {
        ++r;
      }
      l = r;
    }
  }
  std::vector<int> R(K);
  {
    int l = W - 1, r = W - 1;
    for (int i: revrange(0, K)) {
      R[i] = work[r];
      if (i == 0) {
        break;
      }
      while (work[l] > work[r] - C - 1) {
        --l;
      }
      r = l;
    }
  }
  for (int i: range(0, K)) {
    if (L[i] == R[i]) {
      std::cout << L[i] + 1 << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 4216