akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M, Q;
  cin >> N >> M >> Q;
  vector<llvec> T(N+1, llvec(N+1, 0));
  vector<llvec> S(N+1, llvec(N+1, 0));
  rep(i, M){
    ll a, b;
    cin >> a >> b;
    T[a][b] += 1;
  }
  FOR(i, 1, N+1){
    FOR(j, 1, N+1){
      S[i][j] = S[i][j-1] + T[i][j];
    }
  }
  FOR(i, 1, N+1){
    FOR(j, 1, N+1){
      S[i][j] += S[i-1][j];
    }
  }

  rep(i, Q){
    ll a, b;
    cin >> a >> b;
    a--;
    cout << S[b][b] - S[a][b] - S[b][a] + S[a][a] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e13+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
//ll x[100001]={0};
ll a[100001]={0};
ll b[100001]={0};

//bool c[1000001]={0};
//vector<pair<ll,ll> > adj[100001];
//vector<ll> adj[200001];
//vpii edges;
//bool visited[200001]={0};
//bool color[200001]={0};
//ll dist[100001]={0};
ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}

double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr);
        }
    }
}*/

/*void dfs(ll x,ll y){
    if(x<0 || y<0 || x>=n || y>=m)return;
    //if(grid[x][y]!=color)return;
    if(visited[x][y] || Map[x][y]=='#'){
        //f=true;
        return;
    }
    visited[x][y]=true;
    Map[x][y]='#';
    //if(px!=(x+1) || py!=y)
        dfs(x+1,y);
    //if(px!=(x-1) || py!=y)
        dfs(x-1,y);
    //if(px!=(x) || py!=y+1)
        dfs(x,y+1);
    //if(px!=(x) || py!=y-1)
        dfs(x,y-1);
}*/

/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};
/*void dfs(ll s){
    if(visited[s])return;
    visited[s]=true;
    for(auto u:adj[s]){
        dfs(u);
    }
}*/
//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/

ll dp[100001]={0};

void solve(){
    ll n;cin>>n;
    ll k;cin>>k;
    input(a,n);

    dp[0]=0;
    
    for(ll i=1;i<n;i++){
        dp[i]=1e9;
        for(ll j=1;j<=k;j++){
            if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }

    cout<<dp[n-1];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    //sieve(1000001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


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

nx = 1
ny = 1

for _ in range(N):
    x, y = map(int, input().split())
    Xmul = (nx + x - 1) // x
    Ymul = (ny + y - 1) // y
    mul = max(Xmul, Ymul)
    nx = x * mul
    ny = y * mul

ans = nx + ny
print(ans)


Measured memory_bytes: 3060
package main

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

func bubbleSort(elems []int) int {
	n := len(elems)
	var swapCount int
	for i := 0; i < n; i++ {
		for j := n-2; j >= i; j-- {
			if elems[j] > elems[j+1] {
				elems[j], elems[j+1] = elems[j+1], elems[j]
				swapCount++
			}
		}
	}
	return swapCount
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	elems := make([]int, n)
	for i := 0; i < n; i++ {
		elem, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		elems[i] = elem
	}

	count := bubbleSort(elems)
	fmt.Println(formatCount(elems))
	fmt.Println(count)
}

func formatCount(elems []int) string {
	n := len(elems)
	as := make([]string, n)
	for i := 0; i < n; i++ {
		as[i] = strconv.Itoa(elems[i])
	}
	return strings.Join(as, " ")
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


Measured memory_bytes: 1144
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <functional>

using i64 = std::int64_t;

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

	std::vector<i64> A(N), F(N);
	for (auto&& e : A)
		std::cin >> e;
	for (auto&& e : F)
		std::cin >> e;

	std::sort(A.begin(), A.end());
	std::sort(F.begin(), F.end(), std::greater<>{});

	auto isOK = [&](i64 t) -> bool {
		i64 lessoned = 0;
		for (size_t i = 0; i < N; ++i) {
			if (A[i] * F[i] > t)
				lessoned += (A[i] * F[i] - t + F[i] - 1) / F[i];

			if (lessoned > K)
				return false;
		}

		return true;
	};

	i64 l = -1, r = 1e12 + 2;
	while (r - l > 1) {
		auto mid = l + (r - l) / 2;

		if (isOK(mid))
			r = mid;
		else
			l = mid;
	}

	std::cout << r << std::endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    while (true){
        int array[10][10], a, b, c, i, j, k, m = 0, n, ans_map = 0, ans_cost = 1 << 25;
        scanf("%d", &n);
        if (!n){
            return 0;
        }
        for (i = 0; i < 10; i++){
            for (j = 0; j < 10; j++){
                if (i == j){
                    array[i][j] = 0;
                }
                else{
                    array[i][j] = 1 << 25;
                }
            }
        }
        for (i = 0; i < n; i++){
            scanf("%d %d %d", &a, &b, &c);
            array[a][b] = array[b][a] = c;
            m = max(m, b);
        }
        m++;
        for (i = 0; i < m; i++){
            for (j = 0; j < m; j++){
                for (k = 0; k < m; k++){
                    array[j][k] = array[k][j] = min(array[j][k], array[j][i] + array[i][k]);
                }
            }
        }
        for (i = 0; i < m; i++){
            int cost = 0;
            for (j = 0; j < m; j++){
                cost += array[i][j];
            }
            if (cost < ans_cost){
                ans_cost = cost;
                ans_map = i;
            }
        }
        printf("%d %d\n", ans_map, ans_cost);
    }
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;


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

  int n;
  cin >> n;

  int h[n];
  for(int i=0; i<n; ++i)
    cin >> h[i];

  int max = h[0], count = 0;
  for(int i=0; i<n; ++i){
    if(h[i] >= max){
      ++count;
      max = h[i];
    }
  }
  cout << count << endl;

  return 0;
}


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

using namespace std;

int a[30],b[30],dp[31][1<<16];

int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(void){

  int n,c,in;

  while(cin >> n >> c,n|c){
    
    fill(a,a+n,0);
    fill(b,b+c,0);

    for(int i=0;i<n;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	a[i] |= in<<(15-j);
      }
    }

    for(int i=0;i<c;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	b[i] |= in<<15-j;
      }
    }

    memset(dp,-1,sizeof(dp));

    dp[0][0]=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<(1<<16);j++){
	if(dp[i][j]<0)continue;

	int now=a[i]|j;
	for(int k=0;k<c;k++){
	  int next=now & ~b[k];
	  dp[i+1][next]=max(dp[i+1][next],dp[i][j]+count(now & b[k]));
	}
      }
    }

    int ans=0;
    for(int i=0;i<(1<<16);i++){
      ans=max(ans,dp[n][i]);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 9104
#!/usr/bin/env python3
import sys
from collections import Counter as cl

def solve(N: int, A: "List[int]"):
    d = cl(A)
    ct = 0
    for x in d.keys():
        ct += d[x] * (d[x] - 1) //2
    for x in A:
        print(ct - (d[x]-1))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34540
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e6 + 5;

ll arr[N];

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rw", stdin);
#endif
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
		sum ^= arr[i];
	}
	for (int i = 0; i < n; ++i) {
		sum ^= arr[i];
		cout << sum << ' ';
		sum ^= arr[i];
	}
	return 0;
}


Measured memory_bytes: 5204
#include <iostream>
#include <string>

int main() {
    int K;
    std::string S;
    std::cin >> K >> S;

    int N = S.size();

    if (N <= K) {
        std::cout << S << "\n";
    } else {
        std::cout << S.substr(0, K) << "...\n";
    }
}

Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n;
signed main()
{
	scanf("%d",&n);
	printf("%d",(((n+1)*n)>>1));
	return putchar(10),0;
}

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

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

	int ans = 1;
	for (int i = 2; i * i <= X; i++) {
		int j = 2;
		while (true) {
			int k = pow(i, j);
			if (k > X) break;

			ans = max(ans, k);
			j++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 384
#include <iostream>

int main()
{
    int A, B, C;
    std::cin >> A >> B >> C;

    if (A == B) {
        std::cout << C << std::endl;
    } else if (A == C) {
        std::cout << B << std::endl;
    } else {
        std::cout << A << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  double D, X, Y;
  int count=0;
  
  cin >> N >> D;
  for(int i=0; i < N; i++){
   	cin >> X >> Y; 
    if(X*X + Y*Y - D*D <= 0){
    	count++;
    }
  }
   
  cout << count << endl;
}

Measured memory_bytes: 3776
from sys import stdin
readline = stdin.readline

N, M = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

result = 0
t = -1
for a, b in ab:
    a, b = a - 1, b - 1
    if a <= t < b:
        continue
    result += 1
    t = b - 1
print(result)


Measured memory_bytes: 28712
# B - Problem Set
from collections import defaultdict
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n = input()
D = list(map(int,input().split()))
m = input()
T = list(map(int,input().split()))

DD = defaultdict(int)

for d in D:
    DD[d] += 1

for t in T:
    DD[t] -= 1
    if DD[t]<0:
        print('NO')
        exit()

print('YES')



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

const int N = 2e5 + 5;
const int M = N * 2;

#define int long long

int n, m, x, y, fir[N], ne[M], to[M], cnt, z, C[M];

void add(int x, int y, int z) {
	ne[++ cnt] = fir[x];
	fir[x] = cnt;
	to[cnt] = y;
	C[cnt] = z;
}

void link(int x, int y, int z) {
	add(x, y, z);
	add(y, x, z);
}

int Quac[N], S[N];

bool vis[N];

struct Edge {
	int x, y, z;
};

vector <Edge> G;

#define Foreachson(i, x) for(int i = fir[x]; i; i = ne[i])

void dfs(int x, int f) {
	vis[x] = 1;
	Quac[x] = Quac[f] * (-1);
	Foreachson(i, x) {
		int V = to[i];
		G.push_back((Edge){V, x, C[i]});
		if(V == f || vis[V])
		continue;
		else S[V] = C[i] - S[x], dfs(V, x);
	}
}

main(void) {
	scanf("%lld%lld", &n, &m);
	for(int i = 1; i <= m; ++ i) {
		scanf("%lld%lld%lld", &x, &y, &z);
		link(x, y, z);
	}
	Quac[0] = -1;
	dfs(1, 0);
	int Xian = -1;
	for(int i = 0; i < (int) G.size(); ++ i) {
		Edge cur = G[i];
		int now = Quac[cur.x] + Quac[cur.y];
		if(!now && S[cur.x] + S[cur.y] != cur.z) {
			puts("0");
			return 0;
		}
		else {
			if(now) {
				if((S[cur.x] + S[cur.y] - cur.z) & 1) {
					puts("0");
					return 0;
				}
				else {
					int now = (cur.z - S[cur.x] - S[cur.y]) / (Quac[cur.x] + Quac[cur.y]);
					if(now <= 0) {
						puts("0");
						return 0;
					}
					else {
						if(Xian == -1) Xian = now;
						else if(Xian != now) return 0 * puts("0");
					}
				}
			}
		}
	}
	if(Xian != -1) {
		for(int i = 1; i <= n; ++ i) {
			if(Xian * Quac[i] + S[i] <= 0) {
				puts("0");
				return 0;
			}
		}
		cout << 1 << endl;
		return 0;
	}
	else {
		int L = 1, R = 1e18;
		for(int i = 1; i <= n; ++ i) if(Quac[i] == -1) R = min(R, S[i] - 1); else L = max(L, -S[i] + 1);
		if(L > R) puts("0");
		else cout << R - L + 1 << endl;
	}
}

Measured memory_bytes: 27504
# include <iostream>
using namespace std; 
int main(){
  int x, y,temp, p; 
  cin>>x>>y; 
  if(y>4*x || y<2*x){
    cout<<"No";
  }
  else{
    temp=(y-2*x)/2;
    p=(4*x-y)/2;
    if(temp+p==x)
    cout<<"Yes";
    else{
      cout<<"No";
    }
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    long long x;
    cin >> x;
    long long a[10] = {100, 101, 102, 103, 104, 105, 206, 207, 208, 209};

    for (int i = 0; i < 6; i++) {
        if (x % a[i] == 0) {
            cout << 1 << endl;
            return 0;
        }
    }

    long long amari = x % 10;
    x -= a[amari];

    //cout << x << endl;

    if (x == 0) {
        cout << 1 << endl;
        return 0;
    }
    else if (x < 100) {
        cout << 0 << endl;
        return 0;
    }

    /*
    long long num = x;
    int cnt = 0;
    while (num) {
        num /= 10;
        cnt++;
    }
    if (cnt <= 2) {
        //cout << cnt << endl;
        cout << 0 << endl;
        return 0;
    }
    */

    x /= 10;
    long long amari2 = x % 10;
    x /= 10;
    //long long amari3 = x % 10;
    
    if (amari2 * 2 <= x) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import heapq

'''
方針：mod Kで考える。すべての数字は、１を足すor10倍するの操作を繰り返せば作ることができる。
1を足す場合は、fは1増える。10倍しても、fは増加しない。
'''

K = int(input())
adj = [dict() for i in range(K)]
for i in range(1,K):
    adj[i] = dict()
    adj[i][(i+1)%K] = 1
    adj[i][(i*10)%K] = 0

# print(adj)
# １から０への最短経路を見つける
# ダイクストラ法
def dijkstra(adj):
    '''
    :param adj: adj[i][j] distance between i and j
    adj = list(dict()) #隣接リスト形式
    :return: d[u]
    '''
    q = []  # プライオリティキュー
    d = dict()  # 始点からvまでの最短コスト
    p = dict()  # 親ノードを保存
    n = len(adj)  # ノードの数

    for i in range(n):
        d[i] = float('inf')
    # 初期化
    start_id = 1
    d[start_id] = 0
    heapq.heappush(q, (0,start_id)) #(d[id], id)
    S = set()

    while len(S) != n:
        # print(q)
        dist, node_id = heapq.heappop(q)
        S.add(node_id)
        for u, c in adj[node_id].items(): #隣接ノード
            # print(u,c)
            if c + d[node_id] < d[u]:
                d[u] = c + d[node_id]
                heapq.heappush(q, (d[u], u))
    return d



d = dijkstra(adj)
print(d[0]+1)


Measured memory_bytes: 61664
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;

int main() {

	int n;
	ll v = 1;

	cin >> n;

	for (int i = 1; i <= n; i++) {
		v = v * i % 1000000007;
	}

	cout << v << endl;

	return 0;
}

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

typedef long long ll;
ll m,a,r,c,h;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin>>t;
    while(t--)
    {
        string str;
        cin>>str;
        if(str[0]=='M')m++;
        else if(str[0]=='A')a++;
        else if(str[0]=='R')r++;
        else if(str[0]=='C')c++;
        else if(str[0]=='H')h++;
    }
    ll ans=0;
    ans+=(m*a*r);
    ans+=(m*a*c);
    ans+=(m*a*h);
    ans+=(m*r*c);
    ans+=(m*r*h);
    ans+=(m*c*h);
    ans+=(a*r*c);
    ans+=(a*r*h);
    ans+=(a*c*h);
    ans+=(r*c*h);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;

    vector<int> vec;
    vec.push_back(a);
    vec.push_back(b);
    vec.push_back(c);
    sort(vec.begin(), vec.end());

    int moves = vec[2] - vec[1];
    vec[0] += moves;
    vec[1] += moves;

    int diff = vec[1] - vec[0];

    if (diff % 2 == 1)
        moves += (diff + 1) / 2 + 1;
    else
        moves += diff / 2;


    cout << moves;


    return 0;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    long long int n, data[5], i, min, pos, ans;
    pos = 0;
    cin >> n;
    for(i = 0; i < 5;i++){
        cin >> data[i];
        if(i == 0){
            min = data[i];
        }else{
            if(min > data[i]){
                min = data[i];
                pos = i;
            }
        }
    }
    if(data[pos] >= n){
        ans = 5;
        printf("%lld\n", ans);
    }else{
        ans = 5;
        if(n % data[pos] == 0){
            ans += n / data[pos] - 1;
        }else{
            ans += n / data[pos];
        }
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int m, n;
vector<bitset<11> > bs;
vector<int> memo;

int solve(int a)
{
    if(memo[a] != -1)
        return memo[a];

    bitset<11> zero, one;
    zero = a & ((1<<m)-1);
    one = a >> m;

    int num = 0;
    for(int i=0; i<n; ++i){
        if((bs[i] & zero).none() && (~bs[i] & one).none())
            ++ num;
    }
    if(num <= 1)
        return memo[a] = 0;

    int ret = INT_MAX;
    for(int i=0; i<m; ++i){
        if(zero[i] || one[i])
            continue;

        zero[i] = true;
        int tmp = solve(zero.to_ulong() + (one.to_ulong() << m));
        zero[i] = false;
        one[i] = true;
        tmp = max(tmp, solve(zero.to_ulong() + (one.to_ulong() << m)));
        one[i] = false;

        ret = min(ret, tmp + 1);
    }

    return memo[a] = ret;
}

int main()
{
    for(;;){
        cin >> m >> n;
        if(m == 0)
            return 0;

        bs.resize(n);
        for(int i=0; i<n; ++i){
            string s;
            cin >> s;
            bs[i] = bitset<11>(s);
        }

        memo.assign(1<<(2*m), -1);
        cout << solve(0) << endl;
    }
}

Measured memory_bytes: 16000
object Main extends App {
  import scala.collection.mutable.{ArrayBuffer, ArrayOps}

  var count: Long = 0
  val n = io.StdIn.readLine().toInt
  val arr: collection.mutable.ArrayOps[Int] = split(io.StdIn.readLine())

  def split(str: String): Array[Int] = {
    val buf: ArrayBuffer[Int] = ArrayBuffer.empty[Int]
    var num_builder = 0
    val iter = str.toIterator

    while(iter.hasNext) {
      val v = iter.next()
      if (v != ' ') num_builder = num_builder*10 + v.toInt
      else {buf += num_builder; num_builder = 0}
    }
    (buf += num_builder).toArray
  }

  def merge(left: Int, middle: Int, right: Int): Unit = {
    val l = arr.slice(left, middle)
    val r = arr.slice(middle, right)
    val lLen = l.length
    val rLen = r.length

    var i = left
    var li = 0
    var ri = 0

    while(li < lLen && ri < rLen) {
      if (l(li) <= r(ri)) {arr(i) = l(li); i += 1; li += 1}
      else {arr(i) = r(ri); count += (lLen - li); i += 1; ri += 1}
    }

    if (li < lLen) while (li < lLen) {arr(i) = l(li); i += 1; li += 1}
    else while (ri < rLen) {arr(i) = r(ri); i += 1; ri += 1}
  }
  def msort() = {
    var step = 1
    while(step < n) {
      var left = 0
      while(left < n) {
        merge(left, left+step, left+step+step)
        left += step + step
      }
      step += step
    }
  }

  msort()
  println(count)
}

Measured memory_bytes: 204180
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll K,N;
    string S;
    cin >> N  >> S >> K;
    rep(i,N){
        if(S[i]!=S[K-1]){
            cout << "*";
        }
        else{
            cout << S[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int a = A;
  int flag = 0;
  REP(i,B){
    if(a%B==C){
      flag = 1;
    }
    a+=A;
  }

  if(flag == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)
    n,k = LI()
    a = LI()
    if max(a) < k:
        print("IMPOSSIBLE")
        return
    g = a[0]
    for i in a[1:]:
        g = gcd(g, i)
    if g == 1:
        print("POSSIBLE")
    else:
        if k%g == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
    return

#B
def B():
    n = I()

    return

#C
def C():
    x,y,z = LI()
    n = x+y+z
    c = LIR(n)
    for i in range(n):
        c[i].append(c[i][0])
    c.sort(key = lambda x:-(x[1]-x[3]))
    for i in range(y):
        c[i][3] = c[i][1]
    c.sort(key = lambda x:-(x[2]-x[3]))
    for i in range(y):
        c[i][3] = c[i][1]

    for i in c:
        print(i)
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 59120
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 100000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 15000001
const int LG = 22;


#undef int 
int main() { 
#define int long long int 
 
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0); 


	int n;
	cin >> n;
	vector<pair<int,int>>v;
	for(int i = 0; i < n ; i++){
		int x,y;
		cin >> x >> y;
		v.pb(mp(y,x));
	}
	sort(v.begin(),v.end());
	int f = 0;
	int pre = 0;
	for(int i = 0; i < n; i++){
		if(pre + v[i].S > v[i].F){
			f = 1;
			break;
		}
		pre += v[i].S;
	}

	if(f) cout << "No";
	else cout << "Yes";



return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


int main(){


  ll N,ans=0;
  cin >> N;

  FOR(i,1,N+1){
    ans += i*floor((long double)N/i) * floor(1.0+(long double)N/i)/2;
  }

  cout << ans << endl;
}




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


int a,b,c,d,n;
long long ans;
int main(){

  while(cin >> n){

    ans = 0;
    for(a = 0 ; a <= 1000 && a <= n  ; a++){
      for(b = 0 ; a + b <= n && b <= 1000 ; b++){
	if(n-a-b > 2000) continue;
	else if( n-a-b > 1000 ) ans += 2000 - (n-a-b) + 1;
	else ans += n-a-b+1;
      }
    }
  
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int[] array = new int[3];

        array[0] = a;
        array[1] = b;
        array[2] = c;

        Arrays.sort(array);

        int cost = 0;
        for(int i=0; i<array.length-1; i++){
            int before = array[i];
            int newCost = Math.abs(before - array[i+1]);
            cost+=newCost;
        }

        System.out.println(cost);
    }
}


Measured memory_bytes: 21844
import heapq


def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    heap = []
    ans = 0
    for i in range(n):
        heapq.heappush(heap, p_list[i])
        if heap[0] >= p_list[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24872
N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
    M = int(input())
    for _ in range(M):
        x,y = map(int,input().split())
        A[i].append((x-1,y))

ans = 0
for b in range(1<<N):
    for i in range(N):
        if b&(1<<i):
            for x,y in A[i]:
                if y:
                    if b&(1<<x)==0:
                        break
                else:
                    if b&(1<<x):
                        break
            else:
                continue
            break
    else:
        t = bin(b).count('1')
        ans = max(ans, t)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define N 1500000
int book[50];
int dan(int k, int n) {
	int num = 0;
	int ans = 1;
	int i;
	for(i = 0; i < n; ++ i) {
		if(book[i] > k) return 0;
		if(num + book[i] > k) {
			ans ++;
			num = book[i];
		} else {
			num += book[i];
		}
	}
	return ans;
}
int main() {
	int m, n;
	int i;
	while(1) {
		scanf("%d %d", &m, &n);
		if(m == 0 && n == 0) break;
		for(i = 0; i < n; ++ i) scanf("%d", &book[i]);
		int left = 0, right = N;
		while(right - left > 1) {
			int ind = (left + right) / 2;
			if(dan(ind, n) > m || dan(ind, n) == 0) {
				left = ind;
			} else {
				right = ind;
			}
		}
		int ans;
		if(dan(left, n) > m || dan(left, n) == 0) ans = right;
		else ans = left;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<math.h>
int main()
{
    int n,t,a,b,flag=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
         scanf("%d %d %d",&t,&a,&b);
         if((t%2!=(a+b)%2))
            flag=1;
         if(a+b>t)
            flag=1;
    }
    if(flag==1)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder_Beginners_selection
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');
            double T = double.Parse(input[0]);
            double A = double.Parse(input[1]);
            int i;
            int[] H = new int[N];
            string[] Hinput = Console.ReadLine().Split(' ');
            for (i = 0; i < N; i++)
            {
                H[i] = int.Parse(Hinput[i]);

            }
            double[] difference = new double[N];
            double[] difference2 = new double[N];
            for (i = 0; i < N; i++)
            {
                difference[i] = T - H[i] * 0.006;
                difference2[i] = A - difference[i];
            }

            for (i = 0; i < N; i++)
            {
                difference2[i] = System.Math.Abs(difference2[i]);
            }
            double mini = difference2.Min();
            int mininumber = Array.IndexOf(difference2, mini);

            Console.WriteLine(mininumber + 1);


        }
    }
}

Measured memory_bytes: 13340
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	ll i,n,m,k,x,c=0;cin>>n>>m>>k;vector<ll>a(n+1,0),b(m+1,0);
	for(i=1;i<=n;i++) cin>>x,a[i]=x+a[i-1];
	for(i=1;i<=m;i++) cin>>x,b[i]=x+b[i-1];
	ll j=m;for(i=0;i<=n;i++){
		while(j&&b[j]>k-a[i]) j--;
		if(a[i]+b[j]<=k) c=max(c,i+j);
	}cout<<c<<endl;
}


Measured memory_bytes: 6408
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
int dp[(int)1e5+1];
vector<int> gh[(int)1e5+1];
int brute(int u){
	if(dp[u] != -1){
		return dp[u];
	}
	int ans = 0;
	for(auto x : gh[u]){
		ans = max(ans,brute(x)+1);
	}
	dp[u] = ans;
	return ans;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	memset(dp,-1,sizeof dp);
	cin>>n>>m;
	vector<int> indeg(n+1,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		indeg[v]++;
		gh[u].pb(v);
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(indeg[i] == 0){
			ans = max(brute(i),ans);
		}
	}
	cout<<ans;
	return 0;
}
//.........

Measured memory_bytes: 12032
S = input()
T = input()
def f(s,t):
    ret = 0
    for c,d in zip(s,t):
        if c != d:
            ret += 1
    return ret
ans = len(T)
for i in range(0, len(S)-len(T)+1):
    ans = min(ans, f(S[i:i+len(T)], T))
print(ans)

Measured memory_bytes: 9124
while True:
    things = {}
    count = input()
    if count == 0: break
    for i in range(count):
        fuga = raw_input().split()
        things[fuga[0]] = int(fuga[1])
    for i in range(input()):
        fuga = raw_input().split()
        money =0
        for j in range(int(fuga[1])):
            hoge = things[fuga[j+2]] if fuga[j+2] in things else 0
            money+= hoge
        things[fuga[0]] = things[fuga[0]] if money > things[fuga[0]] else money
    ans = raw_input()
    print "%s"%(things[ans] if ans in things else "0")

Measured memory_bytes: 4260
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True



MOD = 10**9 + 7
class ModInt:

    def __init__(self, x):
        self.x = x.x if isinstance(x, ModInt) else x % MOD

    __str__ = lambda self:str(self.x)
    __repr__ = __str__
    __int__ = lambda self: self.x
    __index__ = __int__

    __add__ = lambda self, other: ModInt(self.x + ModInt(other).x)
    __sub__ = lambda self, other: ModInt(self.x - ModInt(other).x)
    __mul__ = lambda self, other: ModInt(self.x * ModInt(other).x)
    __pow__ = lambda self, other: ModInt(pow(self.x, ModInt(other).x, MOD))
    __mod__ = lambda self, other: ModInt(self.x % ModInt(other).x)
    __truediv__ = lambda self, other: ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))
    __floordiv__ = lambda self, other: ModInt(self.x // ModInt(other).x)
    __radd__ = lambda self, other: ModInt(other + self.x)
    __rsub__ = lambda self, other: ModInt(other - self.x)
    __rpow__ = lambda self, other: ModInt(pow(other, self.x, MOD))
    __rmod__ = lambda self, other: ModInt(other % self.x)
    __rmul__ = lambda self, other: ModInt(other * self.x)
    __rtruediv__ = lambda self, other: ModInt(other * pow(self.x, MOD - 2, MOD))
    __rfloordiv__ = lambda self, other: ModInt(other // self.x)

    __lt__ = lambda self, other: self.x < ModInt(other).x
    __gt__ = lambda self, other: self.x > ModInt(other).x
    __le__ = lambda self, other: self.x <= ModInt(other).x
    __ge__ = lambda self, other: self.x >= ModInt(other).x
    __eq__ = lambda self, other: self.x == ModInt(other).x
    __ne__ = lambda self, other: self.x != ModInt(other).x


def main():
    S = input()
    N = len(S)-1
    dp = [[0] * 13  for _   in range(N)]
    dp[0] = [ModInt(0) for _ in range(13)]
    
    if S[0] == '?':
        for i in range(10):
            dp[0][i] = ModInt(1)
    else:
        dp[0][int(S[0])] = ModInt(1)

    for i in range(1,N):
        if S[i] == '?':
            for j in range(13):
                for k in range(10):
                    dp[i][(j * 10 + k) % 13 ] += dp[i-1][j]
        else:
            for j in range(13):
                dp[i][ (j* 10 + int(S[i])) % 13 ] += dp[i-1][j]
        

    print(dp[len(S)-2][5])









    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 143300
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<int> v( N );
	rep( i, N ) { cin >> v[i]; }

	vector<int> vv( N + 1 );
	vv[0] = 0;
	rep( i, N )
	{
		vv[i + 1] = vv[i] + v[i];
	}

	int cnt = 10000000;
	reps( i, N )
	{
		int s1 = vv[i] - vv[0];
		int s2 = vv[N] - vv[i];

		chmin( cnt, abs( s1 - s2 ) );
	}

	cout << cnt << endl;

	return ( 0 );
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int main(){
    int n,k;
    cin >> n >> k;
    ld ans=0;
    for(int i=1;i<=n;i++){
        double tmp=1.0/n;
        int point = i;
        while(point<k){
            tmp=tmp/2;
            point=point*2;
        }
        ans+=tmp;
    }
    cout << setprecision(15) <<ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    vi v(5);
    cin >> v;
    rep(i,5) if(v[i] == 0) {
        cout << i+1 << endl;
        return 0;
    }
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    ll ans = 0;
    rep(i, S.size() / 2) ans += S[i] != S[S.size() - i - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572