akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N; 
cin >> N; 
int A[5010] = {}, B[15010] = {}; 
for(int i = 0; i < 5000; i++){
A[i] = (i+1) * 6;
}
for(int i = 0; i < 2500; i++){
B[i * 4] = i * 6 + 2; 
B[i * 4 + 1] = i * 6 + 4; 
B[i * 4 + 2] = i * 12 + 3; 
B[i * 4 + 3] = i * 12 + 9;
}
for(int i = 5000; i < 7500; i++){
B[i * 2] = i * 6 - 14998; 
B[i * 2 + 1] = i * 6 - 14996; 
}

if(N == 3){
cout << 2 << " " << 5 << " " << 63; 
}
else if(N >= 4 && N <= 15000){
for(int i = 0; i < N / 2; i++){
cout << B[i * 2] << " " << B[i * 2 + 1] << " ";   
}
if(N % 2 == 0){
cout << endl; 
}
else if(N % 2 == 1){
cout << A[0] << endl; 
}
}
else if(N >= 15001 && N <= 20000){
for(int i = 0; i < 15000; i++){
cout << B[i] << " ";   
}
for(int i = 0; i < N - 15000; i++){
cout << A[i] << " ";   
}
}
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func abs(n int) int {
	if n >= 0 {
		return n
	}
	return -n
}

func main() {
	var n, l int
	fmt.Scan(&n, &l)

	minTaste := 999
	totalTaste := 0
	for i := 0; i < n; i++ {
		taste := l + i
		totalTaste += taste
		if abs(minTaste) > abs(taste) {
			minTaste = taste
		}
	}

	totalTaste -= minTaste
	fmt.Println(totalTaste)
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, w[110][110], CX[110], CY[110];
char p[210][210], q[4];
long long res = 1, Mod = 1000000007;
int main() {
	int i, j;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) {
		scanf("%s", p[i] + 1);
	}
	if (n % 2 == 1) {
		for (i = 1; i <= m / 2; i++) {
			if (p[n / 2 + 1][i] != p[n / 2 + 1][m + 1 - i]) {
				res = res * 2 % Mod;
				break;
			}
		}
	}
	if (m % 2 == 1) {
		for (i = 1; i <= n / 2; i++) {
			if (p[i][m / 2 + 1] != p[n + 1 - i][m / 2 + 1]) {
				res = res * 2 % Mod;
				break;
			}
		}
	}
	for (i = 1; i <= n / 2; i++) {
		for (j = 1; j <= m / 2; j++) {
			q[0] = p[i][j];
			q[1] = p[n + 1 - i][j];
			q[2] = p[i][m + 1 - j];
			q[3] = p[n + 1 - i][m + 1 - j];
			sort(q, q + 4);
			int s = 0;
			do {
				s++;
			} while (next_permutation(q, q + 4));
			w[i][j] = s;
			if (s == 24) {
				CX[i] = 1, CY[j] = 1;
				res = res * 12 % Mod;
			}
			else res = res*s%Mod;
		}
	}
	int c = 0;
	for (i = 1; i <= 100; i++)c += CX[i] + CY[i];
	if (c > 0)c--;
	for (i = 0; i < c; i++)res = res * 2 % Mod;
	printf("%lld\n", res);
	return 0;
}

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

int main(){
    long n;cin>>n;
    vector<long> a(n);
    vector<long> b(n);
    vector<long> c(n);
    for(long i=0;i<n;i++)cin>>a[i];
    for(long i=0;i<n;i++)cin>>b[i];
    for(long i=0;i<n;i++)cin>>c[i];
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    long res=0;
    for(long i=0;i<n;i++){
        auto aiter=lower_bound(a.begin(),a.end(),b[i]);
        auto citer=upper_bound(c.begin(),c.end(),b[i]);
        res += (aiter-a.begin())*(c.end()-citer);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(ll, x);
    Cin(ll, y);
    
    int ans = 0;
    do{
        ans ++;
        x *= 2;
    }
    while(x <= y);
    Cout(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i, n;
	scanf("%d",&n);
	int x[n];
	for(i=n;i>=1;i--)
		scanf("%d",&x[i]);
	for(i=1;i<=n;i++){
	    if(i>1) putchar(' ');
		printf("%d",x[i]);
	}
	printf("\n");
return(0);
}


Measured memory_bytes: 2072
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s;
ll d[100010][13];
ll md=1e9+7;
ll tac[10]={1,10,9,12,3,4};
int n;
int main()
{
	cin >>s;
	reverse(s.begin(),s.end());
	for (int i=0;i<13;i++)
	{
		if (s[0]!='?') d[0][i]=(i==s[0]-'0' ? 1 : 0);
		else d[0][i]=(i<10 ? 1 : 0);
	}
	n=s.size();
	for (int i=1;i<n;i++)
	{
		for (int j=0;j<13;j++)
		{
			if (s[i]!='?')
			{
				int x=j-(s[i]-'0')*tac[i%6];
				while (x<0) x+=13;
				x%=13;
				d[i][j]=d[i-1][x];
			}
			else
			{
				for (int k=0;k<10;k++)
				{
					int x=j-k*tac[i%6];
					while (x<0) x+=13;
					x%=13;
					d[i][j]+=d[i-1][x];
					d[i][j]%=md;
				}
			}
		}
	}
	cout <<d[n-1][5];
	return 0;
} 

Measured memory_bytes: 10624
#include <iostream>
#include <string>

using namespace std;

int main() {

	string s;
	cin >> s;

	int len = s.length() / 2;
	for (int i = len - 1; i >= 0; i--) {

		bool ok = true;
		for (int k = 0; k < i; k++) {
			if (s[k] != s[i + k]) {
				ok = false;
				break;
			}
		}

		if (ok) {
			cout << i * 2 << endl;
			break;
		}
	}

	return 0;
}


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

memo = [2] * (n+1)
memo[1] = 1

for k in range(2, n // 2 + 2):
    for i in range(2, n):
        if k * i > n:
            break
        memo[k*i] += 1

ans = 0
for i, memoi in enumerate(memo):
    ans += i * memoi
print(ans)



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

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


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

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
  return 0;
}

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


int main(){
    ll k; cin >> k;
    if(k%2==0){
        cout << "-1" << endl;
        return 0;
    }

    ll res = 1;
    ll x = 7;
    while(true){
        if(res == 2000000){
            cout << "-1" << endl;
            break;
        }
        x %= k;
        if(x == 0){
            cout << res << endl;
            break;
        }
        res++;
        x *= 10;
        x += 7;
    }
}

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


def solve(N: int, K: int, S: int):
    L = [len(list(v))for k,v in itertools.groupby(S)]
    LL = list(itertools.accumulate(L))
    isFirstZero = (S[0] == "0")
    NN = 2 * K + 1

    res = 0
    start_index = 0
    if isFirstZero:
        start_index = 1
        res = LL[min(2*K-1,len(LL)-1)]

    for i in range(start_index,len(LL),2):
        s = LL[min(i+NN-1,len(LL)-1)]
        if i > 0:
            s -= LL[i-1]
        res = max(res,s)

    print(res)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: int
    solve(N, K, S)

if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<class T>
void print(vector<T>& V, bool spaced = true) {
    string space;
    spaced ? space = " " : space = "";
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << space;
    }cout<< '\n';
}

template<class T>
void printendl(vector<T>& V) {
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << '\n';
    }
}

template<class T>
T gcd(T a, T b) {
    T r;
    while (b != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

template <class T>
T lcm (T a, T b) {
    return a / gcd(a, b) * b;
}

template<class T>
T Max(T a, T b) {
    return (a < b) ? b : a;
}

template<class T>
T Min(T a, T b) {
    return (a < b) ? a : b;
}

//str

bool isPalindrome(string str){
    
    int length = str.length();
 
    for (int i = 0; i < (length / 2); i++)
        if (str[i] != str[length - 1 - i])
            return false;
 
    return true;    
}

void reverseStr(string& str) 
{ 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
}



//Read through the messages at the end when you're done

int main() {

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


    
    int n, m; cin>> n>>m;
    cout << n*(n-1)/2 + m*(m-1)/2 << '\n';
    
    

    return 0;
}

    //Use long long da5eel rabbak!
    //Dont use endl;
    //DONT SUBMIT IZA UR NOT SURE WALLAHI BTENDAM
    //Dear Amine, just because it worked for the test cases doesnt necessarily mean it is correct.
    //Dear Amine, try it on ur own test cases iza ur not SURE
    //In case u didnt use long long, CHECK FOR POTENTIAL OVERFLOWS
    //DONT FORGET TO MOD EVERYTHING IZA U NEED TO MOD



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rg register
#define maxn 1200000
#define inf 0x7f7f7f7f
#define mod (ll)(1e9+7)
#pragma GCC optimize(3)
#pragma -fcrossjumping
#pragma -fdefer-pop
#pragma -fmerge-constans
#pragma -fthread-jumps
#pragma -floop-optimize
#pragma -fif-conversion
#pragma -fif-conversion2
#pragma -fdelayed-branch
#pragma -fguess-branch-probability
#pragma -fcprop-registers
#pragma -fforce-mem
#pragma -foptimize-sibling-calls
#pragma -fstrength-reduce
#pragma -fgcse
#pragma -fcse-follow-jumps
#pragma -frerun-cse-after-loop
#pragma -fdelete-null-pointer-checks
#pragma -fextensive-optimizations
#pragma -fregmove
#pragma -fschedule-insns
#pragma -fsched-interblock
#pragma -fcaller-saves
#pragma -fpeephole2
#pragma -freorder-blocks
#pragma -fstrict-aliasing
#pragma -funit-at-a-time
#pragma -falign-functions
#pragma -fcrossjumping
#pragma -finline-functions
#pragma -fweb
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
inline ll print(ll x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>=10)
    {
        print(x/10);
    }
    putchar(x%10+'0');
}
int n;
int h;
int a[maxn];
int tot;
int main()
{
    n=read();
    h=read();
    for(rg int i=1;i<=n;++i) a[i]=read();
    for(rg int i=1;i<=n;++i)
    { 
        if(a[i]>=h) ++tot;
    }
    cout<<tot;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int k;cin >> k;
	int n=s.size();
	vector<string> a;
	rep(i,n){
		for(int j=1;j<=k;++j){
			if(i+j>n) continue;
			a.pb(s.substr(i,j));
		}
	}
	sort(a.begin(),a.end());
	a.pb("");
	int j=1;
	rep(i,a.size()){
		if(j==k){
			cout << a.at(i) << endl;
			return 0;
		}
		if(a.at(i)!=a.at(i+1)) j++;
	}
}

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

struct edge{
    ll v,w;
};

int main(){
    ll n;
    cin>>n;
    vector<vector<edge>> adj(n);
    ll a,b,c;
    rep(i,n-1){
        cin>>a>>b>>c;
        a--,b--;
        adj[a].push_back((edge){b,c});
        adj[b].push_back((edge){a,c});
    }
    vector<ll> col(n,-1);
    queue<ll> q;
    q.push(0);
    col[0]=0;
    while(!q.empty()){
        ll now=q.front();
        q.pop();
        rep(i,adj[now].size()){
            ll nv=adj[now][i].v,nw=adj[now][i].w;
            if(col[nv]==-1){
                if(nw%2) col[nv]=!(bool)col[now];
                else col[nv]=col[now];
                q.push(nv);
            }
        }
    }
    rep(i,n) cout<<col[i]<<endl;
    return 0;
}

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

typedef long long ll;

ll N, D;
vector<ll> T;
vector<ll> Pos, X;
ll Q;

int main() {
  cin >> N >> D;
  T.resize(N);
  for (ll i = 0; i < N; ++i) cin >> T[i];
  Pos.resize(N + 1);
  Pos[0] = D;
  for (ll i = 0; i < N; ++i) Pos[i + 1] = min(Pos[i], abs(Pos[i] - T[i]));
  X.resize(N + 1);
  X[N] = 1;
  for (ll i = N - 1; i >= 0; --i)
    X[i] = X[i + 1] <= T[i] / 2 ? X[i + 1] : X[i + 1] + T[i];
  cin >> Q;
  for (ll i = 0; i < Q; ++i) {
    ll q;
    cin >> q;
    --q;
    cout << (Pos[q] >= X[q + 1] ? "YES" : "NO") << endl;
  }
  return 0;
}


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

using namespace std;

int keta(int number){
    int K=0;
    while(number>0){
        number/=10;
        K++;
    }
    return K;
}

int main(void){
    int N;
    cin>>N;
    int count=0;
    for(int i=1;i<=N;i++){
        if(keta(i)%2!=0) count++;
    }
    cout<<count<<endl;
    return 0;
}

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

int main() {
    string s,t;
    int ans = 0;
    cin >> s >> t;
    rep(i, s.size()){
        if(s.at(i)!=t.at(i)){
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3924
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n,m=inp()
l=[0]*m
for _ in range(n):
    a=linp()
    for i in range(1,a[0]+1):
        l[a[i]-1]+=1

ans=0
for x in l:
    if x==n:ans+=1
print(ans)

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;


int main(){
	int n;
	cin>>n;
	ll ans=1,mod=1e9+7;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	cout<<ans;
}





Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
string s,s1,s2;
int a,b;
int main(){
	cin>>s>>s1;
	cin>>a>>b;
	cin>>s2;
	if(s2==s) a--;
	if(s2==s1) b--;
	cout<<a<<" "<<b<<endl;
	return 0;
}

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

int main(){
    int n, k; cin >> n >> k;
    set<int> st;
    for(int i = 0; i < k; i++){
        int tmp;
        cin >> tmp;
        st.insert(tmp);
    }
    int ans;
    for(int i = n; i <= 99999; i++){
        int mny = i;
        bool ok = true;
        while(mny > 0){
            if(st.count(mny % 10)){
                ok = false;
                break;
            }
            mny /= 10;
        }
        if(ok){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long long adjacent_four = 0, even = 0;
	for (long long i = 0; i < N; i++) {
		if (A.at(i) % 2 == 0) {
			if ((A.at(i) / 2) % 2 == 0) adjacent_four++;
			else even++;
		}
	}
	if (adjacent_four >= N / 2) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (adjacent_four + even / 2 >= N / 2) {
		cout << "Yes" << endl;
		return 0;
	}
	else cout << "No" << endl;
}

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

int main() {
    int n, k, cnt = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h >= k) {
            cnt++;
        }        
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  h=min(2*q,h);
  s=min(2*h,s);
  cout<<n/2*min(2*s,d)+n%2*s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    using ll = long long;
    using Pi = pair < int, int >;
     
    constexpr int INF = (1 << 30) - 1;
    constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
    constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
     
    template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
    template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }
     
    int N, K;
    int rui[3005][3005] = {};
     
    void checkR ( int x, int y )
    {
    	rui[y][x]++;
    	rui[y + K][x]--;
    	rui[y][x + K]--;
    	rui[y + K][x + K]++;
    }
     
    int main()
    {
    	
    	cin >> N >> K;
    	for ( int i = 0; i < N; i++ ) {
    		int x, y;
            char c;
    		cin >> x >> y >> c;
    		if ( c == 'B' ) {
    			x += K;
    		}
    		x %= (K * 2), y %= (K * 2);
    		
    		checkR(x, y);
    		checkR((x + K) % (K * 2), (y + K) % (K * 2));
    	}
    	
    	for ( int i = 0; i < K * 3; i++ ) {
    		for ( int j = 0; j < K * 3; j++ ) {
    			if ( i > 0 ) rui[i][j] += rui[i - 1][j];
    			if ( j > 0 ) rui[i][j] += rui[i][j - 1];
    			if ( i > 0 && j > 0 ) rui[i][j] -= rui[i - 1][j - 1];
    		}
    	}
    	
    	int maxv = 0;
    	for ( int i = 0; i < K * 2; i++ ) {
    		for ( int j = 0; j < K * 2; j++ ) {
    			int val = rui[i][j];
    			if ( i < K ) {
    				if ( j < K ) val += rui[i + K * 2][j] + rui[i][j + K * 2];
    				else val += rui[i + K * 2][j];
    			} else {
    				if ( j < K ) val += rui[i][j + K * 2];
    			}
    			maxv = max(maxv, val);	
    		}
    	}
    	
    	cout << maxv << endl;
     
    	return ( 0 );
    }

Measured memory_bytes: 35456
#include <cstdio>
#include <cstring>

using namespace std;

int c[26];
char A[200010];
int main() {
  scanf("%s",A);
  long long n=strlen(A);
  for(int i=0;i<n;++i) {
    c[A[i]-'a']++;
  }
  long long dame = 0;
  for(int i=0;i<26;++i) {
    dame += 1ll*c[i]*(c[i]-1)/2;
  }
  printf("%lld\n", 1ll + n*(n-1)/2 - dame);
  return 0;
}


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

int main(void)
{
    int a, b;
    int num_a = 0, num_b = 0;
    char buf_a[12], buf_b[12];

    scanf("%d%d", &a, &b);

    for(int i = 0; i < b; i++){
        num_a = num_a * 10 + a;
    }

    for(int j = 0; j < a; j++){
        num_b = num_b * 10 + b;
    }

    snprintf(buf_a, 12, "%d", num_a);
    snprintf(buf_b, 12, "%d", num_b);

    if (strcmp(buf_a, buf_b) <= 0 ){
        printf("%d", num_a);
    }
    else if (strcmp(buf_a, buf_b) > 0 ){
        printf("%d", num_b);
    }

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)

{

int a,b,d,r=0;

double f=0.0;

printf("");

scanf("%d",&a);

scanf("%d",&b);

d = a / b;

r = a % b;

f = (double)a / b;

printf("%d %d %lf\n",d,r,f);

return 0;

}

Measured memory_bytes: 636
#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 power(int x, int p)
{
    if (p == 0)
        return 1;
    int y = power(x, p / 2);
    y *= y;

    if (p % 2 == 0)
        return y;
    y *= x;

    return y;
}

signed main()
{

    rootdada;
    int n;
    cin >> n;
    int e = n / 2;
    int o = n - e;
    double p = (double)o / n;
    cout << fixed << setprecision(10) << p << endl;
}

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

const ll mod = 1000000007;
const int INF = 1001001001;

struct UnionFind{
    vector<int> par;
    vector<int> d;
    // the element is negative only if it is a parent
    UnionFind(int n) : d(n, -1){}
    // find the root of the element 
    int root(int x){
        if(d[x] < 0) return x;
        else{
            return d[x] = root(d[x]);
        }
    }
    // attach the smaller subtree to the larger one
    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        else{
            if(d[x] > d[y]) swap(x, y);
            d[x] += d[y];
            d[y] = x;
            return true;
        }
    }
    // judge whether two elements have the same parent
    bool same(int x, int y){
        return root(x) == root(y);
    }
    // the size of a tree to which an element belongs to 
    int size(int x){
        return -d[root(x)];
    }
};
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	UnionFind tree(n);
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		a--; b--;
		tree.unite(a, b);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans = max(ans, tree.size(i));
	}
	cout << ans << endl;
} 

Measured memory_bytes: 3968
package main

import "fmt"

func main() {
	w := []string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	var s string
	fmt.Scan(&s)
  for i, v := range w{
		if s == v{
			fmt.Println(7-i)
			return
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807
#define array(N, t) (t*)calloc(N, sizeof(t))

int main() {
  int X;

  scanf("%d", &X);

  if (X >= 30) {
    printf("%s\n", "Yes");
  } else {
    printf("%s\n", "No");
  }

  return 0;
}


Measured memory_bytes: 1660
numbers =input()
total = 0
for i in range(2**3):
    total = int(numbers[0])
    string = '{0}'.format(numbers[0])
    for j in range(3):
        if i & 2**j:
            total += int(numbers[j+1])
            string += '+{0}'.format(numbers[j+1])
        else:
            total -= int(numbers[j+1])
            string += '-{0}'.format(numbers[j+1])
    if total == 7:
        string += '=7'
        print(string)
        exit(0)
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lowbit(x) ((x) & (-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x) * (x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
char s[maxn], arr[4] = "RGB";
int cnt[3][maxn];
int main(void) {
#ifdef ljxtt
    freopen("data.in", "r", stdin);
#endif
    int n;
    cin >> n >> s + 1;
    mem(cnt, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            if (s[i] == arr[j])
                cnt[j][i] = 1;
            else
                cnt[j][i] = 0;
        }
    } 
    for (int i = n; i >= 1; i--)
        for (int j = 0; j < 3; j++) 
            cnt[j][i] += cnt[j][i + 1];

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (s[i] == s[j]) continue;
            int inx = 3;
            for (int k = 0; k < 3; k++)
                if (s[i] == arr[k]) inx -= k;
            for (int k = 0; k < 3; k++)
                if (s[j] == arr[k]) inx -= k;
            ans += cnt[inx][j];
            if (j + (j - i) <= n && s[j + (j - i)] == arr[inx]) ans--;
            // cout << i << " " << j << " " << cnt[inx][j] << " " << ans << endl;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4944
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    string S;
    int n;
    int m = 2019;

    cin >> S;

    n = S.size();
    reverse(S.begin(), S.end());
    int x = 1, tot = 0;
    vector<int> cnt(m);
    ll ans = 0;
    rep(i,n) {
        cnt[tot]++;
        tot += (S[i]-'0')*x;
        tot %= m;
        ans += cnt[tot];
        x = x*10%m;
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

int main()
{ int x,h,m;
cin>>x;
h=x/3600;
cout<<h<<":";
x=x-h*3600;
m=x/60;
cout<<m<<":";
x=x-m*60;
cout<<x<<endl;


    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
ll a[N];
int main(){
	int n;
	ll x,ans=0;
	scanf("%d%lld",&n,&x);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<n;i++){
		if(a[i]+a[i+1]<=x) continue;
		else if(a[i]<=x){
			ll tmp=(a[i]+a[i+1]-x);
			ans+=tmp;
			a[i+1]-=tmp;
		}
		else {
			ll tmp=a[i]+a[i+1]-x;
			a[i+1]=0;
			ans+=tmp;
		}
	}
	printf("%lld\n",ans); 
	return 0;
}

Measured memory_bytes: 4540
import java.util.*;
import java.io.*;
import java.lang.*;

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

        if (a<9 && b<9)
            System.out.println("Yay!");
        else
            System.out.println(":(");
    }
}


Measured memory_bytes: 35616
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    rep(i, n){
        int x;
        cin >> x;
        pq.push(x);
    }

    while(m--){
        int x = pq.top();
        pq.pop();
        pq.push(x / 2);
    }

    int ans = 0;
    rep(i, n){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    if(A>B){
        swap(A, B);
    }
    B -= A;

    FOR(plus, 0, N){
        ll minus = N-1-plus;
        
        ll right = D * plus - C * minus;
        ll left  = C * plus - D * minus;
        
        if(left<=B && B<=right){
            p_yes();
            return 0;
        }
    }   

    p_no();
    return 0;
}

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

// sort A and B w.r.t. B from s-th component to t-th component
// Note that s and t are 0-indexed, and input N-1 for N-length array
void merge_sort(ll *A, ll* B,int s, int t)
{
  if (s == t) {
    return;
  }
  int k = (s+t)/2;
  merge_sort(A,B,s,k);
  merge_sort(A,B,k+1,t);
  int a = s,b = k+1,i=0;
  ll *tmpA,*tmpB;
  tmpA = (ll*)malloc(sizeof(ll)*(t-s+1));
  tmpB = (ll*)malloc(sizeof(ll)*(t-s+1));
  while( a <= k && b <= t){
    if(B[a] < B[b]){
      tmpA[i] = A[a];
      tmpB[i] = B[a];
      i++,a++;
    } else {
      tmpA[i] = A[b];
      tmpB[i] = B[b];
      i++,b++;
    }
  }
  while(a <= k){
      tmpA[i] = A[a];
      tmpB[i] = B[a];
      a++,i++;
  }
  while(b <= t){
      tmpA[i] = A[b];
      tmpB[i] = B[b];
      b++,i++;
  }
  for(int i=0; i<=t-s; i++){
    A[s+i] = tmpA[i];
    B[s+i] = tmpB[i];
  }
  free(tmpA);
  free(tmpB);
}


int main()
{
  ll N;
  cin >> N;
  ll *A,*B;
  A = (ll*)malloc(sizeof(ll)*N);
  B = (ll*)malloc(sizeof(ll)*N);
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
  }
  merge_sort(A,B,0,N-1);
  ll sum_A = 0;
  for(int i=0;i<N;i++){
    sum_A += A[i];
    if (sum_A > B[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 6668
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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 T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N, M;
  cin >> N >> M;
  set<int> from_start;
  set<int> to_goal;
  rep(i, 0, M) {
    int a, b;
    cin >> a >> b;
    if (a == 1) from_start.insert(b);
    else if (b == N) to_goal.insert(a);
  }

  bool f = false;
  fore(x, from_start) if (to_goal.count(x)) f = true;
  POSS(f);
}

Measured memory_bytes: 9600
package main
import (
  // "bufio"
  // "os"
  "strconv"
  // "strings"
  "fmt"
  "math"
  // "sort"
)

// 行単位で読み込む場合
// var sc = bufio.NewScanner(os.Stdin)

func main() {
  var a, b string
  fmt.Scan(&a, &b)

  num, _ := strconv.ParseFloat(a + b, 64)
  sqrt := math.Trunc(math.Sqrt(num))

  if sqrt * sqrt == num {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
t[9999],W,N,a,b,i;main(c){for(;scanf("%d%d",&W,&N)-1;printf("Case %d:\n%d\n%d\n",c++,t[W],i),bzero(t,W*9)){for(;N--&&scanf("%d,%d",&a,&b);)for(i=W;i>=b;)t[i]=fmax(t[i--],t[i-b]+a);for(i=0;t[++i]-t[W];i);}}

Measured memory_bytes: 0
def main():
    a, b = map(int, input().split())

    h = 0
    old_h = 0
    for i in range(1, 1000):
        h += i

        if (h - old_h) == (b - a):
            print(h - b)
            exit()

        old_h = h

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
s = raw_input()
p = raw_input()
ss = s + s
ps = p[0]
ret = 'No'
for i in range(len(s)):
    if s[i] == ps:
        c = 0
        for k in range(len(p)):
            if ss[i+k] == p[k]:
                c = c + 1
        if c == len(p):
            ret = 'Yes'
print ret

Measured memory_bytes: 4216
import sys
from collections import deque


def main():
    N, p, q, *AB = map(int, sys.stdin.buffer.read().split())
    p -= 1
    q -= 1

    G = [[] for _ in range(N)]
    for a, b in zip(*[iter(AB)] * 2):
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)

    if len(G[p]) == 1 and G[p][0] == q:
        print(0)
        return

    dist1 = [-1] * N
    dist1[p] = 0
    queue = deque([p])
    while queue:
        v = queue.popleft()
        for nv in G[v]:
            if dist1[nv] == -1:
                dist1[nv] = dist1[v] + 1
                queue.append(nv)

    dist2 = [-1] * N
    dist2[q] = 0
    queue = deque([q])
    while queue:
        v = queue.popleft()
        for nv in G[v]:
            if dist2[nv] == -1:
                dist2[nv] = dist2[v] + 1
                queue.append(nv)

    max_d = 0
    for d1, d2 in zip(dist1, dist2):
        if d1 < d2 and max_d < d2:
            max_d = d2

    print(max_d - 1)
    return


if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    string a, b;
    cin >> a >> b;

    int n = a.size(), m = b.size();
    if(n > m){
        cout << "GREATER" << endl;
    }else if(n < m){
        cout << "LESS" << endl;
    }else{
        rep(i, n){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }

        cout << "EQUAL" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int a[3], ans;
	scanf("%d %d %d", &a[0], &a[1], &a[2]);

	sort(a, a+3);

	if((a[2]-a[0])%2==(a[2]-a[1])%2){
		ans=(2*a[2]-a[0]-a[1])/2;
	}else{
		ans=(2*a[2]-a[0]-a[1]+3)/2;
	}

	printf("%d\n", ans);

	return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#define rep(i,N) for(int i = 0; i<N,i++)
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

llong N;

bool SHICHIGOSAN(string s) {

	bool a = false;
	bool b = false;
	bool c = false;
	bool d = true;

	int k = s.length();

	for (int i = 0; i < k; i++) {
		if (s[i] == '3') a = true;
		else if (s[i] == '5') b = true;
		else if (s[i] == '7') c = true;
		else d = false;
	}

	return (a && b) && (c && d);
}

string DFS(string s) {
	int l = s.length();
	for (int i = l - 1; i >= 0; i--) {
		if (s[i] == '3') {
			s[i] = '5';
			break;
		}

		else if (s[i] == '5') {
			s[i] = '7';
				break;
		}

		else {
			s[i] = '3';

			if (i == 0) {
				s.insert(0, "3");
			}
		}
	}

	return s;
}

int main(void) {
	cin >> N;
	llong ans = 0;
	string s = "3";
	for (;;) {
		if (SHICHIGOSAN(s)) ans++;

		s = DFS(s);
		
		
		llong a = 0;
		llong b = 1;

		for (int i = s.length() - 1; i >= 0; i--) {
			a += (s[i] - '0') * b;
			b *= 10;
		}

		if (a > N) break;


	}

	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 3e3+5, inf = 1e9+7;
int n, k, i, j;
int A[N];
double dp[N][N], p;

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n;
    dp[0][0] = 1;
    rep(i, 1, n+1){
        cin>>p;
        rep(j, 0, i+1) {
            if(j) dp[i][j] = dp[i-1][j-1]*p;
            dp[i][j] += dp[i-1][j]*(1-p);
        }
    }
    double res=0;
    rep(i, 0, n+1) if(i*2>=n) res += dp[n][i];
    cout<<fixed<<setprecision(10)<<res;
}

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

#define MAX_H 1000
#define MAX_W 1000
#define MOD 1000000007

int h, w;
char a[MAX_H][MAX_W];

int dp[MAX_H][MAX_W];

int main() {
  std::cin >> h >> w;
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      std::cin >> a[i][j];
      if(a[i][j] == '#') dp[i][j] = -1;
    }
  }

  dp[0][0] = 1;
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(dp[i][j] == -1) continue;
      if(i - 1 >= 0 && dp[i - 1][j] != -1) {
        dp[i][j] += dp[i - 1][j];
        dp[i][j] %= MOD;
      }
      if(j - 1 >= 0 && dp[i][j - 1] != -1) {
        dp[i][j] += dp[i][j - 1];
        dp[i][j] %= MOD;
      }
    }
  }

  std::cout << dp[h - 1][w - 1] << std::endl;
}


Measured memory_bytes: 5120
k, t = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
loop do
  if a.size == 1 && a[0] != 0
    puts a[0] - 1
    exit
  end
  if a.uniq.size == 1
    puts 0
    exit
  end

  a.sort!
  a[-1] -= a[0]
  a.delete_at(0)
end


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

int N;
double T, A;
double H[100010];

int main()
{
	cin >> N >> T >> A;
	for (int i = 0; i < N; ++i) {
		cin >> H[i];
	}
	int index = 0;
	double mn = 1e7;
	for (int i = 0; i < N; ++i) {
		auto x = T - H[i] * 0.006;
		auto d = abs(x - A);
		if (d < mn) {
			index = i;
			mn = d;
		}
	}
	cout << (index + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <atcoder/all>
#define FOR(i,k,n) for(ll i=(k);i<(ll)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)
 
using namespace std;
using namespace std::string_literals;
using namespace atcoder;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  UnionFind uf(n);
  vector<tuple<int,int,int>> vt;
  REP(i,n) {
    int x,y;
    cin>>x>>y;
    --x;--y;
    vt.emplace_back(x,y,i);
  }
  sort(ALL(vt));
  set<tuple<int,int>> st;
  REP(i,n) {
    auto [x,y,j] = vt[i];
    auto itr = st.lower_bound(make_tuple(y,0));
    if (itr != begin(st)) {
      for (auto itr2 = begin(st); itr2 != itr;) {
        auto [y2,j2] = *itr2;
        uf.merge(j, j2);
        if (itr2 != begin(st)) {
          itr2 = st.erase(itr2);
        } else {
          ++itr2;
        }
      }
    } else {
      st.emplace(y, j);
    }
  }
  map<int,int> cnt;
  REP(i,n) {
    ++cnt[uf.root(i)];
  }
  REP(i,n) {
    cout<<cnt[uf.root(i)]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 11096
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    double r;
    cin >> r;
    double pi = 3.14159265359;
    double a = r*r*pi;
    double b = 2*pi*r;
    printf("%.5lf %.5lf\n",a,b);
}


Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int p = scan.nextInt();
		int q = scan.nextInt();
		int r = scan.nextInt();

		System.out.println(p + q + r - Math.max(Math.max(p, q), r));
	}
}

Measured memory_bytes: 23764
while True:
	n = int(input())
	if n == 0: break
	s, vmin, vmax = 0, 1001, -1
	for i in range(n):
		a = int(input())
		vmin = min(vmin, a)
		vmax = max(vmax, a)
		s += a
	print((s-vmin-vmax)//(n-2))


Measured memory_bytes: 5604
h,w,k = map(int,input().split())
mod = 10**9+7
g = [[0]*3 for _ in range(w)]
for bit in range(1<<(w-1)):
  f = 0
  for i in range(w-2):
    if bit & (3<<i) == 3<<i:
      f = 1
      break
  if f:
    continue
  neu = [1]*w
  for i in range(w-1):
    if bit&(1<<i):
      g[i][2] += 1
      g[i+1][0] += 1
      neu[i] = 0; neu[i+1] = 0
    g[i][1] += neu[i]
  g[-1][1] += neu[-1]
g = [[0]*3] + g + [[0]*3]
ol = [0]*(w+2)
ol[k] = 1
for _ in range(h):
  new = [0]*(w+2)
  for i in range(1,w+1):
    new[i] = (ol[i-1]*g[i-1][2] + ol[i]*g[i][1] + ol[i+1]*g[i+1][0])%mod
  ol = new
print(ol[1])
  

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    if((*(lli*)b - *(lli*)a) > 0) {
        return 1;
    } else if((*(lli*)b - *(lli*)a) < 0) {
        return -1;
    }
    return 0;
}

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a<c && c<b) || (b<c && c<a)) {
        printf("Yes");
    } else {
        printf("No");
    }
    return 0;
}


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

using namespace std;

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vpi V(n);
  vi S(2*n);
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    V[i] = pi(a-b,a+b);
    S[2*i] = a-b;
    S[2*i+1] = a+b;
  }
  sort(V.begin(), V.end());
  sort(S.begin(), S.end());
  int sz = unique(S.begin(), S.end()) - S.begin();
  map<ll, ll> M;
  for (int i = 0; i < sz; ++i) M[S[i]] = i+1;
  vi D(sz+1, -1);
  for (int i = 0; i < n; ++i) {
    D[M[V[i].second]] = max(D[M[V[i].second]], M[V[i].first]);
  }
  vi R(sz+1, 0);
  for (int i = 1; i <= sz; ++i) {
    R[i] = R[i-1];
    if (D[i] != -1) {
      R[i] = max(R[i], R[D[i]] + 1);
    }
  }
  cout << R[sz] << endl;
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll Mod = 1000000007;
ll INF = 1e15;
int N,M;
ll L;
ll Graph[320][320];
ll res[320][320];
ll ans[320][320];

void dijkstra() {
  for (int i = 0; i < N; i++) {
    ll dist[N];
    for (int j = 0; j < N; j++) {
      dist[j] = INF;
    }
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> Q;
    Q.push(make_pair(0,i));
    dist[i] = 0;
    while (!Q.empty()) {
      P p = Q.top();
      Q.pop();
      if (p.F > dist[p.S]) {
        continue;
      }
      for (int j = 0; j < N; j++) {
        if (j == p.S) {
          continue;
        }
        if (Graph[p.S][j] + p.F < dist[j]) {
          dist[j] = Graph[p.S][j] + p.F;
          Q.push(make_pair(dist[j],j));
        }
      }
    }
    for (int j = 0; j < N; j++) {
      res[i][j] = dist[j];
    }
  }
}

void Distance() {
  for (int i = 0; i < N; i++) {
    ans[i][i] = 0;
    vector<int> lis;
    vector<int> lis2;
    lis.push_back(i);
    for (int j = 0; !lis.empty(); j++) {
      for (int k = 0; k < (int)lis.size(); k++) {
        for (int l = 0; l < N; l++) {
          if (res[lis[k]][l] <= L) {
            if (ans[i][l] == -1) {
              ans[i][l] = j;
              lis2.push_back(l);
            }
          }
        }
      }
      lis = lis2;
      lis2.clear();
    }
  }
}

int main() {
  cin >> N >> M >> L;
  for (int i = 0; i < 320; i++) {
    for (int j = 0; j < 320; j++) {
      Graph[i][j] = INF;
      res[i][j] = INF;
      ans[i][j] = -1;
    }
  }
  for (int i = 0; i < M; i++) {
    int A,B;
    ll C;
    cin >> A >> B >> C;
    A--; B--;
    if (C <= L) {
      Graph[A][B] = C;
      Graph[B][A] = C;
    }
  }

  dijkstra();
  Distance();

  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int s,t;
    cin >> s >> t;
    s--; t--;
    cout << ans[s][t] << endl; 
  }
  
  return 0;
}

Measured memory_bytes: 6552
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


int n, d[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	
	sort(d, d+n);
	
	cout << d[n/2+n%2] - d[n/2-!(n%2)] << endl;
	
	return 0;
}

Measured memory_bytes: 640
n=int(input())
s=input()

r=set()
g=set()
b=set()

for i in range(n):
    if s[i]=="R":
        r.add(i+1)
    elif s[i]=="G":
        g.add(i+1)
    else:
        b.add(i+1)

lenr=len(r)
leng=len(g)
lenb=len(b)

isum=0
for ir in r:
    for ig in g:
        if (ir+ig)/2 in b: 
            isum=isum+1
for ir in r:
    for ib in b:
        if (ir+ib)/2  in g: 
            isum=isum+1
for ig in g:
    for ib in b:
        if (ig+ib)/2  in r: 
            isum=isum+1

isum=lenr*leng*lenb-isum
                
print(isum)

Measured memory_bytes: 9680
import math
N,K=map(int, input().split())
h = list(map(int, input().split())) 

dp = [float('inf')] * N
dp[0] = 0

for i in range(N):
    for j in range(1,K+1):
        if (i+j < N):
            dp[i+j]=min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))

print(dp[N-1])


Measured memory_bytes: 55264
#include <iostream>
#include <string.h>
using namespace std;
int main(){
  string left="zaqxswcdevfrbgt";
  string right="nhymjukilop";
  string input;
  while (1){
    int count=-1;
    int boo=0;
    cin>>input;
    for (int i=0;i<input.length();i++){
      for (int j=0;j<right.length();j++){
	if (input[i]==right[j]){
	  if (boo!=1)
	    count++;
	  boo=1;
	  break;
	}
      }
      for (int l=0;l<left.length();l++){
	if (input[i]==left[l]){
	  if (boo!=2)
	    count++;
	  boo=2;
	  break;
	}
      }
    }
    if (input=="#"){
      break;
    }
    cout<<count<<endl;
  }
  return 0;
} 

Measured memory_bytes: 1188