akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline
    
    H, W = [int(x) for x in input().split()]
    c = []
    for _ in range(10):
        c.append([int(x) for x in input().split()])
    A = []
    for _ in range(H):
        A.append([int(x) for x in input().split()])

    def warshall_floyd(d):
        for k in range(N):
            for i in range(N):
                for j in range(N):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d

    N = 10
    cost = warshall_floyd(c)
    ans = 0

    for i in A:
        for j in i:
            if j >= 0:
                ans += cost[j][1]

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40412
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 998244353;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

set<int> graph[100001];
vector<int> used(100001);
int aa, bb;
bool flag = false;

void dfs(int p) {
  stack<int> st;
  for(auto e: graph[p]) {
    if (e == bb) continue;
    if (e == aa) {
      flag = true;
      return;
    }
    st.push(e);
  }
  while(st.size()) {
    int k = st.top(); st.pop();
    graph[p].erase(k);
    graph[k].erase(p);
    dfs(k);
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; cin >> n >> m;
  vector<int> vec(n+1);
  rep(i, m) {
    int a, b; cin >> a >> b;
    vec[a]++;
    vec[b]++;
    graph[a].insert(b);
    graph[b].insert(a);
  }

  for(int i=1; i<=n; i++) {
    if (vec[i]&1) {
      cout << "No" << endl;
      return 0;
    }
  }

  vector<int> pp;
  int cnt = 0;
  for(int i=1; i<=n; i++) {
    if (vec[i] >= 6) {
      cout << "Yes" << endl;
      return 0;
    }
    if (vec[i] == 4) {
      cnt++;
      pp.push_back(i);
    }
  }

  if (cnt >= 3) {
    cout << "Yes" << endl;
    return 0;
  }

  if (cnt == 2) {
    aa = pp[0];
    bb = pp[1];
    dfs(aa);
    if (flag) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 34304
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;
const ll INF = 1000000000000000000;

const int ALPHABET = 26;

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

	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		ll num = n / i;


		ans += i * (num * (num + 1)) / 2;
	}

	cout << ans << endl;


}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
// vector<pair<uint, uint>> d;
ll d[100000];
 
int main(int, char**)
{
	unsigned int n;
	ll t = 0;
	cin >> n;
	// d.resize(n);
 
	for (unsigned int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		d[i] = - a - b;
		t += b;
	}
 
	sort(d, d+n);
 
	for (unsigned int i = 0; i < n; i+=2) {
        t += (ll)(d[i]);
	}
 
    cout << - t << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll H, W;
    cin >> H >> W;

    ll c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];

    rep(i, 10){
        //iを経由することを許したときの最小コスト
        rep(j,10) rep(k,10){
            c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
        }
    }

    ll ans = 0;
    rep(i,H*W){
        ll x;
        cin >> x;
        if(x != -1) ans += c[x][1];
    }

    print(ans);

    return 0;
}

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

int main() {
	int h1, h2, m1, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
    if (h2 < h1)
      h2 += 24;
	int ans = (h2 - h1) * 60 + (m2 - m1) - k;
	cout << ans << endl;
}

Measured memory_bytes: 3632
import numpy as np
from collections import Counter
N = int(input())
S = input()
length = len(S)
first = list()
res = 0
for n in range(length-2):
    if S[n] not in first:
        first.append(S[n])
    else:
        continue
    second = list()
    for m in range(n+1, length-1):
        if S[m] not in second:
            second.append(S[m])
        else:
            continue
        third = list()
        for k in range(m+1, length):
            if S[k] not in third:
                third.append(S[k])
            else:
                continue
            res += 1
print(res)


Measured memory_bytes: 12484
import sys
class Node:
    parent = -1
    left = -1
    right = -1

    def __init__(self, key):
        self.key = key

    def __repr__(self):
        return "k:{},p:{},l:{},r:{}".format(self.key, self.parent, self.left, self.right)

root_node_no = -1

def insert(nodes :dict, in_node :Node):
    global root_node_no

    cur_node_no = root_node_no
    parent_node_no = -1
    while cur_node_no != -1:
        parent_node_no = cur_node_no
        if in_node.key < cur_node_no:
            cur_node_no = nodes[cur_node_no].left
        else:
            cur_node_no = nodes[cur_node_no].right

    in_node.parent = parent_node_no

    if root_node_no == -1:
        root_node_no = in_node.key
    elif in_node.key < parent_node_no:
        nodes[parent_node_no].left = in_node.key
    else:
        nodes[parent_node_no].right = in_node.key

    nodes[in_node.key] = in_node

def inorder_tree_walk(nodes, node_no ,inorder):
    if node_no == -1:
        return
    inorder_tree_walk(nodes, nodes[node_no].left, inorder)
    inorder.append(node_no)
    inorder_tree_walk(nodes, nodes[node_no].right, inorder)

def preorder_tree_walk(nodes, node_no, preorder):
    if node_no == -1:
        return
    preorder.append(node_no)
    preorder_tree_walk(nodes, nodes[node_no].left, preorder)
    preorder_tree_walk(nodes, nodes[node_no].right, preorder)


def find(nodes, tgt_node_no):
    cur_node_no = root_node_no
    while cur_node_no != -1:
        cur_node = nodes[cur_node_no]
        if cur_node.key == tgt_node_no:
            return True
        elif tgt_node_no < cur_node.key:
            cur_node_no = cur_node.left
        else:
            cur_node_no = cur_node.right

    return False


def main():
    num_com = int(input())
    commands = sys.stdin.readlines()
    nodes = {}
    for i in range(num_com):
        if commands[i][0] == 'i':
            insert(nodes, Node(int(commands[i][7:])))
        elif commands[i][0] == 'p':
            # inorder
            inorder = []
            inorder_tree_walk(nodes, root_node_no, inorder)
            print(" " + " ".join(map(str, inorder)))
            # preorder
            preorder = []
            preorder_tree_walk(nodes, root_node_no, preorder)
            print(" " + " ".join(map(str, preorder)))
        elif commands[i][0] == 'f':
            if find(nodes, int(commands[i][5:])):
                print('yes')
            else:
                print('no')


main()



Measured memory_bytes: 230076
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
     int k=n/111;
    if(n%111==0)
      cout<<n;
    else 
      cout<<(k+1)*111;
}   
    
    
     

     
   





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

ll n;
std::vector<ll> ara(100010);
ll dp[100010];

ll fnc(ll i){
  if(i+1 == n)return 0;
  if(i == n)return 1<<30;
  if(dp[i] != -1)return dp[i];
  ll res1 = abs(ara[i]-ara[i+1]) + fnc(i+1);
  ll res2 = abs(ara[i]-ara[i+2]) + fnc(i+2);
  dp[i] = min(res1,res2);
  return min(res1,res2);
}

int main(int argc, char const *argv[]) {
  memset(dp,-1,sizeof(dp));
  cin >> n;
  for(ll i = 0;i<n;i++){
    cin >> ara[i];
  }
  cout << fnc(0) << endl;

  return 0;
}


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

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> a;
    for(int i=0;i<3*N;i++){
        int ai;
        cin >> ai;
        a.push_back(ai);
    }
    sort(a.rbegin(),a.rend());
    long long int ans=0;
    for(int i=0;i<2*N;i++){
        if (i%2==1) ans+=a[i];
        //cout << "added " << a[i] << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
N, MA, MB = gets.split.map(&:to_i)
a,b,c = N.times.map do
  gets.split.map(&:to_i)
end.transpose

INF = 10000
abmax = 10

dp = Array.new(N+1) do
  Array.new(N*abmax+1) do
    Array.new(N*abmax+1, INF)
  end
end
dp[0][0][0] = 0

N.times do |n|
  (N*abmax).times do |ca|
    (N*abmax).times do |cb|
      next if dp[n][ca][cb] == INF
      dp[n+1][ca][cb] = [dp[n+1][ca][cb], dp[n][ca][cb]].min
      dp[n+1][ca+a[n]][cb+b[n]] = [dp[n+1][ca+a[n]][cb+b[n]], dp[n][ca][cb] + c[n]].min
    end
  end
end

ans = INF
(1..(N*abmax)).each do |ca|
  (1..(N*abmax)).each do |cb|
    if MB*ca == MA*cb
      ans = [ans, dp[N][ca][cb]].min
    end
  end
end

ans = -1 if ans == INF
p ans


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

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long n;
	for (n = 1; n * n < N; n *= 2);
	if (n * n - N > N - (n-1) * (n-1)) {
		for (n /= 2; n * n < N; n++);
		for (; N % n != 0; n--);
	} else {
		for (; n * n > N; n--);
		for (; N % n != 0; n--);
	}	
	
	printf("%lld\n", n + N / n - 2);
	fflush(stdout);
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int nonxnum = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != 'x') nonxnum++;
    }

    bool isok = true;
    {
        int left = 0;
        int right = s.length()-1;
        while(left < right){
            while(s[left] == 'x') left++;
            while(s[right] == 'x') right--;
            if(left < right && s[left++] != s[right--]) isok = false;
        }
    }

    int ans = 0;
    if(isok){
        int left = 0;
        int right = s.length()-1;
        while(left < right){
            if(s[left] == s[right]){
                left++;
                right--;
            }else if(s[left] == 'x'){
                left++;
                ans++;
            }else{
                right--;
                ans++;
            }
        }
    }else{
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
int main()
{
  ll n,a,mul=1,i,flag=0;
  cin>>n;
  vector<ll> v(n);
  for(i=0;i<n;i++)
  {
    cin>>v[i];
    if(v[i]==0)
      flag=1;
  }
  if(flag==1)
  {
    cout<<0<<endl;
    return 0;
  }
  for(i=0;i<n;i++)
  {
    if(v[i]<=(1000000000000000000)/mul)
    {
      mul*=v[i];
    }
    else
    {
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<mul<<endl;
  return 0;
}
  

Measured memory_bytes: 4032
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int d, n;
    cin >> d >> n;
    
    auto base = pow(100, d);
    size_t minN = base * n;
    if (n == 100)
        minN += base;
    cout << minN;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

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

	string ans = "";

	while (n)
	{
		n--;
		ans += (char)('a' + (n % 26));
		n /= 26;
	}
	reverse(ans.begin(), ans.end());

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <deque>
using namespace std;int d[100005];int main(){int k;cin>>k;deque<int> q;for(int i=0;i<k;i++) d[i]=1e9;d[1]=1;q.push_front(1);while(!q.empty()){int l=q.front();q.pop_front();if(d[l*10%k]>d[l]){d[l*10%k]=d[l];q.push_front(l*10%k);}if(d[(l+1)%k]>d[l]+1){d[(l+1)%k]=d[l]+1;q.push_back((l+1)%k);}}cout<<d[0];}

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


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    string s;
    cin >> s;
    if(s.length() == 6)
    {
    if(s[2]==s[3] && s[4]==s[5])cout << "Yes";
    else
        cout << "No";
    }
    else 
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cmath>
#include <climits>
using namespace std;

class Node
{ 
    public:
    Node *l, *r, *p;
    int key;
    Node()
    {
        l = r = p = NULL;
    }
};
Node *root = NULL;

void insert(int key)
{
    Node **cur = &root, *node = new Node(), *p = NULL;
    node->key = key;
    while (NULL != *cur) {
        node->p = p;
        if (node->key < (*cur)->key) { 
            cur = &((*cur)->l);
        } else {
            cur = &((*cur)->r);
        }
        p = *cur;
    }
    *cur = node;
    return;
}

Node *find(int key)
{
    Node *cur = root;
    while (NULL != cur) {
        if (cur->key == key) break;
        if (key < cur->key) cur = cur->l;
        else cur = cur->r;
    }
    return cur;
}

Node *get_least(Node *r)
{
    if (r == NULL) return NULL;
    while (r->l) r = r->l;
    return r;
}

void inorder(Node *cur)
{
    if (cur == NULL) return;
    inorder(cur->l);
    cout << " " << cur->key;
    inorder(cur->r);
}

void preorder(Node *cur)
{
    if (cur == NULL) return;
    cout << " " << cur->key;
    preorder(cur->l);
    preorder(cur->r);
}

int main()
{
    int n, key;
    string command;
    cin >> n;
    while (n--) {
        cin >> command;
        if ("insert" == command) {
            cin >> key;
            insert(key);
        } else if ("find" == command) {
            cin >> key;
            cout << (find(key) ? "yes" : "no") << endl;
        } else if ("print" == command) {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else printf("ERROR: %d\n", __LINE__);
    }
    return 0;
}

Measured memory_bytes: 21808
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

ll N,Q,c,x,y;
vector<int> par,rnk;


int root(int x){
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
}

void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    else if(rnk[x] < rnk[y]) par[x] = y;
    else {
        par[y] = x;
        if(rnk[x]==rnk[y]) ++rnk[x];
    }
}

bool same(int x, int y){
    return root(x) == root(y);
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> Q;

    // init //
    par.resize(N,0);
    rnk.resize(N,0);
    REP(i,N) par[i] = i;
    // init //

    REP(i,Q){
        cin >> c >> x >> y;
        if(c==0){
            unite(x,y);
        } else {
            cout << (same(x,y) ? 1 : 0) << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3312
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
void lcs(string x,string y,int n,int m)
{
    int t[n+1][m+1];
    
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=m;++j)
        {
            if(i==0 || j==0)
            {
                t[i][j] = 0;
                continue;
            }
            if(x[i-1]==y[j-1])
            {
                t[i][j] = 1 + t[i-1][j-1];
                
            }
            else
            {
                t[i][j] = max(t[i-1][j],t[i][j-1]);
            }
        }
    }
    int idx = t[n][m];
    char v[idx+1];
    v[idx] = '\0';
    int i=n,j=m;
    while(i > 0 && j > 0)
    {
        if(x[i-1]==y[j-1])
        {
            v[idx-1] = x[i-1];
            i--;j--;idx--;
        }
        else if(t[i-1][j] > t[i][j-1])
            i--;
        else
            j--;
    }
    cout<<v;
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    lcs(s,t,n,m);

    return 0;

}


Measured memory_bytes: 38776
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(int(input()) for _ in range(n))

    for a in A:
        if a % 2 != 0:
            print("first")
            break
    else:
        print("second")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 7084
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#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 FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

LL gcd(LL A, LL B)
{
	while (1)
	{
		A = A % B;
		if (A == 0)
			return B;
		B = B % A;
		if (B == 0)
			return A;
	}
}

LL lcm(LL m, LL n)
{
	if ((0 == m) || (0 == n))
		return 0;
	return ((m / gcd(m, n)) * n);
}

int main() {
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	b++;
	LL ans = 0;
	ans += (b - 1) / c - (a - 1) / c;
	ans += (b - 1) / d - (a - 1) / d;
	LL x = lcm(c, d);
	ans -= (b - 1) / x - (a - 1) / x;
	cout << b-a-ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var input = Array.ConvertAll(ReadLine().Split(' '), ulong.Parse);
        var priceA = input[0];
        var priceB = input[1];
        var priceAB = input[2];
        var num1 = input[3];
        var num2 = input[4];
        var min = Math.Min(num1, num2);
        var maxPrice = min == num1 ? priceB : priceA;
        ulong result = 0;
        if (priceA + priceB >= 2 * priceAB) {
            if (maxPrice<=2*priceAB) result += 2 * priceAB * min;
            else { WriteLine(2 * priceAB * Math.Max(num1, num2));return; }
        }
        else { WriteLine(priceA * num1 + priceB * num2); return; }
        WriteLine((Math.Max(num1,num2) - min) * maxPrice+result);
    }
}


Measured memory_bytes: 11220
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {A: usize, B: usize, K: usize};
    if K <= A {
        println!("{} {}", A - K, B);
    } else if (K <= A + B) {
        println!("{} {}", 0, B - (K - A));
    } else {
        println!("{} {}", 0, 0)
    }
}


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

int main() {
  string str;
  cin >> str;
 
  int count = 0;
  int i;
  
  for (int i = 0; i < str.size(); i++) {
       count++;
     }

  for(i=0; i<count; i++){
    if(str.at(i)=='?'){
      str.at(i)='D';
    }
    else{ 
    }
  }
  
    cout << str << endl;

}


Measured memory_bytes: 3756
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	P = inputList()
	Q = inputList()

	PP = tuple(P)
	QQ = tuple(Q)

	nums = []
	for j in range(1,N+1):
		nums.append(j)

	p = itertools.permutations(nums, N)
	cont = 0
	tmpP = 0
	tmpQ = 0
	for v in p:
		cont += 1
		if v == PP:
			tmpP = cont
		if v == QQ:
			tmpQ = cont

	print(abs(tmpP-tmpQ))


if __name__ == "__main__":
	main()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
	//作るときはParentの値を全て-1にする
	//こうするとすべてバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}
	//AとBをくっつける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついているからくっつけない
			return false;
		}
		//大きい方(A)に小さいほう(B)をくっつけたい
		//大小が逆だったらひっくり返しちゃう
		if (size(A) < size(B)) swap(A, B);
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
	//AとBが同じグループにいるか
	bool same(int A, int B) { return root(A) == root(B); }
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> res(n);
	vector<vector<int>> block(n);
	UnionFind Uni(n);
	rep(i, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		Uni.connect(a, b);
		res[a]++; res[b]++;
	}
	rep(i, k) {
		int c, d; cin >> c >> d;
		c--; d--;
		block[c].emplace_back(d);
		block[d].emplace_back(c);
	}
	rep(i, n) {
		int ans = Uni.size(i) - 1 - res[i];
		for (auto& c : block[i]) if (Uni.same(i, c)) ans--;
		cout << ans << (i == n - 1 ? "\n" : " ");
	}

	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll D, G;
vector<ll> p(11, 0);
vector<ll> c(11, 0);
vector<ll> v;
vector<ll> dp(10010, 0);
 
int main(void){
	
	cin >> D >> G;
	for(int i = 0; i < D; ++i) cin >> p[i] >> c[i];
	
	ll sum = 0;
	for(int i = 0; i < D; ++i) sum += p[i], v.push_back(sum);
    
    dp[0] = 0;
    for(int i = 0; i < D; ++i){
        for(int j = v[i]; j >= 0; --j){
            for(int q = p[i]; q >= 0; --q){
                if(j >= q){
                    ll point = q * 100 * (i + 1) + (q == p[i] ? c[i] : 0);
                    dp[j] = max(dp[j], dp[j - q] + point);
                }
            }
        }
    }
    for(int i = 0; i <= v.back(); ++i) if(dp[i] >= G){ cout << i << endl; break; }
    
	return 0;
}

Measured memory_bytes: 384
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *H = map(int, read().split())
    H[0] -= 1
    for i in range(1, N):
        if H[i] < H[i - 1]:
            print('No')
            return
        if H[i] > H[i - 1]:
            H[i] -= 1

    print('Yes')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20412
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//�]���؂�グ�� =>  (a + b - 1) / b 

signed main(){
	char c; cin>>c;
  if(c=='A') cout<<'T';
  else if(c=='T') cout<<'A';
  else if(c=='G') cout<<'C';
  else cout<<'G';
	
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool dp[4][55][55][1111];
bool edge[4][55][55];

struct st{
  int d,y,x,t;
  st(){}
  st(int d,int y,int x,int t):d(d),y(y),x(x),t(t){}
};

signed main(){
  memset(edge,0,sizeof(edge));
  int n,x0,y0,T;
  cin>>n>>x0>>y0>>T;
  for(int i=0;i<n;i++){
    int xs,ys,xt,yt;
    cin>>xs>>ys>>xt>>yt;
    if(xs==xt){
      if(ys>yt) swap(ys,yt);
      for(int j=ys;j<yt;j++) edge[0][j][xs]=1;
      for(int j=yt;j>ys;j--) edge[2][j][xs]=1;
    }else{
      if(xs>xt) swap(xs,xt);
      for(int j=xs;j<xt;j++) edge[1][ys][j]=1;
      for(int j=xt;j>xs;j--) edge[3][ys][j]=1;
    }
  }
  
  int e;
  map<int,int> m;
  for(int i=0,tmp=0;i<T;i++){
    int d;char c;
    cin>>d>>c;
    tmp+=d;
    if(c=='N') m[tmp]=0;
    if(c=='E') m[tmp]=1;
    if(c=='S') m[tmp]=2;
    if(c=='W') m[tmp]=3;
    e=tmp;
  }
  
  int ay[]={1,0,-1,0};
  int ax[]={0,1,0,-1};

  typedef pair<int,int> P;
  vector<P> ans;

  memset(dp,0,sizeof(dp));
  queue<st> q;
  for(int k=0;k<4;k++){
    if(edge[k][y0][x0]){
      dp[k][y0][x0][0]=1;
      q.push(st(k,y0,x0,0));
    }
  }
  while(!q.empty()){
    st p=q.front();q.pop();
    int d=p.d,y=p.y,x=p.x,t=p.t;
    //cout<<d<<" "<<y<<" "<<x<<" "<<t<<endl;
    if(t>e+1) break;
    if(t==e+1){
      ans.push_back(P(x-ax[d],y-ay[d]));
      continue;
    }
    for(int k=0;k<4;k++){
      if(!edge[k][y][x]) continue;
      int nd=k,ny=y+ay[k],nx=x+ax[k],nt=t+1;
      if(nd==(d+2)%4) continue;
      //if(m.count(t)) cout<<":"<<nd<<" "<<ny<<" "<<nx<<" "<<nt<<endl;
      if(m.count(t)&&m[t]!=d&&m[t]!=nd) continue;
      if(dp[nd][ny][nx][nt]) continue;
      dp[nd][ny][nx][nt]=1;
      q.push(st(nd,ny,nx,nt));
    }
  }
  
  sort(ans.begin(),ans.end());
  ans.erase(unique(ans.begin(),ans.end()),ans.end());
  for(P p:ans) cout<<p.first<<" "<<p.second<<endl;
  return 0;
}

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

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;


int main(){
	ll N,K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	vector<ll> count(N+1,0);
	rep(i,N) count[A[i]]++;
	ll tmp=0;
	rep(i,N+1){
		if(count[i]>0) tmp++;
	}
	sort(all(count));
	ll ans=0;
	ll i=0;
	while(tmp>K){
		if(count[i]>0){
			ans+=count[i];
			tmp--;
		}
		i++;
	}
	printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#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 repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b == c) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)COUT(0);
		else COUT(-1);
		return 0;
	}
	int cnt = 0;
	while (true) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			cout << cnt << endl; return 0;
		}
		cnt++;
		int tmp = a / 2 + b / 2;
		int tmp2 = b / 2 + c / 2;
		int tmp3 = a / 2 + c / 2;
		a = tmp2; b = tmp3; c = tmp;
	}
	return 0;
}

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


int pp[2000][1000];

void ps(int x, int y, int k){
  if (x < k){
    pp[x][y] += 1;
    pp[x+k][y] += -1;
    if (y == 0) return;
    pp[0][0] += 1;
    pp[0][y] += -1;
    pp[x][0] += -1;
    pp[x][y] += 1;
    pp[x+k][0] += 1;
    pp[x+k][y] += -1;
  }
  else {
    pp[x][y] += 1;
    pp[0][y] += 1;
    pp[x-k][y] += -1;
    if (y == 0) return;
    pp[x-k][0] += 1;
    pp[x-k][y] += -1;
    pp[x][0] += -1;
    pp[x][y] += 1;
  }
}

int main(){
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < 2 * k; i++){
    for (int j = 0; j < k; j++){
      pp[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++){
    int x, y; char s[1];
    scanf("%d %d %c", &x, &y, s);
     x = x % (2*k);
     y = y % (2*k);
    if ((s[0] - 'B') != 0){
      y = (y + k) % (2*k);
    }
    if (y >= k) {
      y = y - k;
      x = (x + k) % (2 * k);
    }
    ps(x, y, k);
  }

  for (int i = 0; i < 2*k; i++){
    for (int j = 1; j < k; j++){
      pp[i][j] += pp[i][j-1];
    }
  }


  for (int i = 1; i < 2*k; i++){
    for (int j = 0; j < k; j++){
      pp[i][j] += pp[i-1][j];
    }
  }

  int m = 0;
  for (int i = 0; i < 2*k; i++){
    for (int j = 0; j < k; j++){
      m = max(m, pp[i][j]);
      //printf("%d\t", pp[i][j]);
    }
    //printf("\n");
  }

  printf("%d\n", m);
  return 0;

}

Measured memory_bytes: 8064
#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, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& i : a) cin >> i, --i;
    vector<int> s(n + 1, 0);
    for (int i = 1; i <= n; ++i) (s[i] += s[i - 1] + a[i - 1]) %= k;
    map<int, int> m;
    ll r = 0;
    for (int i = 1; i < min(k, n + 1); ++i) ++m[s[i]];
    for (int i = 0; i <= n; ++i) {
        r += m[s[i]];
        if (i + k <= n) ++m[s[i + k]];
        if (i + 1 <= n) --m[s[i + 1]];
    }
    cout << r << endl;
    for (int i : s) cerr << i << " ";
    cerr << endl;
}

Measured memory_bytes: 14324
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;

while(n!=0 && m!=0){
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
long max=0; //最大値
long bg[2]={0,0}; //結果格納配列
for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
        long sum=a[i]+a[j];
        if(sum>max && sum<=m){
            max=sum;
            bg[0]=a[i];
            bg[1]=a[j];
        }
    }
}
if(bg[0]==0 && bg[1]==0){
    cout<<"NONE"<<endl;
}
else{
    cout<<bg[0]+bg[1]<<endl;
}
cin>>n>>m;

}

return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int ceil(int a, int b) {
    if(a%b == 0) {
        return a/b;
    }
    else {
        return a/b + 1;
    }
}

int main() {
    int n, h, ans = 0;
    cin >> n >> h;
    int a[n], b[n];
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(a, a+n);
    sort(b, b+n);
    reverse(a, a+n);
    reverse(b, b+n);

    rep(i, n) {
        if(h <= 0) {
            cout << ans << endl;
            return 0;
        }

        if(b[i] <= a[0]) {
            break;
        }

        h -= b[i];
        ans++;
    }

    if(h > 0) {
        ans += ceil(h, a[0]);
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int r = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == '0') r++;
    }

    ans = min(r, (int)s.size() - r) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(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 REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,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);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl



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

	ll N,M;
	cin >> N >> M;
	ll dp[N+1]={},csize[N+1]={};
	vector<ll> ch[N+1],go[N+1];

	FOR(i,0,M){
		ll x,y;
		cin >> x >> y;
		ch[y].push_back(x);
		go[x].push_back(y);
		csize[y]++;
	}

	queue<ll> v;
	FOR(i,1,N+1){
		if(csize[i]==0)v.push(i);
	}
	while(not v.empty()){
		ll nowv = v.front();
		v.pop();
		for(auto z:go[nowv]){
			dp[z] = max(dp[z],dp[nowv]+1);
			csize[z]--;
			if(csize[z]==0)v.push(z);
		}
	}
	ll ans = 0;
	FOR(i,1,N+1){
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long mod = 1e9 + 7;

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	vector<int> broken(n + 1);
	int a;
	for (int i = 0; i < m; ++i) {
		cin >> a;
		broken[a] = 1;
	}

	vector<int> dp(n + 1);
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (broken[i] != 1) {
			dp[i] += dp[i - 1];
			if (i > 1) {
				dp[i] += dp[i - 2];
			}
		}

		dp[i] %= mod;
	} 

	cout << dp[n] << "\n";

	return 0;

}

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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long N;
int T = 1;
deque<int> L, R;

void f(long long x) {
  if (x == 0) return;
  else if (x % 2 == 0) {
    f(x-1);
    int t = T++;
    L.push_back(t);
    R.push_front(t);
  }
  else {
    f(x/2);
    int t = T++;
    L.push_back(t);
    R.push_back(t);
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  f(N);
  int l = L.size() + R.size();
  if (l > 200) return 1;
  cout << l << "\n";
  for (int x : L) cout << x << " ";
  for (int x : R) cout << x << " "; cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a;
  int sum = 0;
  for(int i = 0; i< 5; i++){
    cin >> a;
    if(a < 40) sum += 40;
    else sum += a;
  }
  sum  = sum/5;
  cout << sum<< endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main() {
  
  int N , M ;
  cin >> N >> M ;
  vector<int> A(M);
  vector<int> B(M);
  rep(i,M) cin >> A.at(i) >> B.at(i) ;
  int L = 0 ;
  int R = 100010 ; 
  rep(i,M){
    if ( L <= A.at(i) ) L = A.at(i) ;
    if ( R >= B.at(i) ) R = B.at(i) ;
  }
  if( R - L < 0 ) cout << 0 << endl;
  else cout <<  R - L + 1 << endl ;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(ll int a, ll int b) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int gcd(int a,int b)
{
    if(a<b)
        swap(a,b);
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
	
	int n;
	cin>>n;
	int a[n+1];
	for(int i=0;i<n;i++)cin>>a[i+1];
	vector<int>vec;
	int b[n+1];
	b[0]=0;
	for(int i=0;i<n;i++)b[i+1]=0;
	for(int i=n;i>0;i--){
		b[i]=a[i];
		for(int j=i*2;j<=n;j+=i){
			b[i]=(b[i]+b[j])%2;
		}
	}
	for(int i=0;i<n;i++)if(b[i+1])vec.pb(i+1);
	cout<<vec.size()<<"\n";
	for(int i:vec)cout<<i<<" ";

}










Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define PYES cout<<"Yay!"<<endl
#define PNO cout<<":("<<endl
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K;
	scan(N>>K);
	if(K!=1) prin(N-(K-1)-1);
	else prin(0);
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds


def tree_init(N):
    edgelist = [[] for _ in range(N)]
    for a, b in [map(int, input().split()) for i in range(N-1)]:#木じゃない場合N-1をNに変える
        edgelist[a-1].append(b-1)#ノードの番号が0から始まる場合-1を消す
        edgelist[b-1].append(a-1)
    return edgelist

def root(x,par):
    px=par[x]
    while px!=x:
        x=px
        px=par[x]
    return px
def union(x,y,par):
    rx,ry=root(x,par),root(y,par)
    if rx!=ry:
        par[ry]=rx 


def main():
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N,M,K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    par=[i for i in range(N)]
    fl=[[] for _ in range(N)]
    counts=[0]*N
    for _ in range(M):
        a, b= map(int,input().split())
        counts[a-1]-=1
        counts[b-1]-=1
        fl[a-1].append(b-1)
        fl[b-1].append(a-1)

    visited=[False]*N
    roots=[0]*N
    pcount=[0]*N
    for i in range(N):
        if visited[i]:
            continue
        q=deque([i])
        while len(q):
            
            e=q.pop()
            if visited[e]:
                continue
            #print(e)
            roots[e]=i
            pcount[i]+=1
            visited[e]=True
            for ne in fl[e]:
                if visited[ne]:
                    continue
                q.append(ne)
    #print(pcount)

    for i in range(N):
        counts[i]+=pcount[roots[i]]-1

    for _ in range(K):
        a, b= map(int,input().split())
        if roots[a-1]==roots[b-1]:
            counts[a-1]-=1
            counts[b-1]-=1

    print(*counts)
    



if __name__ == "__main__":
    main()

Measured memory_bytes: 71056
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &t : a) {
    	cin >> t;
    }
    sort(a.begin(), a.end());
    n -= k;
    int ans = 0;
    for (int i = 0; i < n; i++) {
    	ans += a[i];
    }
    cout << ans << endl;
}   


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
a = list(map(int,input().split()))

n = a[0]
k = a[1]
p = list(map(int,input().split()))

e = [(pi+1)/2 for pi in p]

ret2 = []
b = 0.0
for j in range(k):
        b += e[j]
ret2.append(b)

for i in range(n-k):
        ret2.append(ret2[i] - e[i] + e[i+k])

ret=ret2

ret.sort()
print(ret[n-k])


Measured memory_bytes: 25060