akhauriyash/Code-Regression huggingface dataset:
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  if(s[k-1]=='A') s[k-1]='a';
  else if(s[k-1]=='B') s[k-1]='b';
  else if(s[k-1]=='C') s[k-1]='c';
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef unsigned long long ull;

int main()
{
    string a, b;
    string s;
    
    cin >> a >> s >> b;
    
    printf("A%cC\n", s[0]);
    
    return 0;
}


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

int main(){
  int kekka = 0;
  string s;
  cin >> s;
  for(int i = 0;i < s.size()-1;i++){
    if(s.at(i) != s.at(i+1)){
      kekka++;
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 512
def main():
    H, W = map(int, input().split())
    S = tuple(input() for _ in [0] * H)

    grid = ['.' * (W + 2)]
    apnd = grid.append
    for s in S:
        apnd('.' + s + '.')
    apnd('.' * (W + 2))

    for i in range(1, H + 2):
        idx = [i for i, s in enumerate(grid[i]) if s == '#']
        for j in idx:
            if grid[i-1][j] == grid[i+1][j] == grid[i][j-1] == grid[i][j+1] == '.':
                print('No')
                return
    print('Yes')

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define RANGE(a, l, r) lower_bound(a, a + N, r) - lower_bound(a, a + N, l)
using namespace std;
typedef int ll;

ll N, A[200000], B[200000];
ll pow2[31], l1[29], r1[29], l2[29], r2[29];
ll moda[29][200000], modb[29][200000];

int main(void) {
  scanf("%d", &N);
  REP(i, 0, N) scanf("%d", &A[i]);
  REP(i, 0, N) scanf("%d", &B[i]);

  REP(i, 0, 31) pow2[i] = (1 << i);
  REP(i, 0, 29) {
    l1[i] = pow2[i];
    r1[i] = pow2[i + 1];
    l2[i] = pow2[i + 1] + pow2[i];
    r2[i] = pow2[i + 2];
  }
  REP(i, 0, 29) REP(j, 0, N) moda[i][j] = A[j] % pow2[i + 1];
  REP(i, 0, 29) {
    REP(j, 0, N) modb[i][j] = B[j] % pow2[i + 1];
    sort(modb[i], modb[i] + N);
  }

  ll ans = 0;
  REP(k, 0, 29) {
    REP(i, 0, N) {
      ll cnt = 0;
      cnt += RANGE(modb[k], l1[k] - moda[k][i], r1[k] - moda[k][i]);
      cnt += RANGE(modb[k], l2[k] - moda[k][i], r2[k] - moda[k][i]);
      if(cnt & 1) ans = ans ^ pow2[k];
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 47104
<?php
$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
$args =[];
foreach ($input as $value) {
	$tmp = (int)$value;
	if (isset($args[$tmp])) {
		$args[$tmp] += 1;
	}else{
		$args[$tmp] = 1;
	}
}
krsort($args);
$long = null;
foreach ($args as $key => $val) {
	if ($val >= 4) {
		if ($long === null) {
			echo $key*$key;
			exit();
		}else{
			echo $long*$key;
			exit();
		}
	}elseif ($val >= 2) {
		if ($long === null) {
			$long = $key;
		}else{
			echo $long*$key;
			exit();
		}
	}
}

echo 0;

Measured memory_bytes: 19188
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 200100;
int R[maxn];
void print(int A[], int n)
{
    for(int i = 0; i < n - 1; i++)
        cout << R[i] << ' ';
    cout << R[n-1] << endl;
}
void bubbleSort(int A[], int n)
{
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        int flag = 1;
        for(int j = n - 1; j > i; j--)
            if(A[j] < A[j-1])
            {
                swap(A[j], A[j-1]);
                cnt++;
                flag = 0;
            }
        if(flag)
            break;
    }
    print(A, n);
    cout << cnt << endl;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> R[i];
    bubbleSort(R, n);
    return 0;
}



Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<< X <<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};

const int INF=100000000;
int mode=1;

int main(){
	int n,m,a[60],b[60],count=0,c[1000]={};
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[j]==i+1){
				c[i]++;
			}
			else if(b[j]==i+1){
				c[i]++;
			}
		}
	}
	REP(i,n){
		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>
#include <limits.h>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

int main() {
    int N, L;

    cin >> N >> L;
    int sum = 0;
    int min = INT_MAX;
    for (int i = 0; i < N; i++) {
        sum += L + i;
        if (abs(L + i) < min) min = abs(L + i);
    }

    if (sum >= 0)
        cout << sum - min;
    else
        cout << sum + min;

    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;
int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=0;
    if(n<b){
        ans=(a*n/b);
    }
    else{
        if(a<b){
            ans=(a*(b-1)/b);
        }
        else{
            int x=n/b*b-1;
            ans=(a*x/b)-a*(x/b);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, L; cin >> N >> L;
	vector<string> S(N);
	rep (i, N){
		cin >> S[i];
	} // end rep

	sort(ALL(S));
	
	string res = "";
	rep (i, N){
		res += S[i];
	} // end rep

	cout << res << endl;

	return 0;
}

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

int main() {
	int n;

	while (cin >> n, n) {
			int point[50000];
			for (int i = 0; i < n; i++) {
				cin >> point[i];
			}
		
		sort(point, point + n);

		int ans = 1000000;
		for (int i = 0; i < n-1; i++) {
			ans = min(ans, point[i+1] - point[i]);
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int n,a[1010],b[1010],h;
int main()
{
     cin>>n;
     for(int i=1;i<=n;i++)
     {
     	cin>>a[i]>>b[i];
     	h+=(b[i]-a[i])+1;
     }
	 cout<<h;
    return 0;
}

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

int main() {

  int N;
  cin >> N;

  vector<int> v(N);
  for(int i = 0;i < N;i++) {
    cin >> v.at(i);
  }

  vector<int> l(100005),r(100005);
  for(int i = 0;i < N;i++) {
    if(i % 2 == 1) {
      l.at(v.at(i) + 1)++;
    }else {
      r.at(v.at(i) + 1)++;
    }
  }

  int maxil = 0,maxir = 0,maxl,maxr;
  for(int i = 1;i < 100002;i++) {

   
     maxil = max(l.at(i),maxil);
     if(maxil == l.at(i)) maxl = i;

     maxir = max(r.at(i),maxir);
     if(maxir == r.at(i)) maxr = i;
  }

  sort(l.begin(),l.end(),greater<int>());
  sort(r.begin(),r.end(),greater<int>());

  if(maxl == maxr) {
    cout << N - l.at(0) - max(l.at(1),r.at(1)) << endl;
  }else {
    cout << N - l.at(0) - r.at(0) << endl;
  }

}

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

int sum[100001];

int main(){
  int N;cin >> N;
  int count = 0;
  int d[100001];
  for(int i = 0;i < N;i++)cin >> d[i];
  sort(d,d + N);
  for(int i = 0;i < N;i++)sum[d[i]]++;
  for(int i = 1;i < 100001;i++){
    sum[i] = sum[i] + sum[i - 1];
    if(sum[i] == N / 2)count++;
    else if(sum[i] > N / 2)break;
  }
  cout << count;
}


Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

int main(){
		int n;
		int a[1000];
		int v;

		scanf("%d",&n);
		for(int i=0 ; i<n ; i++) scanf("%d",&a[i]);

		for(int i=0 ; i<n ; i++){
				v = a[i];
				for(int j=i-1 ; j>=0 ; j--){
						if(a[j]>v){
								a[j+1] = a[j];
								a[j] = v;
						}else break;
				}

				for(int j=0 ; j<n-1 ; j++) printf("%d ",a[j]);
				printf("%d\n",a[n-1]);
		}
		return 0;
}




Measured memory_bytes: 2732
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int x,y,z;
    cin >> x >> y >> z;
    printf("%d %d %d\n",z,x,y);

    return 0;
}

Measured memory_bytes: 3708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		long[] A = GetLongs(N);

		long[] B = A.Select(x => x - 1).ToArray();
		long[] csum = new long[N + 1];
		for(int i = 0; i < N; i++)
			csum[i + 1] = csum[i] + B[i];

		long ans = 0;
		var dict = new Dictionary<long, long>();
		for(int i = 0; i <= N; i++)
		{
			long c = 0;
			if(dict.TryGetValue(csum[i] % K, out c))
				ans += c;

			dict[csum[i] % K] = c + 1;
			if(i >= K - 1)
				dict[csum[i - K + 1] % K]--;
		}
		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 53268
//Head File
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<ctime>
#include<set>
#include<cstdlib>
#include<vector>
#include<cassert>
#include<cmath>
#include<iostream>
using namespace std;

#define il inline

//Variable
#define ll long long
#define ull unsigned long long
#define db double
#define lb long double
#define ui unsigned int

//Debug
#define B cerr<<"Break Point"<<endl;
#define P(x) cerr<<#x<<' '<<"="<<' '<<(x)<<endl;
#define p(x) cerr<<#x<<' '<<"="<<' '<<(x)<<' ';
#define ml(x) cerr<<"Size of array is "<<x*4/1024/1024<<" MB"<<endl;

//Vector
#define vc vector
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define vbe(x) x.begin(),x.end()

//Memset
#define ms(x) memset(x,0,sizeof(x))
#define MS(x) memset(x,0x3f3f3f3f,sizeof(x))

//Pair
#define fi first
#define se second

//File

#define fin(x) freopen(x,"r",stdin)
#define fou(x) freopen(x,"w",stdout)
void fio()
{
    #ifndef ONLINE_JUDGE
    freopen("sample.in","r",stdin);
    freopen("sample.out","w",stdout);
    #endif
}
void pti()
{
    double timeuse = clock()*1000.0/CLOCKS_PER_SEC;
    cerr<<"Timeuse "<<timeuse<<"ms"<<endl;
}
void end()
{
    #ifndef ONLINE_JUDGE
    pti();
    #endif
    exit(0);
}

//Inf
#define INF 0x3f3f3f3f
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))

//IO
#define pc(s) putchar(s)
#define say(s) cout<<s<<endl
namespace io
{
    const int SIZ=55;int que[SIZ],op,qr;char ch;
    template<class I>
    il void gi(I &w)
    {
        ch=getchar(),op=1,w=0;
	    while(!isdigit(ch)){if(ch=='-') op=-1;ch=getchar();}
        while(isdigit(ch)){w=w*10+ch-'0';ch=getchar();}w*=op;
    }
    template<typename T,typename... Args>
    il void gi(T& t,Args&... args){gi(t);gi(args...);}
    template<class I>
    il void print(I w)
    {
        qr=0;if(!w) putchar('0');if(w<0) putchar('-'),w=-w;
	    while(w) que[++qr]=w%10+'0',w/=10;
        while(qr) putchar(que[qr--]);
    }
}
using io::gi;
using io::print;

const int N=2e7+5;
const int base=131;
const ll mod=192608179;

string a,b;
int tag[N];
ll ha[N],hb[N],fac[N];

ll gethash(int x)
{
    if(x+b.size()>a.size()) return -1;
    return (ha[x+b.size()-1]-ha[x-1]*fac[b.size()]%mod+mod)%mod;
}
int main()
{
    cin>>a>>b;
    while(a.size()<b.size()*2) a=a+a;
    a=a+a,a=a+a,a=a+a;
    fac[0]=1,ha[0]=a[0]-'a',hb[0]=b[0]-'a';
    for(int i=1;i<a.size();++i) fac[i]=fac[i-1]*base%mod;
    for(int i=1;i<a.size();++i) ha[i]=(ha[i-1]*base%mod+a[i]-'a')%mod;
    for(int i=1;i<b.size();++i) hb[i]=(hb[i-1]*base%mod+b[i]-'a')%mod;
    for(int i=0;i<a.size();++i) tag[i]=hb[b.size()-1]==gethash(i);
    int ans=0;
    for(int i=a.size()-b.size();i>=0;--i) if(tag[i]) tag[i]+=tag[i+b.size()],ans=max(ans,tag[i]);
    if(ans+1>=a.size()/b.size()) print(-1);
    else print(ans);
    end();
}


Measured memory_bytes: 342868
package main

import (
	"container/heap"
	"fmt"
)

type Node struct {
	NowPosition          int
	DiscountTicketTCount int
	Amount               int
}

type PriorityQueueNode []*Node

func (pq PriorityQueueNode) Len() int {
	return len(pq)
}

func (pq PriorityQueueNode) Less(i, j int) bool {
	return pq[i].Amount < pq[j].Amount
}

func (pq PriorityQueueNode) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PriorityQueueNode) Push(node interface{}) {
	*pq = append(*pq, node.(*Node))
}

func (pq *PriorityQueueNode) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

type Point struct {
	NextPoint int
	Fee       int
}

type Memo struct {
	NowPoint             int
	DiscountTicketTCount int
}

func main() {
	var c, n, m, s, d int
	var a, b, f int

	for {
		fmt.Scan(&c, &n, &m, &s, &d)
		if c == 0 && n == 0 && m == 0 && s == 0 && d == 0 {
			break
		}
		s--
		d--
		pointMap := make([][]Point, n)
		for i := 0; i < n; i++ {
			pointMap[i] = make([]Point, 0, n)
		}
		for i := 0; i < m; i++ {
			fmt.Scan(&a, &b, &f)
			a--
			b--
			pointMap[a] = append(pointMap[a], Point{NextPoint: b, Fee: f})
			pointMap[b] = append(pointMap[b], Point{NextPoint: a, Fee: f})
		}
		pq := make(PriorityQueueNode, 0, m)
		start := Node{NowPosition: s, DiscountTicketTCount: c, Amount: 0}
		heap.Push(&pq, &start)
		memo := make(map[Memo]int)
		for len(pq) != 0 {
			now := heap.Pop(&pq).(*Node)
			if now.NowPosition == d {
				fmt.Println(now.Amount)
				break
			}
			memo[Memo{NowPoint: now.NowPosition, DiscountTicketTCount: now.DiscountTicketTCount}] = now.Amount
			for _, v := range pointMap[now.NowPosition] {
				next := &Node{v.NextPoint, now.DiscountTicketTCount, now.Amount + v.Fee}
				if memoAmount, ok := memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}]; !ok || (ok && memoAmount > next.Amount) {
					memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}] = next.Amount
					heap.Push(&pq, next)
				}
				if now.DiscountTicketTCount > 0 {
					next = &Node{v.NextPoint, now.DiscountTicketTCount - 1, now.Amount + v.Fee/2}
					if memoAmount, ok := memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}]; !ok || (ok && memoAmount > next.Amount) {
						memo[Memo{NowPoint: v.NextPoint, DiscountTicketTCount: now.DiscountTicketTCount}] = next.Amount
						heap.Push(&pq, next)
					}
				}
			}
		}
		//runtime.GC()
	}
}



Measured memory_bytes: 6080
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s,t;
  cin>>s>>t;
  map<char, char> ms, mt;
  string ans = "Yes";
  rep(i,s.size()) {
    if(ms.find(s[i]) != ms.end()) {
      if(ms[s[i]] != t[i]) {
        ans = "No";
      }
    } else {
      ms[s[i]] = t[i];
    }
    if(mt.find(t[i]) != mt.end()) {
      if(mt[t[i]] != s[i]) {
        ans = "No";
      }
    } else {
      mt[t[i]] = s[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 916
A = list(input())
n = int(input())

for _ in range(n):
	command = input().split(" ")
	st = int(command[1])
	en = int(command[2]) + 1

	if command[0] == "replace":
		A[st:en] = list(command[3])
	elif command[0] == "reverse":
		A[st:en] = reversed(A[st:en])
	else:
		print(*A[st:en],sep="")



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

int main(){
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        int check=0;
        if(i%3==0){
            cout << " " << i;
            check=1;
        }
        int x=i;
        while(check==0){
            if(x%10==3){
                cout << " " << i;
                check=1;
            }
            x/=10;
            if(x==0){break;}
        }
    }
    cout << endl;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  ll t;
  //assert(true);//ok
  //assert(false);//fails
  //  cin>>t;
  ll N,K,S;

  //cout<<x<<endl;
  cin>>N;
  cin>>K;
  cin>>S;
  if(N<S){
      for (int j=0;j<N;j++){
	if(j<K){
	  cout<<S<<" ";
	}else{
	  cout<<1<<" ";	  
	}
      }
    }else{
      for (int j=0;j<N;j++){
	if(j<K){
	  cout<<S<<" ";
	}else{
	  cout<<S+1<<" ";	  
	}
      }
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <float.h>
#include <iomanip>
using namespace std;
int main(void){
    
    int N, K;
    long double sum = 0;
    //double ans = DBL_MIN;
    cin >> N >> K;
    vector<long long> P(N);
    vector<double> p(N);
    
    for(int i = 0; i < N; i++){
        cin >> P[i];
        p[i] = P[i]/2.0 + 0.5;

    }
    
    for(int i = 0; i < K ; i++){
        sum += p[i];
    }
    
    long double ans = sum;
    int count = 0;
    
    for(int i = K; i < N ; i++){
        sum += p[i] - p[count];
        count++;
        ans = max(ans, sum);
    }
    
    cout << fixed << setprecision(12);
    cout << ans << endl;
    
    
    
}


Measured memory_bytes: 3328
def main():

    A, B, K = map(int, input().split())

    if A > K:
        A -= K
    else:

        K -= A
        A = 0
        B -= K
        if B <= 0:
            print("0 0")
            exit(0)

    print(str(A) + " " + str(B))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;

    if(A == 5 && B == 7 && C == 5){
        cout << "YES" << endl;
    }else if(A == 5 && B == 5 && C == 7){
        cout << "YES" << endl;
    }else if(A == 7 && B == 5 && C == 5){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main() {
  int x, y;
  cin >> x >> y;
  
  if ((((x <= 7)&&(x%2 == 1))||((x >= 8)&&(x%2 == 0)))&&(((y <= 7)&&(y%2 == 1))||((y >= 8)&&(y%2 == 0))))
    cout << "Yes" << endl;
  else if ((((x >2)&&(x <= 6)&&(x%2 == 0))||((x >= 9)&&(x%2 == 1)))&&(((y > 2)&&(y <= 6)&&(y%2 == 0))||((y >= 9)&&(y%2 == 1))))
    cout << "Yes" << endl;
  else if ((x == 2)&&(y ==2))
    cout << "Yes" << endl;
  else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    if(a>=x)
        cout<<x<<endl;
    else if(a+b>=x)
        cout<<a<<endl;
    else
        cout<<a-(x-a-b)<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>

using namespace std;

const int MAX_N = 20;

int main() {
    int n;
    int p[MAX_N];

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

    int ans = 0;

    for (int i = 0; i < n - 2; i++) {
        if (p[i] <= p[i + 1] && p[i + 1] < p[i + 2]) {
            ans++;
        } else if (p[i + 2] <= p[i + 1] && p[i + 1] < p[i]) {
            ans++;
        } else if (p[i] == p[i + 2] && p[i + 1] < p[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}


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

double arr[20][20];

int main(void) {
	int n, d;
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> arr[i][j];
		}
	}
	int count = 0;
	double sum = 0;
	for (int i = 0; i < n; i++) {
		for (int ii = 0; ii < n; ii++) {
			for (int j = 0; j < d; j++) {
				sum += pow(arr[i][j] - arr[ii][j], 2);
			}
			sum = sqrt(sum);
			if (floor(sum) == ceil(sum) && i<ii) {
				count++;
			}
			sum = 0;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#include <random>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//#ifdef __int128
using hll = __int128;

using ll = long long;
//#endif
using pii = pair<ll, ll>;
using ld = double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1000000007;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

ll sub(ll a, ll b) {
    return add(a, mod - b);
}

const int MAXN = 3e5 + 32;


int dp[4 * MAXN];

int get_max (int v, int tl, int tr, int l, int r) {
    if (l > r)
        return -1e9;
    if (l == tl && r == tr)
        return dp[v];
    int tm = (tl + tr) / 2;
    return max(
            get_max(v * 2, tl, tm, l, min(r, tm)),
            get_max(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r)
    );
}

void update (int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr)
        dp[v] = new_val;
    else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v * 2, tl, tm, pos, new_val);
        else
            update(v * 2 + 1, tm + 1, tr, pos, new_val);
        dp[v] = max(dp[v * 2], dp[v * 2 + 1]);
    }
}



void solve() {

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {

        int a;
        cin >> a;

        int maxx = get_max(1, 0, MAXN - 1, max(0, a - k), min(a + k, MAXN - 1));

        update(1, 0, MAXN - 1, a, maxx + 1);
    }

    int answr = get_max(1, 0, MAXN - 1, 0, MAXN - 1);
    cout << answr << "\n";
}


#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case " << i << ": ";
        solve();
//        cout << "\n";
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
#else
#endif
#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 7772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
const ll MOD = 1e9 + 7;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    int N;
    cin >> N;
    vector<ll> L(N * 2);
    rep(i, N * 2) cin >> L[i];
    sort(all(L), greater<ll>());
    ll ans = 0;
    for (int i = 1; i < N * 2; i += 2) ans += L[i];
    cout << ans << endl;
    return 0;
}

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

"""
Performs topological sorting of the given DAG using Kahn's algorithm.

Verification: []()
"""

import heapq


class TopologicalSortError(Exception):
    """This exception is raised when something gets wrong while performing `topological_sort`.
    """    
    pass


def topological_sort(num_vs, adj_vs):
    """Performs topological sorting of the given DAG.

    This function computes the lexicographically least
    topological order of the given DAG.

    Parameters:

    - `num_vs`: The number of vertices of the DAG.
    - `adj_vs` The adjacency list of the DAG.

    Returns: the lexicographically least topological order as a list.
    
    Raises `TopologicalSortError` if the given graph is not a DAG.
    """
    
    in_deg = [0 for _ in range(num_vs)]
    for dests in adj_vs:
        for dest in dests:
            in_deg[dest] += 1
    sorted_vs = []
    pq = []
    for s in range(num_vs):
        if in_deg[s] == 0:
            heapq.heappush(pq, s)
    while pq:
        u = heapq.heappop(pq)
        sorted_vs.append(u)
        for v in adj_vs[u]:
            in_deg[v] -= 1
            if in_deg[v] == 0:
                heapq.heappush(pq, v)
    if all(x == 0 for x in in_deg):
        return sorted_vs
    else:
        raise TopologicalSortError("The graph has a cycle")


def main():
    v, e = map(int, input().split())
    adj_vs = [set() for _ in range(v)]
    for _ in range(e):
        s, t = map(int, input().split())
        adj_vs[s].add(t)
    for u in topological_sort(v, adj_vs):
        print(u)


if __name__ == "__main__":
    main()


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
tmp = list(map(int, input().split()))
A, B, K= tmp[0], tmp[1], tmp[2]

i, j = A, B
if A > B:
  i, j = B, A

for k in reversed(range(i)):
  tmp = k + 1
  if i % tmp == 0 and j % tmp == 0:
    K -= 1
  if K == 0:
    print(tmp)
    break


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,a,b) = get!(usize, usize, usize);
    if (b-a) % 2 == 0 {
        println!("Alice");
    } else {
        println!("Borys");
    }
}


Measured memory_bytes: 8572
#include <iostream>
using namespace std;
int main(void){
    int a;
    int b;
    int c;
    cin>>a;
    cin>>b;
    if(a<b){
        c=b-a;
        cout<<(c)<<endl;
    }else{
        c=a-b;
        cout<<(c)<<endl;
    }
}



Measured memory_bytes: 3116
import java.util.*;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int hei [] = new int[10];
        for (int i = 0; i < 10; i++) {
            hei[i] = scanner.nextInt();
        }

        Arrays.sort(hei);
        for (int i = 0; i < 3; i++) {
            System.out.println(hei[9 - i]);
        }
    }
}



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

int main() {
	int n,l,sum=0,mx=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l;
		sum+=l;
		mx=max(mx,l);
	}
	if((sum-mx)>mx){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



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

int N;

void rec(int m = N){
    if(m == 0){
        cout << "Yes" << endl;
        exit(0);
    }
    if(m - 7 >= 0) rec(m - 7);
    if(m - 4 >= 0) rec(m - 4);
    return ;
}

int main(void){
    
    cin >> N;
    rec();
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    return x.first>y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}

void solve()
{   
    int n;
    cin>>n;
    vector<int> b(n-1);
    for(auto &it :b)
        cin>>it;
    int cur=INT_MAX;
    ll sum=0;
    for(int i=0;i<n-1;i++){
        if(b[i]>cur)
            sum+=cur;
        else
            sum+=b[i];
        cur=b[i];
    }
    cout<<sum+cur;
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] array = new int[n];
		for(int i=1;i<n;i++) array[sc.nextInt()-1]++;
		sc.close();
		for(int i=0;i<n;i++) System.out.println(array[i]);
	}
}

Measured memory_bytes: 61616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define vi vector<int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define ll long long
const int MOD = 998244353;
const int INF  = 2e9 + 5;
const int LEN = 2e5 + 5;
typedef tree<
int, null_type,
less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;
ordered_set s;
int p[10];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    auto startt = clock();
    int k;
    long long ans = 0;
    cin>>k;

    for (int a = 1; a <= k; ++a)
    {
    	for(int b =1; b<=k ; b++) {
    		for(int c = 1; c<=k; c++) {
    			ans += __gcd(__gcd(a,b),c);
    		}
    	}
    }
    
    cout<<ans<<"\n";
    cerr << " Time : " << (double)(clock() - startt) / CLOCKS_PER_SEC << " s" << "\n";
    return 0;       
}

Measured memory_bytes: 3788
#include<stdio.h>

int h = 0,r = 0;

int main(){

scanf("%d %d",&h,&r);
if (h+r==0)
		{
			printf("0\n");

		}
		if (h+r<0)
		{
			printf("-1\n");
		
		}

		if (h+r>0)
		{
			printf("1\n");
		}


return 0;
}

Measured memory_bytes: 580
N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans = ans * A[i]
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)        
            

Measured memory_bytes: 84736
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

#define rep(i,x) for(int i=0;i<(int)(x);++i)

int main() {
	string s; cin >> s;
    
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            printf("%d %d\n", i, i + 1);
            return 0;
        } else if (i >= 2 && s[i] == s[i - 2]) {
            printf("%d %d\n", i - 1, i + 1);
            return 0;
        }
    }
	
    puts("-1 -1");
    
	return 0;
}

Measured memory_bytes: 512
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-09 16:25:23
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1 << 28);
int64_t A[301][301], B[301][301];

void init()
{
  for (int i = 0; i < 301; i++)
  {
    for (int j = 0; j < 301; j++)
    {
      A[i][j] = INF;
      B[i][j] = INF;
    }
  }
  for (int i = 0; i < 301; i++)
  {
    A[i][i] = 0;
    B[i][i] = 0;
  }
}

int main()
{
  int64_t N, a, ans = 0;
  cin >> N;
  init();
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin >> a;
      A[i][j] = B[i][j] = a;
    }
  }
  for (int k = 0; k < N; k++)
  {
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
      }
    }
  }
  bool same = true;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (A[i][j] != B[i][j])
        same = false;
    }
  }
  if (same)
  {
    for (int i = 0; i < N - 1; i++)
    {
      for (int j = i; j < N; j++)
      {
        int64_t d = A[i][j]; // i->jに直結する場合
        bool connected = true;
        for (int k = 0; k < N; k++)
        {
          if (i == k || j == k)
            continue;
          if (A[i][k] + A[k][j] <= d)
            connected = false;
        }
        if (connected)
          ans += d;
      }
    }
    cout << ans << endl;
  }
  else
  {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cstdlib>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

int main() {
    int A,B;
    cin >> A >> B;
    if(A-2*B>0){
        cout << A-2*B << endl;
    }else{
        cout << 0 << endl;
    }


}





Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main()
{
    int n, q;
    std::cin >> n >> q;
    std::vector<std::vector<int>> A(n, std::vector<int>(0));

    for (int i = 0; i < q; i++)
    {

        int m, t, x;
        std::cin >> m >> t;
        if (m == 0)
        {
            std::cin >> x;
            A.at(t).push_back(x);
        }
        else if (m == 1)
        {
            for (auto itr = A.at(t).begin(); itr != A.at(t).end(); itr++)
            {
                std::cout << *itr;
                if (next(itr) != A.at(t).end())
                    std::cout << " ";
            }
            std::cout << std::endl;
        }
        else if (m == 2)
        {
            if (A.at(t).size() > 0)
                A.at(t).clear();
        }
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct edge {
  ll to, cost;
  edge() {}
  edge(ll t, ll c): to(t), cost(c) {}
};

vector<ll> G[100010];
vector<edge> G2[100010];
ll state[100010];
ll d[100010];
const ll INF = 1e18;

void dijkstra(int s) {
  fill(d, d + 100010, INF);
  priority_queue< pll, vector<pll>, greater<pll> > que;
  d[s] = 0;
  que.push(pll(0, s));
  while (!que.empty()) {
    pll p = que.top(); que.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G2[v].size(); i++) {
      edge e = G2[v][i];
      if (d[e.to] <= d[v] + e.cost) continue;
      d[e.to] = d[v] + e.cost;
      que.push(pll(d[e.to], e.to));
    }
  }
}

void danger(int p, int s) {
  queue<pll> que;
  for (int i = 0; i < G[p].size(); i++) {
    que.push(pll(G[p][i], s - 1));
  }

  while (!que.empty()) {
    pll v = que.front(); que.pop();
    if (v.second == 0) continue;
    for (int i = 0; i < G[v.first].size(); i++) {
      int w = G[v.first][i];
      if (state[w] == -1 || state[w]) continue;
      state[w] = 1;
      que.push(pll(w, v.second - 1));
    }
  }
}

int main(void) {
  ll n, m, k, s;
  ll p, q;
  cin >> n >> m >> k >> s;
  cin >> p >> q;

  vector<ll> c(k);
  for (int i = 0; i < k; i++) {
    cin >> c[i];
    state[--c[i]] = -1;
    G[n].push_back(c[i]);
  }
  for (int i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  danger(n, s + 1);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      int v = G[i][j];
      if (state[v] < 0) continue;
      if (!state[v]) {
        G2[i].push_back(edge(v, p));
      } else {
        G2[i].push_back(edge(v, q));
      }
    }
  }
  dijkstra(0);
  
  cout << d[n - 1] - (!state[n - 1] ? p : q) << endl;

  return 0;
}


Measured memory_bytes: 24996