akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K, tmp, c=0; 
  cin >> N >> K;
  priority_queue<int> h;
  for(int i=0; i<N; i++){
    cin >> tmp;
    h.push(tmp);
  }
  while(!h.empty()){
    if(h.top() >= K){
      c++;
      h.pop();
    }else{
      break;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 892
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 1e5, MAXM = 200;

int n, m;

inline void input()
{
	n = read<int>(), m = read<int>();
}

vector<int> adj[MAXN + 5];
int vis[MAXN + 5], edge_cnt = 0;

inline void dfs(int u)
{
	vis[u] = 1, edge_cnt += SZ(adj[u]);
	for(auto v : adj[u]) if(!vis[v]) dfs(v);
}

inline void solve()
{
	static int indeg[MAXM * 2 + 5], outdeg[MAXM * 2 + 5];
	static int plg[MAXM + 5], skt[MAXM + 5], type[MAXM * 2 + 5];
	int cnt = 0;

	for(int i = 1; i <= m; ++i)
	{
		type[plg[i] = ++cnt] = 0;
		type[skt[i] = ++cnt] = 1;
	}

	for(int i = 1; i <= n; ++i)
	{
		int a = read<int>(), b = read<int>(), c = read<int>(), d = read<int>();
		int u = c == 0 ? plg[a] : skt[c];
		int v = d == 0 ? skt[b] : plg[d];
		adj[u].push_back(v);
		++outdeg[u], ++indeg[v];
	}

	int din = 0, dout = 0;
	for(int i = 1; i <= cnt; ++i) if(indeg[i] != outdeg[i])
	{
		if(outdeg[i] > indeg[i])
		{
			if(type[i] == 1) { puts("NO"); return; }
			dout += outdeg[i] - indeg[i];
		}
		else
		{
			if(type[i] == 0) { puts("NO"); return; }
			din += indeg[i] - outdeg[i];
		}
	}
	if(din != dout) { puts("NO"); return; }

	for(int i = 1; i <= cnt; ++i) if(!vis[i] && outdeg[i] > indeg[i]) dfs(i);
	if(edge_cnt < n) { puts("NO"); return; }

	puts("YES");
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 3328
N, M = gets.chomp.split(" ").map(&:to_i)
ABm = (1..M).map { gets.chomp.split(" ").map(&:to_i) }

abm = ABm.sort_by{|a, b| b}
count = 0
bridge = -1

abm.each do |a, b|
  next if a <= bridge
  bridge = b - 1
  count += 1
end

p count


Measured memory_bytes: 12664
S = list(input())

cnt = [1,0,0,0]

if(S[1] == S[0]):
    cnt[0] += 1
else:
    cnt[1] += 1

if(S[2] == S[0]):
    cnt[0] += 1
elif(S[2] == S[1]):
    cnt[1] += 1
else:
    cnt[2] += 1

if(S[3] == S[0]):
    cnt[0] += 1
elif(S[3] == S[1]):
    cnt[1] += 1
elif(S[3] == S[2]):
    cnt[2] += 1
else:
    cnt[3] += 1

if(cnt == [2,2,0,0] or cnt == [2,0,2,0]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define ll long long
//#define int long long
using namespace std;
void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void free()
{
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
}
main()
{
	//free();
	boost();
	int a, b;
	cin >> a >> b;
	if(a <= 0 && b >= 0) cout << "Zero";
	else if(a >= 1) cout << "Positive";
	else if(a <= 1) 
	{
		int x = abs(abs(b) - abs(a)) + 1;
		if(x % 2 == 1) cout << "Negative";
		else cout << "Positive";
	}
	exit(0);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int H1, H2, M1, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	int hour = H2 - H1;
	int minute = M2 - M1;
	int ans = (hour * 60) + minute - K;
	cout << ans << endl;
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;


int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}


int main() {
  ll a,b;
  cin >> a >> b;
  
  int c = gcd(a,b);
  
  ll ans = a/c * b/c * c;
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define pb push_back
#define point pair <int, int>
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

const string FILENAME = "input";
const int MAXN = 2e3 + 1;

int n, k;
vector <int> a, c;

int main() {
	ios::sync_with_stdio(false);
	srand(time(0));
	//read(FILENAME); 
	cin >> n >> k;
	if (k == 1) {
		int b;
		cin >> b;
		cout << b << endl;
		if (b == 1) {
			cout << 1 << endl;
			cout << 1 << endl;
		} else {
			cout << 2 << endl;
			cout << b - 1 << ' ' << 1 << endl;
		}
		return 0;
	}
	for (int i = k; i--;) {
		int b;
		cin >> b;
		if (b & 1) c.pb(b);
		else a.pb(b);
	}
	if (c.size() > 2) {
		cout << "Impossible" << endl; 
	} else {
		if (c.size() >= 1) a.insert(a.begin(), c[0]);
		if (c.size() >= 2) a.pb(c[1]);
		for (int i = 0; i < k; ++i) cout << a[i] << ' ';
		cout << endl;
		cout << k - int(a[0] == 1) << endl;
		for (int i = 0; i < k; ++i) {
			if (a[i] - int(i == 0) + int(i + 1 == k))
				cout << a[i] - int(i == 0) + int(i + 1 == k) << ' ';
		}
		cout << endl;
	}
	
}

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

void solve(std::string S, std::string T)
{
    int cnt = 0;
    for (size_t i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
program main;
var 
    a,i,b : integer;
    p : boolean;
begin 
    p := true;
    readln(a);
    for i := 1 to a do 
        begin 
            read(b);
            if ( b mod 2 ) = 0 then 
                begin 
                    if (( b mod 3 ) <> 0) then
                        if (( b mod 5 ) <> 0) then
                            p := false;
                end;
        end;
    if ( p = true ) then 
        writeln('APPROVED')
    else 
        writeln('DENIED');
end.

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

int main() {
  int a,b;
  cin >> a >> b;
  
  double x = (a+b)%2;
  int y =(a+b)/2;
    
  if(x>0){
    cout << y+1 << endl;
  }
  
  if(x==0){
    cout << y <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>

int main(void) {
  int N, K;
  std::cin >> N >> K;

  std::map<int,int> ball;
  std::vector<int> vec;
  int size = 0;
  for (int i = 0; i < N; i++) {
    int n;
    std::cin >> n;
    if (ball.count(n)) {
      vec[ball[n]]++;
    } else {
      ball[n] = size;
      vec.push_back(1);
      size++;
    }
  }

  int diff = size - K;
  if (diff <= 0) {
    std::cout << 0 << std::endl;
    return 0;
  }

  std::sort(vec.begin(), vec.end());
  int count = std::accumulate(vec.begin(), vec.begin() + diff,0);

  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 10356
from collections import defaultdict


def is_testimony_correct(hypothesis, testimony):
    # 証言の対象者が仮説上、正直者となっているかを検証。
    for target, is_honest in testimony.items():
        if int(hypothesis[target]) == is_honest:
            continue
        return False
    return True


def is_hypothesis_correct(hypothesis, testimony_dict):
    for witness_num, testimony in testimony_dict.items():
        # 仮説上の正直者の証言だけ検証する
        if hypothesis[witness_num] == "1":
            # 証言を検証
            if is_testimony_correct(hypothesis, testimony):
                continue
            else:
                # 証言に誤りがある場合、Falseで抜ける
                return False
    return True


def main():
    N = int(input())
    testimony_dict = defaultdict(dict)

    # 証人ごとに証言をdictで保存
    for witness_num in range(N):
        for j in range(int(input())):
            target, is_honest = list(map(int, input().split()))
            testimony_dict[witness_num][target - 1] = is_honest

    # 仮説を検証  e.g.'010010' 正直者が2人 (witness_num =1, 4)
    max_count = 0
    for i in range(1, 2**N):
        # 仮説を01で表現
        hypothesis = format(i, 'b').zfill(N)
        # 仮説が正しい場合のみ、正直者の数でmax_countを更新
        if is_hypothesis_correct(hypothesis, testimony_dict):
            max_count = max(max_count, hypothesis.count(str("1")))
    print(max_count)


if __name__ == '__main__':
    main()


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

using namespace std;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	vector<int> a;
	a.resize(n);

	for(int i = 0; i < n; ++i) {
		a[i] = s[i] - '0' - 1;
	}

	bool one = false;

	for(int i = 0; i < n; ++i) {
		if(a[i] == 1) {
			one = true;
		}
	}

	if(one) {
		for(int i = 0; i < n; ++i) {
			a[i] %= 2;
		}
	}

	int ans = 0;

	for(int i = 0; i < n; ++i) {
		if(((n - 1) & i) == i) {
			ans ^= a[i];
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 5276
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int,int> P;
constexpr ll SIZE= 100010;

    ll N,A[100010],B[SIZE];
    ll ans=0,sum=0,wa=0;
int main() {
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
    }
    int cnt=0,temp;
    REP(i,N){
        if(cnt==0){temp=A[i];cnt++;continue;}
        else{
            if(temp==A[i])cnt++;
            else{
                ans+=cnt/2;cnt=1;
                temp=A[i];
            }
        }
    }
    ans+=cnt/2;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n , q; cin >> n >> q;
  string s; cin >> s;
  vector<pair<int,int>> Q(q);
  rep(i,q) cin >> Q[i].first >> Q[i].second;

  vector<int> ac(n);
  int accnt=0;
  ac[0] = 0;
  rep(i,n-1){
    if(s[i] == 'A' && s[i+1] == 'C') accnt++;
    ac[i+1] = accnt;
  }

  /*for(int p : ac){
    cout << p << endl;
  }*/

  rep(i,q){
    int count =0;
    count = ac[Q[i].second-1] - ac[Q[i].first-1];
    cout << count << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll dp[2111][2];
ll x[2111];


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; ll a,b; cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
	}
	ll ans=abs(b-x[n-1]);
	for(int i=n-2;i>=0;i--)
	{
		dp[i][0]=int(1e9);
		for(int j=i+1;j<n-1;j++)
		{
			dp[i][0]=min(dp[i][0],dp[j][1]);
		}
		dp[i][0]=min(dp[i][0],abs(x[i]-x[n-1]));
		dp[i][1] = 0;
		for(int j=i+1;j<n-1;j++)
		{
			dp[i][1]=max(dp[i][1],dp[j][0]);
		}
		dp[i][1]=max(dp[i][1],abs(x[i]-x[n-1]));
	}
	for(int i=0;i<n-1;i++)
	{
		ans=max(ans,dp[i][0]);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,X;
    cin>>N>>X;
    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
            int g = 10000*i+5000*j+(N-i-j)*1000;
            if(g==X){
                printf("%d %d %d\n",i,j,N-i-j);
                return 0;
            }
        }
    }
    printf("%d %d %d\n",-1,-1,-1);
    return 0;
}


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

using namespace std;

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

    int A, B;

    cin >> A >> B;

    if((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPL(t, x) bool operator<(CRP(t, x)) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 2e5 + 60;
ll a[N];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", a + i), a[i] -= i;
    nth_element(a, a + n / 2, a + n);
    printf("%lld", accumulate(a, a + n, 0ll, [&](ll s, ll c) { return s + abs(c - a[n >> 1]); }));
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int x;
    cin >> x;
    int X = (x/11)*2;
    int Y = x%11;
    if(Y != 0 && Y <= 6) {
        X++;
    }
    else if(Y != 0 && Y < 11){
        X+=2;
    }
    cout << X << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  ll n,a,b;
  cin >> n >> a >> b;
  ll p = n/(a+b);
  ll q = n%(a+b);
  cout << n/(a+b)*a+min(q,a) << endl;
  
 
}


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

int main() {
	string str; cin >> str;
	bool len = false; bool num = false;
	bool cap = false; bool sma = false;
	if (str.size() >= 6) len = true;
	for (auto &itr : str) {
		if (isdigit(itr) != 0) num = true;
		if (isupper(itr) != 0) cap = true;
		if (islower(itr) != 0) sma = true;
	}
	if (len == true && num == true
		&& cap == true && sma == true)
		cout << "VALID" << endl;
	else cout << "INVALID" << endl;
	return 0;
}


Measured memory_bytes: 3212
//A smoothe sea never made a skilled sailor.
//KEEP IT SIMPLE STUPID
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<n;i++)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll a,b;
    cin>>a>>b;
    ll ans=10*b;
    while(ans<10*(b+1))
    {
        if(25*a<=2*ans && 2*ans<25*(a+1))
        {
            break;
        }
        ans++;
    }
    if(ans==10*(b+1))
    {
        cout<<-1;
    }
    else{
        cout<<ans<<"\n";
    }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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


long long A[300100];

int main(){
	long long n,sum=0;
	cin >> n;
	n*=3;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	
	sort(A,A+n);
	for(int i=n/3;i<n;i+=2){
		sum+=A[i];
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) ll x;cin>>x; while(x--)
#define pb push_back
#define mp make_pair
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin>>n;
	ll a[n],c=0;
	for(ll i=1; i<=n; i++){
		cin>>a[i];
		if(i%2==1 && a[i]%2==1)
			c++;
	}
	cout<<c;
}

Measured memory_bytes: 3592
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define repr(i,a,b) for (int i = a; i > b; --i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)
 
#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define mod1 998244353
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
ll dp[100005][2][105];
int d;
string s;

ll digit_dp(int index,int flag,int sum )
{
	//cout<<index _ flag _ sum<<endl;
	if(index == s.length())
	{
		if(sum ==0 )
		{
			return 1;
		}
		return 0;
	}

	if(dp[index][flag][sum] != -1)
	{
		return dp[index][flag][sum];
	}

	int limit = 9;
	if(flag)
	{
		limit = s[index ] -'0';
	}
	ll ans = 0;
	
	for(int i=0;i<=limit;i++)
	{
		bool nf ;
		if(i < limit)
		{
			nf = 0;
		}
		else{
			nf = flag;
		}
		ans += digit_dp(index+1 ,nf,((sum + i)%d) % mod);
		ans %= mod;
	}

	dp[index][flag][sum] = (ans%mod);
	return (ans%mod);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 	
 
	//freopen ("test.txt","r",stdin);
	memset(dp, - 1, sizeof(dp));
	cin>>s;
	cin>>d;

	cout<<(( (digit_dp(0,1,0)- 1) + mod) % mod);

} 

Measured memory_bytes: 165376
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005
string s1,s2;
int memo[3001][3001];
int lcs(int ptr1,int ptr2)
{
	if(ptr1==s1.size()||ptr2==s2.size())
		return 0;
	if(memo[ptr1][ptr2]!=-1)
		return memo[ptr1][ptr2];
	ll ans;
	if(s1[ptr1]==s2[ptr2])
	{
		ans=lcs(ptr1+1,ptr2+1)+1;
	}
	else
	{
		ans=max(lcs(ptr1+1,ptr2),lcs(ptr1,ptr2+1));
	}
	memo[ptr1][ptr2]=ans;
	return ans;
}
int main()
{
    fastread;
    for(int i=0;i<=3000;i++)
    	for(int j=0;j<=3000;j++)
    		memo[i][j]=-1;
    cin>>s1>>s2;
    string ans;
    ll size=lcs(0,0);
    int p1=0,p2=0;
    while(ans.size()<size)
    {
    	if(s1[p1]==s2[p2])
    	{
    		ans.pb(s1[p1]);
    		p1++;
    		p2++;
    	}
    	else
    	{
    		if(memo[p1+1][p2]>memo[p1][p2+1])
    			p1++;
    		else
    			p2++;
    	}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <algorithm>
#include <boost/math/common_factor_rt.hpp>

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

template<class T> T gcd( T v1, T v2 )
{
    T m = max(v1, v2);
    T n = min(v1, v2);

    while( n != 0 )
    {
        T tmp = n;
        n = m % n;
        m = tmp;
    }

    return m;
}

template<class T> T lcm( T v1, T v2 )
{
//    return (v1 * v2) / gcd( v1, v2 );
    return v1 / gcd(v1, v2) * v2;
}

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

    unsigned long long v = 1, t;

    REP(i, N)
    {
        cin >> t;
        v = lcm(t, v);
    }

    cout << v << endl;

    return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

s=get_nsp
n=s.size
ans=0
(1<<(n-1)).times do|bit|
  split_p=array(n-1,1,"")
  (n-1).times do|i|
    unless (bit&(1<<i)).zero?
      split_p[i]="+"
    end
  end
  temp_s=s[0]
  (n-1).times do|i|
    if split_p[i]=="+"
      ans+=temp_s.to_i
      temp_s=s[i+1]
    else
      temp_s+=s[i+1]
    end
  end 
  ans+=temp_s.to_i
end
puts ans

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

int main(){
    int a,b,c,d,e,f,g;
    cin>>a>>b>>c>>d;
    if(a>=c){
        e=a-c;
        if(b>a){
            g=d+1;
            f=d+1;
        }
        else{
            g=a-b;
            f=b-c;
        }

    }
    else{
        e=c-a;
        if(b>c){
            g=d+1;
            f=d+1;
        }
        else{
            g=b-a;
            f=c-b;
        }
    }
    if(e<=d)
        cout<<"Yes"<<endl;
    else if(f<=d&&g<=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a < b) swap(a, b);
  if (a < c) swap(a, c);
  if (b < c) swap(b, c);
  int ans = 0;
  ans += a - b;
  ans += (b - c) / 2;
  if ((b - c) % 2 != 0) ans += 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#define inf 9223372036854775807
#define ll long long
#define pii pair<ll,ll>
#define m_p  make_pair
#define ull unsigned long long
#define spd  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
int main()
{
    spd

    string s,t;
    ll n,i,j,k;

    cin>>s>>t;
    ll mn = t.size();
     n = s.size();
     k = t.size();

    for(i=0;i<=n-k;i++)
    {
        ll cnt = 0;
        ll idx = 0;
        for(j=i;j<i+k;j++)
        {
            if(s[j]!=t[idx])
            {
                cnt++;
            }

            idx++;
        }
        mn = min(mn,cnt);
    }

    cout<<mn<<endl;
}


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

int main(){
  long double A;
  ll N,B;
  cin >> A >> B >> N;
  long double fp, ip, x;
  x = min( B-1, N );
  fp = modf( x * A / B, &ip );
  ll ans = (ll)ip;
  cout << ans << endl;
}


Measured memory_bytes: 3644
from math import sqrt, log


def factor(number):
    i = 2
    s = set()
    while i * i <= number:
        if number % i == 0:
            if i != 2:
                s.add(i)
            if (number // i) != 2:
                s.add(number//i)
        i += 1
    return s


def newFactor(number):
    n = number
    i = 2
    ans = set()
    while i * i <= number:
        if number % i == 0:
            while number % i == 0:
                number //= i
            if number % i == 1:
                ans.add(i)
        number = n
        i += 1
    return ans


n = int(input())
if n == 2:
    print(1)
    exit()
if n == 3:
    print(2)
    exit()
s = set()
s.add(2)
s.add(n-1)
s.add(n)
s = s.union(factor(n-1))
s = s.union(newFactor(n))
print(len(s))


Measured memory_bytes: 38768
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main() {
  string S;
  int w;
  cin >> S >> w;
  int cnt=0;
  while(cnt<S.size()) {
    printf("%c", S[cnt]);
    cnt += w;
  }
  printf("\n");
}

Measured memory_bytes: 256
#include <stdio.h>
int n;
long long t, s, u, v, q, f;
int a[15];
long long x[15];
long long y[15];
long long p[15];
long long r[20];
long long rr[20];
long long b[1024 * 32][15];
long long c[1024 * 32][15];
long long ans[16];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld%lld", x + i, y + i, p + i);
	}
	for (int i = 0; i <= n; i++) {
		ans[i] = 150000;
		ans[i] *= 1000000;
	}
	r[0] = 1;
	rr[0] = 1;
	for (int i = 0; i <= 15; i++) {
		r[i + 1] = r[i] * 3;
		rr[i + 1] = rr[i] * 2;
	}
	for (int i = 0; i < rr[n]; i++) {
		t = i;
		for (int j = 0; j < n; j++) {
			a[j] = t % 2;
			t /= 2;
		}
		for (int j = 0; j < n; j++) {
			s = x[j];
			if (x[j] < 0)s = -x[j];
			for (int k = 0; k < n; k++) {
				if (a[k]) {
					u = x[j] - x[k];
					if (u < 0)u = -u;
					if (s > u)s = u;
				}
			}
			b[i][j] = s * p[j];
		}
		for (int j = 0; j < n; j++) {
			s = y[j];
			if (y[j] < 0)s = -y[j];
			for (int k = 0; k < n; k++) {
				if (a[k]) {
					u = y[j] - y[k];
					if (u < 0)u = -u;
					if (s > u)s = u;
				}
			}
			c[i][j] = s * p[j];
		}
	}
	for (int i = 0; i < r[n]; i++) {
		t = i;
		s = 0;
		u = 0;
		q = 0;
		v = 0;
		for (int j = n - 1; j >= 0; j--) {
			a[j] = t % 3;
			if (a[j] == 1)s++;
			if (a[j] == 2)u++;
			t /= 3;
			s *= 2;
			u *= 2;
			if (a[j])q++;
		}
		s /= 2;
		u /= 2;
		for (int j = 0; j < n; j++) {
			if (!a[j]) {
				f = b[s][j];
				if (f > c[u][j])f = c[u][j];
				v += f;
			}
		}
		if (ans[q] > v)ans[q] = v;
	}
	for (int i = 0; i <= n; i++) {
		printf("%lld\n", ans[i]);
	}
}

Measured memory_bytes: 9368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template <typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main()
{
    string S;
    cin >> S;
    int N = int(S.length());
    string a = S.substr(0,(N-1)/2);
    string b = S.substr((N+3)/2-1,(N-1)/2);
    
    
    bool aa = true,bb = true;
    rep(i,a.size()){
        if(a[i] != a[a.size()-i-1]) aa = false;
        if(b[i] != b[b.size()-i-1]) bb = false;
    }
    bool cc = true;
    rep(i,S.size()){
        if(S[i] != S[S.size()-1-i]) cc = false;
    }
    
    if(aa && bb && cc) cyes;
    else cno;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jul  5 21:33:55 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    Int ans = (n + 1) * n * (n + 1) / 2 - n * (n + 1) * (2 * n + 1) / 6;
    dump(ans);
    REP(i, n - 1) {
        Int u, v;
        std::cin >> u >> v;
        u--, v--;
        Int l = std::min({u, v});
        Int r = std::max({u, v});
        ans -= (l + 1) * (n - r);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3652
s = gets.chomp.chars
atgc = ['A', 'T', 'G', 'C']
parts_length = []
temp = 0
ans = 0

s.each do |str|
  if atgc.include?(str)
    temp += 1
  else
    temp = 0
  end
  ans = temp if temp > ans
end

puts ans

Measured memory_bytes: 1788
package main

import (
	"fmt"
	"io"
	"os"
)

func Solve(stdin io.Reader, stdout io.Writer) {
	var n int
	_, _ = fmt.Fscanf(stdin, "%d\n", &n)

	a := make([]int, n)
	var max int
	_, _ = fmt.Fscanf(stdin, "%d\n", &max)
	a[0] = max
	second := 0

	for i := 1; i < n; i++ {
		var tmp int
		_, _ = fmt.Fscanf(stdin, "%d\n", &tmp)
		a[i] = tmp
		if tmp >= max {
			second = max
			max = tmp
		} else if tmp >= second {
			second = tmp
		}
	}

	for i := 0; i < n; i++ {
		var ans int
		if a[i] == max {
			ans = second
		} else {
			ans = max
		}
		_, _ = fmt.Fprintf(stdout, "%d\n", ans)
	}
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}


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

int main()
{
    int n,count=0,i,j;
    cin >> n;
    int arr[n-1];
    int arr2[n];
    for(i=0; i<n-1; i++)
        cin >> arr[i];
    for(i=0; i<n; i++)
        arr2[i]=0;
    for(i=0; i<n-1; i++)
        arr2[arr[i]-1]++;
    for(i=0; i<n; i++)
        cout << arr2[i] << endl;
    return 0;
}


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


int min(int a, int b)
{
	if(a<b) return a;
	return b;
}


int main(void)
{
	int n, i, j;
	char s[50+1];
	int count[256], result[256];

	while(scanf("%d", &n)==1)
	{
		memset(result, 1, sizeof(result));
		for(i=0;i<n;i++)
		{
			memset(count, 0, sizeof(count));

			scanf("%50s", s);
			for(j=0;s[j];j++)
			{
				count[s[j]]++;
			}
			for(j='a';j<='z';j++)
			{
				result[j]=min(result[j], count[j]);
			}
		}

		for(i='a';i<='z';i++)
		{
			for(j=0;j<result[i];j++)
			{
				putchar(i);
			}
		}
		putchar('\n');
	}

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"yes":"no")
#define YN(f) ((f)?"YES":"NO")

#define MAX 510

string s[MAX];
bool temp[30][30];
int ans;

void fuga(int a, int b){//cout<<(char)(a+'a')<<" "<<(char)(b+'a')<<endl;
	if(a==b||!ans) return;
	temp[a][b] = true;
	if(temp[a][b]&&temp[b][a]){
		ans = false;
		//cout<<"XXXX "<<(char)(a+'a')<<" "<<(char)(b+'a')<<endl;
	}
}

void hogehoge(int a, int b){
	if(a==b||!ans)return;
	
	queue<int> Q;
	bool used[30] = {};
	Q.push(a);
	
	while(!Q.empty()){
		int t = Q.front();Q.pop();
		used[t] = true;//cout<<t<<endl;
		fuga(t,b);
		for(int i = 0 ; i < 26; i++){
			if(!used[i]&&temp[i][t]) Q.push(i);
		}
	}
}

void hoge(string a, string b){
	if(!ans) return;
	int flag = 1;
	for(int i = 0,size = min(a.size(),b.size()); i < size; i++){//cout<<i<<"---"<<endl;
		if(flag)hogehoge(a[i]-'a',b[i]-'a');
		if(a[i] != b[i]) flag = false;
	}
	if(flag&&b.size()<a.size())ans = false;
}

signed main(){
	cout<<fixed<<setprecision(7);
	
	
	while(true){
		int n;
		
		ans = true;
		rep(i,30)rep(j,30)temp[i][j]=false;
		
		cin>>n;
		
		if(!n) break;
		
		for(int i = 0; i < n; i++){
			cin>>s[i];
			if(i) hoge(s[i-1],s[i]);
	}
	
		cout<<yn(ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

vector<vector<ll> > Comb(int n){
  vector<vector<ll> > v(n+1,vector<ll>(n+1));
  for(int i=0;i<=n;i++) v[i][i] = v[i][0] = 1LL;
  for(int i=2;i<=n;i++) {
    for(int j=1;j<i;j++) v[i][j] = v[i-1][j] + v[i-1][j-1];
  }
  return v;
}

void Main() {
  vector<vector<ll> > p=Comb(111);
  string s;
  ll m;
  cin >> s >> m;
  ll ans=0,c=0;
  rep(i,s.size()) {
    if(s[i]!='0') {
      if(m-c>=0) ans+=p[s.size()-i-1][m-c]*pow(9,m-c);
      if(m-c-1>=0) ans+=p[s.size()-i-1][m-c-1]*(s[i]-'1')*pow(9,m-c-1);
      c++;
    }
  }
  if(c==m) ans++;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int n ;
cin>>n ;
ll a[n];

for(int i = 0 ; i<n ; i++){

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

    if(a[i]==0)z++;
    if(z>=1){
            cout<<"0"<<endl;
        return 0 ;
    }
}
 ll prod =1;
for(int i = 0 ; i<n ; i++){

    if(a[i]<=1000000000000000000/prod){
        prod*=a[i];
    }
    else {
         cout<<"-1"<<endl;
           return 0 ;
      }
}
 cout<<prod<<endl;


return 0 ;
}


Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
#define anuj ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define ll long long int
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl '\n'
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5;
const int LG = 20;
double a[N];

int main(){
	anuj;

	int n;
	cin >> n;

	fo(i,n) cin >> a[i];

	double dp[n+1][n+1];
	dp[0][0]=1;

	Fo(i,1,n+1)
		fo(j,i+1)
			dp[i][j]=a[i-1]*(i>0?dp[i-1][j-1]:0)+(1-a[i-1])*dp[i-1][j];

	double sum=0;
	Fo(i,n/2+1,n+1)
		sum+=dp[n][i];

	cout << setprecision(9) << sum;			
}


Measured memory_bytes: 70016
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		long N = scan.nextLong();
		long A[] = new long[(int) N + 1];

		for (int i = 1; i <= N; i++) {
			A[i] = scan.nextLong();
		}

		Map<Long, Long> pair = new HashMap<Long, Long>();

		for (int j = 1; j <= N; j++) {

			if (pair.containsKey(A[j])) {
				long count;
				count = pair.get(A[j]);
				count++;
				pair.put(A[j], count);

			} else {
				//新しく追加
				pair.put(A[j], Long.valueOf(1));
			}

		}

		//Aiとその選び方の値
		long sum = 0;
		Map<Long, Long> pair2 = new HashMap<Long, Long>();
		for (Long key : pair.keySet()) {
			Long itemCount = pair.get(key);

			if (itemCount <= 1) {
				//				pair2.put(key, (long) 1);
				sum += 0;
			} else {
				//				pair2.put(key, itemCount * (itemCount - 1) / 2);
				sum += itemCount * (itemCount - 1) / 2;
			}
		}

		for (int k = 1; k <= N; k++) {

			//kの値をコレクションから引く
			//今のkの影響数
			long k_value = A[k];
			//kの値の数
			long k_count = pair.get(k_value);

			//sumに加算しているkの選び方
			long inputSum = 0;
			if (k_count <= 1) {
				inputSum = 0;
			} else {
				inputSum += k_count * (k_count - 1) / 2;
			}

			//kを除外した場合(個数が1減った場合)のsumへの影響
			long kasoSum = 0;
			if (k_count - 1 <= 0) {
				kasoSum = 0;
			} else {
				kasoSum += (k_count - 1) * (k_count - 2) / 2;
			}

			System.out.println(sum - (inputSum - kasoSum));

		}

	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 108936
n,w = map(int, input().split())
wv = []
vsum=0
for _ in range(n):
    tmp = list(map(int,input().split()))
    wv.append(tmp)
    vsum += tmp[1]

dp = [[float("inf") for i in range(vsum+1)] for j in range(n+1)]
dp[0][0]=0

for i in range(1,n+1):
    now_w,now_v =wv[i-1]
    for v in range(vsum+1):
        dp[i][v] = dp[i-1][v]
        if v - now_v >= 0:
            dp[i][v] = min(dp[i][v],dp[i-1][v-now_v] + now_w)

ans=0
for val in range(len(dp[-1])):
    if dp[-1][val] <= w:
        ans=val
print(ans)

Measured memory_bytes: 320916
import java.util.*;
	
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[][] kami = new int[10][10];
        
        int k,s,tmp;
        for(int i=1;i<N+1;i++) {
        	s=i%10;
        	tmp=i;
        	while(tmp>=10) {
        		tmp=tmp/10;
        	}
        	k=tmp;
        	kami[k][s]=kami[k][s]+1;        	
        }
        long ans=0;
        for(int i=0;i<10;i++) {
        	for(int j=0;j<10;j++) {
            	ans=ans+kami[i][j]*kami[j][i];        		
        	}
        }
        System.out.println(ans);
    }
 

}

Measured memory_bytes: 21588
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

struct Point
{
	int x, y;
	int h;
};

int n;
Point pts[110];

bool compare(const Point &a, const Point &b)
{
	if (a.h == b.h)
	{
		if (a.x == b.x)
			return a.y < b.y;
		else
			return a.x < b.x;
	}
	else
	{
		return a.h > b.h;
	}
}

int calcDist(const Point &a, const Point &b)
{
	return abs(a.x - b.x) + abs(a.y - b.y);
}

int doCheck(const int x, const int y)
{
	Point newPoint;
	newPoint.x = x;
	newPoint.y = y;
	int initD = calcDist(newPoint, pts[0]);
	newPoint.h = pts[0].h + initD;
	
	for (int i = 1 ; i < n ; i++)
	{
		int curDist = calcDist(newPoint, pts[i]);
		if (pts[i].h > 0)
		{
			if ((newPoint.h - curDist) != pts[i].h)
				return -1;
		}
		else
		{
			if ((newPoint.h - curDist) > 0)
				return -1;
		}
	}
	
	return newPoint.h;
}

int main()
{
	scanf("%d", &n);
	
	for (int i = 0 ; i < n ; i++)
		scanf("%d%d%d", &(pts[i].x), &(pts[i].y), &(pts[i].h));
		
	sort(pts, pts + n, compare);
		
	if (n == 1)
	{
		printf("%d %d %d\n", pts[0].x, pts[0].y, pts[0].h);
		return 0;
	}
	
	if (pts[0].h == 0)
	{
		printf("%d %d %d\n", pts[0].x, pts[0].y, pts[0].h);
		return 0;
	}
	
	
	else// if (n == 2)
	{
		int cx, cy;
		int ch;
		for (int x = 0 ; x <= 100 ; x++)
		{
			for (int y = 0 ; y <= 100 ; y++)
			{
				ch = doCheck(x, y);
				if (ch != -1)
				{
					cx = x;
					cy = y;
					break;
				}
			}
			if (ch != -1)
				break;
		}			
			
		printf("%d %d %d\n", cx, cy, ch);
	}
		
		
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<ll>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
   ll n;
   cin>> n ;
   vector<P> A(n) ;
   rep(i,n){
     cin >>A[i].first ;
     A[i].second=i ;
   }
    sort(A.begin(),A.end()) ; //配列の数でソート
    ll ans  =0 ;
    rep(i,n){
    if(abs(i-A[i].second)%2==1) ans++ ;
    }
    cout << ans/2 <<endl ;
    return 0;
  }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
using namespace std;
using ll = long signed long;

using point = pair<ll, ll>;

vector<point> neighborhood_of(const point &xy) {
    const ll x = xy.first, y = xy.second;
    return {
        {x-1, y-1},
        {x  , y-1},
        {x-1, y  },
        {x+1, y  },
        {x  , y+1},
        {x+1, y+1}
    };
}

int main() {

    vector<ll> anss;

    for (ll t, n; cin >> t >> n, t; ) {

        set<point> o;
        REP(i, n) {
            ll x, y; cin >> x >> y;
            o.insert(point(x, y));
        }

        ll rx, ry; cin >> rx >> ry;

        set<point> vst;
        map<point, ll> dep;
        deque<point> q;
        q.emplace_back(rx, ry);
        vst.insert(q.back());
        dep[q.back()] = 0;
        while (q.size()) {
            point u = q.front(); q.pop_front();
            const ll d = dep[u];
            if (d >= t) continue;
            for (const point &v : neighborhood_of(u)) {
                if (o.find(v) == o.end() && vst.find(v) == vst.end()) {
                    q.push_back(v);
                    vst.insert(v);
                    dep[v] = d + 1;
                }
            }
        }

        anss.emplace_back(vst.size());

    }

    for (ll ans : anss) cout << ans << endl;

}


Measured memory_bytes: 3520
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main(string[] args) {
        List<char> ah = cin.next().ToCharArray().ToList();
        List<char> bh = cin.next().ToCharArray().ToList();
        List<char> ch = cin.next().ToCharArray().ToList();
        List<char>[] hands = new List<char>[] { ah, bh, ch };
        int turn = 0;

        while (hands[turn].Count > 0) {
            int tmpTurn = hands[turn].First() - 'a';
            hands[turn].RemoveAt(0);
            turn = tmpTurn;                           
        }
        Console.WriteLine((char)(turn + 'A'));
    }
}


public class cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public static int ni() {
        return int.Parse(next());
    }

    public static long nextLong() {
        return long.Parse(next());
    }

    public static double nextDouble() {
        return double.Parse(next());
    }

}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  if(n%2==0)cout<<n<<endl;
  else cout<<2*n<<endl;


  return 0;
}


Measured memory_bytes: 256
function main(input){
  var In = input.split(' ');
  var pro = In[0] * In[1];
  
  if(pro%2 == 0) {
    console.log('Even');
  } else {
    console.log('Odd');
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7496
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}
const double PI = 3.1415926535897932;
/******define variable start******/
ll n, m;
vl a;
/*******define variable end*******/
ll solve(){
    cin >> n >> m;
    a.resize(n);
    REP(i, n){
        cin >> a[i];
    }
    ll lcm_num = a[0];
    for(ll i = 1; i < n; i++){
        lcm_num = lcm(lcm_num, a[i]);
    }
    lcm_num /= 2;
    REP(i, n){
        if((lcm_num / (a[i]/2)) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ma = m / lcm_num;
    if (m < lcm_num){ 
        cout << 0 << endl;
    }else {
        cout << (ll)ceil((long double)((long double)ma/2))<< endl;
    }
    
    return 0;
    //24m
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}

Measured memory_bytes: 1024
N, Y = list(map(int, input().split()))
S = Y // 10000 + 1
for i in range(S):
    T = (Y - i * 10000) // 5000 + 1
    for j in range(T):
        U = int((Y - i * 10000 - j * 5000) / 1000)
        if i + j + U == N:
            print(i, j, U)
            break
    else:
        continue
    break
else:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-
n=int(input())
a=[int(x) for x in input().split()]
mod=10**9+7
lcm=1
from fractions import gcd
for ai in a:
    lcm=ai*lcm//gcd(ai,lcm)
ans=0
for ai in a:
    ans+=lcm//ai
print(ans%mod)

Measured memory_bytes: 5608