akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[110][110000];//dp[i][j]=i番目の子供までにjこ配る通り数
ll sum[110][110000];//sum[i][j]=dp[i][0]+dp[i][1]+..+dp[i][j];

int main(){cout<<fixed<<setprecision(20);
		   ll n,k;
           cin>>n>>k;
           vll a(n+1);
           rep(i,1,n+1)cin>>a[i];
           rep(j,0,k+1)sum[0][j]=1;
           
           dp[0][0]=1;
           rep(i,1,n+1){
             rep(j,0,k+1){
              dp[i][j]+=sum[i-1][j];
              if(j-a[i]-1>=0)dp[i][j]-=sum[i-1][j-a[i]-1];
                //(dp[i-1][j]+dp[i-1][j-1]+...+dp[i-1][j-a[i]];) 
               sum[i][j]+=dp[i][j];
               if(j-1>=0)sum[i][j]+=sum[i][j-1];
               dp[i][j]%=inf;
               sum[i][j]%=inf;
              //cout<<dp[i][j]<<" ";
             }
            // cout<<endl;
           }
           if(dp[n][k]<0)dp[n][k]+=inf;
             cout<<dp[n][k]<<endl;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define D(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S; cin >>S;

    vector<ll> len;
    bool left_first = S[0] == '<';
    ll c = 0;
    rep(i, S.size()) {
        if (i != 0 && S[i] != S[i-1]) {
            len.push_back(c);
            c = 1;
        } else {
            c++;
        }
    }
    len.push_back(c);
// cout_h(len);

    ll ans = 0;

    rep(i, len.size()) {
        ans += len[i] * (len[i] + 1) / 2;
        if (i != 0 && (left_first == (i%2==1))) {
            ans -=min(len[i-1], len[i]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3352
#include <iostream>
#include <vector>
#include <set>
using namespace std;
static const int MOD = 1e9 + 7;
int main() {
    int N, M;
    cin >> N >> M;
    set<int> a;
    vector<int64_t> dp(N + 1, 0);
    for (int i = 0, t; i < M; i++) {
        cin >> t;
        a.insert(t);
    }
    dp[1] = a.find(1) == a.end() ? 1 : 0;
    dp[2] = a.find(2) == a.end() ? dp[1] + 1 : 0;
    for (int i = 3; i <= N; i++) {
        if (a.find(i) == a.end()) {
            dp[i] += (dp[i - 1] + dp[i - 2]) % MOD;
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 5760
module sortMod
        implicit none
        
        contains
        
        subroutine bSort( a ,kk )
          implicit none
          integer(16) :: a(:)
          integer(16) :: n,i,k,buffer,kk
          
          n = size(a)
          if( n==1 ) return
          if( kk==n ) kk = kk -1
          
          do i = 1,kk
            do k = i+1,n
              if( a(i)<a(k) )then
                buffer = a(i)
                a(i) = a(k)
                a(k) = buffer
              end if
            end do
          end do
        end subroutine
        
        impure recursive function qSort( arr ) result( after )
          !ref
          !https://t.doujin-constant.net/
          !post/143374686394/fortranをより使いこなしたquick-sort
          implicit none
          integer(16),intent(in) :: arr(:)
          !integer(16) :: after( size(arr) )
          integer(16),allocatable :: after(:)
          
          if( size(arr)>1 )then
            after = [ qSort( pack( arr(:),arr(:)> arr(1))), &
                      pack( arr(:),arr(:)==arr(1) ), &
                      qSort( pack( arr(:),arr(:)<arr(1))) ]
          else
            after = arr
          end if
        end function qSort
        
      end module
      
      PROGRAM piyo
      use sortMod
      IMPLICIT NONE
      integer(16) :: n,k
      integer(16),allocatable :: h(:),sh(:)
      
      read*,n,k
      allocate(h(n),sh(n))
      read*,h(:)
      
      !call bsort( h,k )
      sh = qSort( h )
      
      if( k/=0 )then
        if(k>n) k = n
        sh(1:k) = 0
      end if
      
      !test
    !  print*,qSort( [1_16,2_16, 5_16, 3_16, 2_16] )
    !  print*,qSort( [1_16,2_16] )
      print*,sum(sh)
      
      
      
      END PROGRAM

Measured memory_bytes: 20772
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,K;
bool b[200010];

int halt(int p){
	if(N%2==1) printf("%c" , (N+p)%2==1?'A':'B');
	else printf("B");
	repp(i,1,N){
		printf("%c" , (i+N)%2==1?'A':'B');
	}
	printf("\n");
	return 0;
}

int main(){
	scanf("%d%d" , &N , &K);
	repp(i,0,N){
		char c;
		scanf(" %c" , &c);
		b[i] = c == 'A';
	}
	if(N==1){
		printf("%c\n" , (K%2==1)^b[0]?'A':'B');
		return 0;
	}
	int y = N;
	repm(i,N-1,-1){
		if(((N-i)%2 == 1) ^ b[i]) break;
		--y;
	}
	int x = 0;
	bool z = 0;
	repp(i,0,K){
		if(x == y) return halt(K-i);
		if(b[x]^z) {
			b[x] = !b[x];
		} else {
			z = !z;
			++x;
		}
	}
	repp(i,x,y){
		printf("%c" , b[i] ^ z ? 'A' : 'B');
		--N;
	}
	halt(0);
	return 0;
}


Measured memory_bytes: 512
IDENTIFICATION DIVISION.
 PROGRAM-ID.     TEST108.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
  01 INP        PIC 9(3).
  01 SHO        PIC 9(2).
  01 AMA        PIC 9(1).
  01 WANS       PIC 9(4).
  01 ANS        PIC ZZZ9.

 PROCEDURE DIVISION.
  ACCEPT INP.
  DIVIDE INP BY 2 GIVING SHO REMAINDER AMA.
  COMPUTE WANS = SHO * (SHO + AMA).
  MOVE WANS       TO ANS.
  DISPLAY ANS.

 STOP RUN.

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a;
	cout<<a/2*(a/2+a%2);



	cout<<endl;
} 


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

int main() {

  vector<int>a(5);
  int c=0;//端数すべて切り上げの合計数
  int e=0;//%10の余り
  int d=9;//端数の最小値
  int f=0;//%10の余り合計
  for(int i=0;i<5;i++){
  cin>>a.at(i);
    c+=a.at(i);
    e=a.at(i)%10;
    f+=e;
    if(e!=0){//0の場合は省く
    d=min(d,e);
    c-=(a.at(i)%10-10);
    }
  }
  if(f==0){//すべて10の倍数の場合はそのまま足し算
  cout<<c;
  }
  else{
    cout<<c-(10-d);//端数最小値-10が最大短縮
  }
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s= input()
l=list(s)
li=s.split("R")
t=0
for i in li:
    if len(i)>=1:
        t+=1
if l[0]=="R" and l[n-1]=="R":
    t=t*2
elif l[0]=="L" and l[n-1]=="R":
    t=t*2-1
elif l[0]=="R" and l[n-1]=="L":
    t=t*2-1
else:
    t=t*2-2
ans=n-t-1
ans=min(ans+2*k,n-1)
print(ans)

Measured memory_bytes: 52464
N, K = map(int, input().split())
A = list(map(int, input().split()))# 0index
visi = [-1 for i in range(N)]# 訪れたタイミングを記録(-1: 訪れてない)
L = [1] # 今いる町を追加(町番号:1index)
visi[0] = 0
way = A[0] #次に向かう町の番号を取得
#l = []
count = 1

while visi[way-1] == -1: #すでに訪れた町が出てくるまでループ
    visi[way-1] = count
    count += 1
    L.append(way)
    way = A[way-1]

l = count - visi[way-1]
l_pre = visi[way-1]
loop_L = L[l_pre:]



if K > l_pre:
    index = (K- l_pre)% l
    ans = loop_L[index]
else:
    ans = L[K]
print(ans)

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  vector<int> vec = {a,b,c};
  sort(vec.begin(),vec.end());
  cout << (vec.at(2)-vec.at(1)) + (vec.at(1)-vec.at(0))<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;


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

	string s;
	cin >> s;

	char now = s[0];
	int ans = 0;
	rep(i, n) {
		if (s[i] == 'A') now = 'A';
	  else if (now == 'A' && s[i] == 'B') now = 'B';
		else if (now == 'B' && s[i] == 'C') {ans++; now = 'C';}
		else now = 'Z';
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 10000005
int a[MAX]={0};
int main(){
    int n,i,temp;
    cin>>n;
    for(i=1;i<n;i++){
        cin>>temp;
        a[temp]++;
        }
    for(i=1;i<=n;i++){
                cout<<a[i]<<endl;;
                }
    return 0;

}


Measured memory_bytes: 4376
import itertools
import math

def q37(n, d, x):
    count = 0
    for i in itertools.combinations(x, 2):
        c = 0
        for l in range(d):
            c += (i[0][l] - i[1][l])**2

        if math.sqrt(c).is_integer():
            count += 1
        
    return count

N, D = [int(i) for i in input().split()]

x = []
for n in range(N):
    x.append([int(i) for i in input().split()])

print(q37(N, D, x))

Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int N,H,damage=0;
	int a[100000],b[100000];
	int amax=0;
	vector<int> kougeki;
	scan(N);scan(H);
	rep(i,N){
		scan(a[i]);scan(b[i]);
		amax=max(a[i],amax);
		kougeki.push_back(b[i]);
	}
	kougeki.push_back(amax);
	sort(kougeki.begin(),kougeki.end());
	int count=0;
	while(1){
		int nextdamage=kougeki.back();
		if(nextdamage==amax){
			count+=(H-damage)/nextdamage+(((H-damage)%nextdamage)? 1:0);
			break;
		}
		else{
			damage+=nextdamage;
			kougeki.pop_back();
			count++;
			if(damage>=H) break;
		}
	}
	prin(count);
	return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	int max_moves = 0;
	int curr = 0;
	for (int i = 1; i < n; ++i) {
		if (heights[i] <= heights[i - 1]) {
			++curr;
		} else {
			max_moves = max(max_moves, curr);
			curr = 0;
		}
	}

	cout << max(max_moves, curr) << "\n";

	return 0;

}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int a[3][3];

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

    int n; cin >> n;

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

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (b[k] == a[i][j]) {
                    a[i][j] = 0;
                }
            }
        }
    }

    bool ans = false;

    if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0) {
        ans = true;
    }

    if (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0) {
        ans = true;
    }

    if (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0) {
        ans = true;
    }

    if (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0) {
        ans = true;
    }

    if (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0) {
        ans = true;
    }

    if (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0) {
        ans = true;
    }

    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
        ans = true;
    }

    if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
        ans = true;
    }

    if (ans) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
/*
ID: jerrywcy
TASK: AtCoder ABC 101 Problem A
LINK: https://abc102.contest.atcoder.jp/tasks/abc102_a
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

string s;
int ans;

int main(){
	cin>>s;
	int i,j;
	for (i=0;i<s.size();i++){
		if (s[i]=='+')ans++;
		else ans--;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
    int d , n ;
    int i;

    scanf("%d %d",&d,&n);

    if( d == 0 && n != 100){
        printf("%d\n",n);
    }
    else if ( d == 1 && n != 100 ){
        printf("%d\n", 100 * n );
    } 
    else if ( d ==2  && n != 100 ){
        printf("%d\n", 100 * 100 * n );
    }       
    else if( d == 0 && n == 100){
        printf("%d\n",101);
    }
    else if ( d == 1 && n == 100 ){
        printf("%d\n", 10100 );
    } 
    else if ( d == 2 && n == 100 ){
        printf("%d\n", 1010000 );
    }        


    return 0 ;

}

Measured memory_bytes: 128
def main():
    x=int(input())
    if x==2:
        print(2)
        exit()
    for n in range(x,10**5+4):
        for i in range(2,min(int(n**.5)+1,n)):
            flag=1
            if n%i==0:
                flag=0
                break
        if flag:
            print(n)
            break 
main()

Measured memory_bytes: 3060
import sys
S = list(input())
T = list(input())
#print (S)

dic1 = dict()
dic2 = dict()
for i in range(len(S)):
    if not S[i] in dic1.keys():
        dic1[S[i]] = 1
    else:
        dic1[S[i]] += 1
    if not T[i] in dic2.keys():
        dic2[T[i]] = 1
    else:
        dic2[T[i]] += 1
#print(dic1)

dic1 = sorted(dic1.items(), key = lambda x:x[1])
dic2 = sorted(dic2.items(), key = lambda x:x[1])

for j in range(len(dic1)):
    if not dic1[j][1] == dic2[j][1]:
        print ('No')
        sys.exit()
print ('Yes')

Measured memory_bytes: 6704
#include<iostream>

using namespace std;

int main(){
  int A, B, C;
  
  cin >> A >> B >> C;
  
  if(A == B && B == C || A != B && B != C && C != A){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  return 0;
}

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

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		bool info[101][101];
		for(int i = 0; i < 101; ++i)
		{
			for(int j = 0; j < 101; ++j)
			{
				info[i][j] = false;
			}
		}
		for(int i = 1; i <= N; ++i)
		{
			int M;
			cin >> M;
			for(int j = 0; j < M; ++j)
			{
				int p;
				cin >> p;
				info[i][p] = true;
			}
		}
		int K;
		cin >> K;
		vector<int> Vec(K);
		for(int i = 0; i < K; ++i)
		{
			cin >> Vec[i];
		}
		int alreadyFlag = 0;
		int ans = 0;
		for(int i = 1; i <= N; ++i)
		{
			bool flag = true;
			for(int j = 0; j < K; ++j)
			{
				if(!info[i][Vec[j]])
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				++alreadyFlag;
				ans = i;
				if(alreadyFlag >= 2)
				{
					cout << -1 << endl;
					break;
				}
			}
		}
		if(alreadyFlag == 1)
		{
			cout << ans << endl;
		}
		else if(alreadyFlag == 0)
		{
			cout << -1 << endl;
		}
	}
}

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

Measured memory_bytes: 1204
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    long H[N];
    for(int i =0;i<N;i++){
        cin >> H[i];
    }

    int c = 0;
    for(int i = N-1;i >0;i--){
        if((H[i]-H[i-1]) >= 0) ;
        else if(H[i]-H[i-1] == -1) H[i-1] -= 1;
        else {c = 1; break;}  
    }
    if(c==1) cout << "No " <<endl;
    else cout <<"Yes" <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair

ll ncr(ll n, ll r){
    if(n==r){
        return 1;
    }
    if(n<r){
        return 0;
    }else{
        ll temp=r;
        ll res=1;
        while(temp>0){
            res*=(n+temp-r);
            temp--;
            res/=(r-temp);
        }
        return res;
    }
}

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    string n;
	    ll k;
	    cin >> n >> k;
	    ll len=n.length();
	    ll te=len;
	    ull ans=0;
	    ll temp=k;
	    for(int i=0 ; ; i++){
	        if(len<temp){
	            ans--;
	            break;
	        }else if(temp==0 || i==te){
	            break;
	        }
	        if(n[i]-'1'>=0){
	            ans+=ncr(len-1,temp)*pow(9,temp);
	            temp--;
	            ans+=(n[i]-'1')*ncr(len-1,temp)*pow(9,temp);
	        }
	        len--;
	    }
	    cout << ans+1 << endl;
	}
	return 0;
}

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

int main(){
    int N,M;
    while(cin >> N >> M, N&&M){
        vector<int> taro,hana;
        int sumT = 0, sumH = 0, s;
        for(int i=0;i<N;i++){
            cin >> s;
            taro.emplace_back(s);
            sumT += s;
        }
        for(int i=0;i<M;i++){
            cin >> s;
            hana.emplace_back(s);
            sumH += s;
        }

        int a = -1,b = -1, MIN = 1e9;
        bool flg = false;
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                int T = sumT - taro[i] + hana[j];
                int H = sumH - hana[j] + taro[i];
                //cout << T << " " << H << endl;
                if(T == H){
                    int card = taro[i] + hana[j];
                    if(MIN > card){
                        a = taro[i];
                        b = hana[j];
                        MIN = card;
                        flg = true;
                    }
                }
            }
            if(flg) break;
        }

        if(!flg) cout << -1 << endl;
        else cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = -ll(1e18);
    ans = max(ans,a*c);
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

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

// 約数を求める
vi divisor(int n){
	vi res;
	for(int i=1; i*i<=n; ++i){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i){
				res.push_back(n/i);
			}
		}
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin>>n>>m;
	int ans=0;
	vi a=divisor(m);
	REP(i, a.size()){
		if(a[i]<=m/n){
			ans=max(ans, a[i]);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
inline int read()
{
	int s=0,f=1; char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=5e3+20;
const ll inf=1ll<<60;

int n,A,B;
int p[maxn];
ll dp[maxn];
int s[maxn][maxn];

inline void init()
{
	n=read();A=read();B=read();
	REP(i,1,n)p[i]=read(); p[n+1]=n+1; 
	REP(i,1,n+1)s[i][p[i]]++;
	REP(i,1,n+1)REP(j,1,n+1)s[i][j]+=s[i][j-1];
	REP(i,1,n+1)REP(j,1,n+1)s[i][j]+=s[i-1][j];
}

inline int Matrix(int x1,int x2,int y1,int y2)
{
	return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
}

inline void doing()
{
	dp[0]=0;
	REP(i,1,n+1)
	{
		dp[i]=inf;
		REP(j,0,i-1)if(p[j]<p[i])
		{
			int num=Matrix(j+1,i-1,p[j]+1,p[i]-1);
			if(!num)
			{
				int a=Matrix(j+1,i-1,p[i]+1,n+1);
				int b=Matrix(j+1,i-1,1,p[j]-1);
				chkmin(dp[i],(ll)a*A+(ll)b*B+dp[j]);
			}
		}
	}
	printf("%lld\n",dp[n+1]);
}

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


Measured memory_bytes: 98560
#include<stdio.h>

int main(){
  int a,b,c;
  int day,sum,count;
  scanf("%d %d %d",&a,&b,&c);

  day=sum=count=0;
  while(1){
    if(day!=6){
      sum+=a;
      count++;
      day++;
    }else{
      sum+=a+b;
      count++;
      day=0;
    }
    if(sum>=c){
      printf("%d\n",count);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 2132
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  ll n; cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=n;j++){
      for(ll k=1;k<=n;k++){
        ll x=__gcd(i,j);
        x = __gcd(x,k);
        ans+=x;
      }
    }
  }
  cout<<ans;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

Measured memory_bytes: 3668
n=int(input())
d={1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 10: 'j'\
   , 11: 'k', 12: 'l', 13: 'm', 14: 'n', 15: 'o', 16: 'p', 17: 'q', 18: 'r', 19: 's'\
   , 20: 't', 21: 'u', 22: 'v', 23: 'w', 24: 'x', 25: 'y', 26: 'z'}
l=[]
p=10
while p!=-1:
    a=n//26**p
    l.append(a)
    n-=a*26**p
    p-=1

for i in range(len(l)):
    if l[i]!=0:
        break
l=l[i:]
for j in range(12):
    for k in range(len(l)):
        if l[k]==0:
            if k!=0:
                
                l[k]=26
                if 0<=k-1<=len(l)+1:
                    l[k-1]-=1

m=""
for i in l:
    if i!=0:
        
        m+=d[i]
print(m)


Measured memory_bytes: 62040
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n;
  cin>>n;
  vector<int64_t> vec;
  for (int64_t i = 1; i <= sqrt(n); ++i)
  {
    if(n%i==0)
    {
      vec.push_back(i);
      vec.push_back(n/i);
    }
  }
  cout<<vec[vec.size()-1]+vec[vec.size()-2]-2;
}

Measured memory_bytes: 384
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int cnt = 0;

			for (int i = a; i <= b; i++) {
				cnt = (c % i == 0) ? cnt + 1 : cnt;
			}

			System.out.println(cnt);
		}
	}
}


Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];

  vector<Int> v;
  for(Int i=0;i<n;i++){
    v.emplace_back(a[i]);
    v.emplace_back(b[i]);
    v.emplace_back(b[i]+1);
  }

  v=compress(v);
  auto m=dict(v);

  vector<Int> s(v.size());
  for(Int i=0;i<n;i++){
    s[m[a[i]]]++;
    s[m[b[i]+1]]--;
  }
  for(Int i=1;i<(Int)s.size();i++) s[i]+=s[i-1];

  cout<<*max_element(s.begin(),s.end())<<endl;
  return 0;
}



Measured memory_bytes: 27868
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

const int MAX_N = 100;

//隣接リストでもつ
struct edge {
    int to; 
    edge(int to) : to(to) {};
}; 
vector<vector<edge> > G(MAX_N, vector<edge>());
void add_edge(int from, int to) {
    G[from].push_back(edge(to));
    G[to].push_back(edge(from)); //無向グラフのとき
}

vector<int> color(MAX_N, -1); //初期値:-1
void dfs_reachability(int v, int c) {
    color[v] = c;
    for(int i = 0; i < (int)G[v].size(); ++i) { //頂点vから出る各辺を走査
        int u = G[v][i].to;
        if (color[u] < 0) { 
            dfs_reachability(u, c); //同じ色に塗る
        }
    }
}

int main () {

    int n; cin >>n;
    vector<int> x(n); vector<int> y(n);
    REP(i,n) cin >> x[i] >> y[i];

    int res = n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) {
                int p = x[j] - x[i];
                int q = y[j] - y[i];
                for (int k = 0; k < MAX_N; k++) {
                    G[k].clear();
                    color[k] = -1;
                }
                for (int k = 0; k < n; k++) {
                    for (int l = 0; l < n; l++) {
                        if (k != l) {
                            if (x[k] == x[l] + p && y[k] == y[l] + q) {
                                add_edge(k, l);
                            } 
                        } 
                    }
                }
                int col = 0;
                for (int k = 0; k < n; k++) {
                    if(color[k] < 0) {
                        dfs_reachability(k, col);
                        col++;
                    }
                }
                res = min(res, col);
            } 
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 10010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 2019;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll l,r; cin >> l >> r;
	ll ans = INT_MAX;
	if (r-l > 2019) ans = 0;
	else {
		for(ll i = l; i < r; ++i) {
			for(ll j = i+1; j <= r; ++j) {
				if ((i*j)%MOD < ans) ans = (i*j)%MOD; 
			}
		}
	}
	cout << ans << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


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

string s, t;
int dp[1001][1001];

int dfs(int k){
  if(k > s.length()) return 0;
  for(int i = 0; i <= t.length(); i++){
    if(k == 0 && i == 0 ) continue;
    int p = 1000;
    if(s[k-1] == t[i-1] && k > 0 && i > 0) p = min(p, dp[k-1][i-1]);
    else if(k > 0 && i > 0) p = min(p, dp[k-1][i-1]) + 1;
    if(k > 0) p = min(p, dp[k-1][i] + 1);
    if(i > 0) p = min(p, dp[k][i-1] + 1);
    dp[k][i] = p;
  }

  return dfs(k+1);
}

int main(){
  cin >> s >> t;
  memset(dp, 0, sizeof(dp));
  dp[0][t.length()] = t.length();
  dp[s.length()][0] = s.length();
  dfs(0);
  // for(int i = 0; i <= s.length(); i++){
  //   for(int j = 0; j <= t.length(); j++){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[s.length()][t.length()] << endl;;
}



Measured memory_bytes: 7140
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, k = mi()
    L = [elm=='R' for elm in li()]
    seq = [len(list(g)) for _, g in groupby(L)]
    # print(seq)
    x = min(2*k, len(seq)-1)
    print(x + (sum(seq) - len(seq)))
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 5528
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define INF 999999999
#define FOR(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define lin long long

int main(void)
{
    string s;
    cin >> s;

    int c = 0;
    REP(i, s.length())
    {
        if (s[i] == '1')
            c++;
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
def mainusbin(num):
    base = -2
    dst = ""
    i = 0
    if abs(base) > abs(num):
        return num
    while abs(base**i) <= abs(num):
        i += 1
        amari = num % base**i
        if amari:
            dst = "1" + dst
            num -= base**(i-1)
        else:
            dst = "0" + dst
    return dst
src = int(input())
dst = mainusbin(src)
print(dst)


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

using namespace std;

int main() {
  
  int A, B;
  char op;
  
  cin >> A >> op >> B;
  
  if ( op == '+' )
    cout << A + B << endl;
  else
    cout << A - B << endl;

}

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

int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
	if(A.size() == n+1){
		int now = 0;
		for(int i = 0; i < q; i++){
			if(A.at(b.at(i)) - A.at(a.at(i)) == c.at(i))
				now += d.at(i);
		}
		ans = max(ans, now);
		return;
	}

	A.push_back(A.back());
	while(A.back() <= m){
		dfs(A);
		A.back()++;
	}
}

int main(){
	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);

	for(int i = 0; i < q; i++){
		cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
	}

	dfs(vector<int>(1,1));
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
    int a,b,c,d;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    d=a+b+c;
    if(d>=22){
        printf(" bust");
    }else if(d<=21 ){
        printf(" win");
    }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            for (var input = string.Empty; (input = Console.ReadLine()) != "0 0";) {
                Console.WriteLine(
                    Enumerable.Range(0, int.Parse(input.Split()[0]))
                        .Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
                        .GroupBy(q => q[0])
                        .Select(g => g.SelectMany(q => q.Skip(1)).Max())
                        .Sum()
                );
            }
        }
    }
}


Measured memory_bytes: 10408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <tgmath.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

ll n, k;

main()
{
    scanf("%lld%lld", &n, &k);
    printf("%lld\n", miin(n, n % k, k - (n % k)));
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    l = [0 for _ in range(N)]
    is_prime = [True for _ in range(N+1)]
    is_prime[0],is_prime[1] = False,False
    INF = 10**9+7
    
    for i in range(N+1):
        if is_prime[i]:
            for j in range(2*i,N+1,i):
                is_prime[j] = False

    fa = [0 for _ in range(N+1)]                
    for x in range(1,N+1):
        for i in range(1,x+1):
            if (is_prime[i] and x%i == 0):
                while x%i == 0:
                    fa[i] += 1
                    x //= i
 
    ans = 1
    for i in range(N+1):
        ans *= fa[i]+1
        ans %= INF
        
    print(ans)
    
if __name__ == "__main__":
    main()


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

int main()
{
	long int N, max, num=0;
	scanf("%ld", &N);
	int mid = std::sqrt(N);
	for(int i=1; i<=mid; i++){
		if(N%i==0){
			max = N/i;
		}
	}
	while(max>=10){
		max = max/10;
		num++;
	}
	num++;
	printf("%ld\n", num);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    ll mon=1000,ans=1000;
    int i=0;
    while(i<n-1){
        while((i<n-1)&&(a[i+1]<=a[i])) i++;
        if(i==n-1) break;
        ll stocks=mon/a[i]*1LL;
        int buy=i++;
        while((i<n)&&(stocks*a[i]>=stocks*a[i-1])) i++;
        int sell=i-1;
        mon+=stocks*(a[sell]-a[buy]);
        ans=max(ans,mon);
    }
    cout<<mon;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int i,n,x,z,nr,rez;
    scanf("%d%d",&n,&x);
    rez=1;
    nr=0;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&z);
        nr+=z;
        if(nr<=x)
            rez++;
    }
    printf("%d",rez);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <algorithm>
using namespace std;

#define INF 1e8 * 8

int a[1111], b[1111], dp[22222];

int main(void)
{
    int h, n, i, j;

    scanf("%d %d" ,&h, &n);
    for (i = 1; i <= n; i++)
		scanf("%d %d" ,&a[i], &b[i]);

	for (i = 1; i <= 20000; i++)
		dp[i] = INF;

    for (i = 1; i <= n; i++)
		for (j = a[i]; j <= 20000; j++)
			dp[j] = min(dp[j], dp[j - a[i]] + b[i]);

    printf("%d" ,*min_element(dp + h, dp + 20001));
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int N,ans;
int prime[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int p[15];
int a2,a4,a14,a24,a74;

int max(int x,int y){
	if(x>y)return x;
	return y;
}

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		int j=i;
		for(int k=0;k<15;k++){
			while(j%prime[k]==0){
				p[k]++;
				j/=prime[k];
			}
		}
	}
	
	for(int k=0;k<15;k++){
		if(p[k]>=2)a2++;
		if(p[k]>=4)a4++;
		if(p[k]>=14)a14++;
		if(p[k]>=24)a24++;
		if(p[k]>=74)a74++;
	}
	ans+=max(a24*(a2-1),0);
	ans+=max(a14*(a4-1),0);
	ans+=max(a4*(a4-1)*(a2-2)/2,0);
	ans+=a74;
	
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    char s[MAX+10];
    cin>>s;
    int len=strlen(s);
    int count=0;
    for(int i=0;i<len/2;i++){
        if(s[i]!=s[len-1-i]) count++;
    }
    cout<<count<<endl;
}

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

int main() {
  cout << fixed << setprecision(15);
  int N, K; cin >> N >> K;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    int p; cin >> p;
    p++;
    P[i] = p;
  }
  
  vector<long long> S(N + 1, 0);
  for (int i = 0; i < N; i++) S[i + 1] = S[i] + P[i];

  long long ans = 0;
  for (int i = 0; i <= N - K; i++) {
    long long sum = 0;
    sum = S[i + K] - S[i];
    if (sum > ans) ans = sum;
  }

  cout << ans / 2.000000 << endl; 
}


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

using namespace std;

int main() {
	int n; scanf("%d", &n);
	string str;
	map <string , int > mp;
	string A[n];
	bool bb = true;
	char chr = ')';
	for (int i = 0; i < n; i++) {
		cin >> str;
		A[i] = str;
		if (i == 0) chr = str[str.size() - 1];
		if (chr != str[0] && i > 0) {
			bb = false;
		}
		chr = str[str.size() - 1];
		mp[str]++;
	}
	for (int i = 0; i < n; i++) {
		if (mp[A[i]] > 1) {
			bb = false;
			break;
		}
	}
	if (bb) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
using System;

class MainClass {
    static void Main() {
        string s = Console.ReadLine();
        int ans = 0;
        for (int i = 0; i < s.Length; i++) {
            if (s[i] == '+')ans++;
            if (s[i] == '-')ans--;
        }
        Console.WriteLine(ans);
    }
}

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

int main() {
	// 変数宣言
	int a, b, c, d;
	int l, r;

	// 入力
	cin >> a >> b >> c >> d;

	// 計算
	l = a + b;
	r = c + d;

	// 出力
	if (l > r)		cout << "Left" << endl;
	else if (l < r)	cout << "Right" << endl;
	else			cout << "Balanced" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int a, b, c;
    int ans;
    cin >> a >> b >> c;
    // for(int i=0;i<A;i++){
    //     double z;
    //     string p;
    //     cin >> z;
    //     cin >> p;
    //     if(p=="BTC") {
    //         b += z*380000;
    //     }else if(p=="JPY"){
    //         b += z;
    //     }
    // }
    ans = a*b*c/2/max(c,max(a,b));
    cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
k = int(input())
if max(a,b,c) == a:
  print(a*(2**k)+b+c)
elif max(a,b,c) == b:
  print(b*(2**k)+a+c)
else:
  print(a+b+c*(2**k))



Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S, T;
	cin >> S >> T;
	string res = "";
	string t;
	bool f;
	for (int i = 0; i + (int)T.size() - 1 < (int)S.size(); i++) {
		t = S;
		f = true;
		for (int j = 0; j < (int)T.size(); j++) {
			if (S[i + j] != '?' && S[i + j] != T[j]) {
				f = false;
				break;
			}
		}
		if (f) {
			for (int j = 0; j < (int)T.size(); j++) {
				t[i + j] = T[j];
			}
			for (int j = 0; j < S.size(); j++) {
				if (t[j] == '?') {
					t[j] = 'a';
				}
			}
			if (res == "") {
				res = t;
			}
			else {
				res = min(res, t);
			}
		}
	}
	if (res == "") {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		cout << res << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int fastpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

class Combination
{
public:

    vec fact, invfact;
    int MAX_N, mod;

    Combination(int MAX_N, int mod): MAX_N(MAX_N), mod(mod) {
        fact = vec(MAX_N + 1);
        invfact = vec(MAX_N + 1);
        fact[0] = 1;
        FOR(i, 1, MAX_N + 1){
            fact[i] = (fact[i - 1] * i) % mod;
        }
        invfact[MAX_N] = fastpow(fact[MAX_N], mod - 2, mod);
        IREP(i, MAX_N){
            invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
        }
    }

    int comb(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        int a = fact[n];
        a = (a * invfact[r]) % mod;
        a = (a * invfact[n - r]) % mod;
        return a;
    }
};

bool on_line(int x1, int y1, int x2, int y2, int x3, int y3){
    int X1 = x1 - x3;
    int Y1 = y1 - y3;
    int X2 = x2 - x3;
    int Y2 = y2 - y3;
    if(X1 * Y2 == Y1 * X2){
        return true;
    }else{
        return false;
    }
}

signed main(){

    int N; cin >> N;
    vec x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    int ans = 0;
    int mod = 998244353;
    Combination C(N, mod);
    FOR(k, 3, N + 1) ans = (ans + C.comb(N, k)) % mod;

    vector<vector<bool>> used(N, vector<bool>(N, false));
    REP(i, N){
        FOR(j, i + 1, N){
            if(used[i][j]) continue;
            vec list({i, j});
            FOR(k, j + 1, N) if(on_line(x[i], y[i], x[j], y[j], x[k], y[k])) list.push_back(k);
            int n = list.size();
            FOR(k, 3, n + 1) ans = (ans + mod - C.comb(n, k)) % mod;
            REP(k, n) FOR(l, k + 1, n) used[list[k]][list[l]] = true;
        }
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <complex>
using namespace std;
typedef complex<double> xy_t;
xy_t P[110];
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
int main(int argc, const char * argv[]) {
    int N=0;
    double x, y;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> x >> y;
        P[i]= xy_t(x,y);
    }
    double sum = 0.0;
    for (int i=0; i+2<N; ++i){
        xy_t a=P[0], b=P[i+1], c=P[i+2];
        sum += cross_product(b-a, c-a)*0.5;
    }
    printf("%.1f\n",abs(sum));
    return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

ll H;

ll solve() {
    ll cnt = 0;
    ll height = 0;
    ll prev = 0;
    while(H >= 1) {
        if (height == 0) {
            prev = 1;
            cnt += prev;
        } else {
            prev *= 2;
            cnt += prev;
        }
        H /= 2;
        height++;
    }
    return cnt;
}

int main() {
    scanf("%lld", &H);

    ll cnt = solve();

    printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 256