akhauriyash/Code-Regression huggingface dataset:
import sys

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))

times = [0] * 24
times[0] = 1
for d in D:
    times[d] += 1

if max(times) > 2 or times[0] == 2 or times[12] == 2:
    print(0)
else:
    ans = 0
    # 1 - 11時間の時差の場合、Diと24 - Diの両方を試す
    for i in range(2**11):
        positions = [0]
        for j in range(1, 12):
            if times[j] == 2:
                positions.append(j)
                positions.append(24 - j)
            elif times[j] == 1:
                if (i >> j) & 1:
                    positions.append(24 - j)
                else:
                    positions.append(j)
        if times[12] == 1:
            positions.append(12)
        positions.sort()
        # print(positions)
        lp = len(positions)
        d = float("inf")
        for p in range(lp):
            # 0をまたぐ場合がある
            if p == lp -1:
                diff = 24 - positions[p] + positions[0]
            else:
                diff = positions[p+1] - positions[p]
            d = min(d, diff if diff != 24 else 0)
        ans = max(ans, d)

    print(ans)

Measured memory_bytes: 9140
from collections import deque

n, u, v = map(int, input().split())
u -= 1 
v -= 1
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(lambda x : int(x) - 1, input().split())
    tree[a].append(b)
    tree[b].append(a)

q = deque()
q.append((u, 0))
depth = [0] * n

visited = set()
while q:
    p, d = q.popleft()
    depth[p] = d
    visited.add(p)
    for x in tree[p]:
        if not x in visited:
            q.append((x, d+1))


q.append((v, 0))
visited.clear()
max_case = max(depth[v] - 1, 0)
while q:
    p, d = q.popleft()
    visited.add(p)
    is_leaf = True
    for x in tree[p]:
        if not x in visited:
            q.append((x, d+1))
            is_leaf = False
    if is_leaf and depth[p] < d:
        max_case = max(max_case, d - 1)
print(max_case)


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  string s;
  cin>>s;
  int cnt=0;
  r(i,s.size()){
    if(s.at(i)=='o')cnt++;
  }
  cout<<700+100*cnt<<endl;


return 0;}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, D: int, X: int, A: "List[int]"):
    res = X

    for a in A:        
        res += (D-1)//a + 1
             
    print(res)

    return


# Generated by 1.1.4 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
    D = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, D, X, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding:utf-8 -*-
import sys
N=int(input())
List_1=list(map(int,input().split()))
List_2=list(map(int,input().split()))

answer=[]
score=0
for i in range(N):
  score+=sum(List_1[:i+1])
  score+=sum(List_2[i:])
  answer.append(score)
  score=0

print(max(answer))

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

int main()
{
  string s;
  cin >> s;
  bool b = true;
  for (char i = 'a'; i <= 'z'; i++)
  {
    int c = count(s.begin(), s.end(), i);
    if (c % 2 != 0)
    {
      b = false;
      break;
    }
  }
  cout << (b ? "Yes" : "No") << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string PC = "pairwise coprime";
const string SC = "setwise coprime";
const string NC = "not coprime";

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

#define MAX 1000100
int n;
ll A[MAX];

bool is_prime[MAX+10];
ll min_factor[MAX+10];

void init(ll limit) { 
  rep(i,limit+1) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  min_factor[0] = 0, min_factor[1] = 1;
  for(ll i=2;i<=limit;++i) {
    if( is_prime[i] ) {
      min_factor[i] = i;
      for(ll j=i*i;j<=limit;j+=i) {
	is_prime[j] = false;
	if( min_factor[j] == 0 ) {
	  min_factor[j] = i;
	}
      }
    }
  }
}

set<ll> prime_factor(ll v) {
  set<ll> S;
  while( v > 1 ) {
    ll fact = min_factor[v];
    //vec.push_back(fact);
    S.insert(fact);
    v /= fact;
  }
  return S;
}

	
bool hasIJ() {
  set<ll> S;
  rep(i,n) {
    set<ll> vec = prime_factor(A[i]);
    //cout << "-- " << A[i] << endl;
    for(auto v : vec) {
      //cout << "  " << v << " : "  << S.count(v) << endl;
      if( S.count(v) ) {
	return true;
      }
      S.insert(v);
    }
  }
  return false;
}

void solve() {
  init(MAX);
  if( hasIJ() ) {
    ll gcd = A[0];
    REP(i,1,n) {
      gcd = __gcd(gcd,A[i]);
    }
    if( gcd == 1LL ) {
      puts(SC.c_str());
    } else {
      puts(NC.c_str());
    }
    return;
  }
  puts(PC.c_str());
}

int main() {
  if( 0) {
    n = 1000000;
    cout << n << endl;
    rep(i,n) {
      cout << i + 1 << endl;
    }
    return 0;
  }


  scanf("%d",&n);
  int tmp;
  rep(i,n) {
    scanf("%d",&tmp);
    A[i] = tmp;
  }
  sort(A,A+n);
  solve();
  return 0;
}


Measured memory_bytes: 20296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		
		//入力表示
		int H = scanner.nextInt();
		int A = scanner.nextInt();
		
		//攻撃計算
		System.out.println((H+A-1)/A);
		 
		scanner.close();
	}
}

Measured memory_bytes: 22100
#include<stdio.h>
int main(void)
{
	int N,M,i,j,g,cnt[51]={0},ans[51]={0},sans[51]={0};
	int b=0,c=0,d=0,e=2500;
	char a[51][51];
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++){
		scanf("%s",a[i]);
	}
	for(i=0;i<N;i++){
		for(j=0;j<M;j++){
			if(a[i][j]!='W'){
				cnt[i]+=1;
			}
			if(a[i][j]!='B'){
				ans[i]+=1;
			}
			if(a[i][j]!='R'){
				sans[i]+=1;
			}
		}
	}
	for(i=0;i<N-2;i++){
		b=b+cnt[i];
		for(j=i+1;j<N-1;j++){
			c=c+ans[j];
			for(g=j+1;g<N;g++){
				d=d+sans[g];
			}
			if(e>b+c+d){
				e=b+c+d;
			}
			d=0;
		}
		c=0;
	}
	printf("%d\n",e);
	return 0;
}


Measured memory_bytes: 2036
def knapsack(n, w, info):
    # dp[i][j] := i番目までの品物の中から重さの総和がjを超えないように選んだときの、
    #             価値の総和の最大値
    dp = [[0]*(w + 1) for i in range(n + 1)]

    for i in range(n):
        for j in range(w + 1):
            weight, value = info[i]
            if j < weight:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value)
    return dp



n, t = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

ans = 0
if t == 1:
    for i in range(n):
        ans = max(ans, info[i][1])
    print(ans)
    exit()

info = sorted(info)
dp = knapsack(n, t, info)
ruiseki_max = [0]*(n+1)

for i in range(n)[::-1]:
    ruiseki_max[i] = max(ruiseki_max[i+1], info[i][1])

ans = 0
for i in range(n+1):
    ans = max(dp[i][-2] + ruiseki_max[i], ans)
print(ans)

Measured memory_bytes: 116440
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] shine = new int[n];
        
        for (int i = 0; i < shine.length; i++) {
            shine[i] = 0;
        }
        
        for (int i = 0; i < shine.length - 1; i++) {
            int j = sc.nextInt() - 1;
            shine[j]++;
        }
        
        for (int i = 0; i < shine.length; i++) {
            System.out.println(shine[i]);
        }
    }
}


Measured memory_bytes: 55844
def main():
    N = int(input())  # 文字列または整数(一変数)
    d = list(map(int, input().split()))  # 整数のリスト
    answer = 0

    for i in range(0, N-1):
        for j in range(i+1, N):
            answer += d[i] * d[j]

    print(answer)


if __name__ == '__main__':
    main()


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

int main(){
  int N,K;
  cin >> N >> K;
  int x = 1;
  
  int i = 0;
  
  while (i < N){
    if (x < K){
      x *= 2;
    }
    else{
      x += K;
    }
    
    i++;
  }
  
  cout << x << endl;
}

Measured memory_bytes: 256
#pragma region template 1.2
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    ll N, K, S;
    cin >> N >> K >> S;

    vi ans(N);
    REP(i, N)
    {
        if (i < K)
        {
            ans[i] = S;
        }
        else if (S < 1e9)
        {
            ans[i] = 1e9;
        }
        else
        {
            ans[i] = 1e9 - 1;
        }
    }
    OUTA(ans);
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const ll mod=1e9+7;

ll mod_pow(ll x, ll n)
{
    ll pw[40];
    pw[0]=x;
    for(int i=1; i<40; ++i) pw[i]=(pw[i-1]*pw[i-1])%mod;

    ll ret=1;
    rep(i,40)
    {
        if(n>>i&1) (ret*=pw[i])%=mod;
    }
    return ret;
}

vector<int> factor(int n)
{
    vector<int> ret;

    for(int i=1; i*i<=n; ++i)
    {
        if(n%i==0)
        {
            ret.pb(i);
            if(i != n/i) ret.pb(n/i);
        }
    }

    sort(all(ret));
    return ret;
}

int main()
{
    int n,k;
    scanf(" %d %d", &n, &k);

    vector<int> d = factor(n);
    int D=d.size();

    vector<ll> dp(D);
    rep(i,D)
    {
        dp[i] = mod_pow(k,(d[i]+1)/2);

        rep(j,i)if(d[i]%d[j]==0) dp[i] = (dp[i]-dp[j]+mod)%mod;
    }

    ll ans=0;
    rep(i,D)
    {
        if(d[i]%2==0) (ans+=dp[i]*d[i]/2)%=mod;
        else (ans+=dp[i]*d[i])%=mod;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

int main(){
    int res1 = 0;
    int res2 = 0;
    int A; cin >> A;
    int th; th = A/100;
    res1 = th*100 + th* 10 + th;
    res2 = res1+111;
    
    if(A<=res1) cout << res1 << endl;
    else cout << res2 << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
using namespace std;
#pragma warning(disable : 4996)


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	if (s == "SUN") {
		cout << 7;
	}
	else if (s == "SAT") {
		cout << 1;
	}
	else if (s == "FRI") {
		cout << 2;
	}
	else if (s == "THU") {
		cout << 3;
	}
	else if (s == "WED") {
		cout << 4;
	}
	else if (s == "TUE") {
		cout << 5;
	}
	else if (s == "MON") {
		cout << 6;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;
const int MAXN=100005;
int a[MAXN];
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        memset(a, 0, sizeof(a));
        int x;
        for(int i=1;i<=n;++i)
        {
            scanf("%d", &x);
            a[x]++;
        }
        int Max=0;
        for(int i=1;i<=1e5+1;++i)
        {
            Max=max(Max, a[i]+a[i-1]+a[i+1]);
        }
        printf("%d\n", Max);
    }
    return 0;
}


Measured memory_bytes: 640
mod = 10**9+7
def cmb(x, y):
  ret = 1
  for i in range(1, y+1):
    ret = (ret * (x+1-i)) % mod
    ret = (ret * pow(i, mod-2, mod)) % mod
  return ret

n,a,b = map(int,input().split())
ans = (pow(2,n,mod) - 1 - cmb(n,a) - cmb(n,b)) % mod
print(ans)

Measured memory_bytes: 64496
// 2020-06-27 15:10:39
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct RangedFenwickTree {
  ll N;
  vll bit1, bit2;
  void init(ll n) {
    N = n;
    bit1.assign(n+2, 0);
    bit2.assign(n+2, 0);
  }
  void add(vll& bit, ll i, ll a) {
    assert(i > 0);
    while(i <= N) {
      bit[i] += a;
      i += (i & -i);
    }
  }
  void range_add(ll l, ll r, ll a) {
    add(bit1, l, a);
    add(bit2, l, -a*(l-1));
    add(bit1, r+1, -a);
    add(bit2, r+1, a*r);
  }
  ll query(vll& bit, ll i) {
    ll res = 0;
    while(i > 0) {
      res += bit[i];
      i -= (i & -i);
    }
    return res;
  }
  ll sum(ll i) {
    return query(bit1, i) * i + query(bit2, i);
  }
};

ll n, c[200020];
vector<ll> ans;
vector<ll> G[200020];
RangedFenwickTree bit;
ll calc(ll a) {
  return a + (a * (a - 1) / 2);
}
void dfs(ll u, ll p) {
  ll init, cur;
  init = cur = bit.sum(c[u]) - bit.sum(c[u]-1);
  for(ll i = 0; i < G[u].size(); i++) {
    ll v = G[u][i];
    if(p == v) continue;
    dfs(v, u);
    ll now = bit.sum(c[u]) - bit.sum(c[u]-1);
    ans[c[u]] -= calc(now - cur);
    cur = now;
  }
  bit.range_add(1, n, 1);
  bit.range_add(c[u], c[u], init - cur - 1);
}
void answer() {
  cin >> n;
  bit.init(n);
  ans.assign(n+10, calc(n));
  rep(i, n) {
    cin >> c[i];
  }
  rep(i, n-1) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  dfs(0, -1);
  REPC(i, 1, n) {
    ans[i] -= calc(bit.sum(i) - bit.sum(i-1));
  }
  REPC(i, 1, n) cout << ans[i] << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 35864
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

vi parent, children;
int getPar(int c){
    if(c == parent[c]) return c;
    parent[c] = getPar(parent[c]);
    return parent[c];
}

void join(int a, int b){
    a = getPar(a), b = getPar(b);
    if(a == b) return;
    if(children[a] < children[b]) swap(a,b);
    parent[b] = a;
    children[a] += children[b];
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi X(n), Y(n);
    parent.resize(n+1);
    children.resize(n+1,1);
    F0R(i,1,n) parent[i] = i;
    FOR(i,n) cin >> X[i] >> Y[i];
    vi myY(n+1);
    FOR(i,n) myY[X[i]] = Y[i];
    vi ans(n+1);
    set<pi, greater<pi>>  more;
    set<pi> le;
    F0R(i,1,n){
        auto it = le.insert({myY[i],i}).f;
        while(1){
            join(i,(*it).s);
            if(it == le.begin()) break;
            else it = le.erase(it);
            it--;
        }
    }
    for(int i = n; i > 0; i--){
        auto it = more.insert({myY[i],i}).f;
        while(1){
            join(i,(*it).s);
            if(it == more.begin()) break;
            else it = more.erase(it);
            it--;
        }
    }
    F0R(i,1,n) ans[i] = children[getPar(i)];
    FOR(i,n) cout << ans[X[i]] << "\n";
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll m = 1000;
    ll kb = 0;
    ll c = 0;
    rep(i, n)
    {
        if (kb > 0 && c <= a[i])
        {
            m += kb * a[i];
            kb = 0;
        }
        bool buy = false;
        for (int j = i + 1; j < n; j++)
        {
            if (a[i] < a[j])
            {
                buy = true;
                break;
            }
            else if (a[i] > a[j])
            {
                break;
            }
            else if (a[i] == a[j])
            {
                continue;
            }
        }
        if (buy)
        {
            kb = m / a[i];
            m -= kb * a[i];
            c = a[i];
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";

signed main()
{
//	freopen("input.txt", "r", stdin);
	
	int n; cin>>n;
	int b[n-1], a[n];
	for(int i=0; i<n-1; i++) cin>>b[i];
	a[n-1] = b[n-2];
	for(int i=n-2; i>0; i--)
	{
		a[i] = min(b[i-1], b[i]);
	}
	a[0] = b[0];
	for(int i=1; i<n; i++) a[i] += a[i-1]; cout<<a[n-1]<<"\n";
}

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

int main()
{
  int n;
  ll sum = 0;
  cin >> n;
  vector<int> a(n, 0);
  vector<ll> num(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    num[a[i] - 1]++;
  }
  for (int i = 0; i < n; i++) {
    sum += num[i] * (num[i] - 1) / 2;
  }
  vector<ll> ans(n, sum);
  for (int i = 0; i < n; i++) {
    ans[i] -= num[i] - 1;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[a[i] - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 6528
N = int(input())
A = list(map(int, input().split()))
B = map(int, input().split())

count = 0
for i, b in enumerate(B):
    if A[i] >= b:
        A[i] -= b
        count += b
    else:
        count += A[i]
        b -= A[i]
        if b >= 1:
            count += min(A[i + 1], b)
            A[i + 1] = max(0, A[i + 1] - b)

print(count)

Measured memory_bytes: 16576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int T = sc.nextInt();
		
		for(int i = 0; i < T; i++){
			if(i != 0){
				System.out.println();
			}
			
			final int H = sc.nextInt();
			final int W = sc.nextInt();
			
			char[][] map = new char[H+2][W+2];
			
			int p_x = 0, p_y = 0;
			
			for(int j = 0; j < (H + 2); j++){
				char[] str = null;
				if(!(j == 0 || j == H + 1)){
					str = sc.next().toCharArray();
				}
				
				for(int k = 0; k < (W + 2); k++){
					if(j == 0 || j == H + 1 || k == 0 || k == W + 1){
						map[j][k] = '#';
					}else{
						map[j][k] = str[k-1];
						
						if(map[j][k] == '<' || map[j][k] == '>' || map[j][k] == '^' || map[j][k] == 'v'){
							p_x = k;
							p_y = j;
						}
					}
				}
			}
			sc.next();
			char[] input = sc.next().toCharArray();
			for(char c : input){
				if(c == 'U'){
					map[p_y][p_x] = '^';
					if(map[p_y-1][p_x] == '.'){
						map[p_y-1][p_x] = '^';
						map[p_y][p_x] = '.';
						p_y--;
					}
				}else if(c == 'D'){
					map[p_y][p_x] = 'v';
					if(map[p_y+1][p_x] == '.'){
						map[p_y+1][p_x] = 'v';
						map[p_y][p_x] = '.';
						p_y++;
					}
				}else if(c == 'L'){
					map[p_y][p_x] = '<';
					if(map[p_y][p_x-1] == '.'){
						map[p_y][p_x-1] = '<';
						map[p_y][p_x] = '.';
						p_x--;
					}
				}else if(c == 'R'){
					map[p_y][p_x] = '>';
					if(map[p_y][p_x+1] == '.'){
						map[p_y][p_x+1] = '>';
						map[p_y][p_x] = '.';
						p_x++;
					}
				}else if(c == 'S'){
					int s_x = 0, s_y = 0;
					
					if(map[p_y][p_x] == '^'){
						s_y = -1;
					}else if(map[p_y][p_x] == 'v'){
						s_y = 1;
					}else if(map[p_y][p_x] == '<'){
						s_x = -1;
					}else if(map[p_y][p_x] == '>'){
						s_x = 1;
					}
					
					int xx = p_x + s_x;
					int yy = p_y + s_y;
					
					while(!(map[yy][xx] == '*' || map[yy][xx] == '#')){
						yy += s_y;
						xx += s_x;
					}
					
					if(map[yy][xx] == '*'){
						map[yy][xx] = '.';
					}
				}
			}
			
			for(int j = 1; j < H + 1; j++){
				for(int k = 1; k < W + 1; k++){
					System.out.print(map[j][k]);
				}
				
				System.out.println();
			}
		}
	}

}

Measured memory_bytes: 12000
-- D
local N, Kmax, _, tmp = io.read("n", "n", "l", "l")
local S = {}
local ZZ = string.byte('0')
for i=1, N do
    S[i] = string.byte(tmp, i, i) - ZZ
end
local rlast = 1
local k = 0
local left = 1
local ans = 0
for right=1, N do
    if rlast == 1 and S[right] == 0 then
        k = k + 1
    end
    rlast = S[right]
    while k > Kmax do
        local llast = S[left]
        left = left + 1
        if llast == 0 and S[left] == 1 then
            k = k - 1
        end
    end
    assert(right >= left)
    local v = right - left + 1
    if ans < v then
        ans = v
    end
end
print(ans)


Measured memory_bytes: 2584
#include<iostream>
using namespace std;
int main(){
	int a[5];
	int s=0;
	int i=0;
	for(i=0;i<5;i++){
		cin>>a[i];
		if(a[i]<40){
			a[i]=40;
		}
		s=s+a[i];
	}
	s=s/5;
	cout<<s<<endl;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 998244353;
const long long int INF = 1e18;




long long int N,K,M,V,P,A[100050],res=0,line=0,sum[100050]={};

char ch;
string s;

int main()
{
    cout << fixed << setprecision(18);
    cin>>s;
    for(long long int i = 0; i < s.size(); i++){
        if(s[i]=='0'){res++;}
        else{res--;}
    }
    cout<<s.size()-abs(res)<<endl;
}


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

int main(){
    string s,t,u;
    cin >> s;
    int n = s.size();
    int t1=0,u1=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            t += '1';
            u += '0';
        }else{
            t += '0';
            u += '1';
        }
    }
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]) t1++;
        if(s[i]!=u[i]) u1++;
    }
    cout << min(t1,u1)<< endl;
}


Measured memory_bytes: 768
N = int(input())
S = input()

mod = 10 ** 9 + 7

kind = set(S)
each_char = []

for char in kind:
    each_char.append(S.count(char))

count = 1
for i in each_char:
    count = (count % mod) * ((i + 1) % mod) % mod

print((count - 1) % mod)


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

int main() {
	
	int a, b;
	char op;

	while (1) {
		cin >> a >> op >> b;
		if (op == '?') {
			break;
		}
		switch (op)
		{
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		default:
			break;
		}
	}

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

int n,m,W,T;
map<string,int> id;
ll w[11],b[11];
ll times[1<<8],prof[1<<8];
ll dp[10010];

ll x[11],y[11];
vector<P> prod[11];

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>m>>W>>T;
  rep(i,m){
    string name;
    cin>>name>>w[i]>>b[i];
    id[name]=i;
  }

  rep(i,n){
    int l;
    cin>>l>>x[i]>>y[i];
    while(l--){
      string name;
      ll price;
      cin>>name>>price;
      prod[i].push_back(P(id[name],price));
    }
  }

  repl(S,1,1<<n){
    vector<int> vs;
    rep(i,n){
      if(((S>>i)&1)==1){
        vs.push_back(i);
      }
    }
    ll dist=INF;
    do{
      ll sum=abs(x[vs[0]])+abs(y[vs[0]])+abs(x[vs[vs.size()-1]])+abs(y[vs[vs.size()-1]]);
      rep(j,vs.size()-1){
        sum+=abs(x[vs[j]]-x[vs[j+1]])+abs(y[vs[j]]-y[vs[j+1]]);
      }
      minch(dist,sum);
    }while(next_permutation(all(vs)));

    ll minprice[11];
    rep(i,11)minprice[i]=INF;
    rep(i,vs.size()){
      for(P p : prod[vs[i]]){
        if(minprice[p.fi]>p.se)minprice[p.fi]=p.se;
      }
    }
    memset(dp,0,sizeof(dp));
    rep(i,m)rep(j,W-w[i]+1){
      maxch(dp[j+w[i]],dp[j]+mmax(0,b[i]-minprice[i]));
    }
    times[S]=dist; prof[S]=dp[W];
  }

  memset(dp,0,sizeof(dp));
  repl(i,1,1<<n)rep(j,T-times[i]+1){
    maxch(dp[j+times[i]],dp[j]+prof[i]);
  }
  cout<<*max_element(dp,dp+10010)<<endl;
	return 0;
}

Measured memory_bytes: 3336
A, B = map(int, input().split())

ans = 0
for i in range(10000):
    if (i * 8 //100) == 0:
        pass
    else:
        if (i * 8 //100) == A and (i * 10 //100) == B:
            print(i)
            ans = 1
            break

if ans == 0:
    print(-1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> flags(n, 0);
    rep(i, k) {
        ll d;
        cin >> d;
        rep(j, d) {
            ll a;
            cin >> a;
            flags[a - 1] = 1;
        }
    }
    ll cnt = 0;
    rep(i, n) {
        if (flags[i] == 0) {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}
vc list1;vector<vc>a;
ll dfs(ll ind,ll cnt)
{
    ll i;
	    for(i=0;i<a[ind].size();i++)
	    {
	        if(list1[a[ind][i]]==0)
	        {
	            list1[a[ind][i]]=1;
	            cnt++;
	            cnt+=dfs(a[ind][i],0);
	        }
	    }
	    return cnt;
	}
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,m,n,i,j,k,c,f;
	cin>>n>>m;
	vector<vc> a1(n+1,vc());
	set<pairs>s;
	for(i=1;i<=m;i++)
	{
	    cin>>j>>k;
	    s.insert({min(j,k),max(j,k)});
	}
	for(auto x:s){
	    a1[x.first].push_back(x.second);
	    a1[x.second].push_back(x.first);
	}
	a=a1;
	vc list2(n+1);list1=list2;
	ll mx=1;
	for(i=1;i<=n;i++)
	{
	    if(list1[i]!=1)
	    {
	        list1[i]=1;
	        mx=max(mx,dfs(i,1));
	    }
	}
	cout<<mx;
	return 0;
}


Measured memory_bytes: 50088
#include<iostream>
using namespace std;
int w;
main()
{
	while(cin>>w,w)
	{
		int ans=1e9;
		w/=100;
		for(int i=0;i<51;i++)for(int j=0;j<51;j++)for(int k=0;k<51;k++)
		{
			if(i*2+j*3+k*5!=w)continue;
			int now=i/5*5*38*8+i%5*380+j/4*2*55*17+j%4*550+k/3*3*748+k%3*850;
			ans=ans<now?ans:now;
		}
		cout<<ans<<endl;
	}
}



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

int main() {
  int N, X;
  cin >> N >> X;
  int mmin = 100000, msum = 0;
  for(int i = 0; i < N; i++){
    int m;
    cin >> m;
    msum += m;
    mmin = min(m, mmin);
  }
  cout << N + (X - msum) / mmin;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
#include <functional>


using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<ll,ll>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

map <P, ll> memo;
ll n;

ll go(ll u, ll v) {
	ll ans=0LL;
	if (memo.count(P(u, v)) > 0)
		return memo[P(u, v)];
	ans =  (ans + go(u / 2, v / 2))%MOD;
	if (u >= 1 && v >= 1)//
		ans = (ans + go((u - 1) / 2, (v - 1) / 2))%MOD;
	if (v >= 2)//
		ans = (ans + go(u / 2, (v - 2)/2))%MOD;
	return memo[P(u, v)] = ans ;
}

int main(){
	cin >> n;
	memo[P(0, 0)] = 1;//
	cout << go(n, n) << endl;//

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int x = reader.nextInt();
		
		solver(x);
	}
	
	public static void solver(int x) {
		// write logic
		if (x==0) System.out.println(1);
		else System.out.println(0);
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

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

int main(){
	double xp0,yp0,xp1,yp1,xp2,yp2,xp3,yp3;
	double a,b,c,d;
	double x,y;
	int q,i;
	
	cin>>q;
	
	for(i=0;i<q;i++){
		cin>>xp0>>yp0>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3;
		
		if(xp0==xp1 && xp2!=xp3){
			x=xp0;
			y=(yp2-yp3)/(xp2-xp3)*(xp0-xp2)+yp2;
		}else if(xp0!=xp1 && xp2==xp3){
			x=xp2;
			y=(yp0-yp1)/(xp0-xp1)*(xp2-xp0)+yp0;
		}else{
			a=(yp0-yp1)/(xp0-xp1);
			b=yp0-(yp0-yp1)/(xp0-xp1)*xp0;
			c=(yp2-yp3)/(xp2-xp3);
			d=yp2-(yp2-yp3)/(xp2-xp3)*xp2;
			
			x=(d-b)/(a-c);
			y=a*(d-b)/(a-c)+b;
		}
		cout<<fixed<<setprecision(10)<<x<<" ";
		cout<<fixed<<setprecision(10)<<y<<endl;
	}
}


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

int main() {
  int N;
  cin >> N;
  int buf[100000];
  int n = 0;
  for (int x=1; x < 100; x++) for (int y=1; y < 100; y++) for (int z=1; z < 100; z++) {
    n = x*x + y*y + z*z + x*y + y*z + z*x;
    buf[n] += 1; 
  }
  for (int i=1; i < N + 1; i++) {
    cout << buf[i] << endl;
  }
}


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

int main() {
 int n;
  cin>>n;
  int a[20][20][2],A[20];
  for(int i=1;i<=n;i++){
    cin>>A[i];
    for(int j=1;j<=A[i];j++){
      cin>>a[i][j][0]>>a[i][j][1];
    }
  }
  int ans=0;
  for(int k=1;k<(1<<n);k++){
    int cnt=0;
    bool flag=true;
    vector<int> b(20,-1);
    for(int i=1;i<=n;i++){
      if(k>>(i-1)&1){
        if(b[i]==0) {flag=false; break;}
        b[i]=1;
        for(int j=1;j<=A[i];j++){
          int x=a[i][j][0],y=a[i][j][1];
          if(b[x]==-1) b[x]=y;
          else if(b[x]!=y) {flag=false; break;}
        }
        if(!flag) break;
        cnt++;
      }
      else{
        if(b[i]==1) {flag=false; break;}
        b[i]=0;
      }
    }
    if(!flag) continue;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int i;
  char s[10];
  while(scanf("%d",&i),i){
    sprintf(s,"%o",i);
    for(i=0;s[i]!='\0';i++){
      if(s[i]>='4')s[i]++;
      if(s[i]>='6')s[i]++;
}
    printf("%s\n",s);
}
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int a,b;
  cin >> a >> b;
  if(a*b % 2 == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 3576
(function(input) {
    var p = input.split('\n').map(Number);
    var n = p.shift();
    var a = p.slice(0, n);
    var count = 0;
    var g = [];
    for (var i = 0;; i++) {
        var m = Math.pow(4, i);
        if (m > a.length) {
            break;
        }
        g.unshift(m);
    }
    sortShell(a, g);
    console.log(g.length);
    console.log(g.join(' '));
    console.log(count);
    console.log(a.join('\n'));

    function sortShell(a, g) {
        for (var i = 0; i < g.length; i++) {
            sortInsertion(a, g[i]);
        }

        function sortInsertion(a, g) {
            //console.log(a.join(' '));
            for (var i = g; i < a.length; i++) {
                var v = a[i];
                var j = i - g;
                while (j >= 0 && a[j] > v) {
                    a[j + g] = a[j];
                    j -= g;
                    count++;
                }
                a[j + g] = v;
                //console.log(a.join(' '));
            }
        }
    }

})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 135048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


int main(){
  int a,b,c,ans;
	cin>>a>>b>>c;
  vector<int> v;
  v.pb(a);
  v.pb(b);
  v.pb(c);
  SORT(v);

  cout << v.at(0)+v.at(1) << endl;
}

Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		cin>>s;
		n=s.length();
		ll x=0,dp[n+1][13];
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		rep(i,n)
		{
			if(s[i]=='?')
			{
				rep(k,13)
				{
					x=k;
					rep(j,10)
					{
						m=(x*10+(j))%13;
						dp[i+1][m]= (dp[i+1][m]+dp[i][x])%mod;
						x=m;
					}
				}
			}
			else
			{
				rep(k,13)
				{
					x=k;
					m=(x*10+(s[i]-'0'))%13;
					dp[i+1][m]= (dp[i+1][m]+dp[i][x])%mod;
					x=m;
				}
			}
		}
		
		c=dp[n][5];
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

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

int main(){
    long long int n,m,sum=0;
    cin>>n>>m;
    if(n<m/2){
        sum+=n;
        m-=n*2;
        sum+=m/4;
    }else{
        sum+=m/2;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
  
int main(){
    char str[21];
    char temp[21];
  
    memset(str, 0, sizeof(str));
    memset(temp, 0, sizeof(temp));
  
    while(cin >> str){
		int i=0;
        int n = strlen(str);
		for(n--; n>=0; ){
            temp[i++] = str[n--];
        }
        cout << temp << endl;
    }
    return 0;
}

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

int main()
{
	char b;

	cin >> b;

	if (b == 'A')
		cout << "T" << endl;
	else if(b == 'T')
		cout << "A" << endl;
	else if (b == 'C')
		cout << "G" << endl;
	else if (b == 'G')
		cout << "C" << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


// nの約数を列挙する
vector<ll> getdivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n;i++){
        if(n%i == 0) {
            res.push_back(i);
            if(n/i != i) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}

template<class Type>
Type solve(Type res = Type()){
    ll X; cin >> X;

    auto divisors = getdivisor(X);
    for(auto div:divisors){
        for(ll A = -120; A <= 120; A++){
            if(A*A*A*A > X) continue;
            
             
            ll A5 = A*A*A*A*A;
            ll B = A - div;
            
            ll B5 = B*B*B*B*B;

            if(A5 - B5 == X){
                cout << A << " " << B << endl;
                return res;
            }
        }
    }

    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3644
from bisect import bisect
N = int(input())
B = []
BW = []; BB = []
MB = {}; MW = {}
for i in range(2*N):
    c, a = input().split()
    a = int(a)
    c = "BW".index(c)
    B.append((c, a))
    if c:
        MW[a-1] = i
    else:
        MB[a-1] = i

P = [[0]*(N+1) for i in range(N+1)]
Q = [[0]*(N+1) for i in range(N+1)]

for p in range(N):
    cnt = MW[p] - sum(MW[p0] < MW[p] for p0 in range(p))

    P[p][0] = cnt
    for q in range(N):
        if MB[q] < MW[p]:
            cnt -= 1
        P[p][q+1] = cnt

for q in range(N):
    cnt = MB[q] - sum(MB[q0] < MB[q] for q0 in range(q))

    Q[q][0] = cnt
    for p in range(N):
        if MW[p] < MB[q]:
            cnt -= 1
        Q[q][p+1] = cnt

dist = [[10**9]*(N+1) for i in range(N+1)]
dist[0][0] = 0
que = [(0, 0, 0)]
for i in range(N):
    dist[i+1][0] = dist[i][0] + P[i][0]
for i in range(N):
    dist[0][i+1] = dist[0][i] + Q[i][0]
for i in range(N):
    for j in range(N):
        dist[i+1][j+1] = min(dist[i][j+1] + P[i][j+1], dist[i+1][j] + Q[j][i+1])
print(dist[N][N])


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

namespace cs
{
    public class Program
    {
        public static void Main(string[] args)
        {
        
        	
        	var K = int.Parse(Console.ReadLine().Split(' ')[3]);
        	
        	
        	var listA = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
        	var listB = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
        	var listC = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
        	var listAB = new List<long>();
        	
        	for(int i = 0; i < listA.Length; i++){
        	
        		for(int k = 0; k < listB.Length; k++){
        			
        			listAB.Add(listA[i] + listB[k]);
        		
        		
        		}
        	
        	}
        	
        	listAB.Sort();
			listAB.Reverse();
        	
        	listA = listAB.Take(Math.Min(listA.Length * listB.Length,3000)).ToList().ToArray();
        	listAB.Clear();
        	
        	
        	for(int i = 0; i < listA.Length; i++){
        	
        		for(int k = 0; k < listC.Length; k++){
        			
        			listAB.Add(listA[i] + listC[k]);
        		
        		
        		}
        	
        	}
        	
        	listAB.Sort();
			listAB.Reverse();
        	listB = listAB.ToArray();
        	
        	var cnt = 0;
        	
        	while(cnt < K){
        		Console.WriteLine(listB[cnt]);
        		cnt++;
        	}
        	
        	
        	
        
        
        }
            
    }
}



Measured memory_bytes: 62120
#include <iostream>
using namespace std;
//ITP2の9番台はPythonで実装したら負けだという気がしたのでc++で書きます。

int main(void){
  int n,m;
  cin>>n;
  long A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>m;
  long B[m];
  for(int i=0;i<m;i++){
    cin>>B[i];
  }
  int i=0;
  int j=0;
  while(i<n and j<m){
    if(A[i]<B[j]){
      cout<<A[i]<<endl;
      i++;
    }
    else if(A[i]>B[j]){
      j++;
    }
    else{
      i++;
      j++;
    }
  }
  for(int k=i;k<n;k++){
    cout<<A[k]<<endl;
  }
  return 0;
}



Measured memory_bytes: 6188