akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 24/Aug/20 10:27:00 AM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

#define int int64_t

template < typename T > void print (const T& t) {
	cout << t << '\n';
}

template < typename T, typename U, typename... ARGS >
void print (const T& t, const U& u, const ARGS&... args) {
	cout << t << " ";
	print (u, args...);
}

const int N = 1e3 + 5;
map< pair< int, int >, int > mp;
char arr[N][N];
int vis[N][N];
int ans[N][N];
int n, m;
int x, y;
int g, h;
int scc;
vector< pair< int, int > > edges;

bool check (int a, int b) {
	return a >= 0 and a < n and b >= 0 and b < m;
}

vector< pair< int, int > > neighbors (int a, int b) {
	return {{a - 1, b}, {a + 1, b}, {a, b - 1}, {a, b + 1}};
}

void dfs (int a, int b) {
	vis[a][b] = 1;
	mp[{a, b}] = scc;
	if (check (a - 1, b) and arr[a - 1][b] == '.' and !vis[a - 1][b]) dfs (a - 1, b);
	if (check (a + 1, b) and arr[a + 1][b] == '.' and !vis[a + 1][b]) dfs (a + 1, b);
	if (check (a, b - 1) and arr[a][b - 1] == '.' and !vis[a][b - 1]) dfs (a, b - 1);
	if (check (a, b + 1) and arr[a][b + 1] == '.' and !vis[a][b + 1]) dfs (a, b + 1);
}

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	cin >> n >> m;
	cin >> x >> y;
	x--;
	y--;
	cin >> g >> h;
	g--;
	h--;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> arr[i][j];
			ans[i][j] = 1e9;
		}
	}

	// dfs (x, y);


	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < m; ++j) {
	// 		if (!vis[i][j] and arr[i][j] == '.') {
	// 			++scc;
	// 			dfs (i, j);
	// 		}
	// 	}
	// }


	// find the number of islands first and group them
	priority_queue< pair< int, pair< int, int > >, vector< pair< int, pair< int, int > > >, greater<> > q;
	q.push ({0, {x, y}});
	ans[x][y] = 0;

	while (!q.empty ()) {
		auto [dis, p] = q.top ();
		q.pop ();

		int a = p.first, b = p.second;

		if (check (a - 1, b) and arr[a - 1][b] == '.' and ans[a - 1][b] > dis) {
			q.push ({dis, {a - 1, b}});
			ans[a - 1][b] = dis;
		}
		if (check (a + 1, b) and arr[a + 1][b] == '.' and ans[a + 1][b] > dis) {
			q.push ({dis, {a + 1, b}});
			ans[a + 1][b] = dis;
		}
		if (check (a, b - 1) and arr[a][b - 1] == '.' and ans[a][b - 1] > dis) {
			q.push ({dis, {a, b - 1}});
			ans[a][b - 1] = dis;
		}
		if (check (a, b + 1) and arr[a][b + 1] == '.' and ans[a][b + 1] > dis) {
			q.push ({dis, {a, b + 1}});
			ans[a][b + 1] = dis;
		}


		for (int i = -2; i <= 2; ++i) {
			for (int j = -2; j <= 2; ++j) {
				if ((i == 0 and j == 0) or (abs (i) == 1 and abs (j) == 0) or (abs (i) == 0 and abs (j) == 1))
					continue;
				int c = a + i, d = b + j;
				if (check (c, d) and arr[c][d] == '.' and ans[c][d] > dis + 1) {
					q.push ({dis + 1, {c, d}});
					ans[c][d] = dis + 1;
				}
			}
		}
	}
	if (ans[g][h] == 1e9) ans[g][h] = -1;
	print (ans[g][h]);

	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  vector<vector<int>> v(n+1);
  int x,y,z;
  for (int i=1;i<=n;i++)
    {
      cin>>x>>y>>z;
      v[i].push_back(x);
      v[i].push_back(y);
      v[i].push_back(z);
    }
  int dp[n+1][3];
  dp[0][0]=dp[0][1]=dp[0][2]=0;
  for (int i=1;i<=n;i++)
  {
    dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=v[i][2]+max(dp[i-1][0],dp[i-1][1]);
  }
  cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
  return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
 
typedef long long ll;
ll n, s, k, a;
map<ll, ll> v;
int main()
{
	ll i, t;
	cin >> n;
	v[0]++;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a);
		k += a;
		v[k]++;
	}
	map<ll, ll>::iterator it;
	for (it = v.begin(); it != v.end(); it++) {
		t = it->second;
		s += t * (t - 1) / 2;
	}
	cout << s;
    return 0;
}

Measured memory_bytes: 12800
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 1000005
char s[maxn],t[maxn];
int n,cnt,ans;
struct Vergil
{
	int x,y;	
}a[maxn],b[maxn];

bool comp(char *s,char *t) 
{
	for (int i=1;i<=n;i++) 
		if (s[i]!=t[i])	return 0;
	return 1;
}

bool check(int x)
{
	for (int i=1;i<=cnt-x;i++)
		if (b[i+x].x-x<b[i].y) return 0;
	return 1;
}

int main()
{
	scanf("%d",&n);
	scanf("%s%s",s+1,t+1);
	if (comp(s,t)) {puts("0");return 0;}
	for (int i=n,j=n;i>=1;i--) 
	{
		j=min(j,i);
		while (j>0&&s[j]!=t[i]) j--;	
		if (j==0) {puts("-1");return 0;}
		a[i]=(Vergil){j,i};
	}
	b[1]=a[1];cnt=1;
	for (int i=2;i<=n;i++) 
		if (a[i].x==a[i-1].x) b[cnt]=a[i];
		else b[++cnt]=a[i];
	int L=1,R=cnt;
	while (L<=R) 
	{
		int mid=(L+R)>>1;
		if (check(mid))	{ans=mid;R=mid-1;}
		else L=mid+1;
	}
	printf("%d\n",ans);
	return 0;	
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int main() {
    int n,k,ans = 0;
    cin >> n >> k;
    map<int,int> mp;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        mp[x]++;
    }
    for (int i = 0; i != mp.size() ; ++i) {
        v.push_back(mp[i]);
    }
    sort(v.begin(),v.end());
    if(v.size() > k)
        for (int i = 0; i < v.size()-k; ++i) {
            ans += v[i];
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10748
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
  
 
int32_t  main() {

	IOS;

	int N, K;

	cin >> N >> K;
	 
	
	vector<int> arr(N);

	for (int i = 0; i < N; i++) {
		 
		cin >> arr[i];
		 
		arr[i]--;
	}

	vector<int> vis(N);

	vector<int> start, cyc;
 
	int x = 0;

	while (true) {

		vis[x] = 1;

		start.push_back(x);

		x = arr[x];

		if (vis[x]) {

			while (true) {

				int tmp = start.back();

				cyc.push_back(tmp);

				start.pop_back();

				if (tmp == x) {

					break;

				}



			}
			break;


		}


	}
	reverse(cyc.begin(), cyc.end());
	if (K < start.size()) {

		cout << start[K]+1 << endl;

	}
	else {

		K -= start.size();

		K %= cyc.size();

		cout << cyc[K]+1 << endl;

	}

}


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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}
	const int INF = 1001001001;
	int ans = INF;
	for (int bit = 1; bit < (1 << n); bit++) {
		vector<int> now_a(m);
		int now_c = 0;
		for(int i = 0; i < n; i++) {
			if((bit >> i) & 1) {
				now_c += c[i];
				rep(j, m) {
					now_a[j] += a[i][j];
				}
			}
		}
		bool ok = true;
		rep(j, m) {
			if(now_a[j] < x) ok = false;
		}
		if(ok) {
			ans = min(ans, now_c);
		}
	}
	
	if(ans == INF) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

 

int main(void)

{

  int N, i, j, k, v;

  scanf("%d",&N);

  int A[N];

  for(i = 0; i < N ;i++)

  {

    scanf("%d",&A[i]);

    printf("%d",A[i]);

    if (i < N-1)

    {

      printf(" ");

    }

    else

    {

      printf("\n");

    }

  }

  for(i = 1; i < N; i++)

  {

    v = A[i];

    j = i - 1;

    while(j  > -1 && A[j] > v)

    {

      A[j + 1] = A[j];

      j--;

      A[j + 1] = v;

    }

    for(k = 0; k < N; k++)

    {

      if(k > 0)

      {

        printf(" ");

      }

      printf("%d",A[k]);

    }

    printf("\n");

  }

  return 0;

}

Measured memory_bytes: 604
# 剰余系
class Integer
  MOD = 1000000007
  @@inverse = {}
  # a + b
  def plus(other)
    (self + other) % MOD
  end
  # a - b
  def minus(other)
    (self - other) % MOD
  end
  # a * b
  def mult(other)
    ((self % MOD) * (other % MOD)) % MOD
  end
  # a / b
  def divi(other)
    ((self % MOD) * other.inverse) % MOD
  end
  # a ** b
  def power(n)
    res = 1
    a = self
    while (n > 0) do
      res = res.mult(a) if n[0]==1
      a = a.mult(a)
      n = n >> 1
    end
    res
  end
  # nCk
  def combi(k)
    return 0 if self < k
    k = self - k if 2 * k > self
    return 1 if k == 0
    (((self - k + 1)..self).reduce(&:mult)).divi ((1..k).reduce(&:mult))
  end
  # 逆元
  def inverse
    @@inverse[self] ||= self.power(MOD - 2)
  end
end

N, K = gets.split(' ').map(&:to_i)
R = N - K
(1..K).each do |i|
  puts (N-K+1).combi(i) .mult (K-1).combi(i-1)
end

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

bool isPrime[100000];
typedef pair<int,int> P;

int main(){
    int p,q;
    cin>>p>>q;
    int d = gcd(p,q);
    p/=d; q/=d;
    // cout<<p<<' '<<q<<endl;
    fill(isPrime,isPrime+100000,true);
    isPrime[0]=isPrime[1]=false;
    for(int i=0;i<100000;i++){
        if(isPrime[i])for(int k=2;k*i<100000;k++) isPrime[i*k]=false;
    }
    int ans=1;
    vector<P> V;
    for(int i=0;i<100000;i++){
        if(!isPrime[i]) continue;
        if(q%i==0){
            ans*=i;
            while(q%i==0) q/=i;
        }
    }
    ans*=q;
    cout<<ans<<endl;
}

Measured memory_bytes: 3184
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
C = 10 ** 12

jobs = []
for i in 1..N do
  jobs.push(lines[i][0] + lines[i][1] * C)
end

jobs.sort!
time_nec = []
deadline = []
for i in 1..N do
  time = jobs[i-1] % C
  dead = (jobs[i-1] - time) / C
  time_nec.push(time)
  deadline.push(dead)
end

time = 0
ans = "Yes"
for i in 1..N do
  time += time_nec[i-1]
  if time > deadline[i-1] then
    ans = "No"
    break
  end
end
  
print ans

Measured memory_bytes: 55512
# solution
import io
import math

data = int(input())
inin = input()

a1 = 0
a2 = 0

for i in range(data):
    if inin[i] == '(':
        a1 += 1
    else:
        if a1 > 0:
            a1 -= 1
        else:
            a2 += 1
print('('*a2+inin+')'*a1)


Measured memory_bytes: 2940
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    int n;
    cin.scan(n);
    auto a = cin.nextArray!int(n);
    int cnt;
    foreach (i; 1 .. n) {
        if (a[i - 1] == a[i]) {
            a[i] = -1;
            cnt++;
        }
    }
    writeln(cnt);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int X = sc.nextInt();

        System.out.println(solve(X) ? "YES" : "NO");

        sc.close();
    }

    static boolean solve(int X) {
        return X == 3 || X == 5 || X == 7;
    }
}

Measured memory_bytes: 35804
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

long long gcd(long long a, long long b);

int main(void) {
	long long a, b, c, ans;
	while(cin >> a >> b) {
		c = gcd(a, b);
		ans = 1;
		for(long long i = 2; i*i <= c; i++) {
			if(c%i == 0) {
				ans++;
				while(c%i == 0)
					c /= i;
			}
		}
		if(c != 1)
			ans++;
		cout << ans << endl;
	}
}

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a%b);
}

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

int main() 
{
    int N;
    cin >> N;
    vector<int>P(N);
    for(int i = 0; i < N; i++){
        cin >> P.at(i);
    }
    
    for (int i = 1; i <= N; i++) {
        if (P.at(i-1) != i) {
            swap(P.at(i-1), P.at(P.at(i-1)-1));
            break;
        }
    }
    
    bool flag = true;
    for (int i = 1; i <= N; i++) {
        if (P.at(i-1) != i) {
            flag = false;
        }
    }
    if (flag) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int dx[4] = {-1,0,1,0},dy[4] = {0,-1,0,1};
char grid[1000][1000];
queue<pii> Q;
int dist[1000][1000];
int main() {
    int i,j;
    int H,W;
    scanf("%d %d",&H,&W);
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) scanf(" %c",&grid[i][j]);
    }

    int m = 0;
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {
            dist[i][j] = -1;
            if (grid[i][j] == '#') dist[i][j] = 0,Q.push(mp(i,j));
        }
    }
    while (!Q.empty()) {
        int x = Q.front().second;
        int y = Q.front().first;
        Q.pop();

        m = max(m,dist[y][x]);
        for (i = 0; i < 4; i++) {
            int xx = x+dx[i],yy = y+dy[i];
            if ((xx >= 0) && (xx < W) && (yy >= 0) && (yy < H) && (dist[yy][xx] == -1)) {
                dist[yy][xx] = dist[y][x]+1;
                Q.push(mp(yy,xx));
            }
        }
    }
    printf("%d\n",m);

    return 0;
}



Measured memory_bytes: 13328
#B - Simplified mahjong
n=int(input())
modlists=[0]*(n+1)
for  i in range(n):
    s=int(input())
    modlists[i]=s
add=0
lefted=0
for i in range(n):
    if modlists[i]!=0:
        add+=modlists[i]
    elif modlists[i]==0:
        lefted+=add%2
        add=0
sums=sum(modlists)
print((sums-lefted)//2)

Measured memory_bytes: 6900
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;
ll C[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };


int main() {
	//Code Line
	cin >> a;
	cout << C[a - 1] << endl;




	return 0;
}


Measured memory_bytes: 256
import random


def slv(A, B, C, X, Y):
    a = A * X + B * Y
    b = min(X, Y) * 2 * C + (X - min(X, Y)) * A + (Y - min(X, Y)) * B
    c = max(X, Y) * 2 * C
    # print(a, b, c)

    return min(a, b, c)


def main():
    # N = int(input())
    A, B, C, X, Y, = list(map(int, input().split()))
    print(slv(A, B, C, X, Y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N;
	ll result=0;
	cin>>N;
	VI vec(N),num(N+1);
	REP(i, N) {
		cin >> vec[i];
		num[vec[i]]++;
	}

	FOR(i,1,N){
		result+=num[i]*(num[i]-1)/2;//総和
	}
	REP(i,N){
		ll tmp=(num[vec[i]]-1);
		cout << result-tmp << "\n";
	}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  long N, P; scanf("%ld%ld", &N, &P);
  map<long, long> primes;

  while (P % 2 == 0) {
    primes[2]++;
    P /= 2;
  }
  for (long i{3}; i * i <= P; i += 2) {
    while (P % i == 0) {
      primes[i]++;
      P /= i;
    }
  }
  if (P > 1) {
    primes[P]++;
  }

  long factor{1};
  for (auto& prime : primes) {
    for (long i{1}; N * i <= prime.second; ++i) {
      factor *= prime.first;
    }
  }

  printf("%ld\n", factor);
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M,*UV,S,T = map(int,read().split())

it = iter(UV)
graph = [[] for _ in range(1+N+N+N)]
for x,y in zip(it,it):
    x1=x+N; x2=x1+N
    y1=y+N; y2=y1+N
    graph[x].append(y1)
    graph[x1].append(y2)
    graph[x2].append(y)   

INF = 10**15
dist = [INF] * (N+N+N+1)
dist[S] = 0
q = [S]
while q:
    qq = []
    for x in q:
        for y in graph[x]:
            if dist[y] != INF:
                continue
            qq.append(y)
            dist[y] = dist[x] + 1
            if y == T:
                break
    q = qq

d = dist[T]

answer = -1 if d == INF else d//3
print(answer)


Measured memory_bytes: 64648
#!/usr/bin/env python3
#ABC139 E

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [deque() for _ in range(n)]
for i in range(1,n+1):
    x = LI()
    for j in x:
        a[i-1].append((i,j))
ans = 0
s = time.time()
for j in range(n*(n-1)//2+1):
    check = [1]*n
    flg = False
    flg2 = False
    if time.time() - s > 1.6:
        print(n*(n-1)//2)
        quit()
    for i in range(n):
        if len(a[i]) == 0 or check[i] == 0:
            continue
        (x,y) = a[i].popleft()
        flg2 = True
        check[i] = 0
        if a[y-1][0] == (y,x) and check[y-1]:
            a[y-1].popleft()
            flg = True
            check[y-1] = 0
        else:
            a[i].appendleft((x,y))
    if flg:
        ans += 1
    if not flg:
        for i in a:
            if len(i) != 0:
                print(-1)
                quit()
    if not flg2:
        print(ans)
        quit()


Measured memory_bytes: 110040
// Created by Sharat Sachin
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin>>n;
    vector<ll> a(n),b(n),c(n),sa(n),sb(n),sc(n);
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    rep(i,n) {
    	if(i==0) sa[0]=a[0], sb[0]=b[0], sc[0]=c[0];
    	else{
    		sa[i] = max(sb[i-1],sc[i-1])+a[i];
    		sb[i] = max(sc[i-1],sa[i-1])+b[i];
    		sc[i] = max(sb[i-1],sa[i-1])+c[i]; 
    	}
    }
    cout<<max(sa[n-1],max(sb[n-1],sc[n-1]));
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[212345];
int main(){
	int n; scanf("%d", &n);
	int z = 0;
	REP(i, n){
		scanf("%d", a+i);
		z ^= a[i];
	}
	REP(i, n) printf("%d ", z^a[i]);
}


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

int main(){
	long long n,a[100005];
	cin>>n;
	for(long long i=0;i<n;i++){
		cin>>a[i];
	}
	long long sum=0,m=0;
	for(long long i=0;i<n-1;i++){
		if(a[i]<a[i+1] || i==n-2){
			if(a[i]>=a[i+1])
			    sum++;
			if(m<sum){
				m=sum;
			}
			sum=0;
		}
		else{
			sum++;
		}
	}
	cout<<m<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> problem(n);
  for(int i = 0; i < n; ++i) cin >> problem[i];
  sort(problem.begin(), problem.end());
  int del = problem[n / 2 - 1] + 1;
  int ans = 0;
  while(del <= problem[n / 2]){
    ans++;
    del++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long


class CWalkingTakahashi {
public:
	void solve(std::istream& in, std::ostream& out) {
    int x,k,d;
    in >> x >> k >> d;
    int a = abs(x) / d;
    int b = abs(x) % d;
    int ans = 0;
    if(a > k){
      ans = abs(x) - d * k;
    }
    else{
      if(a%2 == 0){
        if(k % 2 == 0){
          ans = b;
        }
        else{
          ans = abs(b - d);
        }
      }
      else{
        if(k%2 == 0){
          ans = abs(b - d);
        }
        else{
          ans = b;
        }
      }
    }
    out << ans << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	CWalkingTakahashi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
    int A, B, X;
    std::cin >> A >> B >> X;
    
    if (A <= X && X <= (A + B)) {
        std::cout << "YES\n";
    } else {
        std::cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
 
int A,B;
 
int main(void){
    cin >> A >> B;
    rep(i,3)if((i+1) != A && (i+1) != B) cout << i+1 << endl;
}


Measured memory_bytes: 256
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n=getint()
hs=getints()

def solve(hs:list):
    if not hs or not max(hs):
        return 0
    add = min(hs)
    for i in range(len(hs)):
        hs[i] -= add
    res = add
    now = []
    for h in hs:
        if not h:
            res += solve(now)
            now = []
            continue
        now.append(h)
    res += solve(now)
    return res

print(solve(hs))


Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>

using namespace std;

#define INF 9999999
 
int main(){
    int e;
     
    while(cin >> e,e){
        //x+y^2+z^3=e
        int ans = INF;
         
        for(int z = 0 ; z*z*z <= e ; z++){
            for(int y = 0 ; (y*y)+(z*z*z) <= e ; y++){
                ans = min(ans,e-y*y-z*z*z+y+z);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> v(1 << n);
    for (int i = 0; i < (1 << n); i++) cin >> v[i];
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < (1 << n); i += (1 << (k+1))) {
            int j = i + (1 << k);
            if (v[i] != v[j]) v[i] = abs(v[i] - v[j]);
            v[j] = 0;
        }
    }
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 1408
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:break
    f=[[0 for i in range(b)]for j in range(a)]
    for i in range(a):
        for j in range(b):
            if i==0 or i==a-1 or j==0 or j==b-1:
                f[i][j]=1
    for i in range(a):
        for j in range(b):
            if f[i][j]==1:
                print('#',end='')
            else :
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct graph{
    size_t n,r,md;
    vector<vector<int>> e;
    vector<bool> vis;
    explicit graph(int n_){
        n=n_;
        e.resize(n);
        vis.resize(n);
    }
    void add(int a,int b){
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }
    void rec(int i,ll&c,int&d,vector<ll>&a){
        if(vis[i]) return;
        vis[i]=true;
        if(a[i]<c) c=a[i],d=i;
        for(auto j:e[i]) rec(j,c,d,a);
    }
};

class DForest {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m,x,y;
        in>>n>>m;
        vector<ll> a(n);
        for(auto&i:a) in>>i;
        graph g(n);
        fr(i,m){
            in>>x>>y;
            g.add(x,y);
        }
        ll ans=0;
        int t=-1;
        vector<bool> b(n);
        fr(i,n){
            ll c=INT_MAX;
            int d=-1;
            g.rec(i,c,d,a);
            if(d!=-1) ans+=c,b[d]=true,++t;
        }
        vector<int> e;
        fr(i,n) if(!b[i]) e.emplace_back(a[i]);
        sort(e.begin(),e.end());
        if(t==0){
            out<<0<<endl;
            return;
        }
        if(e.size()<t-1){
            out<<"Impossible"<<endl;
            return;
        }
        fr(i,t-1) ans+=e[i];
        out<<ans<<endl;
    }
};

int main() {
    DForest solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
  int a;
  int b;

  cin >> a;
  cin >> b;

  int x = (a + b) / 2;

  // 切上げ処理
  x = x + ((a + b) % 2);
  
  cout << x << endl;
}

Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
template<class T>
using V = vector<T>;
template<class T>
using VV = vector<vector<T>>;
typedef unsigned long long ULL;

void input();
void solve();

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}

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

int A, B;

void input() {
	cin >> A >> B;
}

void solve() {
	if (A == B)cout << 2 * A << "\n";
	else cout << 2 * max(A, B) - 1 << "\n";
}

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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int A;
	cin >> A;

	print(pow(A,3));

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

using ll = long long;
using pii = pair<int, int>;

#define INF (LLONG_MAX>>2)
int main()
{
    int V, E, R; cin >> V >> E >> R;
    vector<vector<pii>> g(V);
    for (int i = 0; i < E; i++) {
        int s, t, d; cin >> s >> t >> d;
        g[s].emplace_back(d, t);
    }

    vector<ll> dist(V, INF);
    vector<bool> done(V, false);
    priority_queue<pii, vector<pii>, greater<pii>> q;
    dist[R] = 0;
    q.emplace(0, R);
    while (!q.empty()) {
        auto s = q.top(); q.pop();
        const auto& v = s.second, d = s.first;
        if (d > dist[v]) continue;
        dist[v] = d;
        //done[v] = true;
        for (const auto& e : g[v]) {
            const auto& ev = e.second, ed = e.first;
            //if (done[ev]) continue;
            if (dist[v] + ed < dist[ev]) {
                dist[ev] = dist[v] + ed;
                q.emplace(dist[ev], ev);
            }
        }
    }

    for (const auto& d : dist) {
        if (d == INF) cout << "INF" << endl;
        else cout << d << endl;
    }
}



Measured memory_bytes: 13360
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
#define int ll

#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second

#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())

#define MOD (ll)(1e9+7)
#define INF (1e18)
#define EPS (1e-6)

#ifdef LOCALMEOW
#define debug(...) do{\
	cerr << __PRETTY_FUNCTION__ << " - " << __LINE__ <<\
	" : ("#__VA_ARGS__ << ") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T> void _OUT(T x) { cerr << x << "\n"; }
template<typename T,typename...I>
void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); }
#else
#define debug(...)
#endif
void INIT(){ ios::sync_with_stdio(false); cin.tie(0); }


int32_t main(){
	//code...
	int n, k; cin >> n >> k;
	vector<int> v(n), dp(n);
	for(auto &i:v) cin >> i;
	dp[0] = 0;
	For(i, 1, n - 1){
		dp[i] = INF;
		For(j, 1, min(k, i)){
			dp[i] = min(dp[i], dp[i-j] + abs(v[i] - v[i-j]));
		}
	}
	cout << dp[n-1]<<"\n";
	return 0;
}
























Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,sum=0,mul=1,i,j,k,flag =0,maxi=LONG_LONG_MIN,mini =LONG_LONG_MAX;
    map<ll,ll>mp;
    map<ll,ll> :: iterator  it;
    cin>>n;
    vector<ll>v;
    for(i = 0 ;i<n ;i++)
    {
        cin>>m;
        mp[m]++;
        v.push_back(m);
    }
    for(it=mp.begin();it!=mp.end() ;it++)
    {
        m = it->second;
        sum+= m*(m-1)/2;
    }
    for(i  = 0 ;i<n ;i++)
    {
        m=mp[v[i]];
        m--;
        cout<<sum-m<<endl;
    }
}



Measured memory_bytes: 11120
//Running median
//keeping max heap for first half and min heap for second half
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
# define M_PI           3.14159265358979323846
ll  P=1000000007;
ll M=P;
ll power(ll a, ll b) {
    if(b == 0) return 1;
    ll x = power(a, b / 2);
    x = (x * x)%M;
    if(b%2) x = (x*a)%M;
    return x;
}
ll arr[300001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t;
     memset(arr,0,sizeof(arr));
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>j;
        arr[j]++;
    }
   
    for(i=1;i<=n;i++)
    cout<<arr[i]<<endl;
    return 0;
}


Measured memory_bytes: 6004
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>

using namespace std;

struct result{
    bool ac;
    int wa;
};

void solve() {
    int n, m;
    cin >> n >> m;
    vector<result> res(n);
    for(int i = 0; i < n; i++){
        res[i] = result{false, 0};
    }
    for(int i = 0; i < m; i++){
        int tmpId;
        string tmpStr;
        cin >> tmpId >> tmpStr;
        tmpId--;
        if(tmpStr == "AC"){
            res[tmpId].ac = true;
        } else {
            if(!res[tmpId].ac){
                res[tmpId].wa++;
            }
        }
    }

    int account = 0;
    int wacount = 0;
    for(int i = 0; i < n; i++){
        if(res[i].ac){
            account++;
            wacount += res[i].wa;
        }
    }

    cout << account << " " << wacount << endl;
}

int main() {
    solve();
    return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int H, W, K;
int dp[110][10]; //dp[h][k]:=上からh,左からkの位置にたどり着くような阿弥陀の本数。

signed main() {
  cin >> H >> W >> K;

  m0(dp);
  dp[0][0] = 1;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int bit = 0; bit < 1 << (W - 1); bit++) {
        bool flag = true;
        for (int l = 0; l < W - 2; l++) {
          if ((bit >> l & 1) == 1 && (bit >> (l + 1) & 1) == 1) {
            flag = false;
          }
        }

        if (flag) {
          if (j >= 1 && (bit >> j - 1 & 1) == 1) {
            dp[i + 1][j - 1] += dp[i][j];
            dp[i + 1][j - 1] %= MOD;
          } else if (j <= W - 2 && (bit >> j & 1) == 1) {
            dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + 1] %= MOD;
          } else {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;
          }
        }
      }
    }
  }

  cout << dp[H][K - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	long long T;
	cin >> N >> T;
	long long t[N];
	unsigned long long sum = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> t[i];
	}
	for (int i = 0; i < N-1; ++i)
	{
		if(t[i + 1] - t[i] > T){
			sum += T;
		}else{
			sum += t[i + 1] - t[i];
		}
	}
	cout << sum + T << endl;
}

Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//const int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	N = s.size();
	vector<int>l(N+1);
	vector<int>r(N+1);
	for (int i = 1; i <= N; i++) {
		if (s[i - 1] == '<') {
			l[i] = l[i - 1] + 1;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (s[i] == '>') {
			r[i] = r[i + 1] + 1;
		}
	}
	vector<long long int>v(N + 1);
	for (int i = 0; i <= N; i++) {
		v[i] = max(l[i], r[i]);
	}
	cout << accumulate(v.begin(), v.end(), 0LL) << endl;
}

Measured memory_bytes: 8732
n = input()
number = int(n)
digit = int(len(n))
if digit == 6:
    print(90909)
elif digit == 5:
    print((number - 9999) + 909)
elif digit == 4:
    print(909)
elif digit == 3:
    print((number - 99) + 9)
elif digit == 2:
    print(9)
else:
    print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (b); i > (a); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada ios_base::sync_with_stdio(false)
#define int long long
int nCr(int n, int k)
{
    int C[n + 1][k + 1];
    int i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            //Base case
            if (j == 0 || j == i)
                C[i][j] = 1;
            else
            {
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
            }
        }
    }
    return C[n][k];
}

signed main()
{

    rootdada;
    int n,m;
    cin>>n>>m;
    priority_queue <int> pq;
    int x;
    rep(i,0,n)
    {
        cin>>x;
        pq.push(x);
    }
    while(m--)
    {
        if(pq.top()==0)
            break;
        int tmp=pq.top();
        pq.pop();
        tmp=tmp/2;
        pq.push(tmp);
    }
    int s=0;
    while(!pq.empty()){
        s+=pq.top();
        pq.pop();
    }
    cout<<s<<endl;

}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    cin>>s>>t;

    bool answer=false;

    for (int i=0;i<s.size();i++) {
        if(s==t){
            answer=true;
            break;
        }
        s = s.back()+s;
        s.pop_back();
    }

    if(answer){
            cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (X, A, B): (i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if B <= A  { "delicious" } else if B <= A + X { "safe" } else { "dangerous" };

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

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string s;
    getline(cin,s);
    
    int k;
    cin >> k;
    
    vector<string> strs;
    
    for (int i=0;i<s.size();i++)
        for (int j=1;j<=k&&i+j-1<s.size();j++)
            strs.push_back(s.substr(i,j));
    
    sort(strs.begin(),strs.end());
    unique(strs.begin(),strs.end());
    
    cout << strs[k-1] << '\n';
    return 0;
}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	ll x;
	ll p, y;
	p = 100;
	y = 0;
	cin >> x;
	while (p < x) {
		p += p/100;
		y++;
	}
	cout << y << ende;
  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<numeric>
#include<string>
#define REP(i,n) for(int (i)=0;(i) < (n);(i)++)
using namespace std;



int main(){
  int n;
  cin >> n;
  int s[n];
  REP(i,n) cin >> s[i];
  long int min = *min_element(s,s+n);
  long int max = *max_element(s,s+n);
  long long int sum = accumulate(s,s+n,0LL);
  printf("%ld %ld %lld\n",min,max,sum);
  return 0;
}


Measured memory_bytes: 3236
fn main() {
    let (k, s) = read();
    let s = solve(k, &s);
    write(s);
}

fn read() -> (i32, String) {
    let mut l = String::new();
    std::io::stdin().read_line(&mut l).ok();
    let k = l.trim().parse::<i32>().unwrap();

    let mut l = String::new();
    std::io::stdin().read_line(&mut l).ok();
    let s = l.trim().to_string();

    (k, s)
}

fn write(s: String) {
    println!("{}", s);
}

fn solve(k: i32, s: &str) -> String {
    if s.len() as i32 <= k {
        s.to_string()
    } else {
        let s1 = s[0..(k as usize)].to_string();
        let s2 = "...";
        s1 + s2
    }
}


Measured memory_bytes: 2160
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

char n[1010], a[4];

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=0;n[i];i++){
		if(n[i]=='N')a[0]=1;
		if(n[i]=='S')a[1]=1;
		if(n[i]=='W')a[2]=1;
		if(n[i]=='E')a[3]=1;
	}
	if(a[0]==a[1]&&a[2]==a[3])cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N){
    cin >> h[i];
  }
  int cnt = 0;
  rep(i,N){
    if(h[i] >= K)cnt++;
  }
  cout << cnt  <<endl;
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    println(problem076b(n, k))
}

fun problem076b(n: Int, k: Int): Int {
    var res = 1
    for (i in 0 until n) {
        if (res > k) {
            res += k
        } else {
            res *= 2
        }
    }
    return res
}

Measured memory_bytes: 31384
#include<bits/stdc++.h>
int n,i,j,f;
double x[1<<10],y[1<<10],X,Y,d,e,P=0.1;
int main(){
	auto dist=[](double a,double b){return a*a+b*b;};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf%lf",&x[i],&y[i]);
		X+=x[i];Y+=y[i];
	}
	X/=n;Y/=n;
	for(i=0;i<30000;i++){
		f=0;
		d=dist(X-x[0],Y-y[0]);
		for(j=1;j<n;j++){
			e=dist(X-x[j],Y-y[j]);
			if(d<e)d=e,f=j;
		}
		X+=(x[f]-X)*P;
		Y+=(y[f]-Y)*P;
		P*=0.999;
	}
	printf("%.10lf",sqrt(d));
}


Measured memory_bytes: 256