akhauriyash/Code-Regression huggingface dataset:
import sys
from itertools import accumulate
from collections import Counter
from bisect import bisect as br, bisect_left as bl
from operator import itemgetter
class DammyMap:
    #1-indexed
    def __init__(self, A, B):
        #Aに初期状態の要素をすべて入れる,Bは値域のリスト
        self.X, self.comp = self.compress(B)
        self.size = len(self.X)
        self.tree = [0] * (self.size + 1)
        self.p = 2**(self.size.bit_length() - 1)
        self.dep = self.size.bit_length()
        
        CA = Counter(A)
        S = [0] + list(accumulate([CA[self.X[i]] for i in range(self.size)]))
        for i in range(1, 1+self.size):
            self.tree[i] = S[i] - S[i - (i&-i)]
        
    def compress(self, L):
        #座圧
        L2 = list(set(L))
        L2.sort()
        C = {v : k for k, v in enumerate(L2, 1)}
        # 1-indexed
        return L2, C
    
    def leng(self):
        #今入っている個数を取得
        return self.count(self.size)
    
    def count(self, i):
        #i(Bの元)以下の個数を取得
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    
    def less(self, v):
        #v(Bの元である必要はない)未満の個数を取得
        i = bl(self.X, v)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    
    def leq(self, v):
        #v(Bの元である必要はない)以下の個数を取得
        i = br(self.X, v)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        #iをx個入れる,負のxで取り出す,iの個数以上取り出すとエラーを出さずにバグる
        i = self.comp[i]
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        
        
    def get(self, v):
        # v番目の値を取得
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s]
            k //= 2
        return self.X[s]

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C

N, Q = map(int, input().split())
stx = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N)]
stx.sort(key = itemgetter(2))
D = [int(sys.stdin.readline()) for _ in range(Q)] 
_, comp = compress(D)

T = DammyMap(D, D)

ans = [-1]*Q

for s, t, x in stx:
    tl = T.less(s - x)
    tr = T.less(t - x)
    d = tr - tl
    for _ in range(d):
        i = T.get(tl + 1)
        T.add(i, -1)
        ans[comp[i]] = x
print(*ans, sep = '\n')

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

int main()
{
    unsigned long long n;
    cin>>n;
    vector<int> p;
    while(n>0)
    {
        n--;
        p.push_back((n+1)%26);
        n /= 26;
    }
    reverse(p.begin(), p.end());
    for(int y:p)
        cout<< char((y?y:26)-1+'a');
    cout<<'\n';
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    string s;cin>>s;
    ll n=s.size();
    vector<string>dp(26);
    rep(i,26){
        dp[i]=(char)('a'+i);
    }
    for(int i=n-1;i>=0;i--){
        string a=s;
        rep(j,26){
            if(dp[j].size()<a.size()){
                a=dp[j];
            }
        }
        dp[s[i]-'a']=s[i]+a;
    }
    string a=s;
    rep(i,26){
        if(dp[i].size()<a.size()){
            a=dp[i];
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 4376
s = input()
t = input()

ls,lt = len(s),len(t)
dp = [[0]*(lt+1) for _ in [0]*(ls+1)]

for i,cs in enumerate(s,1):
    for j,ct in enumerate(t,1):
        if cs==ct:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])

i = ls
j = lt
ans = ""
while i>0 and j>0:
    if s[i-1] == t[j-1]:
        ans += s[i-1]
        i -= 1
        j -= 1
    else:
        if dp[i-1][j] > dp[i][j-1]:
            i -=1
        else:
            j -=1
print(ans[::-1])

Measured memory_bytes: 112476
#include <bits/stdc++.h>
#pragma GCC_compile("Ofast")
#define INF 1e9+5
using namespace std;

int main(){
    int N,K,MIN;

    cin>>N>>K;    

    vector<int>h(N);
    vector<int>dp(N);


    for(int& x:h){
        cin>>x;
    }
 
    dp[0]=0;
    for(int i=1;i<N;i++){
        MIN=INF;
        for(int j=1;j<=min(i,K);j++){
            MIN=min(MIN,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i]=MIN;
    }

   cout<<dp[N-1]<<endl;

   return 0;
}

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

int main()
{
	int a, b;
	int cnt[200] = {};
	while (~scanf("%d %d", &a, &b)){
		if (!a && !b){
			int odd = 0;
			for (int i = 0; i < 200; i++){
				odd += cnt[i] & 1;
			}
			if (!odd) puts("NG");
			else if (odd != 2) puts("NG");
			else {
				if (cnt[0] & cnt[1] & 1) puts("OK");
				else puts("NG");
			}
			memset(cnt, 0, sizeof(cnt));
		}
		else {
			cnt[--a]++;
			cnt[--b]++;
		}
	}
	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
using namespace std;
#define EMPTY -1
const int N = 100005;

struct Node{
    int parent, leftChild, rightBrother;
};
Node node[N];
int depth[N];

void getDepth(int nowId, int nowDepth){//递归求深度
    depth[nowId] = nowDepth;
    if(node[nowId].leftChild!=EMPTY){
        getDepth(node[nowId].leftChild, nowDepth+1);//左子节点深度+1
    }
    if(node[nowId].rightBrother!=EMPTY){
        getDepth(node[nowId].rightBrother, nowDepth);//右兄弟节点深度设为相同
    }
}

void printNode(int id){
    int next;
    cout<<"node "<<id<<": "
        <<"parent = "<<node[id].parent<<", "
        <<"depth = "<<depth[id]<<", ";
        if(node[id].parent==EMPTY){
            cout<<"root, ";
        }else if(node[id].leftChild!=EMPTY){
            cout<<"internal node, ";
        }else{
            cout<<"leaf, ";
        }
        next=node[id].leftChild;
        bool first = true;
        cout<<"[";
        while(next!=EMPTY){
            if(first){
                first = false;
            }else{
                cout<<", ";
            }
            cout<<next;
            next=node[next].rightBrother;//节点位置后移
        }
        cout<<"]"<<endl;
}

int main(){
    int n;
    cin>>n;
    for(int i=0; i<n; i++){//初始化
        node[i].parent = node[i].leftChild = node[i].rightBrother=EMPTY;
    }
    for(int i=0;i<n;i++){//创建树
        int flag, id;
        cin>>id>>flag;
        for(int j=0, nowId;j<flag;j++){
            if(j==0){//指定当前节点的左子节点
                cin>>nowId;
                node[id].leftChild = nowId;//指定父节点的左子节点
            }else{
                int temp;
                cin>>temp;
                node[nowId].rightBrother = temp;//指定当前节点的右兄弟节点
                nowId=temp;//当前节点索引后移
            }
            node[nowId].parent = id;//指定父节点
        }
    }
    int root;
    for(int i = 0;i<n;i++){//寻找根节点
        if(node[i].parent==EMPTY){
            root = i;
        }
    }
    getDepth(root, 0);//根节点深度为0
    for(int i=0;i<n;i++){
        printNode(i);
    }
    return 0;
}



Measured memory_bytes: 4652
using System;
using System.Linq;
class E { static void Main() => new K(); }
class K
{
	int F => int.Parse(Console.ReadLine());
	int[] G => Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();
	public K()
	{
		int N = F, c = 0;
		var A = G;
		for (var i = 0; i < N; i++) if (i == A[A[i] - 1] - 1) c++;
		Console.WriteLine(c / 2);
	}
}

Measured memory_bytes: 10968
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <random>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;
int gcd (int a, int b) {
    if (a < b) { swap(a, b); }
    while (b > 0) {
        a = a % b;
        swap(a, b);
    }
    return a;
}

int main () {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    int N, X;
    cin >> N >> X;
    cin >> t;
    int g = X-t;
    for (int i = 0; i < N-1; ++i) {
        
        cin >> t;
        g = gcd(abs(X-t), g);
    }
    
    cout << abs(g) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int a,li[10]={};

int main(){
	REP(i,0,3) cin >> a,li[a]++;
	
	cout << (li[5]==2&&li[7]==1?"YES":"NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    stack<char> S;
    for (int i = 0; i < n; i++) {
        char ch; cin >> ch;
        if (S.empty()) {
            S.push(ch);
            continue;
        }
        while (!S.empty() && S.top() == ch) {
            S.pop();
        }
        S.push(ch);
    }
    cout << SZ(S) << "\n";
}


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

int main() {
  string S;
  cin >> S;
  
  int alpha[26];
  for(int i = 0; i < 26; i++) {
    alpha[i] = 0;
  }
  
  for(int i=0; i < S.size(); i++) {
    ++alpha[S[i] - 'a'];
  }
  
  for(int i = 0; i < 26; i++) {
    if(alpha[i] == 0) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  
  cout << "None" << endl;
  
  return 0;
}

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

d_lst = list(map(int, input().split()))

total = 0
for i in range(N):
  d = d_lst[:i] + d_lst[i+1:] # iを除いたリスト
  total += sum(d_lst[i] * d for d in d_lst[:i] + d_lst[i+1:])
print(total//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct poll {
    int p, q, r, b;
};

int gcd(int x, int y) {
    return (y == 0) ? x : gcd(y, x % y); 
}

int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}

int solve(const vector<poll>& polls, int i) {
    if (i == -1) return 1;

    int r_w = solve(polls, polls[i].r);
    int b_w = solve(polls, polls[i].b);

    int l = lcm(polls[i].p * r_w, polls[i].q * b_w);

    return l / polls[i].p + l / polls[i].q;
}

int main() {
    int n;
    
    while (cin >> n, n) {
        vector<poll> polls(n);
        vector<bool> child(n, false);

        int s = -1;
        REP(i, n) {
            int p, q, r, b; cin >> p >> q >> r >> b;
            --r; --b;
            polls[i] = {p, q, r, b};

            if (r != -1 && b != -1) s = i;
            if (r != -1) child[r] = true;
            if (b != -1) child[b] = true;
        }

        cout << solve(polls, find(child.begin(), child.end(), false) - child.begin()) << endl;
    }

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>           // sorted map so O(logn)
#include <unordered_map> // O(1)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        a[x - 1] = i + 1;
    }
    for (int i = 0; i < n; ++i)
    {
        cout << a[i] << " ";
    }
}


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

int main() {
  
  string n;
  cin >> n;
  
  if (n[0] == '7' || n[1] == '7' || n[2] == '7') {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
  
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
         
        using namespace std;
         
        #define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
        #define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
        #define pb			push_back
        #define mp			make_pair
        #define	all(c)			(c).begin(),(c).end()
        #define	present(c,x)		((c).find(x) != (c).end())
        #define	cpresent(c,x)		(find(all(c),x) != (c).end())
        #define	endl			'\n'
         
        typedef long long		ll;
        typedef unsigned long long	ull;
        typedef unsigned char	 	byte;
        typedef vector<int>		vi;
        typedef pair<int, int>		pii;
        typedef pair<ll, ll>		pll;
        typedef vector<pii>		vpii;
         
        const int MX = 25;
         
        int main(int argc, char *argv[])
        {
        #ifdef	HTRINH_UNIT_TEST
        	freopen(argv[1],"r",stdin);
        	ifstream cin(argv[1]);
        #endif
        #if 0
        	ofstream cout(argv[2]);
        #endif
        	ios :: sync_with_stdio(false);
        	cin.tie(NULL);
         
        	int x,y;
        	cin >> x >> y;
        	if (x == y) {
        		cout << 0 << endl;
        	} else if (x < y) {
        		if (x >= 0 || y <= 0) cout << y-x << endl;
        		else {
        			if (abs(x) > abs(y)) cout << 1+abs(x)-abs(y) << endl;
        			else cout << 1+abs(y)-abs(x) << endl;
        		}
        	} else { // x > y
                        if (y == 0) cout << 1+x << endl;
                        else if (y > 0) cout << 2+x-y << endl;
        		else {
        			if (x == 0) cout << 1+abs(y) << endl;
        			else if (x > 0) {
        				if (abs(x) >= abs(y)) cout << 1+abs(x)-abs(y) << endl;
        				else cout << 1+abs(y)-abs(x) << endl;
        			} else {
        				cout << 2+abs(y)-abs(x) << endl;
        			}
        		}
        	}
        	return 0;
        }

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

n,m=map(int,input().split())
pair=[i for i in range(n)]
a=[0]*m
b=[0]*m
for i in range(m):
    ai,bi=map(int,input().split())
    a[i]=ai-1
    b[i]=bi-1
    
def root(x):
    if x==pair[x]:
        return x
    else:
        tmp=root(pair[x])
        pair[x]=tmp
        return tmp

def unite(x,y):
    x=root(x)
    y=root(y)
    if x==y:return
    pair[x]=y

icnt=0
for i in range(m):
    pair=[i for i in range(n)]
    for ii in range(m):
        if ii==i:
            continue
        unite(a[ii],b[ii])

    l=[root(ii) for ii in range(n)]
#    print(i,l)
    lenpair=len(set(l))    
    if lenpair!=1:
        icnt+=1

print(icnt)

Measured memory_bytes: 9268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a[5];
int main(){
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	printf("%d\n",a[2] - a[0]);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  string s;
  int k;
  cin >> s >> k;

  int l = s.size();
  vvt<vt<i64>> dp(l + 1, vvt<i64>(2, vt<i64>(k + 2, 0)));
  dp[0][0][0] = 1;

  rep(i, 0, l) {
    int d = s[i] - '0';
    rep(smaller, 0, 2) {
      rep(j, 0, k + 1) {
        rep(m, 0, (smaller ? 9 : d) + 1) {
          dp[i + 1][smaller || m < d][j + (m != 0)] += dp[i][smaller][j];
        }
      }
    }
  }
  cout << dp[l][0][k] + dp[l][1][k] << endl;
}

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

int main(void) {
	int n,a,max = INT_MIN,min = INT_MAX;
	long sum = 0;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >>a;
		sum += a;

		if (max < a)
		{
			max = a;
		}

		if (min > a)
		{
			min = a;
		}
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3096
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toInt()
        val B = sc.next().toInt()
        val C = sc.next().toInt()
        var K = sc.next().toInt()
        var ans = 0
        if (K > 0) {
            val d = arrayOf(A, K).min()!!
            ans += d
            K -= d
        }
        if (K > 0) {
            val d = arrayOf(B, K).min()!!
            K -= d
        }
        if (K > 0) {
            val d = arrayOf(C, K).min()!!
            ans -= d
            K -= d
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 38308
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

int main() {
	int n;
	cin >> n;
	
	int min = 200000;
	int ans = 0;
	for (int i = 0; i < n;i++) {
		int p;
		cin >> p;
		if (min >= p) {
			ans++;
			min = p;
		}

	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
	int K;
	int A,B;
	cin>>K;
	cin>>A>>B;
	if(K==1)
	cout<<"OK"<<endl;
	else{
		if(A/K!=B/K||A%K==0||B%K==0)
		cout<<"OK"<<endl;
	    else  
	    cout<<"NG"<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	
	string s="yuiophjklnm";
	
	while(1){
		
		string a;
		
		cin >> a;
		
		if(a=="#") break;
		
		bool left=true;
		for(int i=0;s[i];i++){
			if(s[i]==a[0]){
				left=false;
			}
		}
		int cnt=0;
		
		for(int i=1;a[i];i++){
			bool be=left;
			for(int j=0;s[j];j++){
				left=true;
				if(s[j]==a[i]){
					left=false;
					break;
				}
			}
			if(be!=left){
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll dp[10005][2][100];
ll d;
string k;
ll func(ll n,ll tight,ll rem)
{
    if(n==k.length())
    {
        if(rem==0)
            return 1;
        return 0;
    }
    ll &ret = dp[n][tight][rem];
    if(ret!=-1)
        return ret;
    ll mi = 9;
    if(tight)
        mi = k[n]-'0';
    ll i;
    ret = 0;
    for(i=0;i<=mi;i++)
    {
        ll ntight = tight&(i==(k[n]-'0'));
        ret = (ret + func(n+1,ntight,(rem+i)%d))%mod;
    }
    return ret;
}
signed main()
{
    fast;
    cin>>k>>d;
    mem(dp,-1);
    cout<<(func(0,1,0)+mod-1)%mod;
}

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

const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }

    rep(i,60){
        ll count = 0;
        rep(j,n){
            if(a[j]>>i&1){
                count++;
            }
        }
        ll tmp = count * (n - count) % mod;
        rep(j,i){
            tmp = tmp * 2 % mod;
        }
        ans = (ans + tmp) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;

    if(n >= 1 + 2*(k-1)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = (a); i <= (b); i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 100005, mod = 998244353, SQ = (1 << 9);
int n, m, inv2, f[MX];
ll a[3][SQ], res;
vi adj[MX];

ll pot (ll b, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

void dfs (int u) {
	if (f[u] != -1) return;

	set<int> st;
	for (int v : adj[u])
		if (v > u) {
			dfs(v);
			st.insert(f[v]);
		}

	for (int i = 0;; i++)
		if (!st.count(i)) {
			f[u] = i;
			break;
		}
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	inv2 = pot(2, mod - 2);

	cin >> n;
	forn (i, 3) {
		for (int j = 1; j <= n; j++)
			adj[j].clear();

		cin >> m;
		while (m--) {
			int a, b;
			cin >> a >> b;
			adj[a].pb(b);
			adj[b].pb(a);
		}

		memset(f, -1, sizeof(f));
		for (int j = 1; j<= n; j++) {
			dfs(j);
			(a[i][f[j]] += pot(10, 18 * j)) %= mod;
		}
	}

	for (int i = 0; i < SQ; i++)
		for (int j = 0; j < SQ; j++)
			(res += a[0][i] * a[1][j] % mod * a[2][i ^ j]) %= mod;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    ll h,w,k;cin>>h>>w>>k;
    string s[h];
    bool bol[h];rep(i,0,h-1)bol[i]=false;
    rep(i,0,h-1){
        cin>>s[i];
        rep(j,0,w-1){
            if(s[i][j]=='#')bol[i]=true;
        }
    }
    ll ans[h][w];
    bool first=true;
    ll now=1;
    rep(i,0,h-1){
        if(!bol[i] && first){
            continue;
        }else if(!bol[i]){
            rep(j,0,w-1){
                ans[i][j]=ans[i-1][j];
            }
        }else if(bol[i]){
            bool fir=true;
            rep(j,0,w-1){
                if(s[i][j]=='.' && fir){
                    continue;
                }else if(s[i][j]=='.'){
                    ans[i][j]=ans[i][j-1];
                }else if(s[i][j]=='#'){
                    ans[i][j]=now;
                    if(fir){
                        fir=false;
                        rep(k,0,j){
                            ans[i][k]=now;
                        }
                    }
                    now++;
                }
            }
            if(first){
                first=false;
                rep(j,0,i){
                    rep(k,0,w-1){
                        ans[j][k]=ans[i][k];
                    }
                }
            }
        }
    }
    rep(i,0,h-1){
        rep(j,0,w-1){
            cout<<ans[i][j];
            if(j<w-1){
                cout<<' ';
            }else{
                cout<<endl;
            }
        }
    }
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 1664
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		int[] a = new int[m];
		long sum=0;
		for (i = 0; i < m; i++) {
			a[i] = parseInt(sc.next());
			sum+=a[i];
		}
		sc.close();
		long dif = n -sum;
		out.println(dif<0?-1:dif);
	}
}


Measured memory_bytes: 35396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define MOD 1000000007
#define ll long long
#define MAX 10001

int cmpfunc(const void *a, const void *b){
    return (*(int*)a - *(int*)b);
}

int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    int c[8];
    for(i=0;i<8;i++) c[i]=0;
    int freec=0;
    for(i=0;i<n;i++){
        if(a[i]<=399) c[0]++;
        else if(a[i]<=799) c[1]++;
        else if(a[i]<=1199) c[2]++;
        else if(a[i]<=1599) c[3]++;
        else if(a[i]<=1999) c[4]++;
        else if(a[i]<=2399) c[5]++;
        else if(a[i]<=2799) c[6]++;
        else if(a[i]<=3199) c[7]++;
        else freec++;
    }
    int min=0,max=0;
    for(i=0;i<8;i++){
        if(c[i]!=0) break;
    }
    if(i==8){
        printf("1 %d\n",freec);
        return 0;
    }
    for(i=0;i<8;i++){
        if(c[i]!=0){
            min++;
            max++;
        }
    }
    max=max+freec;
    printf("%d %d\n",min,max);
    return 0;
}


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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); cout.tie(NULL);

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

  vector < int > x(n); 
	vector < array < int, 3 > > edges(m);
  vector < vector < pair < int, int > > > g(n);

  for(int i = 0; i < n; ++i) {
    cin >> x[i];
  }

  for(int i = 0; i < m; ++i) {
    cin >> edges[i][1] >> edges[i][2] >> edges[i][0];
    --edges[i][1]; --edges[i][2];
    g[edges[i][1]].emplace_back(edges[i][2], edges[i][0]);
    g[edges[i][2]].emplace_back(edges[i][1], edges[i][0]);
  }

  sort(edges.begin(), edges.end());

  vector < int > lab(n, -1);
  vector < long long > sum(n);
  vector < vector < int > > comp(n);
  vector < vector < pair < int, long long > > > sumRoot(n), getRoot(n);

  for(int i = 0; i < n; ++i) {
    sum[i] = x[i];
    comp[i].push_back(i);
    sumRoot[i].emplace_back(0, x[i]);
    getRoot[i].emplace_back(0, i);
  }


  function < int(int) > find = [&](int x) {
    if(lab[x] < 0) return x;
    return lab[x] = find(lab[x]);
  };

  function < bool(int, int, int) > join = [&](int x, int y, int w) {
    if((x = find(x)) == (y = find(y))) return false;
    if(comp[x].size() < comp[y].size()) swap(x, y);
    sum[x] += sum[y];
    sumRoot[x].emplace_back(w, sum[x]);
    for(int &v : comp[y]) {

      comp[x].push_back(v);
      lab[v] = x;
      getRoot[v].emplace_back(w, x);
    }
    return true;
  };

  for(auto &p : edges) {
    join(p[1], p[2], p[0]);
  }

  function < long long(int, int) > getWeightRoot = [&](int v, int w) {
   // cout << v << " : " << w << endl;  //  for(auto p : sumRoot[v]) cout << p.first << " " << p.second << endl;
    auto it = upper_bound(sumRoot[v].begin(), sumRoot[v].end(), make_pair(w, (long long)1e18));
    it--;
    return it -> second;
  };

  function < long long(int, int) > getWeightVertice = [&](int v, int w) {
    auto it = upper_bound(getRoot[v].begin(), getRoot[v].end(), make_pair(w, n + 1LL));
    it--;
    return getWeightRoot(it -> second, w);
  };

  vector < bool > visited(n, false);
  map < pair < int, int >, bool > marked;

  function < void(int, int) > dfs = [&](int v, int w) {
    visited[v] = 1;
    for(auto e : g[v]) {
      if(e.second > w) continue;
      marked[make_pair(v, e.first)] = 1;
      if(visited[e.first]) continue;
      dfs(e.first, w);
    }
    return;
  };

  for(int i = edges.size() - 1; i >= 0; --i) {
    auto p = edges[i];
    if(marked[make_pair(p[1], p[2])]) {
      --m;
      continue;
    }

    if(getWeightVertice(p[1], p[0]) >= p[0]) {
      --m;
      dfs(p[1], p[0]);
    }
  }

  cout << m;

  return 0;
}

Measured memory_bytes: 54896
#include <iostream>
#include <string>
using namespace std;
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for(int (I)=(A);(I)<(B);++(I))
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) cin>>(P);
#define INPUT2(P1,P2) cin>>(P1)>>(P2);
#define INPUT3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3);
#define INPUTS(I,A,B,V) FOR(I,A,B)cin>>V[I];
#define OUTPUT(P) cout<<P<<endl;
#define OUTPUTS(I,A,B,V) FOR(I,A,B)cout<<V[i]<<endl;
typedef long long ll;
const double INF = 1e9;
inline void solve()
{
  int n;
  cin>>n;
  string string_n = to_string(n);
  replace(ALL(string_n), '1', 'X');
  replace(ALL(string_n), '9', '1');
  replace(ALL(string_n), 'X', '9');
  cout<<string_n<<endl;
}
int main(int argc,char**argv)
{
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<(f?YES:NO)<<"\n";

void solve_old(std::string S){
    bool f=true;
    if(S != string(rbegin(S), rend(S))){
        f=false;
        judge(f);
        return;
    }
    string s1=string(begin(S), begin(S)+(S.size()-1)/2);
    // debg(s1);
    if(s1 != string(rbegin(s1), rend(s1))){
        f=false;
        judge(f);
        return;
    }
    string s2=string(begin(S)+(S.size()+3)/2-1, end(S));
    // debg(s2);
    if(s2 != string(rbegin(s2), rend(s2))){
        f=false;
        judge(f);
        return;
    }
    judge(f);
}

void solve(std::string S){
    bool f=true;
    string s1=string(begin(S), begin(S)+(S.size()-1)/2);
    string s2=string(begin(S)+(S.size()+3)/2-1, end(S));
    judge(is_palindrome(S)&&is_palindrome(s1)&&is_palindrome(s2));
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
w, h, n =map(int, input().split())
c=0
d=0
cl=[0]
dl=[0]
wl=[w]
hl=[h]
for i in range(n):
    x, y, a= map(int, input().split())
    if a==1:
        cl.append(x)
    elif a==2:
        wl.append(x)
    elif a==3:
        dl.append(y)
    elif a==4:
        hl.append(y)
if min(wl)-max(cl)<0 or min(hl)-max(dl)<0:
    print(0)
else:
    print((min(wl)-max(cl))*(min(hl)-max(dl)))


Measured memory_bytes: 3064
# 高橋君A枚
# 青木君B枚
# 高橋君の行動回数K回
A, B, K = map(int, input().split())

# 高橋君がK枚以下なら全部食べる
if A <= K:
    K -= A
    A = 0
else:
    A -= K
    K = 0
    print('{} {}'.format(A, B))
    exit()
    
#print(A,B,K)
    
if B >= K:
    B -= K
    K = 0
    print('{} {}'.format(A, B))
else:
    print("0 0")

Measured memory_bytes: 3060
N = int(input())
a_list = []
for i in range(N):
    a_list.append(int(input()))

has_pushed_button = set()
pushed_button_num = 1
count = 0
can_push_2 = False
while not pushed_button_num in has_pushed_button:
    has_pushed_button.add(pushed_button_num)
    pushed_button_num = a_list[pushed_button_num - 1]
    count += 1
    if pushed_button_num == 2:
        can_push_2 = True
        break

if can_push_2:
    print(count)
else:
    print(-1)

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a, b;
  cin >> a >> b;
  int ans = abs(abs(a) - abs(b));
  if(a < 0 && b < 0 && a > b) ans += 2;
  if(a >= 0 && b >= 0 && a > b) {
    ans += 2;
    if(b == 0) ans--;
  }
  if(a >= 0 && b < 0 || a < 0 && b > 0) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdlib.h>
#include <numeric>
#include <cmath>
#define mod 1000007
typedef long long ll;
using namespace std;
bool comparator(pair<string,int> a,pair<string,int> b){
    if(a.first==b.first)
    return a.second>b.second;
    else
    return a.first<b.first;
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    vector<pair<string,int> > a,b;
    for(int i=0;i<n;i++)
    {
        pair<string,int> p;cin>>p.first>>p.second;
        a.push_back(p);b.push_back(p);
    }
    
    sort(a.begin(),a.end(),comparator);
    for(auto i:a)
    {
        vector<pair<string,int> >::iterator it;
        it=find(b.begin(),b.end(),i);
        cout<<it-b.begin()+1<<"\n";

    }


        
        
    

   
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto V=vecin(N);
	//sort(ALL(V),greater<int>());
	vector<int> dp(N,-1);
	REP(i,N){
		auto res = upper_bound(ALL(dp),V[i],greater<int>());
		*res = V[i];
	}
	out(count_if(ALL(dp),[](int v){return v>=0;}));
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,s;
	cin>>a>>s;
	for(int d=1;;d++)
	{
		int e=d*0.08,t=d*0.1;
		if(e==a&&t==s){
			cout<<d<<endl;
			return 0;
		}
		if(e>a||t>s){
			cout<<-1<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int k, s;
	cin >> k >> s;

	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (0 <= z && z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = 5;
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int tmp = 0;
        int tmp2 = 10 - (array[0] % 10);
        for (int i = 0; i < n; i++) {
            if (array[i] % 10 == 0) continue;
            if (tmp2 < 10 - (array[i] % 10)) {
                tmp2 = 10 - (array[i] % 10);
                tmp = i;
            }
        }
        
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (tmp == i) continue;
            if (array[i] % 10 != 0) {
                array[i] += 10 - (array[i] % 10);
            }
            count += array[i];
        }
        count += array[tmp];
        
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}


int main() {
	string S; cin >> S;
	int N = S.length();
	if (N == 2) {
		if (S[0] == S[1]) {
			p("1 2");
		}
		else {
			p("-1 -1");
		}
		return 0;
	}
	REP(i, N - 2) {
		if (S[i] == S[i + 1] || S[i + 1] == S[i + 2] || S[i] == S[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define fast ios::sync_with_stdio(false), cout.tie(), cin.tie();
#define sz(s) int(s.size())

int main(){
	int n, k;
	cin >> n >> k;
	map <int, pair<string, int>> m;
	string s;
	int x;
	for (int i  = 0; i < k; i++){
		cin >> x >> s;
		if(m[x].first == "AC"){
			continue;
		}
		if (s == "AC"){
			m[x].first = "AC";
		}else{
			m[x].second ++;
		}
	}
	int ans1 = 0, ans2 = 0;
	for (int i = 1; i <= n; i++){
		if(m[i].first == "AC"){
			ans1++;
			ans2 += m[i].second;
		}
	}
	cout << ans1 << ' ' << ans2;  
}


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

int main() {
	string str,ans="";
	cin >> str;

	for(int i=0; i<str.size(); i++) {
		if(str.at(i)=='B') {
			if(ans.size()) ans.erase(ans.size()-1);
		} else {
			ans += str.at(i);
		}
	}

	cout << ans << endl;
}

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

A=[0 for i in range(n+1)] #素因数分解のリスト

for i in range(2,n+1) :
    j=2
    while i!=1 :
        
        if i%j==0 :
            i=i//j
            A[j]+=1
        else :
            j+=1

#print(A)

B=[]
for i in [2,4,14,24,74] :
    co=0
    for j in A :
        if j>=i :
            co+=1
    B.append(co)

#print(B)

print((B[0]-2)*B[1]*(B[1]-1)//2 + (B[1]-1)*B[2] + (B[0]-1)*B[3] + B[4])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    u--;
    v--;
    vector<vector<int>> g(n);
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> dist1(n, -1);
    dist1[u] = 0;
    queue<int> que1;
    que1.push(u);
    while (!que1.empty()) {
        int now = que1.front();
        que1.pop();
        for (int next : g[now]) {
            if (dist1[next] != -1) continue;
            dist1[next] = dist1[now] + 1;
            que1.push(next);
        }
    }

    vector<int> dist2(n, -1);
    dist2[v] = 0;
    queue<int> que2;
    que2.push(v);
    while (!que2.empty()) {
        int now = que2.front();
        que2.pop();
        for (int next : g[now]) {
            if (dist2[next] != -1) continue;
            dist2[next] = dist2[now] + 1;
            que2.push(next);
        }
    }

    int ans = 0;
    rep(i, 0, n) {
        if (dist1[i] < dist2[i]) ans = max(ans, dist2[i]);
    }
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 6656
#include <iostream>

using namespace std;

int main(void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    while(B <= A) {
        --K;
        B *= 2;
    }
    while(C <= B) {
        --K;
        C *= 2;
    }

    if(K >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow ---question galat mat padhna */
{
    fast;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}   

Measured memory_bytes: 3652
import sys
from itertools import accumulate

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


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    A = list(accumulate(A))
    B = list(accumulate(B))

    ans = 0
    for i in range(N):
        if i > 0:
            res = A[i] + B[-1] - B[i - 1]
        else:
            res = A[i] + B[-1]

        if ans < res:
            ans = res

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define Tree int h,int l,int r,int L,int R
#define left 2*h,l,(l+r)/2,L,R
#define right 2*h+1,(l+r)/2+1,r,L,R
#define F first
#define S second
#define Pb push_back
using namespace std;
long long n,m,A,B,ans;
main ()
{
	cin>>n>>m;
	
	for (int i=1; i<=sqrt(m); i++)
		if (m%i==0)
		{
			A=i;
			B=m/i;
			
			if (n*A<=m) ans=max(ans,A);
			if (n*B<=m) ans=max(ans,B);
		}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
from itertools import groupby
n = int(input())
a = list(map(int,input().split()))
b = [i + 1 == j for i, j in enumerate(a)]
res = 0
for k, v in groupby(b):
    if not k:continue
    vv = len(list(v))
    res += (vv + 1) // 2
print(res)

Measured memory_bytes: 14260
h = int(input())
w = int(input())
n = int(input())

ans = 0
point = 0
if h <= w:
    for i in range(h):
        point += w
        ans += 1
        if point >= n:
            break
else:
    for i in range(w):
        point += h
        ans += 1
        if point >= n:
            break
print(ans)


Measured memory_bytes: 3060