akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations

def getval():
    h,w,k = map(int,input().split())
    return h,w,k

def main(h,w,goal):
    dp = [0 for i in range(w)]
    dp[0] = 1
    mod = 10**9 + 7
    for i in range(h):
        temp = [0 for i in range(w)]
        for j in range(w):
            for comb in combinations(range(w-1),j):
                arr = [k for k in comb]
                arr.sort()
                flag = False
                for k in range(len(arr)-1):
                    if arr[k]+1==arr[k+1]:
                        flag = True
                        break
                if flag:
                    continue
                for k in range(w):
                    if k in arr:
                        temp[k+1] += dp[k]
                        temp[k+1] %= mod
                    elif k-1 in arr:
                        temp[k-1] += dp[k]
                        temp[k-1] %= mod
                    else:
                        temp[k] += dp[k]
                        temp[k] %= mod
        dp = temp
    print(dp[goal-1]%mod)
                
                
if __name__=="__main__":
    h,w,k= getval()
    main(h,w,k)

Measured memory_bytes: 74280
#include<stdio.h>
int main(void)
{
	int a,am,pm;
	char name[16];
	for(a=0;a<9;a++)
	{
		scanf("%s %d %d",&name,&am,&pm);
		printf("%s %d %d\n",name,am+pm,am*200+pm*300);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const double pi = acos(-1);

int main(){
    int a, b; cin >> a >> b;
    int h, m; cin >> h >> m;
    int time = 60 * h + m;
    double l = 2.0 * pi / 720 * time; 
    double s = 2.0 * pi / 60 * m;
    double w = min(abs(l-s), 2 * pi - abs(l-s));
    double ans = a*a + b*b - 2*a*b*cos(w);
    ans = sqrt(ans);
    cout << fixed << setprecision(12) << ans << endl;
}

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

#define PI 3.1415926535897932384662433832795028841971
#define pb push_back

typedef long long ll;

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

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	int ret = 0;
	ret += min(a, k);
	k -= min(a, k);
	
	k -= min(b, k);
	
	ret -= min(c, k);
	
	cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3612
#### import ####
import sys
import math
from collections import defaultdict

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

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

S = str(input())
N = len(S)
count = 1
now = 1
temp = S[0]
while now<=N-1:
    if now == N-1:
        if temp == S[N-1]:
            break
        else:
            count += 1
            break
    for i in range(now+1,N+1):
        if S[now:i] != temp:
            count += 1
            temp = S[now:i]
            now = i
            break
print(count)

Measured memory_bytes: 42972
#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	scanf("%d",&n);
	char str[10005],c='A';
	scanf("%s",str);

	int len=strlen(str);
	for(int i=0;i<len;i++)
	{
		int v=n;
		while(v--)
		{
			if(str[i]=='Z')
				str[i]='A';
			else
				str[i]=str[i]+1;
		}
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}

		
	


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int N=1e5+5;
typedef long long ll;
const ll inf=(ll)1e18;
ll tr[N<<2];
void change(int p,ll v,int l,int r,int rt){
    if(l==r){
        tr[rt]=min(tr[rt],v);
        return ;
    }
    int m=l+r>>1;
    if(p<=m) change(p,v,lson);
    if(p>m) change(p,v,rson);
    tr[rt]=min(tr[rt<<1],tr[rt<<1|1]);
}
ll query(int L,int R,int l,int r,int rt){
    if(L<=l && r<=R) return tr[rt];
    ll ret=inf;
    int m=l+r>>1;
    if(L<=m) ret=min(ret,query(L,R,lson));
    if(R>m) ret=min(ret,query(L,R,rson));
    return ret;
}
struct node{
    int l,r;
    ll c;
    friend bool operator < (const node &a,const node &b){
        return a.l==b.l?a.c<b.c:a.l<b.l;
    }
};
vector<node> ve;
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int l,r;ll c;
    for(int i=1;i<=m;++i){
        scanf("%d %d %lld",&l,&r,&c);
        ve.push_back(node{l,r,c});
    }
    sort(ve.begin(),ve.end());
    fill(tr,tr+(N<<2),inf);
    change(1,0,1,n,1);
    //cout<<"Q: "<<query(1,n,1,n,1)<<"\n";
    for(node p:ve){
        //cout<<p.l<<" "<<p.r<<" "<<p.c<<"\n";
        ll c=p.c+query(p.l,n,1,n,1);
        //cout<<c<<"\n";
        change(p.r,c,1,n,1);
        //cout<<"cuc\n";
    }
    ll anx=query(n,n,1,n,1);
    if(anx==inf) puts("-1");
    else printf("%lld\n",anx);
}


Measured memory_bytes: 5104
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}
int digit(ull x) { //O(logN)
  if (x < 10)
    return 1;
  return digit(x / 10) + 1;
}

int N, A, B;
const int MAX_N = 50;
double vmax = 0;
ull v[MAX_N];
ull dp[MAX_N + 1][MAX_N + 1];

void comb_table(int N) {
  for (int i = 0; i <= N; ++i) {
    for (int k = 0; k <= i; ++k) {
      if (i == 0 or k == 0) {
        dp[i][k] = 1LL;
      } else {
        dp[i][k] = dp[i - 1][k] + dp[i - 1][k - 1];
      }
    }
  }
}

int main() {
  cin >> N >> A >> B;
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v, v + N);
  reverse(v, v + N);
  ull sum = 0;
  for (int i = 0; i < A; ++i) {
    sum += v[i];
  }
  double maxave = (double) sum / (double) A;
  //calc count
  comb_table(N);
  ull cnt = 0LL;
  int ath_val_cnt = 0, ath_val_cnt_within = 0;
  for (int i = 0; i < N; ++i) {
    if (v[A - 1] == v[i]) {
      ath_val_cnt++;
      if (i <= A - 1) {
        ath_val_cnt_within++;
      }
    }
  }
  if (v[0] == v[A - 1]) { //33333...3
    for (int i = A; i <= B; ++i) {
      cnt += dp[ath_val_cnt][i];
    }
  } else { //33332...
    cnt = dp[ath_val_cnt][ath_val_cnt_within];
  }
  cout.precision(20);
  cout << fixed << maxave << endl;
  cout << cnt << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  char op;
  int B;
  cin >> A;
  cin >> op;
  cin >> B;
  int S;
  
  if(op=='+'){
    S=A+B;
  }
  else{
    S=A-B;
  }
  
  cout << S << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }

  ll tot = 0;
  for (ll v : a) {
    tot ^= v;
  }
  // cout << tot << endl;

  rep(i,n) {
    cout << (tot^a[i]);
    if (i < n-1) {
      cout << " ";
    }
  }
  cout << endl;

  // // For Debug
  // {
  //   vector<ll> b = { 26, 5, 7, 22 };
  //   ll tot = 0;
  //   for (ll v : b) {
  //     tot ^= v;
  //   }
  //   cout << tot << endl;

  //   // for (ll v : b) {
  //   //   cout << (tot ^ v) << endl;
  //   // }
  // }
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

random_device rd;
mt19937 rng(rd());

template<class T>
T randomize(T mod)
{
	return uniform_int_distribution<T>(0, mod - 1)(rng);
}

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

vector<string> gen(string s)
{
    string t = s;
    reverse(ALL(s)); t += s;
    vector<string> res;
    FOR(i, 0, SZ(s) + 1)
    {
        res.PB(t.substr(i, SZ(s)));
    }
    return res;
}
string move(string s)
{
    char mn = 127;
    for (char c : s) ckmin(mn, c);
    //find the chain of ending things.
    int len = 0;
    while(len < SZ(s) && s[len] == mn)
    {
        len++;
    }
    // cerr << "s = " << s << " mn = " << mn << " len = " << len << endl;
    reverse(ALL(s));
    string t; t = s; reverse(ALL(s)); t += s;
    return t.substr(SZ(s) - len, SZ(s));
}

int K;
string s, ans;

// void dfs(string s, int depth)
// {
//     // cout << s << '\n';
//     if (s == "aaaaaa")
//     {
//         cout << "depth=" << depth << endl;
//     }
//     if (depth == 0) return;
//     auto g = gen(s);
//     for (string t : g)
//     {
//         dfs(t, depth - 1);
//     }
// }
int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> K >> K >> s;
    ans = s;
    ckmin(K, 15);
    auto g = gen(s);
    // cerr << SZ(g) << endl;
    for (string str : g)
    {
        FOR(i, 0, K - 1)
        {
            str = move(str);
        }
        ckmin(ans, str);
    }
    cout << ans << '\n';
}


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

int main() {
  	int n, m, a;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
      cin >> a;
      n -= a;
    }
	if(n >= 0){
      cout << n << endl;
    }else{
      cout << -1 << endl;
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>

using namespace std;
int main() {
    int n,k;
    int count = 0;
    cin >> n >> k;
    count = k;
    for (int i = 0; i < n -1; ++i) {
        count *= k-1;
    }
    cout << count ;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int euclid( int a, int b )
{
    int temp;

    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return euclid( b, a % b );
}

int main(){
  int N,X;
  scanf("%d%d",&N,&X);
  int x[N];
  int y[N];
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&x[i]);
  }

  for(i=0;i<N;i++){
    if(x[i]>X){
      x[i]=x[i]-X;
    }else{
      x[i]=X-x[i];
    }
  }

  if(N==1){
    printf("%d", x[0]);
    return 0;
  }
  
  if(x[0]==1||x[1]==1){
    printf("1");
    return 0;
  }
  y[0]=euclid(x[0],x[1]);
  for(i=1;i<N-1;i++){
    if(x[i+1]==1){
      printf("1");
      return 0;
    }
    y[i]=euclid(y[i-1],x[i+1]);
  }
  printf("%d", y[N-2]);
  return 0;
}

  


Measured memory_bytes: 896
#include <iostream>

int main(int argc, char* argv[])
{
	int a = 0;
	int b = 0;
	std::cin >> a;
	std::cin >> b;
	std::cout << a * b;
	std::cout << " ";
	std::cout << a * 2 + b * 2;
	std::cout << std::endl;
	return 0;
}

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

#define MAX_X (1000005)

void calcPrime(bitset < MAX_X > &prime)
{
    for ( int i = 2; i < MAX_X; i++ ) {
        prime[i] = true;
    }

    for ( int i = 2; i * i < MAX_X; i++ ) {
        if ( prime[i] ) {
            for ( int j = i * i; j < MAX_X; j += i ) {
                prime[j] = false;
            }
        }
    }
}

int main()
{
    int N, X;
    bitset < MAX_X > prime;

    calcPrime(prime);

    while ( cin >> N >> X, N || X ) {
        bool dp[MAX_X] = {};

        dp[0] = true;
        for ( int i = 0; i < N; i++ ) {
            int v;
            cin >> v;
            for ( int j = 0; j <= X; j++ ) {
                if ( dp[j] && j + v <= X ) {
                    dp[j + v] = true;
                }
            }
        }
        int k = X;
        while ( k > 0 && (!prime[k] || !dp[k]) ) {
            k--;
        }
        if ( k > 0 ) {
            cout << k << endl;
        } else {
            cout << "NA" << endl;
        }
    }

    return (0);
}


Measured memory_bytes: 4196
n = int(input())
a = list(map(int,input().split()))
dp = [[0 for i in range(3)] for j in range(n+1)]
for i in range(1,n+1):
  ai = a[i-1]
  dp[i] = dp[i-1][:]
  if i%2:
    dp[i][0] += +ai
    dp[i][1] = max(dp[i-1][0],dp[i-1][1])
  if i%2 == 0:
    dp[i][1] += ai
    dp[i][2] = max(dp[i-1][1],dp[i-1][2])
  if i >= 3 and i%2:
    dp[i][2] += ai
if n%2 == 0:
  print(max(dp[-1][0],dp[-1][1]))
else:
  print(max(dp[-1][1],dp[-1][2]))

Measured memory_bytes: 149000
#include <cstdio>

typedef long long ll;

int main() {
	ll n, k, ans = 0;
	scanf("%lld%lld", &n, &k);
	ans = (n / k) * (n / k) * (n / k);
	if (k % 2 == 0) {
		ll ano = n / (k / 2) - (n / k);
		ans += ano * ano * ano;
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define fori(x,a,b) for (int x=a;x<=b;x++)
using namespace std;
int main()
{
    int x;
    cin>>x;
    if (x>=400 && x<=599) cout<<8;
    else if (x>=600 && x<=799) cout<<7;
    else if (x>=800 && x<=999) cout<<6;
    else if (x>=1000 && x<=1199) cout<<5;
    else if (x>=1200 && x<=1399) cout<<4;
    else if (x>=1400 && x<=1599) cout<<3;
    else if (x>=1600 && x<=1799) cout<<2;
    else  cout<<1;

}


Measured memory_bytes: 3624
package main

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

func readf(sc *bufio.Scanner) float64 {
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	v := make([]float64, n)
	for i := range v {
		sc.Scan()
		v[i] = readf(sc)
	}

	max := 0.0
	sort.Float64s(v)
	for i := n - 1; i >= 0; i-- {
		tmp := Alchemy(v)
		if max < tmp {
			max = tmp
		}
	}
	fmt.Println(max)
}

func alchemy(x, y float64) float64 {
	return (x + y) / 2
}

func Alchemy(list []float64) float64 {
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		list[i+1] = alchemy(list[i], list[i+1])
	}
	return list[len(list)-1]
}

func Permute(nums []float64) [][]float64 {
	n := factorial(len(nums))
	ret := make([][]float64, 0, n)
	permute(nums, &ret)
	return ret
}

func permute(nums []float64, ret *[][]float64) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	p := make([]float64, n+1)
	for i := 0; i < n+1; i++ {
		p[i] = float64(i)
	}
	for i := 1; i < n; {
		p[i]--
		j := 0
		if i%2 == 1 {
			j = int(p[i])
		}

		nums[i], nums[j] = nums[j], nums[i]
		*ret = append(*ret, makeCopy(nums))
		for i = 1; p[i] == 0; i++ {
			p[i] = float64(i)
		}
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}

func makeCopy(nums []float64) []float64 {
	return append([]float64{}, nums...)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	char c;
  	cin >> c;
  	if(islower(c)) puts("a");
  	else puts("A");



	return 0;
}


Measured memory_bytes: 3580
//package june2020;

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {
	static FastReader scn = new FastReader();
	static OutputStream out = new BufferedOutputStream(System.out);
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int n =scn.nextInt(),k= scn.nextInt();
		
		int[] x = new int[n];
		for(int i=0;i<n;i++) {
			x[i] = scn.nextInt();
		}
		
		int min = Integer.MAX_VALUE;
		
		for(int i=0;i<=n-k;i++) {
			int a = Math.abs(x[i])+Math.abs(x[i+k-1]-x[i]);
			int b = Math.abs(x[i+k-1])+Math.abs(x[i+k-1]-x[i]);
			a = Math.min(a, b);
			min = Math.min(a, min);
		}
		out.write((min+"\n").getBytes());
		out.close();
	}
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


Measured memory_bytes: 35596
import bisect
MOD = 10**9+7
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 1
A.sort()
B.sort()
if not max(A) == max(B) == N*M:
    print(0)
    exit()
for i in range(N-1):
    if A[i] == A[i+1]:
        print(0)
        exit()
for i in range(M-1):
    if B[i] == B[i+1]:
        print(0)
        exit()
for i in range(N*M,0,-1):
    a = bisect.bisect_left(A,i)
    b = bisect.bisect_left(B,i)
    if A[a] == B[b] == i:
        continue
    if A[a] == i:
        ans = (ans*(M-b))%MOD
        continue
    if B[b] == i:
        ans = (ans*(N-a))%MOD
        continue
    ans = (ans*((N-a)*(M-b)-(N*M-i)))%MOD
print(ans)


Measured memory_bytes: 3188
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
//this code is sucks lol
typedef struct d{
	char name[11];
	int time;
}data;
int head, tail;
data c[100100];
void enqueue(data x){
	c[tail]= x;
	tail = (tail + 1) % 100100;
}
data dequeue(){
	data x = c[head];
	head = (head + 1) % 100100;
	return x;
}
int main(){
	int i, n, q;
	int tim, total=0;
	data tmp;
	cin >> n >> q;
	repx(i, n+1, 1) cin >> c[i].name >> c[i].time;
	head=1;
	tail=n+1;
	while(head != tail){
		tmp = dequeue();
		if((tmp.time - q) > 0){
			tmp.time -= q;
			total += q;
			enqueue(tmp);
		}else{
			total +=tmp.time;
			printf("%s %d\n", tmp.name, total);
		}
#ifdef DBG
		cout << head << tail << endl;
#endif
	}

}



Measured memory_bytes: 4720
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int H1, H2, M1, M2, K;

int main() {

	cin >> H1 >> M1 >> H2 >> M2 >> K;

	pair<int, int> s(H1, M1), e(H2, M2);
	if (s > e) swap(s, e);
	int v = (e.first - s.first) * 60 + (e.second - s.second);


	cout << (v / K ? v - K : 0) << endl;

	return 0;
}


Measured memory_bytes: 3672
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn head(n: u32) -> u32 {
    let s: String = n.to_string();
    let c: Vec<char> = s.chars().collect();
    c[0] as u32 - '0' as u32
}

fn tail(n: u32) -> u32 {
    n % 10
}

fn middle(n: u32) -> u32 {
    let s: String = n.to_string();
    let c: Vec<char> = s.chars().collect();
    let mut ret = 0;
    for i in 1..c.len() - 1 {
        ret *= 10;
        ret += c[i] as u32 - '0' as u32;
    }
    ret
}

fn pow10(l: usize) -> u32 {
    let mut ret = 1;
    for _ in 0..l {
        ret *= 10;
    }
    ret
}

fn main() {
    let n: u32 = read();

    let mut ans = 0;

    let nh = head(n);
    let nt = tail(n);
    let nl = n.to_string().len();

    for a in 1..n + 1 {
        let bt = head(a);
        let bh = tail(a);

        if bh == 0 {
            continue;
        }
        if bh == bt {
            ans += 1;
        }
        if bh * 10 + bt <= n {
            ans += 1;
        }

        for bl in 3..nl + 1 {
            if bl == nl {
                if bh < nh {
                    ans += pow10(bl - 2);
                } else if bh == nh {
                    if bt <= nt {
                        ans += middle(n) + 1;
                    } else {
                        ans += middle(n);
                    }
                }
            } else {
                ans += pow10(bl - 2);
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define maxn 55
using namespace std;
typedef long long LL;
int a[maxn];
int main() {
//    freopen("in.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    printf("%d\n", 2*n-2);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    int p1=1, p2=1;
    for (int i = 2; i <= n; ++i) {
        if (a[i] > a[p1]) p1 = i;
        if (a[i] < a[p2]) p2 = i;
    }
    if (abs(a[p1]) >= abs(a[p2])) {
        for (int i = 1; i < p1; ++i) printf("%d %d\n", p1, i);
        for (int i = p1+1; i <= n; ++i) printf("%d %d\n", p1, i);
        for (int i = 2; i <= n; ++i) printf("%d %d\n", i-1, i);
    }
    else {
        for (int i = 1; i < p2; ++i) printf("%d %d\n", p2, i);
        for (int i = p2+1; i <= n; ++i) printf("%d %d\n", p2, i);
        for (int i = n-1; i >= 1; --i) printf("%d %d\n", i+1, i);
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
from bisect import bisect_left, bisect_right
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        ans +=bisect_left(A, A[i] + A[j]) - (j + 1)
print(ans)

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

map<ll, ll> prime_factorizatoin(ll num)
{
    map<ll, ll> prime_factors;
    for (ll i = 2; i * i <= num;) {
        if (num % i == 0) {
            num /= i;
            prime_factors[i]++;
        } else {
            i++;
        }
    }
    if (num > 1) {
        prime_factors[num]++;
    }
    return prime_factors;
}

ll f(ll num)
{
    ll cnt = 0;
    for (ll i = 1; num > 0; i++) {
        if (num >= i) {
            cnt++;
        }
        num -= i;
    }
    return cnt;
}

void solve(long long N)
{
    auto pfs = prime_factorizatoin(N);
    ll ans = 0;
    for (auto& pf : pfs) {
        ans += f(pf.second);
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<queue>
#include<vector>
#include<utility>
#include<functional>
#include<tuple>
using namespace std;
typedef tuple<int, int, pair<int, int> > T;

int dp[100][100];
bool used[100][100];
const int INF = 1145141919;

int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){	
			dp[i][j] = INF;
		}
		dp[i][i] = 0;
	}
	vector<	pair<int, int> > road[n];
	for(int i = 0; i < m; ++i){
		int a, b, c; cin >> a >> b >> c;
		--a; --b;
		road[a].push_back(pair<int, int>(b, c));
		road[b].push_back(pair<int, int>(a, c));
		used[a][b] = used[b][a] = 1;
	}
	for(int i = 0; i < n; ++i){
		priority_queue<T, vector<T>, greater<T> >q;
		q.push(T(0, i, pair<int, int>(i, i)));
		while(!q.empty()){
			auto t = q.top(); q.pop();
			if(dp[i][get<1>(t)] < get<0>(t)) continue;
			dp[i][get<1>(t)] = get<0>(t);
			used[get<2>(t).first][get<2>(t).second] = used[get<2>(t).second][get<2>(t).first] = 0;
			for(pair<int, int> u : road[get<1>(t)]){	
				if(dp[i][get<1>(t)] + u.second < dp[i][u.first]){
					q.push(T(dp[i][get<1>(t)] + u.second, u.first, pair<int, int>(get<1>(t), u.first)));
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			ans += used[i][j];
		}
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(){
  int i, j, k, n, z[1005][1005], l1, l2;
  char s1[1005], s2[1005];
  for(i = 0; i < l1; i++)
    z[i][0] = 0;
  for(j = 0; j < l2; j++)
    z[0][k] = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",s1);
    l1 = strlen(s1);
    scanf("%s",s2);
    l2 = strlen(s2);
    for(j = 1; s1[j-1]!='\0'; j++){
      for(k = 1; s2[k-1] != '\0'; k++){
	if(s1[j-1] == s2[k-1]) {
	  z[j][k] = z[j-1][k-1] + 1;
	  //printf("%d",z[j][k]);
	}
	else if(z[j-1][k] >= z[j][k-1]){
	  z[j][k] = z[j-1][k];
	  //printf("%d",z[j][k]);
	}
	else {
	  z[j][k] = z[j][k-1];
	  //printf("%d",z[j][k]);
	}
      }
    }
    printf("%d\n",z[j-1][k-1]);
  }
  return 0;
}

Measured memory_bytes: 4536
package main

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

func main() {
	op := []string{}
	sc := bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		op = strings.Fields(sc.Text())
	}
	r, l := -1, -1
	st := newStack()
	for i := 0; i < len(op); i++ {
		switch op[i] {
		case "+":
			r, l = st.pop(), st.pop()
			st.push(l + r)
		case "-":
			r, l = st.pop(), st.pop()
			st.push(l - r)
		case "*":
			r, l = st.pop(), st.pop()
			st.push(l * r)
		default:
			num, err := strconv.Atoi(op[i])
			if err != nil {
				fmt.Println(err)
			}
			st.push(num)
		}
	}
	fmt.Println(st.peek())
}

type stack struct {
	top *node
	len int
}

type node struct {
	value int
	prev  *node
}

func newStack() *stack {
	return &stack{nil, 0}
}

func (s *stack) Len() int {
	return s.len
}

func (s *stack) peek() int {
	if s.len == 0 {
		return -1
	}
	return s.top.value
}

func (s *stack) pop() int {
	if s.len == 0 {
		return -1
	}
	n := s.top
	s.top = n.prev
	s.len--
	return n.value
}

func (s *stack) push(num int) {
	s.top = &node{value: num, prev: s.top}
	s.len++
}



Measured memory_bytes: 1104
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,k,x;
map<int,int>m;
int ans;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> k;
	for(int i = 1;i <= n;i++)
	{
		cin >> x;
		m[x]++;
	}
	vector<int>vec;
	int x = 0;
	int t = sz(m);
	for(auto it : m) vec.pb(it.second);
	sort(vec.begin(),vec.end());
	auto it = vec.begin();
	while(x < t - k)
	{
		ans += *it;
		it++;
		x++;
	}
	rc(ans);
}

Measured memory_bytes: 10744
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        int temp_l, temp_r;
        cin >> temp_l >> temp_r;

        sum += (temp_r - temp_l + 1);
    }

    cout << sum << endl;
}

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

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long money = 100L;
		int year = 0;
		while (money < x) {
			money += money / 100L;
			++year;
		}
		System.out.println(year);
	}

}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; 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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];
 
 
int main () {
    long long A, B,V ,W,T;
    cin >> A >> V >> B >> W >> T;

    if( V <= W){
        cout << "NO" << endl;
        return 0;
    }

    long long kyori = abs(B-A);
    if(kyori <= T * abs(V-W) ){
        cout << "YES" << endl;
    }else cout << "NO" << endl;


}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
    int N;
    int num[200005];
    int count[200005];
    scanf("%d",&N);
    num[0] = 0;
    count[0] = 0;
    for(int i=1;i<N;i++)
    {
        scanf("%d",&num[i]);
        count[i]=0;
    }
    for(int i=1;i<N;i++)
    {
        count[num[i]-1]++;
    }
    for(int i=0;i<N;i++)
    {
        printf("%d\n",count[i]);
    }
}

Measured memory_bytes: 3288
import itertools
def course_judge(edge,arr):
    ok = True
    for i in range(1,len(arr)):
        go = arr[i-1]
        to = arr[i]
        if edge[go][to] == 0 or edge[to][go] == 0:
            ok = False
    return ok

N,M = map(int,input().split())
arr = [i for i in range(1,N+1)]
edge = [[0]*(N+1) for i in range(N+1)]
for i in range(M):
    go,to = map(int,input().split())
    edge[go][to] = 1
    edge[to][go] = 1
count = 0
for a in itertools.permutations(arr):
    if a[0] == 1 and course_judge(edge,a):
        count += 1
print(count)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S; cin >> S;
    for(int i = 1; i < S.length();i++){
        if(S[i]!=S[i-1]) res++;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp;
use std::num::Wrapping; // overflowを回避
use std::f64::consts;

fn main() {
    let n: i32 = read();
    let n_str: String = n.to_string();
    let min_len: usize = n_str.len();
    let input_vec: Vec<String> = vec!["7".to_string(), "5".to_string(), "3".to_string()];

    let mut out_vec: Vec<String> = vec![];

    for length in 3..min_len+1 {
        dfs(String::from(""), length, &mut out_vec, &input_vec);
    }

    let mut count = 0;

    for str in out_vec {
        if is_753(&str) && str.parse::<i32>().unwrap() <= n {
            count+=1;
        }
    }

    println!("{}", count);
}

fn is_753(s: &String)-> bool {
    if s.contains(&"7".to_string()) &&
        s.contains(&"5".to_string()) &&
        s.contains(&"3".to_string()) {
        return true;
    }
    return false;
}

fn dfs(mut s: String, min_len: usize, out_vec: &mut Vec<String>, input_vec: &Vec<String>) {
    if s.len() >= min_len {
        out_vec.push(s.clone());
        return;
    }

    for c in input_vec {
        dfs(s.clone() + c, min_len, out_vec, input_vec);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
from sys import stdin
import sys
#import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    S = [rs() for _ in range(3)]
    mi = len(S[0]) + len(S[1]) + len(S[2])
    L = [[set() for i in range(3)] for j in range(3)]
    
    for i in range(3):
        for j in range(3):
            if(i == j): continue
            s = S[i]
            t = S[j]
            for k in range(-len(t), len(s) + 1):
                chk = True
                for l in range(len(s)):
                    ti = l - k
                    if(ti < 0 or ti >= len(t)): continue
                    if(s[l] == t[ti]): continue
                    if(s[l] == '?'): continue
                    if(t[ti] == '?'): continue
                    chk = False
                    break
                if(chk): L[i][j].add(k)
    a = [[0,1,2], [0,2,1], [1,0,2], [1,2,0], [2,0,1], [2,1,0]]
    for ord in a:
        i = ord[0]
        j = ord[1]
        k = ord[2]
        la = 0
        ra = len(S[i])
        for ij in L[i][j]:
            lb = ij
            rb = ij + len(S[j])
            for ik in L[i][k]:
                lc = ik
                rc = ik + len(S[k])
                if lb <= lc and lc < rb:
                    if not ((lc - lb) in L[j][k]): continue
                if lc <= lb and lb < rc:
                    if not ((lb - lc) in L[k][j]): continue
                l = min(la, lb)
                l = min(l, lc)
                r = max(ra, rb)
                r = max(r, rc)
                mi = min(mi, r - l)
    
    print(mi)
                


if __name__ == "__main__":
    main()


Measured memory_bytes: 57820
#include<stdio.h>
#include<math.h>
int n;
typedef struct 
{
    double x;
    double y;
}point;

int kock(int n,point p1,point p2){
    point  s,t,u;

    if(n==0)return 0;

    s.x=(2*p1.x+1*p2.x)/3;
    s.y=(2*p1.y+1*p2.y)/3;

    t.x=(1*p1.x+2*p2.x)/3;
    t.y=(1*p1.y+2*p2.y)/3;
    
    u.x=(t.x-s.x)*cos(M_PI/3.0)-(t.y-s.y)*sin(M_PI/3.0)+s.x;
    u.y=(t.x-s.x)*sin(M_PI/3.0)+(t.y-s.y)*cos(M_PI/3.0)+s.y;

    kock(n-1,p1,s);
    printf("%g %g\n",s.x,s.y);
    kock(n-1,s,u);
    printf("%g %g\n",u.x,u.y);
    kock(n-1,u,t);
    printf("%g %g\n",t.x,t.y);
    kock(n-1,t,p2);

    return 0;
}

int main(void){
    scanf("%d",&n);
    point p1,p2;
    p1.x=0;p1.y=0;
    p2.x=100;p2.y=0;
    printf("%g %g\n",p1.x,p1.y);
    kock(n,p1,p2);
    printf("%g %g\n",p2.x,p2.y);

    return 0;

}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a*b)%2==1&&(c+d)%2==1){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 3104
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]


class UnionFind:
    def __init__(self, size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]

    def find(self, x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x

    def union(self, s1, s2):
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]


def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab[1:]):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.number[px] * uf.number[py]
            uf.union(px, py)
        ans.append(p)

    for a in reversed(ans):
        print(a)


main()

Measured memory_bytes: 23252
package main

import (
	"fmt"
	"sort"
)

type node struct {
	k int
	v int
}

func factorize(n int) []node {
	m := make(map[int]int)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			m[i]++
			n /= i
		}
	}
	if n != 1 {
		m[n] = 1
	}
	a := make([]node, 0, len(m))
	for k, v := range m {
		a = append(a, node{k, v})
	}
	sort.Slice(a, func(i, j int) bool { return a[i].k < a[j].k })
	return a
}

func main() {
	n := 0
	fmt.Scan(&n)
	fmt.Printf("%d:", n)
	for _, e := range factorize(n) {
		for i := 0; i < e.v; i++ {
			fmt.Printf(" %d", e.k)
		}
	}
	fmt.Printf("\n")
}



Measured memory_bytes: 1196
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int n,m;
	cin>>n>>m;
	vi a(n);
	rep(i,n)cin>>a[i];
	vi b(m);
	rep(i,m)cin>>b[i];

	vvi dp(n+1,vi(m+1));
	rep(i,n+1)dp[i][0]=1;
	rep(i,m+1)dp[0][i]=1;
	int MOD=1000000007;
	rep(i,n)rep(j,m){
		if(a[i]==b[j]){
			dp[i+1][j+1]=dp[i][j];
		}
		(dp[i+1][j+1]+=MOD+dp[i+1][j]+dp[i][j+1]-dp[i][j])%=MOD;
	}
	cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 31616
#include <iostream>

using namespace std;
int a,b,c,d,e,k,w,q,t,z,f,l,p,m,o,u;
int main()
{
    cin>>a>>b>>c>>d>>e>>k;
    w=b-a; q=c-a; t=d-a; z=e-a;f=c-b;l=d-b; p=e-b; m=d-c; o=e-c; u=e-d;
     if(k>=w&&k>=q&&k>=t&&k>=z&&k>=f&&k>=l&&k>=p&&k>=m&&k>=o&&k>=u)
     {
          cout<<"Yay!";

     }
     else
     {
         cout<<":(";
     }

    return 0;
}


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

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<int> a(N+1), b(N+1, 0);
	for (ll i = 1; i < N+1; ++i) cin >> a[i];

	for (ll i = N/2+1; i < N+1; ++i)
		b[i] = a[i];

	for (ll i = N/2; i >= 1; --i)
	{
		ll sum{0};
		for (ll j = i*2; j <= N; j += i)
		{
			sum += b[j];
		}

		if (sum % 2 != a[i])
			b[i] = 1;
		else
			b[i] = 0;;
	}

	ll sum = accumulate(next(b.begin()), b.end(), 0ll);
	std::cout << sum << std::endl;
	vector<ll> ans;
	for (ll i = 1; i <= N; ++i)
	{
		if (b[i] == 1)
			ans.push_back(i);
	}
	
	for (ll i = 0; i < ans.size(); ++i)
	{
		std::cout << (i ? " " : "" ) << ans[i];
	}
	std::cout << std::endl;
}


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

int main(){
    ll n,count=0,max=0;
    cin >> n;
    vector<ll> h(n);
    rep(i,n){
        cin >> h[i];
    }
    rep(i,n){
        if(h[i] >= h[i+1] && i+1 < n) count++;
        if(h[i] < h[i+1]){
            count=0;
        }
        if(max < count) max = count;
    }
    cout << max << endl;
}

Measured memory_bytes: 1024
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

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

const ll mod=1e9+7;
const int INF=0x3f3f3f3f; 
const int MAX=2e5+5;

int n,k; 

int main()
{
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef pair<int,int> pi;
typedef long long ll;

const int N = 1000005;

int n , a[N],k,res,h[N];

vector<int> g[N];
void dfs(int u){
	for(auto v : g[u]){
		dfs(v);
		h[u] = max(h[u],1+h[v]);
	}

	if(h[u]==k-1 && u > 1){
		if(a[u] != 1){
			res++;
			h[u] = -1;
		}
	}
}

int main(){
	cin >> n >> k;
	for (int i = 1; i <= n; ++i){
		scanf("%d",&a[i]);
		if(i == 1 && a[i] != 1)res++,a[i] = 1;
		//cout << a[i] << " " << i << endl;
		if(i>1)g[a[i]].push_back(i);
	}
	dfs(1);

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 34688
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
vector<int>a[100001];
int len[100001]={0};
int dfs(int n,int vis[]){
	if(!vis[n]){
		vis[n]=1;
		for(int i=0;i<(int)a[n].size();i++){
			len[n]=max(len[n],dfs(a[n][i],vis));	
		}
		len[n]=max(len[n],1);
	}
	return len[n]+1;	
}
int main(){ 
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		a[x].pb(y);
	}
	int vis[100001]={0};
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i,vis);
		}
	}
	int mx=0;
	for(int i=1;i<=n;i++)mx=max(mx,len[i]);
	cout<<mx-1<<endl;
}



Measured memory_bytes: 11940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,i,n;
    char ch[1000];
    cin>>ch>>n;
    l=strlen(ch);
    for(i=0;i<l;i=i+n) cout<<ch[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void) {
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1}, x, y;
  cin >> x >> y;
  if (a[x] == a[y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,cnt=0;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    ll j=a[i]-1;
    if(a[j]==i+1){
      cnt++;
    }
  }
  cout << cnt/2<< endl;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      int x = Integer.parseInt(sc.next());
      int t = Integer.parseInt(sc.next());
      for(int i = 1; i <= t; i++){
        x--;
        if(x == 0){
          break;
        }
      }
      System.out.println(x);
    }
  }
}

Measured memory_bytes: 21716