akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> Q;
typedef pair<int, Q> R;
const int INF = 1000000000;

int h, w, a[30][30];
int d[901][30][30];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) scanf("%d", &a[i][j]);
  for (int k = 0; k <= 900; k++) for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) d[k][i][j] = INF;
  priority_queue<R, vector<R>, greater<R> > que;
  d[0][0][0] = 0;
  que.push(R(0, Q(0, P(0, 0))));
  while (!que.empty()) {
    R q = que.top(); que.pop();
    int cost = q.first, len = q.second.first, x = q.second.second.first, y = q.second.second.second;
    if (cost > d[len][y][x]) continue;
    if (y == h - 1 && x == w - 1) break;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      int newcost = cost + (len * 2 + 1) * a[ny][nx] + 1;
      if (len + 1 >= 901) continue;
      if (newcost >= d[len + 1][ny][nx]) continue;
      d[len + 1][ny][nx] = newcost;
      que.push(R(newcost, Q(len + 1, P(nx, ny))));
    }
  }
  int ans = INF;
  for (int i = 0; i <= 900; i++) ans = min(ans, d[i][h - 1][w - 1] - i);
  printf("%d\n", ans);
}



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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
const ll M = 1000000007;
signed main() {
    ll n,x;
    cin>>n>>x;
    vector<ll> A(n);
    cin>>A;
    ll s=0;
    REP(i,n-1){
        ll d=A[i]+A[i+1]-x;
        if(d>0){
            s+=d;
            if(A[i+1]-d>=0){
                A[i+1]-=d;
            }else{
                A[i+1]=0;
            }
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 1024
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var z = parseInt(input[0].split(" ")[1]);
  var w = parseInt(input[0].split(" ")[2]);
  tmp = input[1].split(" ");
  var ans = 0;
  a = new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp[i]);
  }
  if(n==1){
    ans=Math.abs(a[0]-w);
  }else{
    ans=Math.max(Math.abs(a[n-2]-a[n-1]),Math.abs(a[n-1]-w));
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n = int(input())

def calc(a, n_=n):
    nn = n_ // a
    l = nn * a
    return (a + l) * nn // 2 

s = calc(1)
fizz = calc(3)
buzz = calc(5)
fb = calc(15)
ans =  s - fizz - buzz + fb
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define N 200005
#define INF ((1<<30)-1)
#define int long long
using namespace std;

int n;
int ans;
int a[N];
int sum,x;

inline void read(int &X)
{
    X=0;int w=0;char ch=0;
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    X=w?-X:X;
}

signed main()
{
  read(n);
  for(int i=1;i<=n;i++)
    read(a[i]);
  int l=1;
  for(int i=1;i<=n;i++)
  {
    x^=a[i],sum+=a[i];
    while(x!=sum)
    {
      x^=a[l];
      sum-=a[l];
      l++;
    }
    ans+=i-l+1;
  }
  

  cout<<ans;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

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

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

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    rep(i, N) cout << A[i] << (i == N - 1 ? '\n' : ' ');

    repe(i, 1, N){
        repr(j, i){
            if (A[j] > A[j + 1]) swap(A[j], A[j + 1]);
            else break;
        }

        rep(j, N) cout << A[j] << (j == N - 1 ? '\n' : ' ');
    }
    
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n,m;
	cin >> n >> m;
	vector<pair<ll,ll>> p(n);
	for(int i = 0; i < n; i++){
		int a,b;
		cin >> a >> b;
		p[i].first = a;
		p[i].second = b;
	}
	sort(p.begin(),p.end());
	ll ans = 0;
	for(int i = 0; i < n; i++){
		if(m == 0) break;
		if(p[i].second >= m){
			while(m > 0){
				m--;
				ans += p[i].first;
			}
			break;
		}else{
			m -= p[i].second;
			ans += p[i].first*p[i].second;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i, a in enumerate(A):
        if i%2 == 0 and a%2 == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62140
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ff first
#define ss second
#define maxn 1000000007
#define PI 3.14159265358979323846
#define MAX 1000007 
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //cout<<fixed<<setprecision(20);
    ll n;
    cin>>n;
    ll a[n];
    ll b[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    for (int i = n-2; i >=0; i--)
    {
        b[i]=b[i]+b[i+1];
    }
    for (int i = 1; i < n; i++)
    {
        a[i]=a[i]+a[i-1];
        //cout<<a[i]<<endl;
    }
    ll ans=LLONG_MAX;
    for (int i = 0; i < n-1; ++i)
    {
        //cout<<a[i]<<" "<<b[i+1]<<endl;
        ans=min(ans,abs(a[i]-b[i+1]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	string s;

	cin >> s;

	string s2;
	bool flag1 = false, flag2 = false, flag3 = false;

	for (int i = s.length() - 1; i >= 0; i--) {
		s2 += s[i];
	}

	if (s == s2)flag1 = true;

	string s3 = s.substr(0, (s.length() - 1) / 2);

	string s4 ;
	for (int i = s3.length() - 1; i >= 0; i--) {
		s4 += s3[i];
	}

	if (s3 == s4)flag2 = true;

	string s5 = s.substr((s.length() + 3) / 2 - 1, s.length() - ((s.length() + 3) / 2-1));

	string s6;
	for (int i = s5.length() - 1; i >= 0; i--) {
		s6 += s5[i];
	}

	if (s5 == s6)flag3 = true;

	if (flag1 == true && flag2 == true && flag3 == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

using namespace std;

int main()
{
    map<int,int> mp;
    int n, m;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int v; cin >> v;
        mp[v]++;
    }
    cin >> m;
    bool fail = 0;
    for(int i = 0; i < m; ++i){
        int v; cin >> v;
        if(mp[v] > 0) --mp[v];
        else fail |= 1;
    }
    if(fail) cout << "NO" << endl;
    else cout << "YES" << endl;
    //system("pause");
    return 0;
}


Measured memory_bytes: 9600
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# 2文字の繰り返しで負け
# これはs[0]=s[-1]なら奇数文字，s[0]!=s[-1]なら偶数文字

s = str(input())

if s[0] == s[-1]:
    if len(s)%2:
        print('Second')
    else:
        print('First')
else:
    if len(s)%2:
        print('First')
    else:
        print('Second')

Measured memory_bytes: 39152
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int tot=0;
    for(int i=1;i<=m;i++)
    {
        int a;
        scanf("%d",&a);
        tot+=a;
    }
    int ans=max(-1,n-tot);
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

long long solve(long long a,long long b)
{
    long long t=a-1;
    a=1;
    b-=t;
    t++;
    b--;
    t+=(b-a)/2;
    return t;
}

int main()
{
    long long n,a,b;
    cin >> n >> a >> b;
    if(((a-b)%2)==0) cout << (b-a)/2 << endl;
    else cout << min(solve(a,b),solve(n-b+1,n-a+1)) << endl;
    return 0;
}


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

const uint64_t M = 1'000'000'007;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, c[200000];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> c[i];
        c[i]--;
    }

    vector<int> idx[200000];
    for(int i=0;i<n;i++) idx[c[i]].push_back(i);
    
    static map<int, uint64_t> dp[200000];
    dp[0][c[0]] = 1;
    for(int i=0;i<n-1;i++){
        for(auto x:dp[i]){
            dp[i+1][c[i+1]] += x.second;
            dp[i+1][c[i+1]] %= M;
            auto it = lower_bound(idx[x.first].begin(), idx[x.first].end(), i+1);
            if(it != idx[x.first].end() && *it > i+1){
                dp[*it][x.first] += x.second;
                dp[*it][x.first] %= M;
            }
        }
    }

    cout << dp[n-1][c[n-1]] << endl;

    return 0;
}

Measured memory_bytes: 33792
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
int a[20];
int a_ = -1, b_ = -1;
signed main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		if (a[i]) {
			if (a_ < 0)a_ = k;
			else a_ = min(a_, k);
		}
		else{
			if (b_ < 0)b_ = k;
			else b_ = min(b_, k);
		}
	}
	if (a_ < 0 || b_ < 0)cout << "0\n";
	else cout << a_ + b_ << endl;
}


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

int main(){
  string s, t;
  cin>>s>>t;
  int op=0;
  //sort(s.begin(), s.end());
  //sort(t.begin(), t.end());
  //cout<<s<<" "<<t<<endl;
  int n=s.size();
  for (int i=0; i<n; i++){
    if (s[i]!=t[i]){ s[i]=t[i]; op++;}
  }
  
  cout<<op<<endl;
}

Measured memory_bytes: 3844
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;

struct Medicine{
    int a,b,c;
    Medicine(int a,int b,int c):a(a),b(b),c(c){};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    vector<Medicine> Med;
    int a,b,c;
    REP(i,N){
        cin >>a>>b>>c;
        Med.emplace_back(a,b,c);
    }
    int MAX_capa=10*40;
    vector<vector<vector<int>>> dp(N+1,vector<vector<int>>(MAX_capa+1,vector<int>(MAX_capa+1,inf)));

    dp[0][Med[0].a][Med[0].b]=Med[0].c;
    REP(i,N){
        dp[i][0][0]=0;
        REP(A,MAX_capa){
            REP(B,MAX_capa){
                a=Med[i].a;
                b=Med[i].b;
                c=Med[i].c;
                if(A+a<=MAX_capa && B+b<=MAX_capa)
                    chmin(dp[i+1][A+a][B+b],dp[i][A][B]+c);
                chmin(dp[i+1][A][B],dp[i][A][B]);
            }
        }    
    }
    // REP(i,N){
    //     REP(A,MAX_capa){
    //         REP(B,MAX_capa){
    //             auto v = dp[i][A][B];
    //             // if (v==inf) cout << "inf" << " ";
    //             // else cout << v << " " ;
    //         }
    //     }
    //     cout << endl << endl;
    // }
    int ans=inf;
    for(int a=Ma,b=Mb; a<=MAX_capa&&b<=MAX_capa; a+=Ma,b+=Mb){
        chmin(ans,dp[N][a][b]);
    }
    if (ans!=inf)
        cout << ans << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 27264
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    long long ans = 0;
    for(long long i = 1; i <= N; i++){
        long long c = N / i;
        long long t = c * i;
        ans += (i + t) * c / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(){
    int i=2,n,dp[31];
    dp[0]=dp[1]=1;
    dp[2]=2;
    while(++i<31)
        dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
    while(scanf("%d",&n),n)
        printf("%d\n",dp[n]/(10*365)+1);
}

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

const int N = 1005, K = 31;

int n, x[N], y[N], r[N][K + 1], v[K + 1];

void f(int x, int y, int z, int *r, int w){
    if(x == K) return;
    if(z > y){
        r[x] |= w;
        f(x + 1, y + v[x], z, r, w);
    }
    else f(x + 1, y - v[x], z, r, w);
}

int main(){
    scanf("%d", &n);
    for(int i = 0, z, w; i < n; i++){
        scanf("%d%d", &z, &w);
        x[i] = z + w;
        y[i] = z - w;
        if((x[i] & 1) != (x[0] & 1)){ puts("-1"); return 0; }
    }
    if(~x[0] & 1){
        v[K] = 1;
        for(int i = 0; i < n; i++){
            x[i]--;
            y[i]--;
            r[i][K] = 3;
        }
    }
    for(int i = 0; i < K; i++) v[i] = (1 << (K - 1 - i));
    printf("%d\n", K + v[K]);
    for(int i = 0; i < K + v[K]; i++) printf("%d ", v[i]); puts("");
    for(int i = 0; i < n; i++){
        f(0, 0, x[i], r[i], 1);
        f(0, 0, y[i], r[i], 2);
        for(int j = 0; j < K + v[K]; j++) putchar("LUDR"[r[i][j]]);
        puts("");
    }
}

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

int main() {
	int n;
    cin >> n;
    bool flg = false; 
 for(int i = 1; i < 10; i++){
    if(n%i==0 && n / i < 10){
      flg = true;
      break;
    }
 }
  if(flg){
      cout << "Yes" << endl;
  }else{   
	cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string x;
  cin >> x;
  int n = x.length();
  int cnt = 0, stack = 0;
  rep(i,n) {
    if (x[i] == 'S') stack++;
    else if (stack > 0) {
      stack--; cnt++;
    }
  }
  debug(cnt);
  int ans = n - 2*cnt; //popしたら2つ消える
  cout << ans << endl;
  return 0;
}

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

string s, t, ans;

int main() {
  cin >> s >> t;
  ans = "No";
  if (s.size() == t.size() - 1) {
    rep (i, s.size()) {
      if (t[i] != s[i]) break;
      if (i == s.size()-1) ans = "Yes";
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
int X,A,B;
  cin>>X>>A>>B;
  if(0>=B-A){
  cout<<"delicious"<<endl;
  }
  else if(X>=B-A){
  cout<<"safe"<<endl;
  }
  else{
  cout<<"dangerous"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 111111
int n,i,j;
double pw,vw[N],pf[N],vf[N],th[N],l,r,m1,m2,ans,res;
double calc(double x){
  res=pw*x;
  for(j=0;j<n;j++) res+=max(0.0,(th[j]-vw[j]*x)*pf[j]/vf[j]);
  ans=min(ans,res);
  return res;
}
int main(){
  while(cin>>n,n){
    for(cin>>pw,i=0;i<n;i++) scanf("%lf%lf%lf%lf",vw+i,pf+i,vf+i,th+i);
    for(i=0,l=0,r=1e9,ans=calc(0);i<100;i++) m1=l+(r-l)/3,m2=l+(r-l)*2/3,(calc(m1)>calc(m2))?l=m1:r=m2;
    cout<<ans<<endl;
  }
  return 0;
}

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

const ll mod=1000000007;

int main() {
  ll n,m,count=0;
  cin >> n >> m;
  vector<int> v(n);
  r(i,n)cin >> v[i];
  map<int,int> mp;
  r(i,n)mp[i]++;
  r(i,m){
    int a,b;
    cin >> a >> b;
    a--;	b--;
    if(v[a]>v[b])mp[b]--;
    else if(v[b]>v[a])mp[a]--;
    else {
      mp[a]--;
      mp[b]--;
    }
  }
  r(i,n){
    if(mp[i]==1)count++;
  }
  cout<<count<<endl;
}

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

using namespace std;

int main(){
	int N, ans = 0; cin >> N;
	string S; cin >> S;
	int left[26] = {}, right[26] = {};
	for(int i = 1; i < S.size(); ++i){
		int count = 0;
		string left_S = S.substr(0, i), right_S = S.substr(i, S.size());
		for(int i = 0; i < left_S.size(); ++i) left[left_S[i]-'a']++;
		for(int i = 0; i < right_S.size(); ++i) right[right_S[i]-'a']++;
		for(int i = 0; i < 26; ++i) if(left[i] > 0 && right[i] > 0) count++;
		ans = max(ans, count);
		fill(left, left + 26, 0);
		fill(right, right + 26, 0);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N ;
    cin >> N ;
    
    cout << N*N*N << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> v;
    int a;
    cin >> a;
    v.eb(a);
    rep3(i, 1, n) {
        cin >> a;
        if (a == v.back()) continue; // いらないもの
        v.eb(a);
    }
    // outa(v, SZ(v));
    
    // 昇順と降順の切り替え
    // 山か谷になる
    
    int ans = 1;
    rep3(i, 1, SZ(v) - 1) {
        if ((ll)(v[i] - v[i - 1]) * (v[i + 1] - v[i]) < 0) {
            ans++;
            i++; // sample2 : 1 2 1 2 1 2 1 2 1
        }
    }
    
    out(ans);
}


Measured memory_bytes: 892
#include<iostream>;
using namespace std;
int main(){
    int A[100][100],b[100],c[100],n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i]+=A[i][j]*b[j];
        }
    }
    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

  ll n, m;
  cin >> n >> m;
  ll a, b;
  map<ll, ll> mp;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    mp[a] += b;
  }
  ll cnt, ans = 0;
  
  for(auto& itr : mp){
    cnt = min(m, itr.second);
    ans += itr.first * cnt;
    m -= cnt;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int res = 0;
	int a, b; cin >> a >> b;
	if (a > b) {
		res += a;
		a--;
	}
	else {
		res += b;
		b--;
	}
	res += max(a, b);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define map Map
 
int H,W,K;
char map[1000][1000];
int dst[1000][1000];

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

void bfs(int sx, int sy){
	typedef pair<int,int> pii;
	queue<pii> q;
	q.push(pii{sx, sy});
	dst[sx][sy]=1;
	while(q.size()){
		int x, y; tie(x, y) = q.front(); q.pop();
		if(dst[x][y] == K+1) continue;
		for(int d=0; d<4; ++d){
			int nx=x+dx[d], ny=y+dy[d];
			if(nx>=0 && ny>=0 && nx<H && ny<W && map[nx][ny]!='#' && !dst[nx][ny]){
				dst[nx][ny] = dst[x][y]+1;
				q.push(pii{nx, ny});
			}
		}
	}
}

int main()
{
	cin >> H>>W>>K;
	for (int i = 0; i < H; i++)
	{
		cin >> map[i];
	}
	int sx, sy;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (map[i][w] == 'S') {
				sx = i; sy = w; map[i][w] = '.';
			}
		}
	}
	bfs(sx, sy);
 
	int res = 1e9;
	for (int i = 0; i < H; i++)
	{
		for (int w = 0; w < W; w++)
		{
			if (map[i][w] != '#' && dst[i][w]) {
				res = min(res, 1 + (min({ i,H - i - 1,w,W - w - 1 })+K-1)/K);
			}
		}
	}
	cout << res << endl;
 
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

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

  rep(bit, (1<<3)){
    string ans; ans += s[0];
    int sum = s[0] - '0';
    rep(i, 3){
      if(bit & (1<<i)){
        ans += '+';
        ans += s[i+1];
        sum += s[i+1] - '0';
      }
      else{
        ans += '-';
        ans += s[i+1];
        sum -= s[i+1] - '0';
      }
    }
    if(sum == 7){
      ans += "=7";
      std::cout << ans << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
//#include <algorithm>
#include <vector>
#define NMAX 105
#define WMAX 10005
//#define SELECTED 1
//#define UNSELECTED 0

using namespace std;

struct Item {
    int value,weight;
};

int N,W;
Item items[NMAX+1]; // ??°????¬¬i???????????????????????????
int C[WMAX+1]; // C[i][w]??¨??????????£???\?????????w???????????¶?????????????????§???
//int G[NMAX+1][WMAX+1]; // G[i][w]??°?????¨?????????w????????????????????????????¢??????????

void compute(int &maxValue
//            , vector<int> &selection
            ) {

    for(int i=1; i<=N; i++) {
        for(int w = W; w > 0; --w) {
            if(w<items[i].weight)
                continue;
            if(C[w]<C[w-items[i].weight] + items[i].value)
                C[w] = C[w-items[i].weight] + items[i].value;
        }
    }
    maxValue=C[W];
//    selection.clear();
//    for(int i=N,w=W;i>=1;i--) {
//        if(G[i][w]==SELECTED) {
//            selection.push_back(items[i].value);
//            w-=items[i].weight;
//        }
//    }
//    reverse(selection.begin(), selection.end());
}

void input() {
    cin>>N>>W;
    for(int i=1;i<=N;i++)
        cin>>items[i].value>>items[i].weight;
}

int main() {
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue
//            ,selection
    );

    cout<<maxValue<<endl;

    /*cout<<endl;
    for(int n=0;n<=N;n++)
    {
        for(int m=0;m<=W;m++)
        cout<<G[n][m]<<" ";
        cout<<endl;
    }*/
    /*cout<<"??????????????????????????????";
    for(int i=0;i<selection.size();i++)cout<<selection[i]<<" ";*/

}

Measured memory_bytes: 3116
from collections import Counter


def slv(K, D):
    rl = Counter()
    r = Counter()
    rl[0] = 1

    M = 10**9 + 7
    for c in K:
        d = int(c)
        rln = Counter()
        rn = Counter()
        for rem, count in rl.items():
            rln[(rem + d) % D] += count
            rln[(rem + d) % D] %= M

        for rem, count in rl.items():
            for i in range(d):
                rn[(rem + i) % D] += count
                rn[(rem + i) % D] %= M
        for rem, count in r.items():
            for i in range(10):
                rn[(rem + i) % D] += count
                rn[(rem + i) % D] %= M
        rl = rln
        r = rn
    return (rl[0] + r[0] - 1) % M


K = input()
D = int(input())
print(slv(K, D))


Measured memory_bytes: 49768
#include <bits/stdc++.h>
using namespace std;
//{
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#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 {
~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 << "]";
}
};
//{
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);
//}

char s[105];

int main() {
	make2(a, v);
	make2(b, w);
	make(t);
	int d = abs(a-b);
	int dv = v - w;
	if (dv <= 0) {
		printf("NO\n"); return 0;
	}
	if (t * 1LL * dv >= d) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
}


Measured memory_bytes: 3764
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
 long long int a;
 float b;
 cin >> a >> b;
 long long int ib = b*100+0.1;
 long long int result =a*ib;
 printf("%lld",result/100);
return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main() {
    ll n,c;
    cin>>n;
    vector<ll> v(n);
    vector<ll> sum(n);
    rep(i, n) cin>>v[i];
    ll sss=0;
    rep(i, n){
        sss+=v[i];
        sum[i]=sss;
    }
    sum.push_back(0);
    ll ans=0;
    map<ll,ll> m;
    for(auto it:sum){
        if(m.count(it)==0) m[it]=1;
        else m[it]+=1;
    }
    for(auto it:m){
//        if(it.second==1) continue;
        ans+=it.second*(it.second-1)/2;
    }
//    fr(i,0, n) fr(j,i,n){
//        if(i==0){if(sum[j] == 0) ans++;}
//        else{
//        if(sum[i-1] == sum[j]) ans++;
//        }
//    }
    pr(ans);
    
}



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

int main() {
  char s[4];cin>>s;
  vector<bool> ans(2);
  rep(i,2) ans[i] = s[i] == s[i+1] && s[i+1] == s[i+2];
  cout << (ans[0] || ans[1] ? "Yes" : "No") << endl;
}


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

using namespace std;

int main(){
  int i, j;
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  vector< pair<int, int> > P(M+1);
  for(i=0; i<N; i++)
    cin >> A[i];
  //都合上，BとCを逆順に入力している
  for(i=0; i<M; i++)
    cin >> P[i].second >> P[i].first;

  //Aを降順にソート．Pをfirstでソート
  sort(A.begin(), A.end());
  sort(P.begin(), P.end(), greater< pair<int, int> >() );

  long long int sum = 0;

  //Pを追っていく添字変数j
  j = 0;
  
  for(i=0; i<N; i++){
    //選んだカードの方が大きければそっちを足す
    if(A[i] < P[j].first){
      sum += P[j].first;
      //選べる回数を一回減らす．B[j]--と同値
      P[j].second--;
      //選べる上限に達したら次の操作に移る
      if(P[j].second == 0)
	j++;
    }
    //選べるカードより元の数字の方が大きい
    else
      sum += A[i];
  }

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


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


int main() {
	
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h,vector<char>(w));
	for(auto &i:a){
		for(auto &j:i) cin >> j;
	}
	for(int i=0; i<w; i++){
		bool flg = 1;
		for(int j=0; j<h; j++){
			if(a.at(j).at(i)=='#') flg = 0;
		}
		if (flg){
			for(int j=0; j<h; j++){
				a.at(j).at(i) = '+';
			}
		}
	}
		
	for(int i=0; i<h; i++){
		bool flg = 1;
		for(int j=0; j<w; j++){
			if(a.at(i).at(j)=='#') flg = 0;
		}
		if(flg){
			for(int j=0; j<w; j++){
				a.at(i).at(j) = '+';
			}
		}
	}
	for(auto i:a){
		for(auto j:i){
			if(j!='+') cout << j;
		}
		cout << endl;
	}
	
	
	return 0;
}

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

#define DIV 1000000007

long long K;
string S;
long long memo[2000006];
long long downmemo[2000006];

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

int main(){
	cin >> K;
	cin >> S;

	long long Ssize = S.size();

	memo[0] = 1;
	downmemo[0] = 1;
	for(long long i = 1; i < 2000006; i++) {
		memo[i] = memo[i-1] * i;
		memo[i] %= DIV;
		downmemo[i] = downmemo[i-1] * modpow(i, DIV - 2);
		downmemo[i] %= DIV;
	}

	long long ans = 0;
	for(long long endidx = (long long)S.size() - 1; endidx < Ssize + K; endidx++) {
		long long tmp = 1;
		//enddx C S.size() - 1
		tmp *= memo[endidx];
		tmp%=DIV;
		tmp *= downmemo[endidx - (Ssize - 1)];
		tmp%=DIV;
		tmp *= downmemo[Ssize-1];
		tmp%=DIV;

		//25 ** (end + 1 - S.size())
		tmp *= modpow(25, endidx + 1 - Ssize);
		tmp%=DIV;


		//26 ** (K + S.size() - endidx)
		tmp *= modpow(26, K + Ssize - endidx - 1);
		tmp%=DIV;

		ans += tmp;
		ans %= DIV;
	}
	cout << ans << endl;
}


Measured memory_bytes: 35572
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


cnt = 0
a, b, k = map(int, input().split())
for num in range(max(a, b), -1, -1):
    if a % num == 0 and b % num == 0:
        cnt += 1
        if k == cnt:
            print(num)
            exit()

Measured memory_bytes: 61956
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), k = sc.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			ans += Math.min(Math.abs(k - x), x) * 2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
	int n , N = 103;
	int a[N] = {0};
	scanf("%d" , &n);
	int i;
	for(i = 0 ; i < n ; i++)
	{
		scanf("%d" , &a[i]);
	}
	for(i = n - 1; i >= 0 ; i--)
	{
		if(i)
		{
			printf("%d " , a[i]);
		}
		else
		{
			printf("%d\n" , a[i]);
		}
	}
	return 0;
}


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

int main()
{
  int a,b;
  cin>>a>>b;
  if(a>=b)
  {
    for(int i=0;i<a;i++)
    {
      cout<<b;
    }
  }
  else
  {
    for(int i=0;i<b;i++)
    {
      cout<<a;
    }
  }
}

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	vector<int> dif;
	long long sum;

	for(int i=0; i<m; i++){
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	for(int i=1; i<x.size(); i++){
		dif.push_back(x[i] - x[i-1]);
	}
	sort(dif.begin(), dif.end());
	for(int i=0; i< n-1 && 0 < dif.size(); i++){
		dif.pop_back();
	}
	sum = 0;
	for(int i=0; i<dif.size(); i++){
		sum += dif[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1276
#include<stdio.h>
int a[102],b[102];
int main()
{
	int N,i,j,max=0,k;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{	
		k=i;
		for(j=0;k%2==0;j++)
			k=k/2;
			a[i-1]=j;
	}
	for(j=0;j<i;j++)
	{
		if(a[j]<=a[max])
			max=max;
		else
			max=j;
	}
	for(j=0;j<i;j++)
	{
		b[j]=j+1;
	}
	printf("%d",b[max]);				
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int


int cmpAsc(const void* a, const void* b){
    int x = *(int*)a, y = *(int*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    int ans = 0;
    rep(i, 0, n){
        scanf("%d", &a[i]);
    }
    qsort(a, n, sizeof(int), cmpAsc);
    int x = 0;
    while(x < n){
        int y = x+1;
        while(y<n){
            if(a[x] != a[y]){
                break;
            }
            y++;
        }
        if(y - x < a[x]){
            ans += y - x;
        }else if(a[x] < y - x){
            ans += (y - x) - a[x];
        }
        x = y;
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 892
#include <cstdint>
#include <iostream>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

} // namespace null_null

namespace null_null {

void main_() {
  i32 N;
  std::cin >> N;

  i32 odd = 0, even = 0;
  for (usize i = 1; i <= N; i++) {
    if (i % 2 == 1) {
      odd++;
    } else {
      even++;
    }
  }

  double ans = double(odd) / N;
  std::cout << ans << std::endl;
}

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#define INF 9999999
using namespace std;

const int maxn = 10000 + 5;
const int maxm = 500000 + 5;

struct Edge{
	int next;
	int to;
	int value;
	Edge():next(0),to(0),value(INF){}
}G[maxm];

struct Node{
	int to;
	int dist;
	bool operator < (const Node& rhs) const{
		return dist > rhs.dist;
	}
};

int head[maxn],cnt;
int dis[maxn];
bool vis[maxn];

int n;

void Insert(int u,int v,int c){
	G[++cnt].next = head[u];
	G[cnt].to = v;
	G[cnt].value = c;
	head[u] = cnt;
}

void init(){
	memset(dis,INF,sizeof(dis));
	memset(vis,false,sizeof(vis));
}

priority_queue<Node >Q;

void Dijkstar(int s){
	dis[s] = 0;
	Q.push((Node){s,0});
	while(!Q.empty()){
		int u = Q.top().to;Q.pop();
		if(vis[u])continue;
		vis[u] = true;
		for(int e = head[u];e; e = G[e].next){
			int v = G[e].to;
			if(dis[u] + G[e].value < dis[v] && !vis[v]){
				dis[v] = dis[u] + G[e].value;
				Q.push((Node){v,dis[v]});
			}
		}
	}
}

int main(){
	init();
	scanf("%d",&n);
	for(int i = 0;i < n; i++){
		int u,m;
		scanf("%d%d",&u,&m);
		for(int j = 0;j < m; j++){
			int v,c;
			scanf("%d%d",&v,&c);
			Insert(u,v,c);
		}
	}
	Dijkstar(0);
	for(int i = 0;i < n; i++){
		printf("%d %d\n",i,dis[i]);
	}
}

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

int main() {
  int N;
  string S, T;
  string out;

  cin >> N >> S >> T;

  for (int i = 0; i < N; i++) {
    out += S[i];
    out += T[i];
  }

  cout << out << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
n_l = [1] * n
h_l = list(map(int, input().split())) #list
ab_li = [list(map(int, input().split())) for _ in range(m)] #n行にmつずつ入力される整数
for a, b in ab_li:
    if h_l[a-1] > h_l[b-1]:
        n_l[b-1] = 0
    elif h_l[a-1] < h_l[b-1]:
        n_l[a-1] = 0
    else:
        n_l[a-1] = 0
        n_l[b-1] = 0
print(sum(n_l))

Measured memory_bytes: 93424
# 単純実装

n,d=gets.chomp.split(' ').map{|n| n.to_i}

l__ = 2
l_ = 1
l = 3

iter = n-2
while(iter>0)
	l__ = l_
	l_ = l
	l = l__ + l_
	iter -= 1
end
case n
when 0
	puts 2
when 1
	puts 1
else
	puts l
end


Measured memory_bytes: 1916
public class Main {


  private static void solve() {
    int n = ni();
    char[] a = ns();
    char[] b = ns();
    char[] c = ns();
    
    int ret = 0;
    for (int i = 0; i < n; i ++) {
      if (a[i] == b[i] && b[i] == c[i]) {
        continue;
      }
      if (a[i] == b[i] || b[i] == c[i] ||c[i] == a[i] ) {
        ret ++;
      } else {
        ret += 2;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF 1000000009
int a[10];
vector<int> dp(10);
vector<int> new_dp(10);
int n;
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=3;j++)
        cin >> a[j];

        for(int k=1;k<=3;k++)
        {
            for(int j=1;j<=3;j++)
            {
                if(k!=j)
                new_dp[k] = max(new_dp[k],dp[j]+a[k]);
                //cout << new_dp[1] << " ";
            }
        }
        dp = new_dp;
        //cout << dp[1] << " " << dp[2] <<  " " << dp[3];
        //cout << endl;
    }
    
    cout << max({dp[1],dp[2],dp[3]});
}

Measured memory_bytes: 256