akhauriyash/Code-Regression huggingface dataset:
using Yorukatsu045.Questions;
using Yorukatsu045.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu045.Questions
{
    /// <summary>
    /// ARC059 D
    /// </summary>
    public class QuestionE : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();

            for (int begin = 0; begin < s.Length - 1; begin++)
            {
                if (s[begin] == s[begin + 1])
                {
                    yield return $"{begin + 1} {begin + 2}";
                    yield break;
                }
                else if (begin + 2 < s.Length && s[begin] == s[begin + 2])
                {
                    yield return $"{begin + 1} {begin + 3}";
                    yield break;
                }
            }

            yield return "-1 -1";
        }
    }
}


namespace Yorukatsu045
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionE();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu045.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu045.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion


Measured memory_bytes: 13280
import Data.Bits ((.&.))
import Data.Array.IArray(Array,listArray,(!))

main = do
    n <- read <$> getLine
    list <- (fmap read . words) <$> getLine
    putStrLn $ show $ solve n 1 1 0 (listArray (1,n) list) 0

solve :: Int -> Int -> Int -> Int -> Array Int Int -> Int -> Int
solve lim l r bsum numls ac
    | l>lim = ac
    | length numls>=r = do
        let target = numls!r
        case bsum.&.target==0 of
            True -> solve lim l (r+1) (bsum+target) numls (ac+r-l+1)
            False -> shiftL
    | otherwise = shiftL
        where
            shiftL = solve lim (l+1) r (bsum-(numls!l)) numls ac


Measured memory_bytes: 88316
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
class point {
public:
	int np;
	ll num;
};
bool compare(const point a, const point b) {
	return a.num > b.num;
}
int main() {
	int n;
	cin >> n;
	vector<ll> ans(n + 1);
	vector<point> line(n + 1);
	for (int i = 0; i < n; ++i) {
		cin >> line[i].num;
		line[i].np = i + 1;
		ans[i + 1] = 0;
	}
	line[n].num = 0;
	line[n].np = n * 2;
	sort(line.begin(), line.end(), compare);
	int minp = line[0].np;
	for (ll i = 0; i < n; ++i) {
		minp = min(minp, line[i].np);
		if (line[i].num != line[i + 1].num) {
			ans[minp] += (i + 1)*(line[i].num - line[i + 1].num);
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

int n,prvi,drugi;
int niz[100001];
int valu[100001];
int main () {
	
	cin >>n;
	for(int i=0;i<n;i++) {
		cin >>niz[i];
	}
	valu[0] = 0;
	valu[1] = abs(niz[1] - niz[0]);
	for(int i=2;i<n;i++) {
		prvi = abs(niz[i] - niz[i - 1]) + valu[i - 1];
		drugi = abs(niz[i] - niz[i - 2]) + valu[i - 2];
		valu[i] = min(prvi, drugi);
	}
	cout <<valu[n - 1];
	return 0;
}

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

using namespace std;
typedef pair<int, int> pii;
typedef pair<int, long double> pild;
typedef pair<long double, int> pldi;

void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//素数判定
//O(√n)
bool isPrime(int n) {
	for (int i = 2; i <= floor(sqrt(n)); i++) {
		if (n%i == 0)return false;
	}
	return true;
}

//n未満の自然数のでのエラトステネスの篩
//arr[n]=true -> 素数
//O(nlog(logn)) , 実質O(n)
bool* eratosthenes(int n) {
	bool* array = new bool[n];
	for (int i = 0; i < n; i++)array[i] = true;
	for (int i = 2; i < n; i++) {
		if (!array[i])continue;
		int t = 2*i;
		while (t < n) {
			array[t] = false;
			t += i;
		}
	}
	return array;
}

long int M = 1000000007;

void solve() {
	int N;
	cin >> N;
	bool* arr = eratosthenes(N+1);
	long int ans = 1;
	for (int p = N; p >= 2; p--) {   //各素数p
		if (!arr[p])continue;
		long int c = 0;   //pで何回割れる?
		long int t = p;
		while (t <= N) {
			c += floor((double)N/t);
			t *= p;
		}
		c++;
		t = ans;
		for (int cc = 1; cc < c; cc++) {
			ans = (ans + t) % M;
		}
	}
	cout << ans << endl;
	delete arr;
	return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9 + 7;

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


Measured memory_bytes: 3660
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+30;
int n, id=0, cnt=0, Next[maxn], in[maxn], out[maxn], son[maxn]={0}, zhong[maxn];
int msize = 0x3f3f3f3f, mid;
LL ans = 0;
struct node{int e, w, next;}edge[maxn<<1];
void add_edge(int u, int v, int w)
{
    edge[cnt] = {v, w, Next[u]};
    Next[u] = cnt++;
    edge[cnt] = {u, w, Next[v]};
    Next[v] = cnt++;
}
void dfs(int cur, int pre, int w)
{
    in[cur] = ++id;
    int imax = 0;
    for(int i=Next[cur]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].e;
        if(v == pre) continue;
        dfs(v, cur, edge[i].w);
        son[cur] += son[v] + 1;
        imax = max(imax, son[v]+1);
    }
    out[cur] = id;
    int imin = min(out[cur]-in[cur]+1, n-out[cur]+in[cur]-1);
    ans = ans + (LL)imin*w*2;
    imax = max(imax, n-1-son[cur]);
    zhong[cur] = imax;
    if(imax < msize)
    {
        msize = imax;
        mid = cur;
    }
}
int main()
{
	//freopen("233.txt","r",stdin);
    memset(Next, -1, sizeof(Next));
    int a, b, c;
    scanf("%d",&n);
    for(int i=1; i<n; ++i)
    {
        scanf("%d%d%d",&a,&b,&c);
        add_edge(a, b, c);
    }
    dfs(1, 0, 0);
    int com = 0x3f3f3f3f;
    for(int i=Next[mid]; i!=-1; i=edge[i].next)
    {
        int v = edge[i].e;
        com = min(com, edge[i].w);
        if(zhong[v] == zhong[mid])
        {
            ans -= edge[i].w;
            return 0*printf("%lld\n",ans);
        }
    }
    printf("%lld\n",ans-com);
    return 0;
}

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

int main(){
    ll d,g;
    cin >> d >> g;
    vector<ll> p,c,all;
    p.resize(d);c.resize(d);all.resize(d);
    rep(i,d){
        cin >> p[i] >> c[i];
        c[i];
        all[i]=p[i]*100*(i+1)+c[i];
    }

    ll res=pow(10,9);

    for(int bit=0;bit < (1<<d);++bit){
        ll sum=0,cnt=0;
        rep(i,d){
            if(bit & (1<<i)){
                sum+=all[i];
                cnt+=p[i];
            }
        }
        if(sum>=g){
            res=min(res,cnt);
            continue;
        }
        for(int i=d-1;i>=0;i--){
            if(bit & (1<<i)){
                continue;
            }
            rep(j,p[i]){
                if(sum>=g)break;
                sum+=(i+1)*100;
                cnt++;
            }
        }
        if(sum>=g)res=min(res,cnt);
    }

    cout << res << endl;
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int n, m; cin >> n >> m;
  cout << (n != m ? "No" : "Yes");
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N >> M;
    string ans = "No";
    vector<string> A(N), B(M);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for (int k = 0; k < M; k++){
        cin >> B.at(k);
    }
    int pos;
    if (A == B) ans = "Yes";
    for(int i = 0; i < N ; i++){
        pos = A[i].find(B[0]);
        if (pos != string::npos && i+M < N){
            for (int k = 1; k < M; k++){
                if (A[i+k].substr(pos, M) != B[k]){
                    break;
                }
                if (k == M -1){
                    ans = "Yes";
                    break;
                }
            }
        }
    }
    cout << ans << endl;   
}

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

using namespace std;

#define ll long long
#define MOD ((long long)1e9 + 7)

//#define TEST

// コンビネーションの計算を行うためのクラス
class Combination {
public:
	ll* inv; // 階乗の逆元を格納
	// コンストラクタ
	Combination(ll n) {
		this->n = n;
		frac = new ll[n + 1];
		inv = new ll[n + 1];
		frac[0] = 1; // 0! = 1
		inv[0] = 1; // 0!の逆元 = 1
		for (int i = 1; i <= n; ++i) {
			frac[i] = frac[i - 1] * i % MOD;
			inv[i] = Inverse(frac[i]);
		}
	}
	// メモリの開放を行う
	void free() {
		delete[] frac, inv;
	}
	// nCkの計算を行う 
	ll C(ll n, ll k) {
		if (k < 0) return 0;
		if (k > n) return 0;
		return frac[n] * inv[k] % MOD * inv[n - k] % MOD;
	}
private:
	ll n;
	ll* frac; // 階乗を格納
	ll Pow(ll a, ll b) { // aのb乗の計算
		if (b == 0) return 1;
		ll temp = Pow(a, b / 2);
		if (b & 1) {
			return temp * temp % MOD * a % MOD;
		}
		return temp * temp % MOD;
	}
	ll Inverse(ll a) { // aの逆元を計算
		return Pow(a, MOD - 2);
	}
};

// a^b%MODを計算
ll modpow(ll a, ll b) {
	if (b == 0) return 1;
	ll t = modpow(a, b / 2);
	if (b & 1)
		return t * t % MOD * a % MOD;
	return t * t % MOD;
}

signed main() {
	// 入力を受け取る
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;

	// コンビネーションの前計算を行う
	Combination com(1001);

	/*
		  dp[i][j] := i人をa～a+j人のグループに2番目
				の条件を満たすように分ける分け方
		というdpを行う.
	*/
	// dpテーブルの用意
	ll** dp = new ll * [n + 1];
	for (int i = 0; i <= n; ++i)
		dp[i] = new ll[b - a + 1];
	// dpテーブルの初期化を次の通り行う.
	// ・dp[0][0] = 1
	// ・dp[a*i][0] = a*iCa * a*(i-1)Ca * ... * aCa / (i!) (i=c,c+1,...,min(n/a,d))
	// ・dp[その他][0] = 0
	for (int i = 0; i <= n; ++i)
		dp[i][0] = 0;
	dp[0][0] = 1;
	for (int i = 1; i <= n / a; ++i) {
		dp[a * i][0] = dp[a * (i - 1)][0] * com.C((ll)a * i, a)
			% MOD * modpow(i, MOD - 2) % MOD;
	}
	for (int i = 1; i <= min(c - 1, n / a); ++i)
		dp[a * i][0] = 0;
	for (int i = min(n / a, d) + 1; i <= n / a; ++i)
		dp[a * i][0] = 0;
	// dpの遷移を行う.
	// ・dp[i][j] = 
	//		f=0,c～min(i/(a+j),d)について、	
	//		  dp[i-f*(a+j)][j-1]*(i人からのa+j人グループf個の作り方)
	//		の和
	for (int j = 1; j <= b - a; ++j) {
		for (int i = 0; i <= n; ++i) {
			int fmax = min(i / (a + j), d);
			dp[i][j] = dp[i][j - 1]; // f=0のとき
			if (fmax == 0) continue;
			// m[l] = iC(a+j) * i-(a+j)C(a+j) * ... * i-(a+j)*lC(a+j)
			ll* m = new ll[fmax];
			m[0] = com.C(i, (ll)a + j);
			for (int l = 1; l < fmax; ++l)
				m[l] = m[l - 1] 
				* com.C((ll)i - ((ll)a + j) * (ll)l, (ll)a + j) % MOD;
			for (int f = c; f <= fmax; ++f) {
				// i人からのa+j人グループf個の作り方はm[f-1]/(f!)
				ll t = dp[i - (a + j) * f][j - 1] * m[f - 1] % MOD
					* com.inv[f] % MOD;
				dp[i][j] += t;
				dp[i][j] %= MOD;
			}
			delete[] m;
		}
	}

	// dpの確認(TEST時のみ)
#ifdef TEST
	cout << "------------dp------------" << endl;
	for (int i = 0; i <= n; ++i) {
		cout << i << " : ";
		for (int j = 0; j <= b - a; ++j)
			cout << dp[i][j] << " ";
		cout << endl;
	}
#endif

	// 答えはdp[n][b-a].
#ifdef TEST
	cout << "------------ans-----------" << endl;
#endif
	cout << dp[n][b - a] << endl;

	// メモリの開放
	for (int i = 0; i <= n; ++i)
		delete[] dp[i];
	delete[] dp;
	com.free();

	return 0;
}

Measured memory_bytes: 8064
#include <stdio.h>

int main() {
    char s[101],a = '\0',b=0,i;
    scanf("%s",s);
    for( i=0;i<101;i++) {
        if(s[i]=='C')
            a=i;
        if(s[i]=='C')
            break;
    }
    if(i==101)
        a=101;
    for(int i=a;i<101;i++) {
       if(s[i]=='F')
           b++;
       if(s[i]=='F')
           break;
    }
    if(b>0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
    
}



Measured memory_bytes: 128
#include <stdio.h>

#define N 100003
#define INF 1 << 29

int enqueue(long *queue, long data, int *head, int *tail){
	if(*head % N != (*tail+1) % N) {
		queue[(*tail)++ % N] = data;
		return *tail - *head;
	}else{
		return INF;
	}
}

long dequeue(long *queue, int *head, int * tail){
	if(*head != *tail) {
		return queue[(*head)++ % N];
	}else{
		return INF;
	}
}

void initQueue(long *queue, int *head, int *tail){
	for(long i=1; i <= 9; i++)
		enqueue(queue, i, head, tail);
}

int main(void){
	long queue[N], x;
	int k, head = 0, tail = 0;

	scanf("%d", &k);

	initQueue(queue, &head, &tail);
	for(int i=0; i < k-1; i++) {
		if(k <= tail-head) {
			for(int j=i; j < k-1; j++)
				dequeue(queue, &head, &tail);
			printf("%ld", dequeue(queue, &head, &tail));
			return 0;
		}
		if((x = dequeue(queue, &head, &tail)) == INF) {
			return 1;
		}else{
			for(int j=-1; j <= 1; j++) {
				int d = x%10 + j;
				if(d < 0 || d > 9) continue;
				if(enqueue(queue, 10*x+d, &head, &tail) == INF)
					return 1;
			}
		}
	}
    printf("%ld", dequeue(queue, &head, &tail));

	return 0;
}


Measured memory_bytes: 896
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

typedef long long llong;
using namespace std;


struct Pair {
	char ch;
	int num;
};

int main() {
	Pair chList[130];
	char get_str[1300];


	for (int i = 0; i < 128; i++) {
		chList[i].ch = i;
		chList[i].num = 0;
	}

	while (fgets(get_str, 1300, stdin)) {
		for (int i = 0; get_str[i] != '\0'; i++) {
			chList[get_str[i]].num++;
		}
	}


	for (int i = 65; i <= 90; i++) {
		chList[i + 32].num += chList[i].num;
	}
	for (int i = 97; i <= 122; i++) {
		cout << chList[i].ch << " : " << chList[i].num << endl;
	}
	return 0;
}



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

int dp[1010][1010];
int H, W;
char arr[1010][1010];

int main()
{
    scanf("%d%d", &H, &W);
    for(int i=0; i<H; ++i) scanf("%s", arr[i]);
    // required # of swap
    dp[0][0] = (arr[0][0] == '#');
    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            if(i==j && j == 0) continue;
            dp[i][j] = 0x3f3f3f3f;
            if(j) dp[i][j] = min(dp[i][j-1]+(arr[i][j] != arr[i][j-1]), dp[i][j]);
            if(i) dp[i][j] = min(dp[i-1][j]+(arr[i][j] != arr[i-1][j]), dp[i][j]);
        }
    }
    printf("%d\n", (1+dp[H-1][W-1])/2);
}

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

int main() {
  int n;
  cin >> n;
  int MAX = -1;
  int ans = MAX;
  for(int i = 1; i*i <= n; i++) {
    ans = max(ans, i*i);
  }
  
  cout << ans << endl;
  return 0;
}

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


int main(){
	string s;
	cin >> s;
	for(int i=1;i<s.size();i++){
		if(s[i]==s[i-1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[200005];
ll grade[200005];
int main(){
    ll n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=1;i<=n-k;i++){
      if(arr[i]/arr[i+k]>0)puts("No");
      else puts("Yes");
      
  	}
    return 0;
}

Measured memory_bytes: 5196
#include <iostream>
using namespace std;
int cnt,n,ans;
string s;
int main(void){
    cin>>n>>s;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;k++){
                for(int ii=0;ii<n;ii++){
                    if(cnt==0&&s[ii]-'0'==i)cnt++;
                    else if(cnt==1&&s[ii]-'0'==j)cnt++;
                    else if(cnt==2&&s[ii]-'0'==k)cnt++;
                }
                if(cnt==3)ans++;
                cnt=0;
            }
        }
    }
    cout<<ans<<endl;
}


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

from fractions import gcd

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    s = 0
    m = 1
    for i, Ai in enumerate(A):
        g = gcd(m, Ai)
        Ai_g = Ai // g
        s = s * Ai_g % MOD
        m *= Ai_g
        s = (s + (m // Ai) % MOD) % MOD
    print(s)


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
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6228
h, w, k = map(int, input().split())
x1, y1, x2, y2 = [int(i)-1 for i in input().split()]
ans = [[-1] * w for _ in range(h)]
ans[x1][y1] = 0
c = [input() for _ in range(h)]
qu = [(x1, y1)]


for x, y in qu:
    if x == x2 and y == y2:
        print(ans[x2][y2])
        break

    for i in range(x + 1, min(x + k + 1, h)):
        if c[i][y] == "@":
            break
        if ans[i][y] == -1:
            ans[i][y] = ans[x][y] + 1
            qu.append((i, y))
        elif ans[i][y] <= ans[x][y]:
            break
    for i in reversed(range(max(0, x - k), x)):
        if c[i][y] == "@":
            break
        if ans[i][y] == -1:
            ans[i][y] = ans[x][y] + 1
            qu.append((i, y))
        elif ans[i][y] <= ans[x][y]:
            break

    for i in range(y + 1, min(y + k + 1, w)):
        if c[x][i] == "@":
            break
        if ans[x][i] == -1:
            ans[x][i] = ans[x][y] + 1
            qu.append((x, i))
        elif ans[x][i] <= ans[x][y]:
            break
    for i in reversed(range(max(0, y - k), y)):
        if c[x][i] == "@":
            break
        if ans[x][i] == -1:
            ans[x][i] = ans[x][y] + 1
            qu.append((x, i))
        elif ans[x][i] <= ans[x][y]:
            break
else:
    print(-1)


Measured memory_bytes: 127556
#include <string>
#include <iostream>
#define min(a, b) a > b ? b : a

using namespace std;

int main()
{
    string s1, s2;
    cin >> s1 >> s2;

    int min_change = 1000;
    for (int i = 0; i < s1.length() - s2.length() + 1; i++)
    {
        int cnt = 0;
        for (int j = 0; j < s2.length(); j++)
        {
            if (s1[j + i] != s2[j])
                cnt++;
        }
        min_change = min(min_change, cnt);
    }
    cout << min_change;

    return 0;
}

Measured memory_bytes: 3596
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

//const int N = 100 +5;

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    string s1, s2 = ""; cin>> s1;
    for(int i=0; i<s1.size(); ++i){
        if(s1[i] == 'B' && !s2.empty()) s2.pop_back();
        else if(s1[i] != 'B') s2 += s1[i];
    }
    cout<< s2;

return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
using namespace std;
const int N=100005;
int p,dis[N],q1[N],l1,r1,q2[N],l2,r2;
bool vi[N][2],flag;
int read()
{	char x=getchar();
	while(x<48||x>57) x=getchar();
	int ans=0;
	while(x>=48&&x<=57)
	{	ans=(ans<<1)+(ans<<3)+(x^48);
		x=getchar();
	}
	return ans;
}
void add(int num)
{	int x;
	x=(num+1)%p;
	if(!vi[x][1]&&!vi[x][0])
	{	vi[x][1]=true;dis[x]=dis[num]+1;
		q2[r2]=x;r2++;
	}
	x=(num*10)%p;
	if(!vi[x][0])
	{	vi[x][0]=true;dis[x]=dis[num];
		q1[r1]=x;r1++;
		if(x==0) { flag=true;return;}
	}
}
void solve()
{	l1=1;r1=2;l2=r2=1;
	q1[1]=1;dis[1]=1;vi[1][0]=true;
	while(r1>l1||r2>l2)
	{	while(r1>l1)
		{	add(q1[l1]);l1++;
			if(flag) return;
		}
		while(r2>l2)
		{	if(vi[q2[l2]][0]) {l2++;continue;}
			vi[q2[l2]][0]=true;add(q2[l2]);l2++;
			if(flag) return;
			break;
		}
	}
}
int main()
{	p=read();
	solve();
	printf("%d\n",dis[0]);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin() , v.end()
#define w(x) cout << (#x) << " is " << x << "\n" ;
#define fast ios_base::sync_with_stdio(false) , cin.tie(0) ;
int main()
{
    fast ;
    int k, x ,n , i;
    vector<int>v ;
    cin >> n ;
    for(i = 0 ; i < n ; i++)
    {
        cin >> x ;
        v.pb(x) ;
    }
    sort(all(v)) ;
    n = n/2 ;
    cout << v[n] - v[n-1] << "\n" ;
    return 0;
}

Measured memory_bytes: 3876
#include <stdio.h>

int main(void) {
	int a=NULL,b=NULL,c=NULL,i;
	scanf("%d",&i);
	i=0;
	while(scanf("%d %d %d", &a, &b, &c) != EOF){
		if(a&&b&&c) {
			if((a*a+b*b) == c*c) {
				printf("YES\n");
			} else if((b*b+c*c)==a*a) {
				printf("YES\n");
			} else if((c*c+a*a)==b*b) {
				printf("YES\n");
			}else {
				printf("NO\n");
			}	
		}
	}
	return 0;
}

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

int main() {
  int a, b, c, d, x, y;
  cin >> a >> b >> c >> x >> y;
  if(x < y) swap(x, y), swap(a, b);
  long long ans = 1000000000000000;
  for(int i = 0; i <= x; i++){
    long long k = i*a;
    k += (x-i) * 2 * c;
    if(y > x-i) k += (y - (x-i)) * b;
    ans = min(ans, k);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i;
    int height[10];
    int temp, flag;

    for(i = 0; i < 10; i++){
        scanf("%d", &height[i]);
    }
    do{
        flag = 0;
        for(i = 0; i < 9; i++){
            if(height[i] > height[i + 1]){
                flag = 1;
                temp = height[i + 1];
                height[i + 1] = height[i];
                height[i] = temp;
            }
        }
    }while(flag);

    printf("%d\n%d\n%d\n", height[9], height[8], height[7]);

    return 0;
}


Measured memory_bytes: 1988
#include <stdio.h>
long long int b[200005];
void merging(long long int a[],int low, int mid, int high) {
   int l1, l2, i;

   for(l1 = low, l2 = mid + 1, i = low; l1 <= mid && l2 <= high; i++) {
      if(a[l1] <= a[l2])
         b[i] = a[l1++];
      else
         b[i] = a[l2++];
   }
   
   while(l1 <= mid)    
      b[i++] = a[l1++];

   while(l2 <= high)   
      b[i++] = a[l2++];

   for(i = low; i <= high; i++)
      a[i] = b[i];
}

void sort(long long int a[],int low, int high) {
   int mid;
   
   if(low < high) {
      mid = (low + high) / 2;
      sort(a,low, mid);
      sort(a,mid+1, high);
      merging(a,low, mid, high);
   } else { 
      return;
   }   
}
int main()
{
    int t,a;
    scanf("%d",&t);
    char s[12];
    long long int x[t],num;
    for(int i=0;i<t;i++)
    {
        scanf("%s",s);num=0;
        for(int j=0;s[j]!='\0';j++)
        {
            a=s[j]-'a';
            num=num*100+(a+1);
        }
        x[i]=num;
    }
    sort(x,0,t-1);
    num=x[0];int count=1;
    for(int i=0;i<t;i++)
    {
        if(x[i]!=num)
        {
            count++;
            num=x[i];
        }
    }

    printf("%d",count);
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int tmp = 0;
  if (A > B) {
    tmp += A;
    A--;
  } else {
    tmp += B;
    B--;
  }
  if (A > B) {
    tmp += A;
  } else {
    tmp += B;
  }
  cout << tmp << endl;
  return 0;
}

Measured memory_bytes: 256
def Convert(string): 
    li = list(string.strip()) 
    return li 

s=str(input())

l=[]
l=Convert(s)
#print(l)
x=len(l)
count=0
if(l[0]=='R'):
	count=1
	if(l[1]=='R'):
		count=count+1
		if(l[2]=='R'):
			count=count+1		
	
else:
	if(l[1]=='R'):
		count=count+1
		if(l[2]=='R'):
			count=count+1
	else:
		if(l[2]=='R'):
			count=count+1

print(count)

Measured memory_bytes: 9012
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var slist = new Dictionary<char, int>() { };
        var scount = 0;
        StringBuilder stmp = new StringBuilder("");
        for (int i = 0; i < s.Length; i++)
        {
            if (!slist.ContainsKey(s[i]))
            {
                slist.Add(s[i], scount);
                stmp.Append(scount);
                scount++;
            }
            else
            {
                stmp.Append(slist[s[i]]);
            }
        }


        var tlist = new Dictionary<char, int>() { };
        var tcount = 0;
        StringBuilder ttmp = new StringBuilder("");
        for (int i = 0; i < t.Length; i++)
        {
            if (!tlist.ContainsKey(t[i]))
            {
                tlist.Add(t[i], tcount);
                ttmp.Append(tcount);
                tcount++;
            }
            else
            {
                ttmp.Append(tlist[t[i]]);
            }
        }


        var ans = "No";
        if (stmp.Equals(ttmp))
        {
            ans = "Yes";
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 19928
# include<iostream>
# include<algorithm>
# include<cctype>
# include<cstdio>
# include<cstring>
# include<sstream>
# include<cmath>
# include<limits.h>
using namespace std;
int main()
{
      int n, k;
      cin >> n >> k;
      int bit=0;
      if (n==0) cout << 1 << endl;
      else
      {
            while(n>0)
            {
                  bit++;
                  n = n/k;
            }
            cout << bit << endl;
      }

      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes";
	else cout << "No";
	return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

vector<string> s;

void dfs(int now, int depth, VVI e){
    REP(i,depth) cout << ".";
    cout << s[now] << endl;
    REP(i,e[now].size()){
        dfs(e[now][i], depth+1, e);
    }
}

int main() {
    int n;

    while (cin >> n && n) {
        s.resize(n);
        VVI e(n);
        REP(i,n){
            int x;
            cin >> x >> s[i];
            if (i > 0)
                e[x-1].push_back(i);
        }
        dfs(0, 0, e);
    }

    return 0;
}

Measured memory_bytes: 58084
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    cout<<n*(n-1)/2-n/2<<endl;
    if(n%2){
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                if(i+j!=n) cout<<i<<" "<<j<<endl;
            }
        }
        for(int i=1;i<=n-1;i++)
        cout<<i<<" "<<n<<endl;
    }
    else{
        for(int i=1;i<=n-1;i++){
            for(int j=i+1;j<=n;j++){
                if(i+j!=n+1) cout<<i<<" "<<j<<endl;
            }
        }
    }
}

Measured memory_bytes: 256
L, R = map(int, input().split())

l = L // 2019
r = R // 2019

mi = 2019
if l == r:
	L = L % 2019
	R = R % 2019
	for i in range(L, R):
		for j in range(i+1, R+1):
			mi = min((i*j)%2019, mi)
else:
	L = L % 2019
	for i in range(L, 2019):
		for j in range(i+1, 2020):
			mi = min((i*j)%2019, mi)
print(mi)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

string s;

int main() {
    cin >> s;
    int l=s.size();
    int i=0;
    bool flag=true;
    while(i<l){
        if (s.substr(i,7)=="dreamer" and s[i+7]!='a'){
            i+=7;
            continue;
        }
        if (s.substr(i,6)=="eraser"){
            i+=6;
            continue;
        }
        if (s.substr(i,5)=="dream"){
            i+=5;
            continue;
        }
        if (s.substr(i,5)=="erase"){
            i+=5;
            continue;
        }
        flag=false;
        break;
    }
    if (flag==false) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 512
while 1:
    list1=input().split('"')
    if list1[0]==".":
        break
    list2=input().split('"')
     
    cnt1=0
    cnt2=0
    flag=0
     
    if len(list1)!=len(list2):
        print("DIFFERENT")
    else:
        i=0
        while i<len(list1):
            if list1[i]==list2[i]:
                cnt1+=1
            elif i%2==0:	#「""の間で」の意味
                print("DIFFERENT")
                flag=1
                break
            else:
                cnt2+=1
                if cnt2>1:
                    print("DIFFERENT")
                    break
            i+=1
                 
        if flag==0 and cnt2==1:
            print("CLOSE")
        if cnt1==len(list1):
            print("IDENTICAL")



Measured memory_bytes: 5576
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isKai(int n){
    stringstream ss;
    ss<<n;
    string s=ss.str();
    string g=ss.str();
    
    reverse(all(s));
    if(s==g)return true;
    else return false;
}


int main() {
    int n;
    cin>>n;
    int now=-1;
    rep(i,9999999){
        if(isKai(i)){
            if(i<n)now=i;
            else{
                if(abs(n-now)>abs(n-i))cout<<i<<endl;
                else cout<<now<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1220
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/cf16-relay-open/submissions/8979673
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    int n;
    scanf("%d", &n);
    if(n == 2){
        puts("-1");
        return 0;
    }
    
    vector<vector<int>> a(n, vector<int>(n - 1));
    rep(i, n) rep(j, n - 1) a[i][j] = (i + j + 1) % n;
    if(n % 2 == 0){
        rep(i, n / 2) swap(a[i][i + (i == n / 2 - 1) * (n == 4 ? -1 : 1)], a[i][n / 2 - 1]);
    }
    rep(i, n){
        rep(j, n - 1){
            if(j > 0) printf(" ");
            printf("%d", a[i][j] + 1);
        }
        printf("\n");
    }
    return 0;
}

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

const int N = 1e5 + 100, M = 16;

int n, ans, a[N], cnt[M], dp[1 << M];

bool ok(int mask) {
	int res = 0;
	for (int i = 0; i < M; i++)
		if (mask & (1 << i))
			res ^= i;
	return res == 0;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		a[u] ^= w;
		a[v] ^= w;
	}
	for (int i = 0; i < n; i++)
		cnt[a[i]]++;
	int mask = 0;
	for (int i = 1; i < M; i++) {
		ans += (cnt[i] >> 1);
		mask |= (cnt[i] &= 1) << i;
		ans += cnt[i];
	}
	for (int x = 1; x <= mask; x++) {
		dp[x] = ok(x);
		if ((mask & x) == x)
			for (int y = x; y; y = (--y & x))
				if (y < x && ok(y))
					dp[x] = max(dp[x], dp[y] + dp[x ^ y]);
	}
	ans -= dp[mask];
	cout << ans;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m,x;
  cin >> x;
  ll t[2][3];
  for(i=0;i<2;i++)cin >> t[i][0] >> t[i][1] >> t[i][2];
  ll dp[x+1]={};
  ll mt=max(t[1][0],max(t[1][1],t[1][2]));
  for(i=0;i<3;i++){
    for(j=t[0][i];j<x+1;j++){
      if(t[1][i]>t[0][i])dp[j]=max(dp[j],dp[j-t[0][i]]+t[1][i]-t[0][i]);
    }
  }
  //cout << "a" << endl;
  ll ret=0;
  for(i=0;i<x+1;i++)ret=max(dp[i],ret);
  x+=ret;
  mt=max(t[0][0],max(t[0][1],t[0][2]));
  ll dp2[x+1]={};
  for(i=0;i<3;i++){
    for(j=t[1][i];j<x+1;j++){
      if(t[0][i]>t[1][i])dp2[j]=max(dp2[j],dp2[j-t[1][i]]+t[0][i]-t[1][i]);
    }
  }
  ret=0;
  for(i=0;i<x+1;i++)ret=max(dp2[i],ret);
  x+=ret;
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll> a(X);
    vector<ll> b(Y);
    vector<ll> c(Z);
    for(int i = 0;i < X;i++) {
        cin >> a.at(i);
    }
    for(int i = 0;i < Y;i++) {
        cin >> b.at(i);
    }
    for(int i = 0;i < Z;i++) {
        cin >> c.at(i);
    }
    vector<ll> cnt;
    for(int i = 0;i < Y;i++) {
        for(int j = 0;j < Z;j++) {
            cnt.push_back(b.at(i) + c.at(j));
        }
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(cnt.begin(),cnt.end());
    reverse(cnt.begin(),cnt.end());
    vector<ll> cnt2;
    for(int i = 0;i < X;i++) {
        int A = cnt.size();
        for(int j = 0;j < min(K,A);j++) {
            cnt2.push_back(a.at(i) + cnt.at(j));
        }
    }
    sort(cnt2.begin(),cnt2.end());
    reverse(cnt2.begin(),cnt2.end());
    for(int i = 0;i < K;i++) {
        cout << cnt2.at(i) << endl;
    }
}

Measured memory_bytes: 43240
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    ll b[n+1];
    b[0]=0;
    for(int i=0;i<n;i++){
        b[i+1]=(b[i]+a[i])%k;
    }
    map<ll,ll> mp;
    ll ans=0;
    queue<ll> q;
    for(int i=0;i<=n;i++){
        ans+=mp[b[i]];
        mp[b[i]]++;
        q.push(b[i]);
        if((q.size())==k){
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 17536
n,x,y=map(int,input().split())
D=[0]*(n-1)
x-=1
y-=1
for i in range(n-1):
    for j in range(i+1,n):
        D[min(j-i-1,abs(x-i)+abs(y-j))]+=1
for d in D:print(d)

Measured memory_bytes: 3444
N,M=map(int,input().split())
if abs(N-M)>1:
    print(0)
else:
    ans=1
    for i in range(1,N+1):
        ans=ans*i
        ans%=10**9+7
    for i in range(1,M+1):
        ans=ans*i
        ans%=10**9+7
    if N==M:
        print(2*ans%(10**9+7))
    else:
        print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n,m;
int main(){
    cin>>n>>m;
    int sum=m*1900+100*(n-m);
    cout<<sum*(1<<m)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
const ll sqrtN = 512; //* 512*512=262144 > 10^5

struct RAQ{
    ll N, K;
    vll data;
    vll bucketAdd;
    //* init using 0 data
    void init(ll n){ 
        N = n;
        K = (n + sqrtN - 1) / sqrtN; //* number of buckets = ceil(n/sqrtN)
        data.assign(K * sqrtN, 0);
        bucketAdd.assign(K, 0);
    }
    //* constructor
    RAQ(ll n){ init (n); }
    RAQ(ll n, vll const &a){
        init(n);
        REP(i, n){
            data[i] = a[i];
        }
        //* zero initialization is enough
    }
    //* update [s, t) with addition x
    void add(ll s, ll t, ll x){
        REP(k, K){
            ll l= k * sqrtN, r = (k + 1) * sqrtN; //* bucket [l, r)
            if(r <= s || t <= l) //* no intersection
                continue;
            if(s <= l && r <= t) {//* [l, r) in [x, y)
                bucketAdd[k] += x; //* update bucket data
            }
            else{ //* has intersection on boundary
                for(ll i = max(l, s); i < min(r, t); i++){
                    data[i] += x;
                }
            }
        }
    }
    //* get i-th data
    ll get(ll i){
        ll k = i / sqrtN;
        return data[i] + bucketAdd[k];
    }

};

void solve(long long N, long long D, long long A, std::vector<long long> X, std::vector<long long> H){
    vector<pll> pt(N);
    REP(i, N){
        pt[i].first = X[i]; pt[i].second = H[i];
    }
    sort(ALL(pt));
    REP(i, N){
        X[i] = pt[i].first; H[i] = pt[i].second;
    }
    RAQ st(N, H);
    ll res = 0;
    REP(i, N){
        ll val = st.get(i);
        ll time = (val + A-1) / A;
        if(st.get(i)>0){
            ll xstart = X[i], xend = X[i]+2*D;
            ll s = i, t = upper_bound(ALL(X), xend) - X.begin();
            st.add(s, t, -A*time);
            res += time;
        }
    }
    cout<< res << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    long long A;
    scanf("%lld",&A);
    std::vector<long long> X(N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&H[i]);
    }
    solve(N, D, A, std::move(X), std::move(H));
    return 0;
}


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

using namespace std;


int main() {
    int x;
    cin >> x;
    int ans = 0;
    while (x >= 500) {
        ans += 1000;
        x -= 500;
    }
    while (x >= 5) {
        ans += 5;
        x -= 5;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
S_list = []
for i in range(N):
  S_list.append(input())

c = collections.Counter(S_list)

d = c.most_common() 

keys = [k for k, v in c.items() if v == d[0][1]]

keys = sorted(keys)

for i in keys:
  print(i)

Measured memory_bytes: 49156
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int x,y,z,k;
int main(){
    cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y),c(z);
    for(int i = 0; i < x; i++) cin >> a[i];
    for(int i = 0; i < y; i++) cin >> b[i];
    for(int i = 0; i < z; i++) cin >> c[i];
    vector<ll> sum(0);
    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            sum.push_back(a[i] + b[j]);
        }
    }
    vector<ll> ans(0);
    sort(sum.begin(),sum.end());
    reverse(sum.begin(),sum.end());
    int mx = min(x*y,3000);
    for(int i = 0; i < mx; i++){
        for(int j = 0; j < z; j++){
            ans.push_back(sum[i] + c[j]);
        }
    }
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    for(int i = 0; i < k; i++){
        cout << ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 43368
#include <cstdio>
#include <queue>
#include <map>
#include <cctype>
#include <climits>

using namespace std;

typedef pair<int, int> P;

#define W 1005
#define H 1005
#define N 15

int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};

char a[H][W];
int d[H][W];
P fa[N];
int h, w, n;

int bfs(int sx, int sy, int gx, int gy){
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			d[i][j] = INT_MAX;
		}
	}
	queue<P> que;
	d[sx][sy] = 0;
	que.push(P(sx, sy));
	
	while(!que.empty()){
		P p = que.front();
		que.pop();
		int x = p.first;
		int y = p.second;

		if (x == gx && y == gy) break;
	
		for (int i = 0; i < 4; i++){
			int nx = x + dx[i];
			int ny = y + dy[i];
			
			if (nx >= 0 && nx < h && ny >= 0 && ny < w && a[nx][ny] != 'X' && d[nx][ny] == INT_MAX){
				d[nx][ny] = d[x][y] + 1;
				que.push(P(nx, ny));
			}
		}
	}
	return d[gx][gy];
}

int main(){
	scanf("%d %d %d", &h, &w, &n);
	for (int i = 0; i < h; i++){
		getchar();
		for (int j = 0; j < w; j++){
			scanf("%c", &a[i][j]);
			if (a[i][j] == 'S'){
				fa[0] = P(i, j);
			}
			if (isdigit(a[i][j])){
				fa[a[i][j] - '0'] = P(i, j);
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++){
		sum += bfs(fa[i].first, fa[i].second, fa[i + 1].first, fa[i + 1].second);
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 7572
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <15/Jun/2019 05:47:43 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = [0] * n
    for i in range(n):
        arr[i] = tuple(get_ints())
    if n == 1 or n == 2:
        print(1)
        return
    arr.sort()
    d = {}
    for i in range(n):
        for j in range(i + 1, n):
            if (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1]) not in d:
                d[(arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])] = 0
            d[(arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])] += 1

    from operator import itemgetter
    sorted_d = sorted(d.items(), key=itemgetter(1), reverse=True)
    # print(sorted_d)

    print(n - sorted_d[0][1])


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
import heapq
import copy

N, K = map(int, input().split())
V = list(map(int, input().split()))
max_sum = 0
for a in range(0, min(K+1, N+1)):
    for b in range(0, min(K+1-a, N+1-a)):
        sum_list=copy.copy(V[:a]+V[N-b:])
        heapq.heapify(sum_list)
        for i in range(K-a-b):
            if sum_list:
                q=heapq.heappop(sum_list)
                if q>0:
                    heapq.heappush(sum_list, q)
                    break
            else:
                break
        # print(a, b,K-a-b,V[:a]+V[N-b:], sum_list, sum(sum_list))
        # print(a, b,K-a-b)
        max_sum = max(max_sum, sum(sum_list))
print(max_sum)

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

int main() {
  int n,a = 0,b = 0,c = 0,d = 0;
  cin >> n;
  vector<string> s(n);
  for(int i = 0; i < n; i++){
    cin >> s[i];
    if(s[i] == "AC"){
      a += 1;
    }else if(s[i] == "WA"){
      b += 1;
    }else if(s[i] == "TLE"){
      c += 1;
    }else if(s[i] == "RE"){
      d += 1;
    }
  }
  cout << "AC" << " " << "x" << " " << a << endl;
  cout << "WA" << " " << "x" << " " << b << endl;
  cout << "TLE" << " " << "x" << " " << c << endl;
  cout << "RE" << " " << "x" << " " << d << endl;
  return 0;
}

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

int main(void)
{
	int n,h,w;
	std::cin>>n>>h>>w;
	int ct = 0;
	for(int i=0;i<n;i++)
	{
		int a,b;
		std::cin>>a>>b;
		if(a >= h && b >= w)
		ct++;	
	}
	std::cout<<ct<<"\n";
}

Measured memory_bytes: 256