akhauriyash/Code-Regression huggingface dataset:
//
//$$$$$$$$$$$$$$$$$$$$$$
//$$                  $$
//$$   gyoubu_oniwa   $$
//$$                  $$
//$$$$$$$$$$$$$$$$$$$$$$
//
#include<bits/stdc++.h>
using namespace std;
#define DBG(a) if(DBGDO) cout<<#a<<':'<<a<<endl;
#define PB push_back
#define EB emplace_back
#define btoe(v) (v).begin(),(v).end()
#define etob(v) (v).rbegin(),(v).rend()
#define F first
#define S second
#define SZ size()
#define pow(a,b) (pow(a,b)+0.5)

typedef unsigned long long int ulli;
typedef long long int lli;
typedef long double ldbl;
#define f(i,a,b) for(int i=(a); i<(b); ++i)
#define fr(i,a,b) for(int i=(a); i>(b); --i)
#define fl(i,a,b) for(lli i=(a); i<(b); ++i)
#define flr(i,a,b) for(lli i=(a); i>(b); --i)
#define w(x) lli x; cin>>x; while(x--) 
#define inpn(n,v,T) T n; cin>>n; vector<T> v(n); fl(i,0,n) cin>>v[i];
#define inp(n,v,T) vector<T> v(n); fl(i,0,n) cin>>v[i];

typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<vector<pii>> vvpii;typedef pair<lli,lli> plli;typedef vector<lli> vlli;typedef vector<vlli> vvlli;typedef vector<plli> vplli;typedef vector<vector<plli>> vvplli;typedef vector<bool> vb;typedef vector<string> vs;typedef vector<vector<string>> vvs;

#define unmp unordered_map

#define PRIME ((lli)(1e9+7ll))
#define PRIME2 (998244353ll)
const lli TEN_18 = 1e18;
const lli TEN_9 = 1e9;
const lli TEN_5 = 1e5;

inline void debugORfast(int a=1,int b=1){
    if(a){
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
        #endif
    }
    if(b){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}}

template<typename T>
void print(const T &v, int begin=-1, int end=-1, int w=2)
{
	if(begin<=end){
		if(begin==-1) fl(i,0,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) fl(i,begin,v.SZ) cout<<setw(w)<<v[i]<<' ';
		else fl(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;}
	else{
		if(begin==-1) flr(i,v.SZ-1,-1) cout<<setw(w)<<v[i]<<' ';
		else if(end==-1) flr(i,begin,-1) cout<<setw(w)<<v[i]<<' ';
		else flr(i,begin,end) cout<<setw(w)<<v[i]<<' ';
		cout<<endl;
	}
}

void pans(char v){
	switch(v){
		case 'y' : cout<<"yes"<<endl; break;
		case 'n' : cout<<"no"<<endl; break;
		case 'Y' : cout<<"Yes"<<endl; break;
		case 'N' : cout<<"No"<<endl; break;
		case 'B' : cout<<"YES"<<endl; break;
		case 'S' : cout<<"NO"<<endl; break;
	}
}

int DBGDO=0;

lli brute(){
	return 0;
}

lli solve(){
    return 0;
}

int main()
{
	debugORfast(0,1);
	//w(ttt)
	{
		lli sum=0;
		unmp<int,int> freq;
		int n;cin>>n;
		f(i,0,n){
			int tmp; cin>>tmp;
			sum += tmp;
			freq[tmp]++;
		}
		int q; cin>>q;
		f(i,0,q){
			lli b,c; cin>>b>>c;
			lli oldfreq = freq[b];
			sum -= (b*oldfreq);
			sum += (c*oldfreq);
			freq[b]=0;
			freq[c]+=oldfreq;

			cout<<sum<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 7004
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vi A(n);
  ll ans=0;
  for(auto &a:A)cin>>a;
  for(int i=0;i<n-1;i++){
    if(A[i]+A[i+1]>m){
      ll sa=A[i]+A[i+1]-m;
      if(A[i+1]>=sa){
	A[i+1]-=sa;
      }else{
	A[i]-=sa-A[i+1];
	A[i+1]=0;
      }
      ans+=sa;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, ans = 0, cnt;
	string S;
	map<char, int> m1, m2;

	for (char c = 'a'; c <= 'z'; c++) {
		m1[c] = 0;
		m2[c] = 0;
	}

	cin >> N >> S;

	rep(i, N) m2[S[i]]++;

	rep(i, N) {
		m1[S[i]]++;
		m2[S[i]]--;

		cnt = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			if (m1[c] >= 1 && m2[c] >= 1) cnt++;
		}
		ans = max(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import itertools
n, m = map(int,input().split())
switchs = {}
for i in range(m):
  switchs[i] = set(list(map(int,input().split()))[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(pow(2,n)):
  l = [0] * m
  for b in range(n):
    if (i&(1<<b)):
      #b番目のスイッチがon
      for j in range(m):
        if ((b+1) in switchs[j]):
          l[j] += 1
  s = 0
  for k in range(m):
    if (l[k]%2 == p[k]):
      s += 1
  if (s == m):
    ans += 1
print(ans)
      

Measured memory_bytes: 42480
#include<bits/stdc++.h>
using namespace std;
#define  inf 2e18
#define  bg begin()
#define  en end()
#define  ll long long int
#define  pb push_back
#define  mp make_pair
#define  mod 1000000007
#define  vi vector<int>
#define  eb emplace_back
#define  lb(v,a) lower_bound(v.begin(),v.end(),a)
#define  ub(v,a) upper_bound(v.begin(),v.end(),a)
#define  bs binary_search
#define  vll vector<long long int>
#define  vpll vector<pair<long long int,long long int> >
#define  vpii vector<pair<int,int> >
#define  mpii map<int ,int>
#define  mpll map<long long int,long long int >
#define  max3(a,b,c) max(a,max(b,c))
#define  min3(a,b,c) min(a,min(b,c))
#define  w(t) ll t; cin>>t; while(t--)
#define  forn(i,n) for(int i=0;i<n;i++)
#define  forn1(i,n) for(int i=1;i<=n;i++)
#define  forv(it,v) for(auto it=v.begin();it!=v.end();it++)
#define  mem(a,val) memset(a,val,sizeof(a))
#define  Sort(vec) sort(vec.begin(),vec.end())
#define  RSort(vec) sort(vec.rbegin(),vec.rend())
#define  vin(v,n) for(int i=0;i<n;i++){cin>>x; v.pb(x);}
#define  deb1(x) cerr<<#x<<": "<<x<<" "<<endl
#define  deb2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define  deb3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define  deb4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define  FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define  PI 3.141592653589793238462643383279502884L
mpii mpx;
int main() {
    ll k;
    string s;
    cin >> k >> s;
    if (s.length() <= k)
        cout << s;
    else {
        for (int i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    }

    return 0;
}


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

int main() {
	int N; 
  	int A[100001];
    int min;
    cin >> N;
  	for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A, A + N, greater<int>());  // A[0:N] を大きい順にソート
    while(true){
      if(A[1]==0){
        break;
      }
      for (int i = 0; i < N; ++i){
        if(A[N-i-1]!=0){
          min = A[N-i-1];
          break;
        }
      }
      for (int i = 0; i < N; ++i){
      	if(A[i]/min>=1){
        	A[i] %= min;
      	}
      	A[N-1] = min;
      	//cout << A[i] << endl;
      }
      sort(A, A + N, greater<int>());  // A[0:N] を大きい順にソート
    }
  
    cout << A[0] << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <climits>

using namespace std;

int dp[1000001][2];

int main() {
  string N;
  cin >> N;
  N = "0" + N;
  const int n = N.size();
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < 2; j++) {
      dp[i][j] = INT_MAX;
    }
  }
  dp[n][0] = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 2; j++) {
      if (dp[i + 1][j] == INT_MAX) continue;
      for (int x = 0; x <= 9; x++) {
        int y = N[i] - '0';
        int diff = x - y - j;
        int borrow = diff < 0 ? 1 : 0;
        if (diff < 0) diff += 10;
        int cost = x + diff;
        dp[i][borrow] = min(dp[i][borrow], dp[i + 1][j] + cost);
      }
    }
  }
  cout << dp[0][0] << endl;
}

Measured memory_bytes: 9136
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vec A(N), B(N);
    Rep (i, N) {
        cin >> A[i];
    }
    Rep (i, N) {
        cin >> B[i];
    }

    mat dp(1<<N, vec(51, inf));
    dp[0][0] = 0;

    Rep (mask, 1<<N) {
        ll cnt = 0;
        Rep (i, N) {
            if (mask & (1 << i)) {
                cnt++;
            }
        }
        ll now = 0;
        Rep (i, N) {
            if (!(mask & (1 << i))) {
                ll num;
                if (abs(cnt-i)%2==0) num = A[i];
                else num = B[i];
                // cout << mask << " " << i << " " << num << "\n";
                Rep (j, num+1) {
                    chmin(dp[mask|(1<<i)][num], dp[mask][j] + now);
                }
                now++;
            }
        }
    }

    ll ans = inf;
    Rep (j, 51) {
        chmin(ans, dp[(1<<N)-1][j]);
    }

    if (ans == inf) ans = -1;
    cout << ans << "\n";
}

Measured memory_bytes: 113024
#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
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  int N, M;
  int INF = 100000;
  cin >> N >> M;
  vector<P> SC(M);
  vector<int> ANS(3);
  rep(i, M) cin >>
      SC.at(i).first >> SC.at(i).second;

  rep(x, 1000)
  {
    int keta = 1;
    int nx = x / 10;
    vector<int> d(1, x % 10);
    while (nx)
    {
      keta++;
      d.push_back(nx % 10);
      nx /= 10;
    }
    if (keta != N)
    {
      continue;
    }
    bool ok = true;
    reverse(d.begin(), d.end());
    rep(i, M)
    {
      if (d.at(SC.at(i).first - 1) != SC.at(i).second)
      {
        ok = false;
      }
    }
    if (ok)
    {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> cnt(13,0);
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    cnt[a]++;
  }
  if(cnt[0]){
    cout << 0 << endl;
    return 0;
  }
  if(cnt[12] >= 2){
    cout << 0 << endl;
    return 0;
  }
  for(int i=1; i<=12; i++){
    if(cnt[i] >= 3){
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = 0;
  for(int bit=0; bit<(1<<12); bit++){
    set<int> se;
    se.insert(0);
    se.insert(24);
    if(cnt[12]){
      se.insert(12);
    }
    for(int i=1; i<12; i++){
      if(cnt[i] == 2){
        se.insert(i);
        se.insert(24-i);
      }else if(cnt[i] == 1){
        if(bit & (1<<(i-1))){
          se.insert(i);
        }else{
          se.insert(24-i);
        }
      }
    }
    int pos = *se.begin();
    se.erase(pos);
    int res = 30;
    while(se.size()){
      chmin(res,*se.begin()-pos);
      pos = *se.begin();
      se.erase(pos);
    }
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
k = 2
h = np.array(list(map(int, input().split())))
dp = np.array([0]*n)

for i in range(1,n):
  s = max(i-k,0)
  dp[i] = np.min(dp[s:i]+np.abs(h[s:i]-h[i]))
print(dp[n-1])

Measured memory_bytes: 22696
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string w, m = ""; char ch;
	cin >> w;
	int n = w.length(), c, l;

	for (int i = 0; i < n; i++) {
		ch = w[i];
		m += w[i];
		c = 0;
		for(l = 0; l < m.length(); l++) if (m[l] == w[i]) break;
		if(l+1 == m.length()) for (int j = i; j < n; j++) if(ch == w[j]) c++;

		if (c % 2 != 0) {
			cout << "No" << '\n';
			return 0;
		}
	}

	cout << "Yes" << '\n';
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

int n;
int a[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> a[i];
    int ans = 0;
    ans += a[0] - 1;
    int mn = 2;
    rep2(i, 1, n) {
        if (a[i] == mn) mn += 1;
        else if (a[i] > mn) {
            if (a[i] % mn == 0) {
                ans += a[i] / mn - 2;
                ans++;
            }
            else ans += a[i] / mn;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>A;
    reps(i, A, 100004){
        bool yes = true;
        reps(j,2,min(i, int(sqrt(i) + 3))){
            if(i%j == 0){
                yes = false;
                break;
            }
        }
        if(yes){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

int main(){
  
  int N;
  cin >> N ;
	vector<int> V(N);
	for (int i = 0; i < N; i++) {
 		cin >> V.at(i);
	}
  	vector<int> C(N);
	for (int i = 0; i < N; i++) {
 		cin >> C.at(i);
	}
  
    vector<int> SUM(N);
  	for (int i = 0; i < N; i++) {
 		SUM.at(i) = V.at(i) - C.at(i);
		}
  int sum = 0;
  
  for(int i = 0; i < N; i++){
  	if(SUM.at(i) > 0){
  	sum = sum + SUM.at(i);
    }
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
fn main() {
    let inputs: Vec<u32> = read_as_vec();
    /*
    if let &[x, y] = &inputs[..] {
        println!("{}", gcd(x, y));
    }
    */
    println!("{}", gcd(inputs[0], inputs[1]));
}

fn gcd(x: u32, y: u32) -> u32 {
    fn sub(x: u32, y: u32) -> u32 {
        let m = x % y;
        if m == 0 {
            y
        } else {
            gcd(y, m)
        }
    }
    if x > y { sub(x, y) } else { sub(y, x) }
}

fn read<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input.trim().parse::<T>().ok().unwrap()
}

fn read_as_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    lint dp[100005][105][2];
  int main(){
      string s;
      lint d;
      cin>>s>>d;
      dp[0][0][0]=1;
    rep(i,s.size()){
        rep(j,d){
            rep(k,2){
                lint x=s[i]-'0';
                rep(l,10){
                    if(l<x){
                        dp[i+1][(j+l)%d][1]+=dp[i][j][k];
                        dp[i+1][(j+l)%d][1]%=MOD;
                    }else if(l==x){
                         dp[i+1][(j+l)%d][k]+=dp[i][j][k];
                         dp[i+1][(j+l)%d][k]%=MOD;
                    }else{
                      if(k){  dp[i+1][(j+l)%d][k]+=dp[i][j][k];
                         dp[i+1][(j+l)%d][k]%=MOD;}
                    }
                }
            }
        }
    }
    cout<<(dp[s.size()][0][0]+dp[s.size()][0][1]-1+MOD)%MOD;
  }
  
     


Measured memory_bytes: 18688
require 'pp'

# n件読み込んだ結果を数値の配列で返却する
def gets_n_iarray
  n = gets.chomp.to_i
  array = []
  n.times do
    array.push(gets.chomp.to_i)
  end
  return n, array
end

N, a_list = gets_n_iarray

# 配列に出現する数値をカウント
# {1=>3, 2=>1, 3=>2}
count_hash = a_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h
puts count_hash.values.count{|v| v.odd? }


Measured memory_bytes: 27828
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int n,m;
    int a,b;

    vector<vector<int> > f;
    set<int> ans;

    cin >> n >> m;
    while(n!=0 && m!=0) {
        for(int i=0; i<=n; ++i) {
            f.push_back({});
        }

        for(int i=0; i<m; ++i) {
            cin >> a >> b;
            f[a].push_back(b);
            f[b].push_back(a);
        }

        ans.insert(f[1].begin(),f[1].end());

        for(int i=0; i<(int)f[1].size(); ++i) {
            ans.insert(f[f[1][i]].begin(), f[f[1][i]].end());
        }
        ans.erase(1);
        cout << ans.size() << endl;

        cin >> n >> m;
        f.clear();
        ans.clear();
    }
    return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
ll mod=998244353;
ll n;

string bit(ll nn,ll nx){
  string ans="";
  for(int i=0;i<nx;i++){
    char c=nn%2+'0';
    ans=c+ans;
    nn/=2;
  }
  return ans;
}

int main(){
  string x;
  cin >> n >> x;
  ll sum=0,c=1;
  for(int i=n-1;i>=0;i--){
    if(x[i]=='1'){
      sum+=c; sum%=mod;
    }
    c*=2; c%=mod;
  }
  ll ans=(sum+1)*2*n%mod;
  vector<ll> cnt(n);
  for(int i=n/2*2+1;i>=3;i-=2){
    if(n%i==0){
      ll y=1,z=0;
      int k=n/i;
      for(int j=k-1;j>=0;j--){
        if(x[j]=='1'){
          z+=y; z%=mod;
        }
        y*=2; y%=mod;
      }
      cnt[k]+=z;
      string st="";
      string sts=x.substr(0,k);
      string stt="";
      for(int j=0;j<k;j++){
        if(sts[j]=='0') stt+='1';
        else stt+='0';
      }
      for(int j=0;j<i;j++){
        if(j%2==0) st+=sts;
        else st+=stt;
      }
      cerr << st << endl;
      if(st<=x) cnt[k]++;
      for(int j=1;j<k;j++){
        if(k%j==0) cnt[k]-=cnt[j];
      }
      ans=(ans+mod-(2*(n-k)*cnt[k])%mod)%mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n := next()
	ans := 0
	for _, v := range n {
		if v == '2' {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  int minusnum = 0;
  ll miniabs = inf;
  for(int i=0;i<N;++i) {
    if(A[i]<0) minusnum++;
    miniabs = min(miniabs, abs(A[i]));
  }
  ll ans = 0;
  if(minusnum%2==0) {
    for(int i=0;i<N;++i) ans += abs(A[i]);
  }
  else {
    for(int i=0;i<N;++i) ans += abs(A[i]);
    ans -= 2*miniabs;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4388
#include<stdio.h>
#define N 100000

int partition(int *, int, int);

int main(){
  int a[N];
  int n, kijun;
  int i;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }

  kijun = partition(a, 0, n-1);

  for(i=0;i<n;i++){
    if(i == n-1) printf("%d\n", a[i]);
    else if(i == kijun) printf("[%d] ", a[i]);
    else printf("%d ", a[i]);
  }

  return 0;
}

int partition(int *a, int p, int r){
  int x, v;
  int i, j;
  x = a[r];
  i = p - 1;
  for(j=p;j<r;j++){
    if(a[j] <= x){
      i++;
      //a[i]とa[j]を交換
      v = a[i];
      a[i] = a[j];
      a[j] = v;
    }
  }
  //a[i+1]とa[r]を交換
  v = a[i+1];
  a[i+1] = a[r];
  a[r] = v;

  return i+1;
}



Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define INF 1e12

using namespace std;
typedef long long int ll;

int main()
{
   ll N; cin >> N;
   vector<vector<ll>>A(N,vector<ll>(N,INF));
   vector<vector<ll>>cost(N,vector<ll>(N,INF));
   for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) cin >> A[i][j],cost[i][j] = A[i][j];
   for(int k = 0; k < N; k++) for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]);
   if(A == cost)
   {
       for(int k = 0; k < N; k++)
       {
           for(int i = 0; i< N; i++)
           {
               for(int j = 0; j < N; j++)
               {
                   if(k == i || k == j) continue;
                   if(A[i][j] == A[i][k] + A[k][j]) cost[i][j] = -1;
               }
           }
       }
       ll ans = 0;
       for(int i = 0; i < N; i++)
       {
           for(int j = i+1; j < N; j++)
           {
               if(cost[i][j] == -1) continue;
               ans += cost[i][j];
           }
       }
       cout << ans << endl;
   }
   else
   {
       cout << -1 << endl;
   }
}

Measured memory_bytes: 5028
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int k;
vector<int>q;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>k;
	q.pb(0);
	for(int i=1;i<=k;i++){
		int flag=0;
		for(int j=0;j<q.size()-1;j++){
			if(j==0&&abs(q[j]+1-q[j+1])<=1&&q[j]+1<=9){
				++q[j];
				flag=1;
				break;
			}
			if(j>0&&abs(q[j]+1-q[j+1])<=1&&q[j]+1<=9){
				++q[j];
				for(int k=j-1;k>=0;k--) q[k]=max(0,q[k+1]-1);
				flag=1;
				break;
			}
		}
		int sz=q.size();
		if(!flag){
			if(q[sz-1]==9){
				q.pb(1);
				sz++;
			}else{
				q[sz-1]++;
			}
			for(int j=sz-2;j>=0;j--) q[j]=max(0,q[j+1]-1);
		}
		/*vector<int>f=q;
		reverse(f.begin(),f.end());
		for(int x:f) cout<<x;
		cout<<endl;*/
	}
	reverse(q.begin(), q.end());
	for(int x:q) cout<<x;
	return 0;
}


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

int main()
{
    int k, s; cin>>k>>s;
    int sum = 0;
    for(int i = 0; i<= k; i++){
        for(int j = 0; j <= k; j++){
            if(i + j <= s && s - k <= i + j) sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
def max(a,b); a > b ? a : b; end

N, M = gets.split.map(&:to_i)
S = gets.split.map(&:to_i)
T = gets.split.map(&:to_i)

dp = Array.new(N + 1){Array.new(M + 1, 0)}
dp[0][0] = 1
(1 .. N).each{|i| dp[i][0] = 1}
(1 .. M).each{|j| dp[0][j] = 1}

(1 .. N).each do |i|
  (1 .. M).each do |j|
    if S[i-1] == T[j-1]
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD
    else
      dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % MOD
    end
  end
end
puts dp[N][M]


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N-1) cin >> A[i];
    map<ll, ll> cnt;
    rep(i, N) {
        cnt[A[i]]++;
    }
    cout << cnt[1] << '\n';
    rep(i, N-1) {
        cout << cnt[i + 2] << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 17216
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
struct Tm{
  int t, a, p; //team, ac, pena
  Tm(int t, int a, int p) :
    t(t), a(a), p(p) {}
  bool operator < (const Tm& r) const {
    return a != r.a ? a > r.a : p != r.p ? p < r.p : t < r.t;
  }
};

int main(){
  int T, P, R;
  while(cin>>T>>P>>R && T){
    int wrong[100][100] = {};
    int ac[100] = {};
    int pena[100] = {};
    REP(iter, R){
      int t, p, time;
      string mes;
      cin>>t>>p>>time>>mes;
      t--; p--;
      if(mes == "WRONG"){
        wrong[t][p] += 1;
      }else{
        pena[t] += 1200 * wrong[t][p] + time;
        ac[t] += 1;
      }
    }
    vector<Tm> team;
    REP(i, T){
      team.push_back(Tm(i+1, ac[i], pena[i]));
    }
    sort(team.begin(), team.end());
    REP(i, T){
      Tm t = team[i];
      printf("%d %d %d\n",t.t, t.a, t.p);
    }
  }
  return 0;
}

Measured memory_bytes: 972
#include <stdio.h>

int main(void){
  int W, X, x, y, r;
  scanf("%d %d %d %d %d", &W, &X, &x, &y, &r);
  if (((x - r) >= 0) && ((x + r) <= W) && ((y - r) >= 0) && ((y + r) <= X)) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1812
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    cout << (a*b) - (a+b) + 1;
    cout << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
int main()
{
	int a=io::F(),b=io::F(),c=io::F();
	long long k=io::G();
	if(k&1)printf("%d\n",b-a);
		else printf("%d\n",a-b);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N;

bool search(vector<int>& v, vector<int>& pq) {
  int cnt = 0;
  for(int i = 0; i < N; i++) {
    if(v[i] == pq[i]) cnt++;
  }
  if(cnt == N) return true;
  else return false;
}

int main() {
  cin >> N;
  vector<int> vec, P(N), Q(N);
  for(int i = 1; i <= N; i++) vec.push_back(i);
  for(int i = 0; i < N; i++) cin >> P[i];
  for(int i = 0; i < N; i++) cin >> Q[i];
  int cnt = 0, a, b;
  do {
    cnt++;
    if(search(vec, P)) a = cnt;
    if(search(vec, Q)) b = cnt;
  } while(next_permutation(vec.begin(), vec.end()));
  cout << max(a-b, b-a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int a,b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define max(a, b) ((a)<(b) ? (b) : (a))

int main(){
  int n, m, len = 0, ans = 0;
  int count[104] = {0};
  char s[104][12];
  scanf("%d", &n);
  for(int i=0; i<n; i++){
    char tmp[12];  scanf("%s", tmp);
    int flag = 0, j;
    for(j=0; j<len; j++)
      if(strcmp(tmp, s[j])==0){
	flag = 1;
	break;
      }
    if(flag){
      count[j]++;
    }else{
      strcpy(s[len++], tmp);
    }
  }
  scanf("%d", &m);
  for(int i=0; i<m; i++){
    char tmp[12];  scanf("%s", tmp);
    for(int j=0; j<len; j++)
      if(strcmp(tmp, s[j])==0)
	--count[j];
  }
  for(int i=0; i<len; i++)
    ans = max(ans, count[i]+1);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll n;
string ans = "";
int main(){
fcin;
	cin >> n;
	while(n>0){
		n--;
		string b = ans;
		ans = 'a' + (n%26);
		ans += b;
		n = n/26;
	}
	cout << ans << "\n";


}

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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var list1 = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();
            var list2 = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();

            var result = 0;

            for (var i = 0; i < n; i++)
            {
                var r1 = list1.Take(i + 1).Sum();
                var r2 = list2.Skip(i).Sum();
                result = Math.Max(result, r1 + r2);
            }
            Console.WriteLine(result);
        }
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ( (A+B)==(C+D) ){
    cout<<"Balanced"<<endl;
  }
  if ( (A+B)<(C+D) ){
    cout<<"Right"<<endl;
  }
  if ( (A+B)>(C+D) ){
    cout<<"Left"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
int main(int argc, char *argv[]) {
  char c;
  bool alpha[26];
  for (int i = 0; i < 26; ++i)
    alpha[i] = false;
  while (std::cin >> c) {
    alpha[c - 'a'] = true;
  }
  for (int i = 0; i < 26; ++i)
    if (!alpha[i]) {
      printf("%c\n", i + 'a');
      return 0;
    }
  std::cout << "None" << std::endl;
}


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

int main() {
    int n, k, x, y;
    cin >> n;
    cin >> k;
    cin >> x;
    cin >> y;
    if (n >= k){
        cout << x*k + y*(n-k) << endl;
    } else {
        cout << x*n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();
		
		for(int i=0;i<10;i++) {
			x=r*x-D;
			System.out.println(x);
		}
		
		sc.close();
	}
}


Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        int[] sortedArr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
            sortedArr[i] = arr[i];
        }
        Arrays.sort(sortedArr);
        int medianBig = sortedArr[N/2];
        int medianSmall = sortedArr[N/2-1];
        for(int a : arr) {
            if(a >= medianBig) System.out.println(medianSmall);
            else System.out.println(medianBig);
        }
    }
}


Measured memory_bytes: 69948
n = int(input())
k = int(input())
min_t = 2**11

def dfs(pa,t):
    global min_t
    if t==n:
        min_t = min(min_t,pa)
        return
    dfs(pa+k,t+1)
    dfs(pa*2,t+1)

dfs(1,0)

print(min_t)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
vector<int> ans;
vector<int> h;
int cnt=0;
int frog1(int N)
{
    cout<<cnt<<" "<<ans[N]<<endl;

  if(N<=0)return 0;
  if(N==1)return abs(h[1]-h[0]);
  if(ans[N]==-1)
  {
    ans[N] = min(abs(h[N]-h[N-1])+frog1(N-1),abs(h[N]-h[N-2])+frog1(N-2));
  }
  return ans[N];
}
int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
  ll N,K;
  cin>>N>>K;
  h.resize(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  ans.resize(N);
  for(int i=0;i<N;i++){
    ans[i] = -1;
  }
  ans[0] = 0;
  ans[1] = abs(h[1]-h[0]);
  for(int i=2;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i-j<0){
        break;
      }
      if(j==1){
        ans[i] = abs(h[i]-h[i-j])+ans[i-j];
      }
      else{
        ans[i] = min(abs(h[i]-h[i-j])+ans[i-j],ans[i]);  
      }
    }
    
  }
  cout<<ans[N-1]<<endl;
  return 0;
  /*
  for(int i=0;i<1e5;i++){
    cout<<i+1<<endl;
  }*/
}


Measured memory_bytes: 4008
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=100;
int a[MAXN+5];
int n,Max,sum,f;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		Max=max(a[i],Max);
	}
	for(int i=1;i<=n;i++)
		if(Max==a[i]&&!f)
			f=1;
		else
			sum+=a[i];
	if(Max<sum)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


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

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

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

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string n;
  cin >> n;
  cout << ((n[0] == n[1] || n[2] == n[3]) && n[1] == n[2] ? "Yes" : "No") << endl;
}



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

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

  int x = n;
  int f = 0;
  while(n != 0){
    f += n % 10;
    n /= 10;
  }

  if (x % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
const ll mod = 1000000007LL;

ll mfactorials[200000+1];

ll powmod(ll x, ll n) {
    if (n == 0LL) return 1LL;
    x %= mod;
    if (n % 2LL == 0) {
        return powmod((x * x) % mod, n / 2LL);
    }
    else {
        return (x * powmod((x * x) % mod, n / 2LL)) % mod;
    }
}

ll comb(ll n, ll k) {
    if (n == 0 || k > n) return 0;
    return (mfactorials[n] * powmod((mfactorials[k] * mfactorials[n - k]) % mod, mod - 2LL)) % mod;
}

ll submod(ll a, ll b) {
    return a > b ? (a - b) % mod : (a - b + mod);
}

int main() {
    mfactorials[0] = mfactorials[1] = 1LL;
    for (ll i = 2ll; i <= 200000LL; ++i) {
        mfactorials[i] = (mfactorials[i - 1] * i) % mod;
    }
    
    ll n; cin >> n;
    vector<ll> A(n);
    vector<ll> B(n + 1, -1);
    ll L;
    for (ll i = 0; i < n; ++i) {
        cin >> A[i];
        if (B[A[i]] >= 0) {
            L = i - B[A[i]] + 1LL;
        }
        B[A[i]] = i;
    }
    if (n == 1LL) {
        cout << 1 << endl;
        cout << 1 << endl;
    }
    else {
        cout << n << endl;
        for (ll k = 2; k <= n + 1; ++k) {
            ll ans = 0;
            ans += comb(n - 1LL, k);
            ans += comb(n - 1LL, k - 2LL);
            ans %= mod;
            ans += (2 * submod(comb(n - 1LL, k - 1LL), comb(n + 1LL - L, k - 1LL))) % mod;
            ans %= mod;
            ans += comb(n + 1LL - L, k - 1LL);
            ans %= mod;
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    cin>>n;
    vector<double> dp(n+1);
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
      double head;
      cin>>head;
      for (int j = i+1; j >= 0; j--)
      {
        dp[j] = (j == 0 ? 0 : dp[j-1]*head ) + dp[j]*(1-head); 
      }
    }
    double sum=0;
    for (int i = 0; i <= n ; i++)
    {
      if(i>n-i){
        sum += dp[i];
      }
    }
    printf("%.10lf",sum);
    
}

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

signed main(){
	string S; cin>>S;
	bool pro=true;
	if(S.size()%2==1)pro=false;
	else{
		map<char,int> a;
		vector<char> dict;
		for(int i=0;i<S.size();i++){
			if(a.count(S[i]))a[S[i]]++;
			else{
				a[S[i]]=1;
				dict.push_back(S[i]);
			}
			
		}
		for(int i=0;i<dict.size();i++){
			if(a[dict[i]]%2==1){pro=false; break;}
		}
	}
	cout<<(pro? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
# coding: utf-8

## atode

n, m = list(map(int, input().split()))

a = []
for i in range(n):
	a.append(input())

b = []
for i in range(m):
	b.append(input())

def check(x, y):
	for i in range(m):
		for j in range(m):
			if a[i+x][j+y] != b[i][j]:
				return False
	return True

def move(d):
	for x in range(d):
		for y in range(d):
			if check(x, y):
				return True
	return False

is_include = move(n-m+1)

if is_include:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std; 
long long n,m,a[200010],b[200010],k,ans,s,x;
int main()
{
   cin>>n>>m>>k;
   for(int i=1;i<=n;i++){cin>>x;a[i]=a[i-1]+x;}
   for(int i=1;i<=m;i++){cin>>x;b[i]=b[i-1]+x;}
   for(int i=0;i<m;i++)b[i]=b[i+1];
   vector<long long> v(b,b+m);
   
   for(int i=0;i<=n;i++)
   {
       if(a[i]<=k)
       {s=i;
       if(k<b[0])x=0;
       else
       x=upper_bound(v.begin(),v.end(),k-a[i])-v.begin();
           
       }
       else
       break;
      
       ans=max(ans,x+s);
   }
   
   cout<<ans<<endl;
    
}

Measured memory_bytes: 7604
n = 10**5
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
 
for i in range(2, int(n**0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, n + 1, i):
        is_prime[j] = False
 
num = [0] * (n + 1)
 
cnt = 0
for i in range(n + 1):
    if is_prime[i] and (i + 1) // 2 > 0:
        if is_prime[(i + 1) // 2]:
            cnt += 1
    num[i] = cnt
 
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]
 
for l, r in LR:
    print(num[r] - num[l - 1])

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

int x;

bool is_prime(int x)
{
	int r=sqrt(x);
	for(int i=2;i<=r;i++)
		if(x%i==0) return false;
	return true;
}

int main()
{
	cin>>x;
	for(int i=x;;i++)
		if(is_prime(i))
			return 0 * printf("%d",i);
}

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

using namespace std;

int main()
{
    int x{};
    int y{};
    cin >> x >> y;
    if ((x+y)%2==0)
    {
        int res{(x+y)/2};
        cout << res << endl;;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  string s,t;
  bool flag=false;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s==t){
      flag=true;
      break;
    }
    s=s.back()+s.substr(0,s.size()-1);
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
w = []
v = []
for i in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)
w_adjust = []
for i in range(N):
    w_adjust.append(w[i]-w[0])

a = w[0]
dp = [[[0 for i in range(N+1)] for j in range(N*3+10)] for k in range(N+1)]
#i個目までの物のうちk個選んで重さの和がjになる中での最大価値
for i in range(N):
    for j in range(3*N):
        for k in range(N):
            if j + w_adjust[i] > W - a*(k+1):
                dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])
            else:
                dp[i+1][j+w_adjust[i]][k+1] = max(dp[i+1][j+w_adjust[i]][k+1], dp[i][j][k] + v[i])
                dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])
ans = [0]
for i in range(1, N+1):
    if W - a*i >= 0 and W - a*i < N*3 + 3:
        ans.append(dp[N][W-a*i][i])

if W - a*N > N*3:
    things = W//w[0]
    if things > N:
        ans.append(sum(v))

elif len(ans) == 1:
    things = W//w[0]
    v.sort()
    v.reverse()
    ans_1 = 0
    for i in range(things):
        ans_1 += v[i]
    ans.append(ans_1)

print(max(ans))


Measured memory_bytes: 72668
s = input().split()

a = int(s[0])
b = int(s[1])
c = int(s[2])

count_5 = 0
if a == 5:
  count_5 += 1
if b == 5:
  count_5 += 1
if c == 5:
  count_5 += 1
  
count_7 = 0
if a == 7:
  count_7 += 1
if b == 7:
  count_7 += 1
if c == 7:
  count_7 += 1
  
if count_5 == 2 and count_7 == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
N = int(input())

work = [list(map(int, input().split())) for _ in range(N)]
work.sort(key=lambda x: x[1])

t = 0

for i in range(N):
    t += work[i][0]
    if t > work[i][1]: 
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 53728