akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import deque
s = deque(map(str, input().rstrip()))

# 辞書の最後は-1
if "".join(s) == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    sys.exit()

# 使える文字リスト作成
s = [ord(x) for x in s]

# 26文字未満なら、未使用の１文字を追加して終わり
if len(s) < 26:
    can_use = set(range(97, 123)) - set(s)
    s = s + [min(can_use)]

# 26文字の時は例外処理を入れる
else:
    add = []
    s = s[::-1]
    prev = s[0]
    add.append(prev)

    # 末尾がzならzを消去し、1文字前をzにして終わり
    if prev == 122:
        s[1] = 122
        s = s[::-1][:-1]

    # そうでなければ、初めて増加する値が減少するタイミングまで見る
    # 減少するポイントで、その時点で使える中で最小の文字に差し替え
    else:
        for i in range(1, len(s)):
            if prev > s[i]:
                add = [x for x in add if x > s[i]]
                s[i] = (min(add))
                s = s[::-1][:-i]
                break
            prev = s[i]
            add.append(prev)

# 文字列に戻す処理
s = [chr(x) for x in s]

print("".join(s))

Measured memory_bytes: 3316
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html
class UnionFind:
    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.table = [-1 for _ in range(size)]

    # 集合の代表を求める
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    # 併合
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                # 小さいほうが個数が多い
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    # 部分集合とその要素数を返す
    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a
        
def solve(N, M, P, xy):
    uf = UnionFind(N + 1)
    for x, y in xy:
        uf.union(x, y)
    result = 0
    for i, n in enumerate(P):
        if uf.find(i + 1) == uf.find(n):
            result += 1
    return result

N, M = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
xy = [[int(x) for x in input().split()] for i in range(M)]

print(solve(N, M, P, xy))



Measured memory_bytes: 26372
n = int(input())
xy = [list(map(float,input().split())) for i in range(n)]
su = 0
t =1
for i in range(n):
     for j in range(n):
          su += ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**(1/2)
print(su/n)


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

int main(){
    int x,n;
    cin>>x>>n;
    int p[n],i,j,xs;
    for(i=0;i<n;i++)cin>>p[i];
    if(n==0){
    	cout<<x<<endl;
    	return 0;
	}
    int mini=1000,ans=0;
    for(i=0;i<=105;i++){
    	if(abs(x-i)<mini){
    		for(j=0;j<n;j++){
    			if(i==p[j])goto pass;
			}
			mini=x-i;
			ans=i;
		}
		pass:
			xs++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    string N; cin >> N;
    int sum = 0;
    for (int i = 0; i < N.size(); i++) {
        sum += N[i] - '0';
    }
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3712
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, less<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    vec a(3);
    rep(i,3)cin>>a[i];
    sort(all(a));
    a.erase(unique(all(a)),a.end());
    cout<<a.size()<<endl;
}

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

long long n;
vector<long long> a, res;

void solve();

int main() {
  cin >> n;
  a.resize(n);
  res.resize(n);
  for (auto& p : a) cin >> p;
  solve();
  for (int i = 0; i < n; ++i) cout << res[i] << " \n"[i == n - 1];
  return 0;
}

void solve() {
  long long x = 0;
  for (int i = 0; i < n; ++i) x ^= a[i];
  for (int i = 0; i < n; ++i) res[i] = x ^ a[i];
}

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

typedef long long LL;
int INF=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(false);
    
    int A,B,C,D,E,F;
    int ans1=0,ans2=0;
    double tmp,LD=-1;
    cin>>A>>B>>C>>D>>E>>F;
    
    for(int a=0;a*A*100<=F;a++){
        for(int b=0;a*A*100+b*B*100<=F;b++){
            for(int c=0;a*A*100+b*B*100+c*C<=F;c++){
                for(int d=0;a*A*100+b*B*100+c*C+d*D<=F;d++){
                    if(c*C+d*D>(a*A+b*B)*E) break;
                    tmp=(1.0)*(c*C+d*D)/(a*A*100+b*B*100+c*C+d*D);
                    if(LD<tmp) {LD=tmp;ans1=(a*A*100+b*B*100+c*C+d*D);ans2=(c*C+d*D);}
                }
            }
        }
    }
    
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD 1000000007
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll n;
ll dp[25][2100000];
ll a[25][25];
ll compute(int i, int cur)
{
    if(i==n)
    {
        if(cur== pow(2, n)-1) return 1;
        return 0;
    }
    if(dp[i][cur]!=-1) return dp[i][cur];
    ll j;
    ll ans = 0;
    FOR0(j, n)
    {
        if(!((1<<j)&cur)&&a[i][j])
        {
            ans += compute(i+1, (1<<j)|cur);
            ans %= MOD;
        }
    }
    return dp[i][cur] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n;
    int i, j;
    FOR0(i, n) FOR0(j, n) cin>>a[i][j];
    memset(dp, -1, sizeof dp);
    cout<<compute(0, 0);
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

using namespace std;

int main() {
	int n;
	ignore = scanf("%d", &n);
	
	map<long long, int> cnt;
	cnt[0] = 1;
	
	long long s = 0, ans = 0;
	for (int i = 0, x; i < n; i++) {
		ignore = scanf("%d", &x);
		s += x;
		if (cnt.count(s) == 1) ans += cnt[s];
		cnt[s]++;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 12800
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> count(6);
    for(int i = 0;i < n;i ++){
        string s;
        cin >> s;
        if(s.at(0) == 'M') count.at(1) ++;
        if(s.at(0) == 'A') count.at(2) ++;
        if(s.at(0) == 'R') count.at(3) ++;
        if(s.at(0) == 'C') count.at(4) ++;
        if(s.at(0) == 'H') count.at(5) ++;
    }

    int ans = 0;
    vector<int> select(6);
    int sum;
    while(select.at(0) == 0){
        select.at(5) ++;
        for(int i = 5;i > 0;i --){
            if(select.at(i) == 2){
                select.at(i) = 0;
                select.at(i-1) ++;
            }
        }

        sum = 0;
        for(int i = 0;i < 6;i ++) sum += select.at(i);
        if(sum == 3){
            int keisan = 1;
            for(int i = 1;i < 6;i ++){
                if(select.at(i) == 1)keisan *= count.at(i);
            }
            ans += keisan;
        }
    }

    cout << ans << endl;
}

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

int main(){
    string x,y;
    while(cin >> x >> y){
        int aa,bb;
        cin >> aa >> bb;
        string str;
        cin >> str;
        if(str==x){
            aa-=1;
            cout << aa << " " << bb << '\n';
        }else{
            bb-=1;
            cout << aa << " " << bb << '\n';
        }
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n; cin >> n;
    if(n%2==1){
        cout << "0\n";
    }else {
        //divide by 10, 50, 250...
        int ans = 0;
        int currDiv = 10;
        while(n/currDiv){
            ans += n/currDiv;
            currDiv *= 5;
        }
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	long long a, b;
	while(cin >> a >> b){
		long long gcd = __gcd(a, b);
		long long lcm = a * b / gcd;
		cout << gcd << ' ' << lcm << '\n';
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
int cnt[2005];

int main(void)
{
	int n, x, y; cin >> n >> x >> y;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int dist = min(j-i, (abs(i-x)+1+abs(y-j)));
			cnt[dist]++;
		}
	}
	for(int i=1;i<n;i++){
		cout << cnt[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,aa,bb,cc,sum;
ll l[8];
ll kado(ll a,ll b,ll c,ll i){
  if(i==n&&(a==0||b==0||c==0)) return 10000000000;
  if(i==n) return abs(a-aa)+abs(b-bb)+abs(c-cc)-30;
  ll sum1=kado(a+l[i],b,c,i+1)+10;
  ll sum2=kado(a,b+l[i],c,i+1)+10;
  ll sum3=kado(a,b,c+l[i],i+1)+10;
  ll sum4=kado(a,b,c,i+1);
  sum=min({sum1,sum2,sum3,sum4});
  return sum;
}
int main(){
  cin >>n>>aa>>bb>>cc;
  for(ll i=0;i<n;i++) cin>>l[i];
  cout <<kado(0,0,0,0)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  int total = 0;
  int x = 0;
  auto findp = [&](int base, int maxn)
  {
    int result = 0;
    for(int i = 1; i <= n; i++)
    {
      int temp = pow(base, i);
      if(temp > maxn)
      {
        break;
      }else{
        result = temp;
      }
    }
    return result;
  };
  vector<int> dp(n + 1, 0);
  for(int i = 1; i <= n; i++)
  {
    int temp9 = findp(9, i);
    int temp6 = findp(6, i);
    int maxtemp = max(temp9, temp6);
    if(maxtemp == 0)
    {
      dp[i] = dp[i - 1] + 1;
    }else if(temp6 != 0 && temp9 != 0){
      dp[i] = dp[i - temp9] < dp[i - temp6] ? dp[i - temp9] + 1 : dp[i - temp6] + 1;
    }else{
      dp[i] = dp[i - maxtemp] + 1;
    }
  }
  cout << dp.back() << endl;
  /*while (n > total)
  {
    int temp9 = findp(9, n - total);
    int temp6 = findp(6, n - total);
    int temp1 = findp(1, n - total);
    int maxtemp = max(temp9, temp6);
    maxtemp = max(maxtemp, temp1);
    total += maxtemp;
    x++;
  }
  cout << x << endl;*/
  return 0;
}


Measured memory_bytes: 640
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    sn = sum([a, b, c])
    mn = max(a, b, c)
    for i in range(mn * 3, 10 ** 10, 3):
        if (i - sn) % 2 == 0:
            print((i - sn) // 2)
            exit()


if __name__ == '__main__':
    solve()


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,x,l,cur=0,ret=1;
	cin>>n>>x;
	for (int i=0; i<n; i++) {
		cin>>l;
		cur+=l;
		if(cur<=x) ret++;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost				  ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
#define dbg(x)                cerr <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
void set_bit(ll &N, int pos) { N=N | (1 << pos);}
void reset_bit(int &N, int pos) { N=N & ~(1 << pos);}
bool check_bit(int N,int pos) {return (bool)( N&(1 << pos));}
template <class T > void max_self(T &a, T b){
	a=max(a,b);
}
template <class T > void min_self(T &a, T b){
	a=min(a,b);
}
////////////////////////
const ll mod =1e9+7;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;

void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
////////////////////////
int compatible[25][25];
const ll nax =(1<<21) +5;
ll dp[nax][25] ;
void sum_self(ll &a, ll b){
	a+=b ;
	if(a>=mod)
		a-=mod;
}
ll find_way(int n,int curr ,ll mask){
	if(curr==n)
		return 1;
	if(dp[mask][curr]!=-1)
		return dp[mask][curr];
	
	ll ways=0,temp;
	for(int i=0; i< n; ++i){
		if(compatible[curr][i] && !check_bit(mask,i)){
			temp = mask;
			set_bit(mask,i);
			sum_self(ways,find_way(n,curr+1,mask));
			mask =temp ;
		}
	}
	
	return dp[mask][curr]=ways;
}
int main()
{
	/* We can use bitmasking to solve this dp problem
	 * This is a very easy bitmasking problem */
	 int n;
	 memset(dp,-1,sizeof(dp));
	 scanf("%d",&n);
	 for(int i=0; i< n; ++i){
		 for(int j=0; j< n; ++j){
			 scanf("%d",&compatible[i][j]);
		 }
	 }
	ll mask =0;
	ll ways = find_way(n,0,mask);
	printf("%lld\n",ways);
    return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	deque<int> dq;
	bool en = false;
	int cur = 0;
	for(int i = 0; i < s.length(); i++)
	{
		if(s[i] == 'T' && !en) continue;
		else if(!en && s[i] == 'S')
		{
			cur = 1;
			en = true;
			continue;
		}
		if(i > 0 && s[i] != s[i - 1])
		{
			dq.pb(cur);
			cur = 1;
		}
		else
		{
			cur++;
		}
	}
	if(cur > 0) dq.pb(cur);
	//for(int i = 0; i < dq.size(); i++) cout << dq[i] << ' ';
	//cout << endl;
	int ans = 0;
	while(dq.size() >= 2)
	{
		if(dq[0] > dq[1])
		{
			ans += dq[1];
			int v = dq[0] - dq[1];
			dq.pop_front(); dq.pop_front();
			if(!dq.empty()) dq[0] += v;
		}
		else
		{
			ans += dq[0];
			dq.pop_front(); dq.pop_front();
		}
	}
	cout << int(s.length()) - 2*ans;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const int INF=1e9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, k;
  int s;
  cin>>n>>k>>s;
  REP(i, k){
    cout<<s<<' ';
  }
  if(s==INF){
    FOR(i, k, n){
      cout<<1<<'\n';
    }
  }
  else{
    FOR(i, k, n){
    cout<<INF<<' ';
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	/*if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;*/
	return ((a.x + 1)*(a.y + 1)) < ((b.x + 1)*(b.y + 1));
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k, ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
 //#define int long long
const long long Inf = 4523372036854775807;
const int inf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin >> n;
	if (n == 0) cout << 1 << endl;
	else if (n == 1) cout << 2 << endl;
	else if (n == 2) cout << 1 << endl;
	else cout << 0 << endl;
	getchar(); getchar();
}


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

using namespace std;

const int MAXN = 200010;
const int MOD = 1e9+7;

long long mod_pow(long long b, long long x){
  if(!x) return 1;
  if(x & 1) return (b * mod_pow(b, x-1))%MOD;
  long long tmp = mod_pow(b, x >> 1);
  return (tmp * tmp) % MOD;
}

int main(){
  int N, K;
  while(scanf("%d%d", &N, &K) > 0){
    long long ans = 0;

    for(int k = K; k <= N+1; k++){
      long long tmp1 = (2*N - k + 1 + MOD)%MOD;
      tmp1 = (tmp1 * k)%MOD;
      tmp1 = (tmp1 * mod_pow(2, MOD-2))%MOD;

      long long tmp0 = (k-1)%MOD;
      tmp0 = (tmp0 * k)%MOD;
      tmp0 = (tmp0 * mod_pow(2, MOD-2))%MOD;

      ans = (ans + ((tmp1-tmp0+1+MOD)%MOD))%MOD;
    }

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


Measured memory_bytes: 3828
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(int x, int y) __attribute__ ((warn_unused_result));


int const mod = 1e9+7;

inline int safe_mul(const int x, const int y) {
    return x * 1LL * y % mod;
}

inline void safe_add(int& x, const int y) {
    x += y;
    if (x >= mod)
        x -= mod;
}

inline int safe_pow(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1)
            res = safe_mul(res, x);
        x = safe_mul(x, x);
        y >>= 1;
    }
    return res;
}

inline int safe_inv(const int x) {
    return safe_pow(x, mod - 2);
}

int const maxn = 100005;
int fact[maxn];
int fact_inv[maxn];

inline int C(const int n, const int k) {
    if (n < 0 || n < k || k < 0) return 0;
    return safe_mul(fact[n], safe_mul(fact_inv[n - k], fact_inv[k]));
}

void precalc() {
    fact[0] = fact_inv[0] = 1;
    for(int i = 1; i < maxn; ++i) {
        fact[i] = safe_mul(fact[i - 1], i);
        fact_inv[i] = safe_inv(fact[i]);
    }
}

inline int FCray(const int n, const int k) {
    int res = C(n, k + 1);
    res = safe_mul(res, fact[k]);
    return safe_mul(res, fact[n - k - 1]);
}

inline int FInl(const int n, const int k) {
    int res = safe_mul(2, C(n, k + 2));
    res = safe_mul(res, fact[k]);
    return safe_mul(res, fact[n - k - 2]);
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);

    precalc();

    int n;
    cin >> n;
    vector<int> a(n);
    int res = 0;
    for (int& x : a) {
        cin >> x;
        safe_add(res, x);
    }

    res = safe_mul(res, fact[n]);

    int curpr = 0;
    for (int i = 0; i + 1 < n; ++i) {
        safe_add(curpr, a[i]);
        safe_add(res, safe_mul(FCray(n, i + 1), curpr));
    }
    curpr = 0;
    for (int i = n - 1; i > 0; --i) {
        safe_add(curpr, a[i]);
        safe_add(res, safe_mul(FCray(n, n - i), curpr));
    }

    int sum = 0;
    for(int i = 1; i + 1 < n; ++i)
        safe_add(sum, a[i]);

    int cur = 0;
    for(int len = 1; len <= n - 2; ++len) {
        safe_add(cur, sum);
        safe_add(sum, mod - a[len]);
        safe_add(sum, mod - a[n - 1 - len]);
        safe_add(res, safe_mul(cur, FInl(n, len)));
    }
    cout << res << endl;
}


Measured memory_bytes: 1408
const main = (input) => {
  const [houseW, curtainW] = input.split(' ');
  console.log( eval(houseW - eval(curtainW * 2)) > 0 ? eval(houseW - (curtainW * 2)) : 0 );  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

vector<int> G[200];
int match[200],V;
bool used[200];

void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}
bool dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i],w=match[u];
		if(w<0||(!used[w]&&dfs(w))){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}
int bipartite_matching(){
	int res=0;
	memset(match,-1,sizeof(match));
	for(int v=0;v<V;v++){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}

int main(){
	int x,y,e,a,b;
	cin>>x>>y>>e;
	for(int i=0;i<e;i++){
		cin>>a>>b;
		add_edge(a,x+b);
	}
	V=x+y;
	cout << bipartite_matching()<<endl;
	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i++)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    int n;
	    cin>>n;
	    int k;
	    cin>>k;
	    set <int >s;
	    f(i,k)
	    {
	        int z;
	        cin>>z;
	        f(j,z)
	        {
	            int w;
	            cin>>w;
	            s.insert(w);
	            
	        }
	        
	    }
	   cout<<n-s.size()<<bn;
	   
	   
	    
	}
	
	return 0;
}


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


int main(){
  int a,b;
  cin>>a>>b;
  string s[a];
  rep(i,a){
    cin>>s[i];
  }
  rep(i,a){
    cout<<s[i]<<endl;
    cout<<s[i]<<endl;
  }

  return 0;
}




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

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n,m,cnt2 = 0;
  cin >> n;
  vector<string> w(n);
  map<string,int> cnt;
  for (int i = 0; i < n; i++){
    cin >> w[i];
    if (i != 0 && cnt2 == 0 && (w[i-1][m-1] != w[i][0] || cnt[w[i]] != 0)){
      cout << "No\n";
      cnt2++;
    }
    m = w[i].size();
    cnt[w[i]]++;
  }
  if (cnt2 == 0){
    cout << "Yes\n";
  } 
  return 0;
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;


typedef map<ll, int> mli;
ll bin_pow(ll x, ll p)
{
	ll res = 1;
	while (p)
	{
		if (p & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		p /= 2;
	}
	return res;
}

map<ll, int> get_div(ll a)
{
	map<ll, int> mp;
	for (ll i = 2; i * i <= a; i++)
	{
		if (a % i == 0)
		{
			int cnt = 0;
			while (a % i == 0)
			{
				cnt++;
				a /= i;
			}
			mp[i] = cnt;
		}
	}
	if (a > 1)
		mp[a] = 1;
	return mp;
}

void mult(map<ll, int>& a, map<ll, int>& b)
{
	for (auto p : b)
		a[p.first] += p.second;
}

void mydiv(mli& a, mli& b)
{
	for (auto p : b)
		a[p.first] -= p.second;
}

map<ll, int> mygcd(mli& a, mli& b)
{
	mli res;
	for (auto p : a)
		if (b.count(p.first))
			res[p.first] = min(p.second, b[p.first]);
	return res;
}


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<mli> amp(n);
	for (auto& i : a)
		cin >> i;
	for (int i = 0; i < n; i++)
		amp[i] = get_div(a[i]);
	map<ll, int> lcm = amp[0];
	for (int i = 1; i < n; i++)
	{
		auto g = mygcd(lcm, amp[i]);
		mult(lcm, amp[i]);
		
		mydiv(lcm, g);
	}
	ll cres = 1;
	for (auto p : lcm)
		cres = cres * bin_pow(p.first, p.second) % mod;

	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		res = (res + cres * bin_pow(a[i], mod - 2)) % mod;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  int ln=0;
  int ot=0;
  rep(i,s.size()){
    if (s[i]=='a'){
      if(ln<a+b){
        cout<<"Yes"<<endl;
        ln++;
      }
      else{
        cout<<"No"<<endl;
      }
    }
    else if (s[i]=='b'){
      if(ln<a+b && ot<b){
        cout<<"Yes"<<endl;
        ln++;
        ot++;
      }
      else{
        cout<<"No"<<endl;
      }
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 896
#include "bits/stdc++.h"

using namespace std;

int N, M;
vector<long long> X, Y, Z;

long long greedy(long long signX, long long signY, long long signZ) {
    vector<long long> sorted(N, 0LL);
    for (int i = 0; i < N; ++i) {
        sorted[i] += signX * X[i] + signY * Y[i] + signZ * Z[i];
    }
    sort(sorted.begin(), sorted.end(), greater<long long>());
    long long ret = 0;
    for (int i = 0; i < M; ++i) {
        ret += sorted[i];
    }
    return ret;
}

void Main() {
    cin >> N >> M;
    X = vector<long long>(N, 0LL);
    Y = vector<long long>(N, 0LL);
    Z = vector<long long>(N, 0LL);
    for (int i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i] >> Z[i];
    }

    long long ans = greedy(1LL, 1LL, 1LL);
    ans = max(ans, greedy(1LL, 1LL, -1LL));
    ans = max(ans, greedy(1LL, -1LL, 1LL));
    ans = max(ans, greedy(-1LL, 1LL, 1LL));
    ans = max(ans, greedy(1LL, -1LL, -1LL));
    ans = max(ans, greedy(-1LL, 1LL, -1LL));
    ans = max(ans, greedy(-1LL, -1LL, 1LL));
    ans = max(ans, greedy(-1LL, -1LL, -1LL));
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

const long double pi=3.14159265359;
int main(){
	long double a,b,x,y,m;
	cin >> a >> b >>x;
	if(a*a*b/2>x){
		y=x/(a*b)*2;
		m=b/y;
	}else{
		y=(a*a*b-x)/(a*a)*2;
		m=a/y;
	}
	long double l=0,r=89.999999999;

	while(l+0.00000001<r){
		long double mid=(l+r)/2;
		if(tan(mid*pi/180)>m){
			r=mid;
		}else{
			l=mid;
		}
	}
	cout << fixed;
	cout << setprecision(12);
	if(a*a*b/2>x){
		cout << l << endl;
	}else{
		cout << 90-l << endl;
	}
}

Measured memory_bytes: 384
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b,c;
	cin>>a>>b>>c;
	c-=a-b;
	if(c<0)cout<<0;
	else cout<<c;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=k)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define MOD 1000000007

ll dp[10010][110][2];//dp[i][j][k]=上からi桁目まで決まっていて、modがjで、Nより小さいことが確定して(k?いる:いない)
char s[10010];

int main(){
	ll d;
	scanf("%s%lld",s,&d);
	ll n=strlen(s);
	dp[0][0][0]=1;
	rep(i,0,n)rep(j,0,d){
		rep(dig,0,10)dp[i+1][(j+dig)%d][1]=(dp[i+1][(j+dig)%d][1]+dp[i][j][1])%MOD;
		rep(dig,0,s[i]-'0')dp[i+1][(j+dig)%d][1]=(dp[i+1][(j+dig)%d][1]+dp[i][j][0])%MOD;
		dp[i+1][(j+s[i]-'0')%d][0]=(dp[i+1][(j+s[i]-'0')%d][0]+dp[i][j][0])%MOD;
	}
	printf("%lld\n",(dp[n][0][0]+dp[n][0][1]-1+MOD)%MOD);
	return 0;
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    int n; cin>>n;
    if(n <= 104){
        cout << 0 << endl;
    }
    else if(n == 105 || n == 106){
        cout << 1 << endl;
    }
    else{
        int ans=0;
        for(int i=107; i<=n; i+=2){
            int cnt=0;
            for(int j=i; j>0; j--){
                if(i % j == 0) cnt++;
            }

            if(cnt == 8) ans++;
        }
        cout << ans + 1 << endl;
    }
}

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

using namespace std;

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

  int h, w;
  int pow[10][10];
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> pow[i][j];
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
    }
  }

  int mins[10];
  for (int i = 0; i < 10; ++i) {
    if (i == 1)
      mins[1] = 0;
    else
      mins[i] = 1000;
  }
  priority_queue<pair<int, int>,
                 vector<pair<int, int>>,
                 greater<pair<int, int>>> q;
  q.push(make_pair(0, 1));
  while (!q.empty()) {
    auto v = q.top();
    q.pop();
    for (int j = 0; j < 10; ++j) {
      if (v.first + pow[j][v.second] < mins[j]) {
        mins[j] = v.first + pow[j][v.second];
        q.push(make_pair(v.first + pow[j][v.second], j));
      }
    }
  }

  uint64_t cost = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (a[i][j] < 0) continue;
      cost += mins[a[i][j]];
    }
  }
  cout << cost << "\n";
}


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

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	for(int i = a;;i += a){
		if(i % b == c % b){
			cout << "YES";
			break;
		}
		cnt++;
		if(cnt > 10000){
			cout << "NO";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();
}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;

const int N = 5e5 + 666;
const ll mo = 1e9 + 7;
char s[N];
int n;
int v[N];
int main() {
	n = read();
	scanf("%s", s + 1);
	n *= 2;
	if(s[1] == 'W' || s[n] == 'W') {
		puts("0");
		return 0;
	}
	int d = 1;
	for(int i = 2; i <= n; ++i) {
		if(s[i] == 'W') {
			if(d & 1) v[i] = 0, ++d;
			else v[i] = 1, --d;
		} else {
			if(d & 1) v[i] = 1, --d;
			else v[i] = 0, ++d;
		}
	}
	if(d) {
		puts("0");
		return 0;
	}
/*	for(int i = 1; i <= n; ++i)
		printf("%d ", v[i]);*/
	d = 0;
	ll res = 1;
	for(int i = 1; i <= n / 2; ++i) res = res * i % mo;
	for(int i = 1; i <= n; ++i) {
		if(v[i] == 0) ++d;
		else res = res * d % mo, --d;
	}
	writeln(res);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;
int cnt[11][11];

itn TOP(int x) {
    if (x >= 10)
        return TOP(x / 10);
    else
        return x;
}
int BOT(int x) {
    return x % 10;
}
int N;

void solve() {
    FOR(i, 1, N + 1) {
        cnt[TOP(i)][BOT(i)]++;
    }
    itn ans = 0;
    FOR(x, 1, 10) {
        FOR(y, 1, 10) {
            ans += cnt[x][y] * cnt[y][x];
        }
    }
    cout << ans << endl;
}


signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    solve();
    return 0;
}


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

int main(){
	char a;
	cin>>a;
	if('a'<=a&&a<='z'){
		cout<<"a"<<endl;
	}
	else if('A'<=a&&a<='Z'){
		cout<<"A"<<endl;
	}

	return 0;
}

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

int HP(int N, vector<int> X, int x){
  int result = 0;
  for (int i=0; i<N; i++){
    result += (X.at(i) - x)*(X.at(i) - x);
  }
  return result;
}

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i=0; i<N; i++){
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());
  int start = X.at(0);
  int end = X.at(N-1);
  int result = HP(N,X,start);
  for (int i=start+1; i<=end; i++){
    result = min(result, HP(N,X,i));
  }
  cout << result << endl;
  
}

Measured memory_bytes: 256
N = int(input())
query = [[] for _ in range(N)]
color = []
m = [0]*N
for n in range(N-1):
    a, b = map(int, input().split())
    query[a-1].append(b-1) 
    query[b-1].append(a-1)
    color.append((min(a, b), max(a, b)))
    m[a-1] += 1
    m[b-1] += 1

print(max(m))
from collections import deque
queue = deque()
queue.appendleft(0)
checked = [-1]*N
checked[0] = 0
dic = {}
while queue:
    v = queue.pop()
    oya = checked[v]
    lis = query[v]
    cnt = 1
    for i in lis:
        if checked[i]!=-1:
            continue
        if cnt==oya:
            cnt += 1
        queue.appendleft(i)
        dic[(min(v+1, i+1), max(v+1, i+1))] = cnt
        checked[i] = cnt
        cnt += 1

for n in range(N-1):
    a, b = color[n]
    print(dic[(min(a, b), max(a, b))])

Measured memory_bytes: 93216
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

bool solve() {
	int n, d;
	cin >> n >> d;
	int i = d + 1;
	int ans = 1;
	while (i + d < n) {
		ans++;
		i += 1 + d * 2;
	}

	cout << ans << endl;
	return true;
}

signed main() {
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char p[201000];
int n,a,b,c,d,S[201000],w[201000];
int main() {
	int i;
	cin>>n>>a>>b>>c>>d;
	scanf("%s",p+1);
	for(int i=1;i<=n;i++) {
		if(p[i]=='#') w[i]=1;
		S[i]=S[i-1]+w[i];
	}
	for(int i=1;i<n;i++) {
		if(w[i] && w[i+1]) {
			if(a<=i && i+1<=c) {
				cout<<"No"<<endl;
				return 0;
			}
			if(b<=i && i+1<=d) {
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	if(c<=d) {
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=b;i<=d;i++) {
		if(!w[i-1] && !w[i] && !w[i+1]) {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
	int k ; cin >> k ;
	for(int i=0;i<k;i++) cout << "ACL" ;
	cout << endl ;
}


Measured memory_bytes: 3624